compiler

package
v3.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2021 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Codegen

func Codegen(prog TreeNodeIf) string

Codegen runs code generation for a node and returns the program as a string

func Parse

func Parse(source string) (TreeNodeIf, []ParserError)

Parse function creates AST

func ParseOneLineCond

func ParseOneLineCond(source string) (TreeNodeIf, []ParserError)

ParseOneLineCond is for parsing one-liners like "(txn.fee == 1) && (global.MinTxnFee < 2000)"

func ParseProgram

func ParseProgram(input InputDesc) (TreeNodeIf, []ParserError)

ParseProgram accepts InputDesc that describes source location

Types

type ExprNodeIf

type ExprNodeIf interface {
	TreeNodeIf
	// contains filtered or unexported methods
}

ExprNodeIf extends TreeNode and can be evaluated and typed

type InputDesc

type InputDesc struct {
	Source     string
	SourceFile string
	SourceDir  string
	CurrentDir string
}

InputDesc struct describe location of the source file This info is later used for imports

type ParserError

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

ParserError provides generic info about the error

func (*ParserError) String

func (err *ParserError) String() (msg string)

type TreeNode

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

TreeNode contains base info about an AST node

func (*TreeNode) Codegen

func (n *TreeNode) Codegen(ostream io.Writer)

Codegen by default emits AST node as a comment

func (*TreeNode) Print

func (n *TreeNode) Print()

Print AST and context

func (*TreeNode) String

func (n *TreeNode) String() string

type TreeNodeIf

type TreeNodeIf interface {
	String() string
	Print()
	Codegen(ostream io.Writer)
	// contains filtered or unexported methods
}

TreeNodeIf represents a node in AST

Jump to

Keyboard shortcuts

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