Documentation ¶
Overview ¶
Package ast provides types representing nodes of an abstract syntax tree. The abstract syntax tree can be evaluated (executed) using an evaluator.Evaluator.
Index ¶
- type Block
- type BoolLiteral
- type BreakStatement
- type CallExpression
- type CaptureExpression
- type ConditionalBlock
- type ContinueStatement
- type Expression
- type ExpressionStatement
- type FieldExpression
- type ForExpression
- type HashExpression
- type Ident
- type IfExpression
- type InfixExpression
- type IntLiteral
- type LetStatement
- type Literal
- type NilLiteral
- type Node
- type PrefixExpression
- type Program
- type Statement
- type StringLiteral
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoolLiteral ¶
BoolLiteral represents a literal bool value.
func (*BoolLiteral) Col ¶
func (b *BoolLiteral) Col() int
func (*BoolLiteral) Line ¶
func (b *BoolLiteral) Line() int
type BreakStatement ¶
BreakStatement breaks the execution of the loop it is used in.
func (*BreakStatement) Col ¶
func (b *BreakStatement) Col() int
func (*BreakStatement) Line ¶
func (b *BreakStatement) Line() int
type CallExpression ¶
type CallExpression struct { StartLine int StartCol int Callee Expression Params []Expression }
CallExpression calls a method or function. The called method or function may return zero or more values. If no values are returned, the CallExpression returns nil, otherwise only the first value is returned. If the method or function returns an error as the last value, execution stops with that error.
Not all method or function arguments need to be supplied. Any remaining arguments not supplied can be supplied automatically by a evaluator.ResolveArgumentFunc.
func (*CallExpression) Col ¶
func (c *CallExpression) Col() int
func (*CallExpression) Line ¶
func (c *CallExpression) Line() int
type CaptureExpression ¶
CaptureExpression captures the return values of all statements in its block, returning them as elements of a slice. If there is only one value, it is returned directly rather than inside a slice.
func (*CaptureExpression) Col ¶
func (c *CaptureExpression) Col() int
func (*CaptureExpression) Line ¶
func (c *CaptureExpression) Line() int
type ConditionalBlock ¶
type ConditionalBlock struct { StartLine int StartCol int Condition Expression Block }
ConditionalBlock contains a block of statements to be executed if the condition is met (if any.)
func (*ConditionalBlock) Col ¶
func (c *ConditionalBlock) Col() int
func (*ConditionalBlock) Line ¶
func (c *ConditionalBlock) Line() int
type ContinueStatement ¶
ContinueStatement starts the next iteration of the for loop it is used in.
func (*ContinueStatement) Col ¶
func (c *ContinueStatement) Col() int
func (*ContinueStatement) Line ¶
func (c *ContinueStatement) Line() int
type Expression ¶
type Expression interface { Node // contains filtered or unexported methods }
Expression represents any expression, such as "1 + 2" or "foo.bar()".
type ExpressionStatement ¶
type ExpressionStatement struct { StartLine int StartCol int Expression }
func (*ExpressionStatement) Col ¶
func (e *ExpressionStatement) Col() int
func (*ExpressionStatement) Line ¶
func (e *ExpressionStatement) Line() int
type FieldExpression ¶
type FieldExpression struct { StartLine int StartCol int Callee Expression Index Expression }
FieldExpression looks up a "field" in a callee, returning it. The "field" may be a struct member or a method. In the case of a method, a CallExpression can be used to call it.
func (*FieldExpression) Col ¶
func (f *FieldExpression) Col() int
func (*FieldExpression) Line ¶
func (f *FieldExpression) Line() int
type ForExpression ¶
type ForExpression struct { StartLine int StartCol int Ident StatusIdent *Ident RangeExpr Expression Block }
ForExpression ranges over a range of values, executing a block of statements for each iteration.
func (*ForExpression) Col ¶
func (f *ForExpression) Col() int
func (*ForExpression) Line ¶
func (f *ForExpression) Line() int
type HashExpression ¶
type HashExpression struct { StartLine int StartCol int Values map[string]Expression }
HashExpression creates a map of expressions indexed by strings.
func (*HashExpression) Col ¶
func (h *HashExpression) Col() int
func (*HashExpression) Line ¶
func (h *HashExpression) Line() int
type Ident ¶
Ident represents a literal identifier, usually looked up automatically in the current scope.
type IfExpression ¶
type IfExpression struct { StartLine int StartCol int Conditionals []ConditionalBlock }
IfExpression executes the statements in one of its conditional blocks if the condition of that block is met.
func (*IfExpression) Col ¶
func (i *IfExpression) Col() int
func (*IfExpression) Line ¶
func (i *IfExpression) Line() int
type InfixExpression ¶
type InfixExpression struct { StartLine int StartCol int Left Expression Operator string Right Expression }
InfixExpression is an expression with an operator in the middle, such as "1 + 2" or "x % 5".
func (*InfixExpression) Col ¶
func (i *InfixExpression) Col() int
func (*InfixExpression) Line ¶
func (i *InfixExpression) Line() int
type IntLiteral ¶
IntLiteral represents a literal signed integer value.
func (*IntLiteral) Col ¶
func (i *IntLiteral) Col() int
func (*IntLiteral) Line ¶
func (i *IntLiteral) Line() int
type LetStatement ¶
type LetStatement struct { StartLine int StartCol int Ident Expression }
LetStatement assigns a value to an identifier, usually in the current scope.
func (*LetStatement) Col ¶
func (l *LetStatement) Col() int
func (*LetStatement) Line ¶
func (l *LetStatement) Line() int
type NilLiteral ¶
NilLiteral represents a literal nil value.
func (*NilLiteral) Col ¶
func (n *NilLiteral) Col() int
func (*NilLiteral) Line ¶
func (n *NilLiteral) Line() int
type PrefixExpression ¶
type PrefixExpression struct { StartLine int StartCol int Operator string Expression }
PrefixExpression is an expression that starts with an operator, such as "-15" or "!x" (where x is a bool.)
func (*PrefixExpression) Col ¶
func (p *PrefixExpression) Col() int
func (*PrefixExpression) Line ¶
func (p *PrefixExpression) Line() int
type Statement ¶
type Statement interface { Node // contains filtered or unexported methods }
Statement is a single statement to be executed, such as a "let" or "if" statement.
type StringLiteral ¶
StringLiteral represents a literal string, such as "foo" (including quotes.)
func (*StringLiteral) Col ¶
func (s *StringLiteral) Col() int
func (*StringLiteral) Line ¶
func (s *StringLiteral) Line() int