ast

package
v0.0.0-...-80e9d33 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: CC0-1.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotNilFilter

func NotNilFilter(_ string, v reflect.Value) bool

NotNilFilter filters out nil nodes.

func Print

func Print(x interface{}) (err error)

Print prints an AST tree given a node.

Types

type ArrayType

type ArrayType struct {
	Byte bool
	X    *ConstExpr
	Len  int
}

type AssignStmt

type AssignStmt struct {
	Name *Symbol
	Lhs  Expr
	Rhs  Expr
}

type BasicLit

type BasicLit struct {
	Pos   scanner.Position
	Type  lex.Token
	Value string
}

type BinaryExpr

type BinaryExpr struct {
	X     Expr
	OpPos scanner.Position
	Op    lex.Token
	Y     Expr
}

type BranchStmt

type BranchStmt struct {
	TokPos scanner.Position
	Tok    lex.Token
}

type ByteVecExpr

type ByteVecExpr struct {
	Lbrack scanner.Position
	Data   []int
	Rbrack scanner.Position
}

type CallExpr

type CallExpr struct {
	Name   *Symbol
	Fun    Expr
	Lparen scanner.Position
	Arg    []Expr
	Rparen scanner.Position
}

type Comment

type Comment struct {
	Pos  scanner.Position
	Text string
}

type CompoundStmt

type CompoundStmt struct {
	Scope *Scope
	Decl  []*GenDecl
	Do    scanner.Position
	Stmt  []Stmt
	End   scanner.Position
}

type CondExpr

type CondExpr struct {
	Op scanner.Position
	X  Expr
	Y  Expr
	Z  Expr
}

type ConstDecl

type ConstDecl struct {
	Name   *Symbol
	X      Expr
	Result int
}

type ConstExpr

type ConstExpr struct {
	X     Expr
	Value int
}

type Decl

type Decl interface {
	Node
}

type EmptyStmt

type EmptyStmt struct {
	Semi scanner.Position
}

type Expr

type Expr interface {
	Node
}

type ExprStmt

type ExprStmt struct {
	X Expr
}

type FieldFilter

type FieldFilter func(name string, value reflect.Value) bool

FieldFilter is a function used to filter out nodes.

type ForStmt

type ForStmt struct {
	For    scanner.Position
	Lparen scanner.Position
	Name   *Symbol
	Init   Expr
	Cond   Expr
	Post   *ConstExpr
	Rparen scanner.Position
	Body   Stmt
}

type FuncDecl

type FuncDecl struct {
	Fwd    *FwdDecl
	Scope  *Scope
	Name   *Symbol
	Lparen scanner.Position
	Arg    []*Symbol
	Rparen scanner.Position
	Body   Stmt
}

type FwdDecl

type FwdDecl struct {
	Name  *Symbol
	X     *ConstExpr
	Arity int
}

type GenDecl

type GenDecl struct {
	TypePos scanner.Position
	Type    lex.Token
	Decl    []Decl
}

type IfStmt

type IfStmt struct {
	IfPos  scanner.Position
	If     lex.Token
	Lparen scanner.Position
	Cond   Expr
	Rparen scanner.Position
	Body   Stmt
	Else   Stmt
}

type IndexExpr

type IndexExpr struct {
	Byte   bool
	X      Expr
	Lbrack scanner.Position
	Index  Expr
	Rbrack scanner.Position
}

type LogicalExpr

type LogicalExpr struct {
	X     Expr
	Depth int
}

type ModuleDecl

type ModuleDecl PackageDecl

type Node

type Node interface{}

type ObjectDecl

type ObjectDecl PackageDecl

type PackageDecl

type PackageDecl struct {
	Name    *Symbol
	Version *Symbol
}

type ParenExpr

type ParenExpr struct {
	Lparen scanner.Position
	X      Expr
	Rparen scanner.Position
}

type Prog

type Prog struct {
	Scope   *Scope
	Comment []*Comment
	Decl    []Decl
	Stmt    *CompoundStmt

	Defs map[*Symbol]Decl
	Uses map[Expr]*Symbol
}

type ReturnStmt

type ReturnStmt struct {
	TokPos scanner.Position
	Tok    lex.Token
	Value  Expr
}

type Scope

type Scope struct {
	Parent *Scope
	Symbol []*Symbol
}

type Stmt

type Stmt interface {
	Node
}

type StructDecl

type StructDecl struct {
	Name  *Symbol
	Field []*Symbol
}

type Symbol

type Symbol struct {
	Pos   scanner.Position
	Type  Type
	Len   int
	Ident string
	Value Expr
}

type TableExpr

type TableExpr struct {
	Lbrack scanner.Position
	Member []Expr
	Rbrack scanner.Position
}

type Type

type Type int
const (
	CONST Type = 1 << iota
	VAR
	VECT
	BYTE
	DECL
	STRUCT
	FUNC
	FNARG
)

func (Type) String

func (i Type) String() string

type UnaryExpr

type UnaryExpr struct {
	OpPos scanner.Position
	Op    lex.Token
	X     Expr
}

type VarDecl

type VarDecl struct {
	Name  *Symbol
	Type  Expr
	Value Expr
}

type WhileStmt

type WhileStmt struct {
	While  scanner.Position
	Lparen scanner.Position
	Cond   Expr
	Rparen scanner.Position
	Body   Stmt
}

Jump to

Keyboard shortcuts

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