Documentation
¶
Overview ¶
Package ast defines structs and methods to handle AST creation.
Index ¶
- type AnyLiteral
- type ArrayLiteral
- type AssignmentStatement
- type BinaryExpr
- type BlockStatement
- type BoolLiteral
- type BreakStatement
- type ConstantDeclaration
- type ContinueStatement
- type ExprNode
- type ForStatement
- type FuncDeclarationStatement
- type FuncParameter
- type FunctionCall
- type Identifier
- type IfStatement
- type ImportStatement
- type IndexAssignmentStatement
- type IndexExpr
- type NullLiteral
- type NumberLiteral
- type PrefixExpr
- type ReturnStatement
- type ShorthandAssignmentExpr
- type SpreadExpr
- type StatementList
- type StringLiteral
- type VariableDeclaration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnyLiteral ¶ added in v0.1.1
AnyLiteral defines a struct for a literal any value.
func (*AnyLiteral) EndPosition ¶ added in v0.1.1
func (e *AnyLiteral) EndPosition() int
EndPosition returns the end position of the any literal.
func (*AnyLiteral) Expr ¶ added in v0.1.1
func (e *AnyLiteral) Expr() string
Expr returns the expression of the any literal.
func (*AnyLiteral) StartPosition ¶ added in v0.1.1
func (e *AnyLiteral) StartPosition() int
StartPosition returns the start position of the any literal.
func (*AnyLiteral) Walk ¶ added in v0.1.1
func (e *AnyLiteral) Walk(fn func(node ExprNode) bool)
Walk walks the any literal.
type ArrayLiteral ¶ added in v0.1.1
ArrayLiteral defines a struct for a literal array value.
func (*ArrayLiteral) EndPosition ¶ added in v0.1.1
func (e *ArrayLiteral) EndPosition() int
EndPosition returns the end position of the array literal.
func (*ArrayLiteral) Expr ¶ added in v0.1.1
func (e *ArrayLiteral) Expr() string
Expr returns the expression of the array literal.
func (*ArrayLiteral) StartPosition ¶ added in v0.1.1
func (e *ArrayLiteral) StartPosition() int
StartPosition returns the start position of the array literal.
func (*ArrayLiteral) Walk ¶ added in v0.1.1
func (e *ArrayLiteral) Walk(fn func(node ExprNode) bool)
Walk walks the array literal and its values.
type AssignmentStatement ¶
type AssignmentStatement struct {
Left *Identifier
Right ExprNode
StartPos int
EndPos int
}
AssignmentStatement represents an assignment statement.
func (*AssignmentStatement) EndPosition ¶
func (a *AssignmentStatement) EndPosition() int
EndPosition returns the end position of the assignment statement.
func (*AssignmentStatement) Expr ¶
func (a *AssignmentStatement) Expr() string
Expr returns the expression of the assignment statement.
func (*AssignmentStatement) StartPosition ¶
func (a *AssignmentStatement) StartPosition() int
StartPosition returns the start position of the assignment statement.
func (*AssignmentStatement) Walk ¶
func (a *AssignmentStatement) Walk(fn func(node ExprNode) bool)
Walk walks the assignment statement and its left and right nodes.
type BinaryExpr ¶
type BinaryExpr struct {
Left ExprNode
Right ExprNode
Operator token.Token
StartPos int
EndPos int
}
BinaryExpr defines a struct for a binary expression.
func (*BinaryExpr) EndPosition ¶
func (e *BinaryExpr) EndPosition() int
EndPosition returns the end position of the binary expression.
func (*BinaryExpr) Expr ¶
func (e *BinaryExpr) Expr() string
Expr returns the expression of the binary expression.
func (*BinaryExpr) StartPosition ¶
func (e *BinaryExpr) StartPosition() int
StartPosition returns the start position of the binary expression.
func (*BinaryExpr) Walk ¶
func (e *BinaryExpr) Walk(fn func(node ExprNode) bool)
Walk walks the binary expression and its left and right nodes.
type BlockStatement ¶
BlockStatement defines a struct for a block statement.
func (*BlockStatement) EndPosition ¶
func (e *BlockStatement) EndPosition() int
EndPosition returns the end position of the block statement.
func (*BlockStatement) Expr ¶
func (e *BlockStatement) Expr() string
Expr returns the expression of the block statement.
func (*BlockStatement) StartPosition ¶
func (e *BlockStatement) StartPosition() int
StartPosition returns the start position of the block statement.
func (*BlockStatement) Walk ¶
func (e *BlockStatement) Walk(fn func(node ExprNode) bool)
Walk walks the block statement and its statements.
type BoolLiteral ¶
BoolLiteral defines a struct for a literal boolean value.
func (*BoolLiteral) EndPosition ¶
func (e *BoolLiteral) EndPosition() int
EndPosition returns the end position of the boolean literal.
func (*BoolLiteral) Expr ¶
func (e *BoolLiteral) Expr() string
Expr returns the expression of the boolean literal.
func (*BoolLiteral) StartPosition ¶
func (e *BoolLiteral) StartPosition() int
StartPosition returns the start position of the boolean literal.
func (*BoolLiteral) Walk ¶
func (e *BoolLiteral) Walk(fn func(node ExprNode) bool)
Walk walks the boolean literal.
type BreakStatement ¶
BreakStatement represents a break statement.
func (*BreakStatement) EndPosition ¶
func (b *BreakStatement) EndPosition() int
EndPosition returns the end position of the break statement.
func (*BreakStatement) Expr ¶
func (b *BreakStatement) Expr() string
Expr returns the expression of the break statement.
func (*BreakStatement) StartPosition ¶
func (b *BreakStatement) StartPosition() int
StartPosition returns the start position of the break statement.
func (*BreakStatement) Walk ¶
func (b *BreakStatement) Walk(fn func(node ExprNode) bool)
Walk walks the break statement.
type ConstantDeclaration ¶
ConstantDeclaration represents a constant declaration.
func (*ConstantDeclaration) EndPosition ¶
func (c *ConstantDeclaration) EndPosition() int
EndPosition returns the end position of the constant declaration.
func (*ConstantDeclaration) Expr ¶
func (c *ConstantDeclaration) Expr() string
Expr returns the expression of the constant declaration.
func (*ConstantDeclaration) StartPosition ¶
func (c *ConstantDeclaration) StartPosition() int
StartPosition returns the start position of the constant declaration.
func (*ConstantDeclaration) Walk ¶
func (c *ConstantDeclaration) Walk(fn func(node ExprNode) bool)
Walk walks the constant declaration and its value.
type ContinueStatement ¶
ContinueStatement represents a continue statement.
func (*ContinueStatement) EndPosition ¶
func (c *ContinueStatement) EndPosition() int
EndPosition returns the end position of the continue statement.
func (*ContinueStatement) Expr ¶
func (c *ContinueStatement) Expr() string
Expr returns the expression of the continue statement.
func (*ContinueStatement) StartPosition ¶
func (c *ContinueStatement) StartPosition() int
StartPosition returns the start position of the continue statement.
func (*ContinueStatement) Walk ¶
func (c *ContinueStatement) Walk(fn func(node ExprNode) bool)
Walk walks the continue statement.
type ExprNode ¶
type ExprNode interface {
Expr() string
StartPosition() int
EndPosition() int
Walk(func(node ExprNode) bool)
}
ExprNode defines a common interface signature for expression structs.
type ForStatement ¶
type ForStatement struct {
Condition ExprNode
Body *BlockStatement
StartPos int
EndPos int
DeclaredVariable string
RangeVariable string
RangeFrom ExprNode
RangeTo ExprNode
IsRange bool
}
ForStatement represents a for statement.
func (*ForStatement) EndPosition ¶
func (f *ForStatement) EndPosition() int
EndPosition returns the end position of the for statement.
func (*ForStatement) Expr ¶
func (f *ForStatement) Expr() string
Expr returns the expression of the for statement.
func (*ForStatement) StartPosition ¶
func (f *ForStatement) StartPosition() int
StartPosition returns the start position of the for statement.
func (*ForStatement) Walk ¶
func (f *ForStatement) Walk(fn func(node ExprNode) bool)
Walk walks the for statement and its condition and body.
type FuncDeclarationStatement ¶ added in v0.1.1
type FuncDeclarationStatement struct {
Name string
Args []FuncParameter
Body ExprNode
ReturnValues []string
NumReturnValues int
StartPos int
EndPos int
}
FuncDeclarationStatement represents a function declaration statement.
func (*FuncDeclarationStatement) EndPosition ¶ added in v0.1.1
func (b *FuncDeclarationStatement) EndPosition() int
EndPosition returns the end position of the function declaration statement.
func (*FuncDeclarationStatement) Expr ¶ added in v0.1.1
func (b *FuncDeclarationStatement) Expr() string
Expr returns the expression of the function declaration statement.
func (*FuncDeclarationStatement) StartPosition ¶ added in v0.1.1
func (b *FuncDeclarationStatement) StartPosition() int
StartPosition returns the start position of the function declaration statement.
func (*FuncDeclarationStatement) Walk ¶ added in v0.1.1
func (b *FuncDeclarationStatement) Walk(fn func(node ExprNode) bool)
Walk walks the function declaration statement.
type FuncParameter ¶ added in v0.1.1
FuncParameter represents a function parameter.
type FunctionCall ¶
type FunctionCall struct {
Namespace string
FunctionName string
Arguments []ExprNode
StartPos int
EndPos int
}
FunctionCall defines a struct for a function call.
func (*FunctionCall) EndPosition ¶
func (fc *FunctionCall) EndPosition() int
EndPosition returns the end position of the function call.
func (*FunctionCall) Expr ¶
func (fc *FunctionCall) Expr() string
Expr returns the expression of the function call.
func (*FunctionCall) StartPosition ¶
func (fc *FunctionCall) StartPosition() int
StartPosition returns the start position of the function call.
func (*FunctionCall) Walk ¶
func (fc *FunctionCall) Walk(fn func(node ExprNode) bool)
Walk walks the function call and its arguments.
type Identifier ¶
Identifier defines a struct for an identifier.
func (*Identifier) EndPosition ¶
func (e *Identifier) EndPosition() int
EndPosition returns the end position of the identifier.
func (*Identifier) Expr ¶
func (e *Identifier) Expr() string
Expr returns the expression of the identifier.
func (*Identifier) StartPosition ¶
func (e *Identifier) StartPosition() int
StartPosition returns the start position of the identifier.
func (*Identifier) Walk ¶
func (e *Identifier) Walk(fn func(node ExprNode) bool)
Walk walks the identifier.
type IfStatement ¶
type IfStatement struct {
Condition ExprNode
ThenBlock *BlockStatement
ElseBlock *BlockStatement
StartPos int
EndPos int
}
IfStatement defines a struct for an if statement.
func (*IfStatement) EndPosition ¶
func (e *IfStatement) EndPosition() int
EndPosition returns the end position of the if statement.
func (*IfStatement) Expr ¶
func (e *IfStatement) Expr() string
Expr returns the expression of the if statement.
func (*IfStatement) StartPosition ¶
func (e *IfStatement) StartPosition() int
StartPosition returns the start position of the if statement.
func (*IfStatement) Walk ¶
func (e *IfStatement) Walk(fn func(node ExprNode) bool)
Walk walks the if statement and its condition and body.
type ImportStatement ¶ added in v0.1.1
type ImportStatement struct {
Path *StringLiteral
Namespace string
Alias string
StartPos int
EndPos int
}
ImportStatement represents an import statement in the AST.
func (*ImportStatement) EndPosition ¶ added in v0.1.1
func (i *ImportStatement) EndPosition() int
EndPosition returns the end position of the import statement.
func (*ImportStatement) Expr ¶ added in v0.1.1
func (i *ImportStatement) Expr() string
Expr returns the expression of the import statement.
func (*ImportStatement) StartPosition ¶ added in v0.1.1
func (i *ImportStatement) StartPosition() int
StartPosition returns the start position of the import statement.
func (*ImportStatement) Walk ¶ added in v0.1.1
func (i *ImportStatement) Walk(fn func(node ExprNode) bool)
Walk walks the import statement.
type IndexAssignmentStatement ¶ added in v0.1.1
type IndexAssignmentStatement struct {
Array ExprNode
Index ExprNode
Right ExprNode
StartPos int
EndPos int
}
IndexAssignmentStatement represents an assignment to an array index.
func (*IndexAssignmentStatement) EndPosition ¶ added in v0.1.1
func (a *IndexAssignmentStatement) EndPosition() int
EndPosition returns the end position of the index assignment statement.
func (*IndexAssignmentStatement) Expr ¶ added in v0.1.1
func (a *IndexAssignmentStatement) Expr() string
Expr returns the expression of the index assignment statement.
func (*IndexAssignmentStatement) StartPosition ¶ added in v0.1.1
func (a *IndexAssignmentStatement) StartPosition() int
StartPosition returns the start position of the index assignment statement.
func (*IndexAssignmentStatement) Walk ¶ added in v0.1.1
func (a *IndexAssignmentStatement) Walk(fn func(node ExprNode) bool)
Walk walks the index assignment statement and its array, index, and right nodes.
type IndexExpr ¶ added in v0.1.1
IndexExpr defines a struct for an index expression.
func (*IndexExpr) EndPosition ¶ added in v0.1.1
EndPosition returns the end position of the index expression.
func (*IndexExpr) StartPosition ¶ added in v0.1.1
StartPosition returns the start position of the index expression.
type NullLiteral ¶
NullLiteral defines a struct for a literal null value.
func (*NullLiteral) EndPosition ¶
func (e *NullLiteral) EndPosition() int
EndPosition returns the end position of the null literal.
func (*NullLiteral) Expr ¶
func (e *NullLiteral) Expr() string
Expr returns the expression of the null literal.
func (*NullLiteral) StartPosition ¶
func (e *NullLiteral) StartPosition() int
StartPosition returns the start position of the null literal.
func (*NullLiteral) Walk ¶
func (e *NullLiteral) Walk(fn func(node ExprNode) bool)
Walk walks the null literal.
type NumberLiteral ¶
NumberLiteral defines a struct for a literal number value.
func (*NumberLiteral) EndPosition ¶
func (e *NumberLiteral) EndPosition() int
EndPosition returns the end position of the number literal.
func (*NumberLiteral) Expr ¶
func (e *NumberLiteral) Expr() string
Expr returns the expression of the number literal.
func (*NumberLiteral) StartPosition ¶
func (e *NumberLiteral) StartPosition() int
StartPosition returns the start position of the number literal.
func (*NumberLiteral) Walk ¶
func (e *NumberLiteral) Walk(fn func(node ExprNode) bool)
Walk walks the number literal.
type PrefixExpr ¶
PrefixExpr defines a struct for a prefix expression.
func (*PrefixExpr) EndPosition ¶
func (e *PrefixExpr) EndPosition() int
EndPosition returns the end position of the prefix expression.
func (*PrefixExpr) Expr ¶
func (e *PrefixExpr) Expr() string
Expr returns the expression of the prefix expression.
func (*PrefixExpr) StartPosition ¶
func (e *PrefixExpr) StartPosition() int
StartPosition returns the start position of the prefix expression.
func (*PrefixExpr) Walk ¶
func (e *PrefixExpr) Walk(fn func(node ExprNode) bool)
Walk walks the prefix expression and its operand.
type ReturnStatement ¶ added in v0.1.1
ReturnStatement represents a return statement.
func (*ReturnStatement) EndPosition ¶ added in v0.1.1
func (b *ReturnStatement) EndPosition() int
EndPosition returns the end position of the return statement.
func (*ReturnStatement) Expr ¶ added in v0.1.1
func (b *ReturnStatement) Expr() string
Expr returns the expression of the return statement.
func (*ReturnStatement) StartPosition ¶ added in v0.1.1
func (b *ReturnStatement) StartPosition() int
StartPosition returns the start position of the return statement.
func (*ReturnStatement) Walk ¶ added in v0.1.1
func (b *ReturnStatement) Walk(fn func(node ExprNode) bool)
Walk walks the return statement.
type ShorthandAssignmentExpr ¶ added in v0.1.1
type ShorthandAssignmentExpr struct {
Left ExprNode
Right ExprNode
Operator token.Token
StartPos int
EndPos int
}
ShorthandAssignmentExpr represents a shorthand assignment expression.
func (*ShorthandAssignmentExpr) EndPosition ¶ added in v0.1.1
func (s *ShorthandAssignmentExpr) EndPosition() int
EndPosition returns the end position of the shorthand assignment expression.
func (*ShorthandAssignmentExpr) Expr ¶ added in v0.1.1
func (s *ShorthandAssignmentExpr) Expr() string
Expr returns the expression of the shorthand assignment expression.
func (*ShorthandAssignmentExpr) StartPosition ¶ added in v0.1.1
func (s *ShorthandAssignmentExpr) StartPosition() int
StartPosition returns the start position of the shorthand assignment expression.
func (*ShorthandAssignmentExpr) Walk ¶ added in v0.1.1
func (s *ShorthandAssignmentExpr) Walk(fn func(node ExprNode) bool)
Walk walks the shorthand assignment expreession.
type SpreadExpr ¶ added in v0.1.1
SpreadExpr represents a spread expression.
func (*SpreadExpr) EndPosition ¶ added in v0.1.1
func (s *SpreadExpr) EndPosition() int
EndPosition returns the end position of the spread expression.
func (*SpreadExpr) Expr ¶ added in v0.1.1
func (s *SpreadExpr) Expr() string
Expr returns the expression of the spread expression.
func (*SpreadExpr) StartPosition ¶ added in v0.1.1
func (s *SpreadExpr) StartPosition() int
StartPosition returns the start position of the spread expression.
func (*SpreadExpr) Walk ¶ added in v0.1.1
func (s *SpreadExpr) Walk(fn func(node ExprNode) bool)
Walk walks the spread expression.
type StatementList ¶
StatementList represents multiple statements separated by newlines.
func (*StatementList) EndPosition ¶
func (sl *StatementList) EndPosition() int
EndPosition returns the end position of the statement list.
func (*StatementList) Expr ¶
func (sl *StatementList) Expr() string
Expr returns the expression in the statement list.
func (*StatementList) StartPosition ¶
func (sl *StatementList) StartPosition() int
StartPosition returns the start position of the statement list.
func (*StatementList) Walk ¶
func (sl *StatementList) Walk(fn func(node ExprNode) bool)
Walk walks the statement list and its statements.
type StringLiteral ¶
StringLiteral defines a struct for a literal string value.
func (*StringLiteral) EndPosition ¶
func (e *StringLiteral) EndPosition() int
EndPosition returns the end position of the string literal.
func (*StringLiteral) Expr ¶
func (e *StringLiteral) Expr() string
Expr returns the expression of the string literal.
func (*StringLiteral) StartPosition ¶
func (e *StringLiteral) StartPosition() int
StartPosition returns the start position of the string literal.
func (*StringLiteral) Walk ¶
func (e *StringLiteral) Walk(fn func(node ExprNode) bool)
Walk walks the string literal.
type VariableDeclaration ¶
VariableDeclaration represents a variable declaration.
func (*VariableDeclaration) EndPosition ¶
func (v *VariableDeclaration) EndPosition() int
EndPosition returns the end position of the variable declaration.
func (*VariableDeclaration) Expr ¶
func (v *VariableDeclaration) Expr() string
Expr returns the expression of the variable declaration.
func (*VariableDeclaration) StartPosition ¶
func (v *VariableDeclaration) StartPosition() int
StartPosition returns the start position of the variable declaration.
func (*VariableDeclaration) Walk ¶
func (v *VariableDeclaration) Walk(fn func(node ExprNode) bool)
Walk walks the variable declaration and its value.
Source Files
¶
- any_literal.go
- array_literal.go
- assignment_statement.go
- ast.go
- binary_expr.go
- block_statement.go
- bool_literal.go
- break_statement.go
- constant_declaration.go
- continue_statement.go
- expr_node.go
- for_statement.go
- func_declaration_statement.go
- func_parameter.go
- function_call.go
- identifier.go
- if_statement.go
- import_statement.go
- index_assignment_statement.go
- index_expr.go
- null_literal.go
- number_literal.go
- prefix_expr.go
- return_statement.go
- shorthand_assignment_expr.go
- spread_expr.go
- statement_list.go
- string_literal.go
- variable_declaration.go