Documentation ¶
Index ¶
- type ArrayLiteral
- type AssignmentExpression
- type BindExpression
- type BlockStatement
- type Boolean
- type CallExpression
- type Comment
- type Expression
- type ExpressionStatement
- type FunctionLiteral
- type HashLiteral
- type Identifier
- type IfExpression
- type ImportExpression
- type IndexExpression
- type InfixExpression
- type IntegerLiteral
- type Node
- type Null
- type PrefixExpression
- type Program
- type ReturnStatement
- type Statement
- type StringLiteral
- type WhileExpression
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayLiteral ¶
type ArrayLiteral struct { Token token.Token // the '[' token Elements []Expression }
ArrayLiteral represents the array literal and holds a list of expressions
func (*ArrayLiteral) String ¶
func (al *ArrayLiteral) String() string
String returns a stringified version of the AST for debugging
func (*ArrayLiteral) TokenLiteral ¶
func (al *ArrayLiteral) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type AssignmentExpression ¶
type AssignmentExpression struct { Token token.Token // The = token Left Expression Value Expression }
AssignmentExpression represents an assignment expression of the form: x = 1 or xs[1] = 2
func (*AssignmentExpression) String ¶
func (ae *AssignmentExpression) String() string
String returns a stringified version of the AST for debugging
func (*AssignmentExpression) TokenLiteral ¶
func (ae *AssignmentExpression) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type BindExpression ¶
type BindExpression struct { Token token.Token // The := token Left Expression Value Expression }
BindExpression represents a binding expression of the form: x := 1
func (*BindExpression) String ¶
func (be *BindExpression) String() string
String returns a stringified version of the AST for debugging
func (*BindExpression) TokenLiteral ¶
func (be *BindExpression) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type BlockStatement ¶
BlockStatement represents a block statement and holds one or more other statements
func (*BlockStatement) String ¶
func (bs *BlockStatement) String() string
String returns a stringified version of the AST for debugging
func (*BlockStatement) TokenLiteral ¶
func (bs *BlockStatement) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type Boolean ¶
Boolean represents a boolean value and holds the underlying boolean value
func (*Boolean) TokenLiteral ¶
TokenLiteral prints the literal value of the token associated with this node
type CallExpression ¶
type CallExpression struct { Token token.Token // The '(' token Function Expression // Identifier or FunctionLiteral Arguments []Expression }
CallExpression represents a call expression and holds the function to be called as well as the arguments to be passed to that function
func (*CallExpression) String ¶
func (ce *CallExpression) String() string
String returns a stringified version of the AST for debugging
func (*CallExpression) TokenLiteral ¶
func (ce *CallExpression) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type Comment ¶
Comment a comment
func (*Comment) TokenLiteral ¶
TokenLiteral prints the literal value of the token associated with this node
type Expression ¶
type Expression interface { Node // contains filtered or unexported methods }
Expression defines the interface for all expression nodes.
type ExpressionStatement ¶
type ExpressionStatement struct { Token token.Token // the first token of the expression Expression Expression }
ExpressionStatement represents an expression statement and holds an expression
func (*ExpressionStatement) String ¶
func (es *ExpressionStatement) String() string
String returns a stringified version of the AST for debugging
func (*ExpressionStatement) TokenLiteral ¶
func (es *ExpressionStatement) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type FunctionLiteral ¶
type FunctionLiteral struct { Token token.Token // The 'fn' token Name string Parameters []*Identifier Body *BlockStatement }
FunctionLiteral represents a literal functions and holds the function's formal parameters and boy of the function as a block statement
func (*FunctionLiteral) String ¶
func (fl *FunctionLiteral) String() string
String returns a stringified version of the AST for debugging
func (*FunctionLiteral) TokenLiteral ¶
func (fl *FunctionLiteral) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type HashLiteral ¶
type HashLiteral struct { Token token.Token // the '{' token Pairs map[Expression]Expression }
HashLiteral represents a hash map or dictionary literal, a set of key/value pairs.
func (*HashLiteral) String ¶
func (hl *HashLiteral) String() string
String returns a stringified version of the AST for debugging
func (*HashLiteral) TokenLiteral ¶
func (hl *HashLiteral) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type Identifier ¶
Identifier represents an identiifer and holds the name of the identifier
func (*Identifier) String ¶
func (i *Identifier) String() string
String returns a stringified version of the AST for debugging
func (*Identifier) TokenLiteral ¶
func (i *Identifier) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type IfExpression ¶
type IfExpression struct { Token token.Token // The 'if' token Condition Expression Consequence *BlockStatement Alternative *BlockStatement }
IfExpression represents an `if` expression and holds the condition, consequence and alternative expressions
func (*IfExpression) String ¶
func (ie *IfExpression) String() string
String returns a stringified version of the AST for debugging
func (*IfExpression) TokenLiteral ¶
func (ie *IfExpression) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type ImportExpression ¶ added in v1.3.0
type ImportExpression struct { Token token.Token // The 'import' token Name Expression }
ImportExpression represents an `import` expression and holds the name of the module being imported.
func (*ImportExpression) String ¶ added in v1.3.0
func (ie *ImportExpression) String() string
String returns a stringified version of the AST for debugging
func (*ImportExpression) TokenLiteral ¶ added in v1.3.0
func (ie *ImportExpression) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type IndexExpression ¶
type IndexExpression struct { Token token.Token // The [ token Left Expression Index Expression }
IndexExpression represents an index operator expression, e.g: xs[2] and holds the left expression and index expression
func (*IndexExpression) String ¶
func (ie *IndexExpression) String() string
String returns a stringified version of the AST for debugging
func (*IndexExpression) TokenLiteral ¶
func (ie *IndexExpression) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type InfixExpression ¶
type InfixExpression struct { Token token.Token // The operator token, e.g. + Left Expression Operator string Right Expression }
InfixExpression represents an infix expression and holds the left-hand expression, operator and right-hand expression
func (*InfixExpression) String ¶
func (ie *InfixExpression) String() string
String returns a stringified version of the AST for debugging
func (*InfixExpression) TokenLiteral ¶
func (ie *InfixExpression) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type IntegerLiteral ¶
IntegerLiteral represents a literal integare and holds an integer value
func (*IntegerLiteral) String ¶
func (il *IntegerLiteral) String() string
String returns a stringified version of the AST for debugging
func (*IntegerLiteral) TokenLiteral ¶
func (il *IntegerLiteral) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type Null ¶
Null represents a null value
func (*Null) TokenLiteral ¶
TokenLiteral prints the literal value of the token associated with this node
type PrefixExpression ¶
type PrefixExpression struct { Token token.Token // The prefix token, e.g. ! Operator string Right Expression }
PrefixExpression represents a prefix expression and holds the operator as well as the right-hand side expression
func (*PrefixExpression) String ¶
func (pe *PrefixExpression) String() string
String returns a stringified version of the AST for debugging
func (*PrefixExpression) TokenLiteral ¶
func (pe *PrefixExpression) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type Program ¶
type Program struct {
Statements []Statement
}
Program is the root node. All programs consist of a slice of Statement(s)
func (*Program) TokenLiteral ¶
TokenLiteral prints the literal value of the token associated with this node
type ReturnStatement ¶
type ReturnStatement struct { Token token.Token // the 'return' token ReturnValue Expression }
ReturnStatement represenets the `return` statement node
func (*ReturnStatement) String ¶
func (rs *ReturnStatement) String() string
String returns a stringified version of the AST for debugging
func (*ReturnStatement) TokenLiteral ¶
func (rs *ReturnStatement) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type Statement ¶
type Statement interface { Node // contains filtered or unexported methods }
Statement defines the interface for all statement nodes.
type StringLiteral ¶
StringLiteral represents a literal string and holds a string value
func (*StringLiteral) String ¶
func (sl *StringLiteral) String() string
String returns a stringified version of the AST for debugging
func (*StringLiteral) TokenLiteral ¶
func (sl *StringLiteral) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node
type WhileExpression ¶
type WhileExpression struct { Token token.Token // The 'while' token Condition Expression Consequence *BlockStatement }
WhileExpression represents an `while` expression and holds the condition, and consequence expression
func (*WhileExpression) String ¶
func (we *WhileExpression) String() string
String returns a stringified version of the AST for debugging
func (*WhileExpression) TokenLiteral ¶
func (we *WhileExpression) TokenLiteral() string
TokenLiteral prints the literal value of the token associated with this node