agora: github.com/PuerkitoBio/agora/compiler Index | Files | Directories

package compiler

import "github.com/PuerkitoBio/agora/compiler"

Package compiler provides the agora source code compiler.

Index

Package Files

asm.go compiler.go disasm.go

Variables

var (
    // Predefined errors
    ErrInvalidInstruction = errors.New("invalid instruction")
    ErrNoInput            = errors.New("no input provided")
)

type Asm Uses

type Asm struct {
    // contains filtered or unexported fields
}

An Asm is an assembly source code compiler. It implements the runtime.Compiler interface, so that it is suitable for runtime.Ctx.

func (*Asm) Compile Uses

func (a *Asm) Compile(id string, r io.Reader) (*bytecode.File, error)

Compile takes a module identifier and a reader, and compiles its assembly source code to an in-memory representation of agora bytecode, ready for execution. If an error is encounted, it is returned as second value, otherwise it is nil.

type Compiler Uses

type Compiler struct{}

A Compiler represents the source code compiler. It implements the runtime.Compiler interface so that it is suitable for runtime.Ctx.

func (*Compiler) Compile Uses

func (c *Compiler) Compile(id string, r io.Reader) (*bytecode.File, error)

Compile takes a module identifier and a reader, and compiles its source date to an in-memory representation of agora bytecode, ready to be executed. If an error is encountered, it is returned as second value, otherwise it is nil.

type Disasm Uses

type Disasm struct {
    // contains filtered or unexported fields
}

A Disasm translates a bytecode representation into assembly source code.

func (*Disasm) ToAsm Uses

func (d *Disasm) ToAsm(f *bytecode.File, w io.Writer) error

ToAsm takes the in-memory bytecode File structure and translates it to assembly source code, writing the results to the provided writer. If an error is encountered, it is returned, otherwise it returns nil.

func (*Disasm) Uncompile Uses

func (d *Disasm) Uncompile(r io.Reader, w io.Writer) error

Uncompile reads the bytecode source data from the provided reader, and translates it to assembly source code written into the writer. If an error is encountered, it is returned, otherwise it returns nil.

Directories

PathSynopsis
emitterPackage emitter generates the bytecode instructions by traversing the abstract syntax tree generated by the parser.
parserPackage parser provides the agora source code parser.
scannerPackage scanner implements a scanner for agora source text.
tokenPackage token defines constants representing the lexical tokens of the agora programming language and basic operations on tokens (printing, predicates).

Package compiler imports 10 packages (graph) and is imported by 2 packages. Updated 2016-07-21. Refresh now. Tools for package owners.