compiler

package
v0.0.0-...-e334538 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compiler

type Compiler struct {
	// The generated bytecode
	Bytes []byte

	Constants []object.Object
	Names     []string
	Jumps     []int
}

A Compiler translates an AST into some bytecode.

func New

func New() *Compiler

New instantiates a new Compiler instance.

func (*Compiler) Compile

func (c *Compiler) Compile(p *ast.Program) error

Compile compiles an ast.Program into bytecode, returning any errors. The bytecode, constants, and names, are stored in the Compiler instance in the respective fields.

func (*Compiler) CompileExpression

func (c *Compiler) CompileExpression(e ast.Expression) error

CompileExpression takes an AST expression and generates some bytecode for it.

func (*Compiler) CompileStatement

func (c *Compiler) CompileStatement(s ast.Statement) error

CompileStatement takes an AST statement and generates some bytecode for it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL