compiler

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: BSD-3-Clause-Clear Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareThanosToMRI

func CompareThanosToMRI(program, label string) (string, string, error)

func Compile

func Compile(p *parser.Root) (string, error)

Types

type GoProgram

type GoProgram struct {
	State        *parser.Stack[State]
	ScopeChain   parser.ScopeChain
	Imports      map[string]bool
	CurrentLhs   []parser.Node
	BlockStack   *parser.Stack[*ast.BlockStmt]
	GlobalVars   []*ast.ValueSpec
	Constants    []*ast.ValueSpec
	TrackerStack []bst.IdentTracker
	// contains filtered or unexported fields
}

func (*GoProgram) AddImports

func (g *GoProgram) AddImports(packages ...string)

func (*GoProgram) BuildBlock

func (g *GoProgram) BuildBlock(blk *parser.Block) *types.Block

func (*GoProgram) CompileArg

func (g *GoProgram) CompileArg(node parser.Node) ast.Expr

func (*GoProgram) CompileAssignmentNode

func (g *GoProgram) CompileAssignmentNode(node *parser.AssignmentNode)

func (*GoProgram) CompileBlockStmt

func (g *GoProgram) CompileBlockStmt(node parser.Node) *ast.BlockStmt

func (*GoProgram) CompileClass

func (g *GoProgram) CompileClass(c *parser.Class) []ast.Decl

func (*GoProgram) CompileExpr

func (g *GoProgram) CompileExpr(node parser.Node) ast.Expr

Expression translation methods _do_ return AST Nodes because of the specificity of where they have to be inserted. Any additional statements can be prepended before returning.

func (*GoProgram) CompileFunc

func (g *GoProgram) CompileFunc(m *parser.Method, c *parser.Class) []ast.Decl

func (*GoProgram) CompileModule

func (g *GoProgram) CompileModule(mod *parser.Module) []ast.Decl

func (*GoProgram) CompileRangeIndexNode

func (g *GoProgram) CompileRangeIndexNode(rcvr ast.Expr, r *parser.RangeNode) ast.Expr

func (*GoProgram) CompileStmt

func (g *GoProgram) CompileStmt(node parser.Node)

Statement translation methods never return AST nodes. Instead, they always append to the current block statement.

func (*GoProgram) CompileStringNode

func (g *GoProgram) CompileStringNode(node *parser.StringNode) ast.Expr

func (*GoProgram) CompileSuperNode

func (g *GoProgram) CompileSuperNode(node *parser.SuperNode) ast.Expr

func (*GoProgram) GetFuncParams

func (g *GoProgram) GetFuncParams(rubyParams []*parser.Param) []*ast.Field

func (*GoProgram) GetReturnType

func (g *GoProgram) GetReturnType(t types.Type) []*ast.Field

func (*GoProgram) TransformInfixExpressionNode

func (g *GoProgram) TransformInfixExpressionNode(node *parser.InfixExpressionNode) ast.Expr

func (*GoProgram) TransformMethodCall

func (g *GoProgram) TransformMethodCall(c *parser.MethodCall) types.Transform

type State

type State string
const (
	InFuncDeclaration   State = "InFuncDeclaration"
	InMethodDeclaration State = "InMethodDeclaration"
	InReturnStatement   State = "InReturnStatement"
	InCondAssignment    State = "InCondAssignment"
	InBlockBody         State = "InBlockBody"
)

Jump to

Keyboard shortcuts

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