Documentation
¶
Overview ¶
Package ast defines the various building blocks of the interpreter's abstract syntax tree (ast)
Index ¶
- type ArrayLiteral
- type BlockStatement
- type Boolean
- type CallExpression
- type Expression
- type ExpressionStatement
- type FunctionLiteral
- type HashLiteral
- type Identifier
- type IfExpression
- type IndexExpression
- type InfixExpression
- type IntegerLiteral
- type LetStatement
- type Node
- type PrefixExpression
- type Program
- type ReturnStatement
- type SetStatement
- 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 gitoken.Token Elements []Expression }
ArrayLiteral is an ast node representing an array of the form: '[<ELEM1>, <ELEME2>, ..., <ELEMn>]'
func (*ArrayLiteral) String ¶
func (al *ArrayLiteral) String() string
func (*ArrayLiteral) TokenLiteral ¶
func (al *ArrayLiteral) TokenLiteral() string
TokenLiteral returns the literal string of the token
type BlockStatement ¶
BlockStatement is an ast node representing a collection of statement and an initiating token
func (*BlockStatement) String ¶
func (bs *BlockStatement) String() string
func (*BlockStatement) TokenLiteral ¶
func (bs *BlockStatement) TokenLiteral() string
TokenLiteral returns the literal string of the token
type Boolean ¶
Boolean is an ast node representing a boolean value
func (*Boolean) TokenLiteral ¶
TokenLiteral returns the literal string of the token
type CallExpression ¶
type CallExpression struct { Token gitoken.Token Function Expression Arguments []Expression }
CallExpression is an ast node representing an expression of the form: 'FNIDENT(PARAMS)'
func (*CallExpression) String ¶
func (ce *CallExpression) String() string
func (*CallExpression) TokenLiteral ¶
func (ce *CallExpression) TokenLiteral() string
TokenLiteral returns the literal string of the token
type Expression ¶
type Expression interface { Node // contains filtered or unexported methods }
Expression is an interface enclosing a node and to be implemented by the language's expression
type ExpressionStatement ¶
type ExpressionStatement struct { Token gitoken.Token Expression Expression }
ExpressionStatement is an ast node representing a statement of the form: '<EXPR>'
func (*ExpressionStatement) String ¶
func (es *ExpressionStatement) String() string
func (*ExpressionStatement) TokenLiteral ¶
func (es *ExpressionStatement) TokenLiteral() string
TokenLiteral returns the literal string of the token
type FunctionLiteral ¶
type FunctionLiteral struct { Token gitoken.Token Parameters []*Identifier Body *BlockStatement }
FunctionLiteral is an ast node representing a function of the form: 'fn(<PARAMS>) ast.BlockStatement'
func (*FunctionLiteral) String ¶
func (fl *FunctionLiteral) String() string
func (*FunctionLiteral) TokenLiteral ¶
func (fl *FunctionLiteral) TokenLiteral() string
TokenLiteral returns the literal string of the token
type HashLiteral ¶
type HashLiteral struct { Token gitoken.Token Pairs map[Expression]Expression }
HashLiteral is an ast node representing a hash of the form: '{<KEY1>: <VAL1>, <KEY2>: <VAL2>, ..., <KEYn>: <VALn>}'
func (*HashLiteral) String ¶
func (hl *HashLiteral) String() string
func (*HashLiteral) TokenLiteral ¶
func (hl *HashLiteral) TokenLiteral() string
TokenLiteral returns the literal string of the token
type Identifier ¶
Identifier is an identifier node
func (*Identifier) String ¶
func (i *Identifier) String() string
func (*Identifier) TokenLiteral ¶
func (i *Identifier) TokenLiteral() string
TokenLiteral returns the literal string of the token
type IfExpression ¶
type IfExpression struct { Token gitoken.Token Condition Expression Consequence *BlockStatement Alternative *BlockStatement }
IfExpression is an ast node representing an expression of the form: 'if(<EXPR>) ast.BlockStatement else ast.BlockStatement '
func (*IfExpression) String ¶
func (ie *IfExpression) String() string
func (*IfExpression) TokenLiteral ¶
func (ie *IfExpression) TokenLiteral() string
TokenLiteral returns the literal string of the token
type IndexExpression ¶
type IndexExpression struct { Token gitoken.Token Left Expression Index Expression }
IndexExpression is an ast node representing an expression of the form: 'ARRAY[<EXPR>]'
func (*IndexExpression) String ¶
func (ie *IndexExpression) String() string
func (*IndexExpression) TokenLiteral ¶
func (ie *IndexExpression) TokenLiteral() string
TokenLiteral returns the literal string of the token
type InfixExpression ¶
type InfixExpression struct { Token gitoken.Token Left Expression Operator string Right Expression }
InfixExpression is an ast node representing an expression of the form: '<EXPR> <OPERATOR> <EXPR>'
func (*InfixExpression) String ¶
func (ie *InfixExpression) String() string
func (*InfixExpression) TokenLiteral ¶
func (ie *InfixExpression) TokenLiteral() string
TokenLiteral returns the literal string of the token
type IntegerLiteral ¶
IntegerLiteral is an ast node representing an integer value
func (*IntegerLiteral) String ¶
func (il *IntegerLiteral) String() string
func (*IntegerLiteral) TokenLiteral ¶
func (il *IntegerLiteral) TokenLiteral() string
TokenLiteral returns the literal string of the token
type LetStatement ¶
type LetStatement struct { Token gitoken.Token Name *Identifier Value Expression }
LetStatement is an ast node representing a statement of the form: 'let <IDENT> = <EXPR>
func (*LetStatement) String ¶
func (ls *LetStatement) String() string
func (*LetStatement) TokenLiteral ¶
func (ls *LetStatement) TokenLiteral() string
TokenLiteral returns the literal string of the token
type Node ¶
Node is an interface that needs to be implemented by every element that the AST will contain
type PrefixExpression ¶
type PrefixExpression struct { Token gitoken.Token Operator string Right Expression }
PrefixExpression is an ast node representing an expression of the form: '<OPERATOR><EXPR>'
func (*PrefixExpression) String ¶
func (pe *PrefixExpression) String() string
func (*PrefixExpression) TokenLiteral ¶
func (pe *PrefixExpression) TokenLiteral() string
TokenLiteral returns the literal string of the token
type Program ¶
type Program struct {
Statements []Statement
}
Program is a collection (slice) of statements that represents the input program
func (*Program) TokenLiteral ¶
TokenLiteral returns the literal string of the token
type ReturnStatement ¶
type ReturnStatement struct { Token gitoken.Token ReturnValue Expression }
ReturnStatement is an ast node representing a statement of the form: 'return <EXPR>'
func (*ReturnStatement) String ¶
func (rs *ReturnStatement) String() string
func (*ReturnStatement) TokenLiteral ¶
func (rs *ReturnStatement) TokenLiteral() string
TokenLiteral returns the literal string of the token
type SetStatement ¶
type SetStatement struct { Token gitoken.Token Name *Identifier Value Expression }
SetStatement is an ast node representing a statement of the form: 'set <KEYWORD> <LITTERAL>
func (*SetStatement) String ¶
func (ls *SetStatement) String() string
func (*SetStatement) TokenLiteral ¶
func (ls *SetStatement) TokenLiteral() string
TokenLiteral returns the literal string of the token
type Statement ¶
type Statement interface { Node // contains filtered or unexported methods }
Statement is an interface enclosing a node and to be implemented by the language's statements
type StringLiteral ¶
StringLiteral is an ast node representing a string value
func (*StringLiteral) String ¶
func (sl *StringLiteral) String() string
func (*StringLiteral) TokenLiteral ¶
func (sl *StringLiteral) TokenLiteral() string
TokenLiteral returns the literal string of the token