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 CommentLiteral
- 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 NewlineLiteral
- type NullLiteral
- type NumberLiteral
- type Position
- type PrefixExpr
- type Range
- 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) Expr ¶ added in v0.1.1
func (e *AnyLiteral) Expr() string
Expr returns the expression of the any literal.
func (*AnyLiteral) GetRange ¶ added in v0.1.2
func (e *AnyLiteral) GetRange() Range
GetRange returns the range 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) Expr ¶ added in v0.1.1
func (e *ArrayLiteral) Expr() string
Expr returns the expression of the array literal.
func (*ArrayLiteral) GetRange ¶ added in v0.1.2
func (e *ArrayLiteral) GetRange() Range
GetRange returns the range 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
Range Range
}
AssignmentStatement represents an assignment statement.
func (*AssignmentStatement) Expr ¶
func (a *AssignmentStatement) Expr() string
Expr returns the expression of the assignment statement.
func (*AssignmentStatement) GetRange ¶ added in v0.1.2
func (a *AssignmentStatement) GetRange() Range
GetRange returns the range 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 ¶
BinaryExpr defines a struct for a binary expression.
func (*BinaryExpr) Expr ¶
func (e *BinaryExpr) Expr() string
Expr returns the expression of the binary expression.
func (*BinaryExpr) GetRange ¶ added in v0.1.2
func (e *BinaryExpr) GetRange() Range
GetRange returns the range 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) Expr ¶
func (e *BlockStatement) Expr() string
Expr returns the expression of the block statement.
func (*BlockStatement) GetRange ¶ added in v0.1.2
func (e *BlockStatement) GetRange() Range
GetRange returns the range 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) Expr ¶
func (e *BoolLiteral) Expr() string
Expr returns the expression of the boolean literal.
func (*BoolLiteral) GetRange ¶ added in v0.1.2
func (e *BoolLiteral) GetRange() Range
GetRange returns the range 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) Expr ¶
func (b *BreakStatement) Expr() string
Expr returns the expression of the break statement.
func (*BreakStatement) GetRange ¶ added in v0.1.2
func (b *BreakStatement) GetRange() Range
GetRange returns the range of the break statement.
func (*BreakStatement) Walk ¶
func (b *BreakStatement) Walk(fn func(node ExprNode) bool)
Walk walks the break statement.
type CommentLiteral ¶ added in v0.1.2
CommentLiteral defines a struct for a comment literal.
func (*CommentLiteral) Expr ¶ added in v0.1.2
func (e *CommentLiteral) Expr() string
Expr returns the expression of the comment literal.
func (*CommentLiteral) GetRange ¶ added in v0.1.2
func (e *CommentLiteral) GetRange() Range
GetRange returns the range of the comment literal.
func (*CommentLiteral) Walk ¶ added in v0.1.2
func (e *CommentLiteral) Walk(_ func(node ExprNode) bool)
Walk walks the comment literal.
type ConstantDeclaration ¶
ConstantDeclaration represents a constant declaration.
func (*ConstantDeclaration) Expr ¶
func (c *ConstantDeclaration) Expr() string
Expr returns the expression of the constant declaration.
func (*ConstantDeclaration) GetRange ¶ added in v0.1.2
func (c *ConstantDeclaration) GetRange() Range
GetRange returns the range 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) Expr ¶
func (c *ContinueStatement) Expr() string
Expr returns the expression of the continue statement.
func (*ContinueStatement) GetRange ¶ added in v0.1.2
func (c *ContinueStatement) GetRange() Range
GetRange returns the range of the continue statement.
func (*ContinueStatement) Walk ¶
func (c *ContinueStatement) Walk(fn func(node ExprNode) bool)
Walk walks the continue statement.
type ForStatement ¶
type ForStatement struct {
Condition ExprNode
Body *BlockStatement
Range Range
DeclaredVariable string
RangeVariable string
RangeFrom ExprNode
RangeTo ExprNode
IsRange bool
HasExplicitFrom bool
}
ForStatement represents a for statement.
func (*ForStatement) Expr ¶
func (f *ForStatement) Expr() string
Expr returns the expression of the for statement.
func (*ForStatement) GetRange ¶ added in v0.1.2
func (f *ForStatement) GetRange() Range
GetRange returns the range 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
Range Range
}
FuncDeclarationStatement represents a 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) GetRange ¶ added in v0.1.2
func (b *FuncDeclarationStatement) GetRange() Range
GetRange returns the range 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 ¶
FunctionCall defines a struct for a function call.
func (*FunctionCall) Expr ¶
func (fc *FunctionCall) Expr() string
Expr returns the expression of the function call.
func (*FunctionCall) GetRange ¶ added in v0.1.2
func (fc *FunctionCall) GetRange() Range
GetRange returns the range 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) Expr ¶
func (e *Identifier) Expr() string
Expr returns the expression of the identifier.
func (*Identifier) GetRange ¶ added in v0.1.2
func (e *Identifier) GetRange() Range
GetRange returns the range 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
Range Range
}
IfStatement defines a struct for an if statement.
func (*IfStatement) Expr ¶
func (e *IfStatement) Expr() string
Expr returns the expression of the if statement.
func (*IfStatement) GetRange ¶ added in v0.1.2
func (e *IfStatement) GetRange() Range
GetRange returns the range 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
Range Range
}
ImportStatement represents an import statement in the AST.
func (*ImportStatement) Expr ¶ added in v0.1.1
func (i *ImportStatement) Expr() string
Expr returns the expression of the import statement.
func (*ImportStatement) GetRange ¶ added in v0.1.2
func (i *ImportStatement) GetRange() Range
GetRange returns the range 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
IndexAssignmentStatement represents an assignment to an array index.
func (*IndexAssignmentStatement) Expr ¶ added in v0.1.1
func (a *IndexAssignmentStatement) Expr() string
Expr returns the expression of the index assignment statement.
func (*IndexAssignmentStatement) GetRange ¶ added in v0.1.2
func (a *IndexAssignmentStatement) GetRange() Range
GetRange returns the range 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.
type NewlineLiteral ¶ added in v0.1.2
type NewlineLiteral struct {
Range Range
}
NewlineLiteral defines a struct for a literal newline value.
func (*NewlineLiteral) Expr ¶ added in v0.1.2
func (e *NewlineLiteral) Expr() string
Expr returns the expression of the newline literal.
func (*NewlineLiteral) GetRange ¶ added in v0.1.2
func (e *NewlineLiteral) GetRange() Range
GetRange returns the range of the newline literal.
func (*NewlineLiteral) Walk ¶ added in v0.1.2
func (e *NewlineLiteral) Walk(fn func(node ExprNode) bool)
Walk walks the newline literal.
type NullLiteral ¶
type NullLiteral struct {
Range Range
}
NullLiteral defines a struct for a literal null value.
func (*NullLiteral) Expr ¶
func (e *NullLiteral) Expr() string
Expr returns the expression of the null literal.
func (*NullLiteral) GetRange ¶ added in v0.1.2
func (e *NullLiteral) GetRange() Range
GetRange returns the range 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) Expr ¶
func (e *NumberLiteral) Expr() string
Expr returns the expression of the number literal.
func (*NumberLiteral) GetRange ¶ added in v0.1.2
func (e *NumberLiteral) GetRange() Range
GetRange returns the range 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) Expr ¶
func (e *PrefixExpr) Expr() string
Expr returns the expression of the prefix expression.
func (*PrefixExpr) GetRange ¶ added in v0.1.2
func (e *PrefixExpr) GetRange() Range
GetRange returns the range 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 Range ¶ added in v0.1.2
Range represents a range in the source code.
func (*Range) IsMultiLine ¶ added in v0.1.2
IsMultiLine returns true if the range is multi-line.
type ReturnStatement ¶ added in v0.1.1
ReturnStatement represents a 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) GetRange ¶ added in v0.1.2
func (b *ReturnStatement) GetRange() Range
GetRange returns the range 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
Range Range
}
ShorthandAssignmentExpr represents a 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) GetRange ¶ added in v0.1.2
func (s *ShorthandAssignmentExpr) GetRange() Range
GetRange returns the range 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) Expr ¶ added in v0.1.1
func (s *SpreadExpr) Expr() string
Expr returns the expression of the spread expression.
func (*SpreadExpr) GetRange ¶ added in v0.1.2
func (s *SpreadExpr) GetRange() Range
GetRange returns the range 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) Expr ¶
func (sl *StatementList) Expr() string
Expr returns the expression in the statement list.
func (*StatementList) GetRange ¶ added in v0.1.2
func (sl *StatementList) GetRange() Range
GetRange returns the range 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) Expr ¶
func (e *StringLiteral) Expr() string
Expr returns the expression of the string literal.
func (*StringLiteral) GetRange ¶ added in v0.1.2
func (e *StringLiteral) GetRange() Range
GetRange returns the range 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) Expr ¶
func (v *VariableDeclaration) Expr() string
Expr returns the expression of the variable declaration.
func (*VariableDeclaration) GetRange ¶ added in v0.1.2
func (v *VariableDeclaration) GetRange() Range
GetRange returns the range 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
- comment_literal.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
- newline_literal.go
- null_literal.go
- number_literal.go
- position.go
- prefix_expr.go
- return_statement.go
- shorthand_assignment_expr.go
- spread_expr.go
- statement_list.go
- string_literal.go
- variable_declaration.go