Documentation ¶
Index ¶
- type ArrayLiteral
- type AssignStatement
- type BlockStatement
- type Boolean
- type CallExpression
- type Expression
- type ExpressionStatement
- type FloatLiteral
- type FunctionLiteral
- type HashLiteral
- type Ident
- type IfExpression
- type IndexExpression
- type InfixExpression
- type IntegerLiteral
- type LetStatement
- type MacroLiteral
- type ModifierFunc
- type Nil
- type Node
- type PrefixExpression
- type Program
- type ReturnStatement
- type Statement
- type StringLiteral
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 an array literal.
func (*ArrayLiteral) String ¶
func (al *ArrayLiteral) String() string
func (*ArrayLiteral) TokenLiteral ¶
func (al *ArrayLiteral) TokenLiteral() string
TokenLiteral returns a token literal of array.
type AssignStatement ¶
type AssignStatement struct { Token token.Token // token.ASSIGN LHS, RHS Expression }
AssignStatement represents an assignment statement.
func (*AssignStatement) String ¶
func (as *AssignStatement) String() string
func (*AssignStatement) TokenLiteral ¶
func (as *AssignStatement) TokenLiteral() string
TokenLiteral returns a token literal of assignment statement.
type BlockStatement ¶
BlockStatement represents a block statement.
func (*BlockStatement) String ¶
func (bs *BlockStatement) String() string
func (*BlockStatement) TokenLiteral ¶
func (bs *BlockStatement) TokenLiteral() string
TokenLiteral returns a token literal of block statement.
type Boolean ¶
Boolean represents a boolean value.
func (*Boolean) TokenLiteral ¶
TokenLiteral returns a token literal of boolean value.
type CallExpression ¶
type CallExpression struct { Token token.Token // the '(' token Function Expression // Ident or FunctionLiteral Arguments []Expression }
CallExpression represents a function call expression.
func (*CallExpression) String ¶
func (ce *CallExpression) String() string
func (*CallExpression) TokenLiteral ¶
func (ce *CallExpression) TokenLiteral() string
TokenLiteral returns a token literal of function call expression.
type Expression ¶
type Expression interface { Node // contains filtered or unexported methods }
Expression represents an expression.
type ExpressionStatement ¶
type ExpressionStatement struct { Token token.Token // the first token of the expression Expression Expression }
ExpressionStatement represents an expression statement.
func (*ExpressionStatement) String ¶
func (es *ExpressionStatement) String() string
func (*ExpressionStatement) TokenLiteral ¶
func (es *ExpressionStatement) TokenLiteral() string
TokenLiteral returns a token literal of expression statement.
type FloatLiteral ¶
FloatLiteral represents a floating point number literal.
func (*FloatLiteral) String ¶
func (fl *FloatLiteral) String() string
func (*FloatLiteral) TokenLiteral ¶
func (fl *FloatLiteral) TokenLiteral() string
TokenLiteral returns a token literal of floating point number.
type FunctionLiteral ¶
type FunctionLiteral struct { Token token.Token Parameters []*Ident Body *BlockStatement Name string }
FunctionLiteral represents a fuction literal.
func (*FunctionLiteral) String ¶
func (fl *FunctionLiteral) String() string
func (*FunctionLiteral) TokenLiteral ¶
func (fl *FunctionLiteral) TokenLiteral() string
TokenLiteral returns a token literal of function.
type HashLiteral ¶
type HashLiteral struct { Token token.Token // the '{' token Pairs map[Expression]Expression }
HashLiteral represents a hash literal.
func (*HashLiteral) String ¶
func (hl *HashLiteral) String() string
func (*HashLiteral) TokenLiteral ¶
func (hl *HashLiteral) TokenLiteral() string
TokenLiteral returns a token literal of hash.
type Ident ¶
Ident represents an identifier.
func (*Ident) TokenLiteral ¶
TokenLiteral returns a token literal of an identifier.
type IfExpression ¶
type IfExpression struct { Token token.Token // The 'if' token Condition Expression Consequence *BlockStatement Alternative *BlockStatement }
IfExpression represents an if expression.
func (*IfExpression) String ¶
func (ie *IfExpression) String() string
func (*IfExpression) TokenLiteral ¶
func (ie *IfExpression) TokenLiteral() string
TokenLiteral returns a token literal of if expression.
type IndexExpression ¶
type IndexExpression struct { Token token.Token // the '[' token Left Expression Index Expression }
IndexExpression represents an expression in array index operator.
func (*IndexExpression) String ¶
func (ie *IndexExpression) String() string
func (*IndexExpression) TokenLiteral ¶
func (ie *IndexExpression) TokenLiteral() string
TokenLiteral returns a token literal of array.
type InfixExpression ¶
type InfixExpression struct { Token token.Token // The operator token, e.g. + Left Expression Operator string Right Expression }
InfixExpression represents an infix expression.
func (*InfixExpression) String ¶
func (ie *InfixExpression) String() string
func (*InfixExpression) TokenLiteral ¶
func (ie *InfixExpression) TokenLiteral() string
TokenLiteral returns a token literal.
type IntegerLiteral ¶
IntegerLiteral represents an integer literal.
func (*IntegerLiteral) String ¶
func (il *IntegerLiteral) String() string
func (*IntegerLiteral) TokenLiteral ¶
func (il *IntegerLiteral) TokenLiteral() string
TokenLiteral returns a token literal of integer.
type LetStatement ¶
type LetStatement struct { Token token.Token // the token.LET token Name *Ident Value Expression }
LetStatement represents a let statement.
func (*LetStatement) String ¶
func (ls *LetStatement) String() string
func (*LetStatement) TokenLiteral ¶
func (ls *LetStatement) TokenLiteral() string
TokenLiteral returns a token literal of let statement.
type MacroLiteral ¶
type MacroLiteral struct { Token token.Token Parameters []*Ident Body *BlockStatement }
MacroLiteral represents a macro literal.
func (*MacroLiteral) String ¶
func (ml *MacroLiteral) String() string
func (*MacroLiteral) TokenLiteral ¶
func (ml *MacroLiteral) TokenLiteral() string
TokenLiteral returns a token literal of function.
type ModifierFunc ¶
ModifierFunc represents a function which modifies a node.
type Nil ¶
Nil represents nil value.
func (*Nil) TokenLiteral ¶
TokenLiteral returns a token literal of nil value.
type Node ¶
Node represents an AST node.
func Modify ¶
func Modify(node Node, modifier ModifierFunc) Node
Modify modifies a `node` using `modifier` function.
type PrefixExpression ¶
type PrefixExpression struct { Token token.Token // The prefix token, e.g. ! Operator string Right Expression }
PrefixExpression represents a prefix expression.
func (*PrefixExpression) String ¶
func (pe *PrefixExpression) String() string
func (*PrefixExpression) TokenLiteral ¶
func (pe *PrefixExpression) TokenLiteral() string
TokenLiteral returns a token literal.
type Program ¶
type Program struct {
Statements []Statement
}
Program is a top-level AST node of a program.
func (*Program) TokenLiteral ¶
TokenLiteral returns the first token literal of a program.
type ReturnStatement ¶
type ReturnStatement struct { Token token.Token // the token.RETURN token ReturnValue Expression }
ReturnStatement represents a return statement.
func (*ReturnStatement) String ¶
func (rs *ReturnStatement) String() string
func (*ReturnStatement) TokenLiteral ¶
func (rs *ReturnStatement) TokenLiteral() string
TokenLiteral returns a token literal of return statement.
type Statement ¶
type Statement interface { Node // contains filtered or unexported methods }
Statement represents a statement.
type StringLiteral ¶
StringLiteral represents a string literal.
func (*StringLiteral) String ¶
func (sl *StringLiteral) String() string
func (*StringLiteral) TokenLiteral ¶
func (sl *StringLiteral) TokenLiteral() string
TokenLiteral returns a token literal of string.