Documentation ¶
Overview ¶
Package ast : Statement and Expression node definitions used to build an Abstract Syntax Tree for Monkey programs
Index ¶
- type ArrayLiteral
- type AssignStatement
- type BlockStatement
- type Boolean
- type CallExpression
- type CharacterLiteral
- type Expression
- type ExpressionStatement
- type FloatLiteral
- type FunctionLiteral
- type HashLiteral
- type Identifier
- type IfExpression
- type IndexExpression
- type InfixExpression
- type IntegerLiteral
- type LetStatement
- type Node
- type PostfixExpression
- type PrefixExpression
- type Program
- type ReturnStatement
- type ShortcutAssignStatement
- 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 Elements []Expression }
ArrayLiteral : Expression node representing an array of elements
func (*ArrayLiteral) String ¶
func (al *ArrayLiteral) String() string
func (*ArrayLiteral) TokenLiteral ¶
func (al *ArrayLiteral) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type AssignStatement ¶
type AssignStatement struct { Token token.Token Name *Identifier Value Expression }
AssignStatement : Statement node representing assigning a value to an existing object
func (*AssignStatement) String ¶
func (as *AssignStatement) String() string
func (*AssignStatement) TokenLiteral ¶
func (as *AssignStatement) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type BlockStatement ¶
BlockStatement : Statement node representing a block of statements
func (*BlockStatement) String ¶
func (bs *BlockStatement) String() string
func (*BlockStatement) TokenLiteral ¶
func (bs *BlockStatement) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type Boolean ¶
Boolean : Expression node representing a boolean literal
func (*Boolean) TokenLiteral ¶
TokenLiteral : Returns the literal representation of the token
type CallExpression ¶
type CallExpression struct { Token token.Token Function Expression Arguments []Expression }
CallExpression : Expression node representing calling a function and passing it arguments
func (*CallExpression) String ¶
func (ce *CallExpression) String() string
func (*CallExpression) TokenLiteral ¶
func (ce *CallExpression) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type CharacterLiteral ¶
CharacterLiteral : Expression node representing a character literal
func (*CharacterLiteral) String ¶
func (cl *CharacterLiteral) String() string
func (*CharacterLiteral) TokenLiteral ¶
func (cl *CharacterLiteral) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type Expression ¶
type Expression interface { Node // contains filtered or unexported methods }
Expression : Generic AST expression node
type ExpressionStatement ¶
type ExpressionStatement struct { Token token.Token Expression Expression }
ExpressionStatement : Statement node representing a high-level expression
func (*ExpressionStatement) String ¶
func (es *ExpressionStatement) String() string
func (*ExpressionStatement) TokenLiteral ¶
func (es *ExpressionStatement) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type FloatLiteral ¶
FloatLiteral : Expression node representing an float literal
func (*FloatLiteral) String ¶
func (fl *FloatLiteral) String() string
func (*FloatLiteral) TokenLiteral ¶
func (fl *FloatLiteral) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type FunctionLiteral ¶
type FunctionLiteral struct { Token token.Token Parameters []*Identifier Body *BlockStatement }
FunctionLiteral : Expression node representing a function literal including its parameters and body statements
func (*FunctionLiteral) String ¶
func (fl *FunctionLiteral) String() string
func (*FunctionLiteral) TokenLiteral ¶
func (fl *FunctionLiteral) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type HashLiteral ¶
type HashLiteral struct { Token token.Token Pairs map[Expression]Expression }
HashLiteral : Expression node representing a map of key-value pairs
func (*HashLiteral) String ¶
func (hl *HashLiteral) String() string
func (*HashLiteral) TokenLiteral ¶
func (hl *HashLiteral) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type Identifier ¶
Identifier : Expression node representing an identifier literal
func (*Identifier) String ¶
func (i *Identifier) String() string
func (*Identifier) TokenLiteral ¶
func (i *Identifier) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type IfExpression ¶
type IfExpression struct { Token token.Token Condition Expression Consequence *BlockStatement Alternative *BlockStatement }
IfExpression : Expression node representing an if/else block
func (*IfExpression) String ¶
func (ie *IfExpression) String() string
func (*IfExpression) TokenLiteral ¶
func (ie *IfExpression) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type IndexExpression ¶
type IndexExpression struct { Token token.Token Left Expression Index Expression }
IndexExpression : Expression node representing finding the index of an array
func (*IndexExpression) String ¶
func (ie *IndexExpression) String() string
func (*IndexExpression) TokenLiteral ¶
func (ie *IndexExpression) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type InfixExpression ¶
type InfixExpression struct { Token token.Token Left Expression Operator string Right Expression }
InfixExpression : Expression node representing infix expressions such as arithmetic and comparisons
func (*InfixExpression) String ¶
func (ie *InfixExpression) String() string
func (*InfixExpression) TokenLiteral ¶
func (ie *InfixExpression) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type IntegerLiteral ¶
IntegerLiteral : Expression node representing an integer literal
func (*IntegerLiteral) String ¶
func (il *IntegerLiteral) String() string
func (*IntegerLiteral) TokenLiteral ¶
func (il *IntegerLiteral) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type LetStatement ¶
type LetStatement struct { Token token.Token Name *Identifier Value Expression }
LetStatement : Statement node representing variable declaration and assignment
func (*LetStatement) String ¶
func (ls *LetStatement) String() string
func (*LetStatement) TokenLiteral ¶
func (ls *LetStatement) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type PostfixExpression ¶
type PostfixExpression struct { Token token.Token Left Expression Operator string }
PostfixExpression : Expression node representing postfix expressions like incrementing and decrementing
func (*PostfixExpression) String ¶
func (pe *PostfixExpression) String() string
func (*PostfixExpression) TokenLiteral ¶
func (pe *PostfixExpression) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type PrefixExpression ¶
type PrefixExpression struct { Token token.Token Operator string Right Expression }
PrefixExpression : Expression node representing prefix expressions like negative numbers, negation, and prefix incrementing/decrementing
func (*PrefixExpression) String ¶
func (pe *PrefixExpression) String() string
func (*PrefixExpression) TokenLiteral ¶
func (pe *PrefixExpression) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type Program ¶
type Program struct {
Statements []Statement
}
Program : Top level construct containing all parsed AST nodes
func (*Program) TokenLiteral ¶
TokenLiteral : Returns the literal representations of the tokens for each of the program's statements
type ReturnStatement ¶
type ReturnStatement struct { Token token.Token ReturnValue Expression }
ReturnStatement : Statement node representing returning a value
func (*ReturnStatement) String ¶
func (rs *ReturnStatement) String() string
func (*ReturnStatement) TokenLiteral ¶
func (rs *ReturnStatement) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type ShortcutAssignStatement ¶
type ShortcutAssignStatement struct { Token token.Token Name *Identifier Value Expression Operator string }
ShortcutAssignStatement : Statement node representing doing an operator to the existing object and assigning that new value
func (*ShortcutAssignStatement) String ¶
func (sas *ShortcutAssignStatement) String() string
func (*ShortcutAssignStatement) TokenLiteral ¶
func (sas *ShortcutAssignStatement) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type Statement ¶
type Statement interface { Node // contains filtered or unexported methods }
Statement : Generic AST statement node
type StringLiteral ¶
StringLiteral : Expression node representing a string literal
func (*StringLiteral) String ¶
func (sl *StringLiteral) String() string
func (*StringLiteral) TokenLiteral ¶
func (sl *StringLiteral) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token
type WhileExpression ¶
type WhileExpression struct { Token token.Token Condition Expression Block *BlockStatement }
WhileExpression : Expression node representing a while loop
func (*WhileExpression) String ¶
func (we *WhileExpression) String() string
func (*WhileExpression) TokenLiteral ¶
func (we *WhileExpression) TokenLiteral() string
TokenLiteral : Returns the literal representation of the token