Documentation ¶
Index ¶
- type Array
- type BlockStatement
- type Bool
- type Declaration
- type DotExpression
- type ExprStatement
- type Expression
- type Flt
- type FnLiteral
- type FunctionCall
- type FunctionDecl
- type Identifier
- type IfExpression
- type IndexExpr
- type InfixExpr
- type Int
- type LetStatement
- type Literal
- type Map
- type Node
- type PrefixExpr
- type Program
- type ReturnStatement
- type Statement
- type Str
- type WhileStatement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array struct { Token lexer.Token Elements []Expression }
Array represents an array literal
func (*Array) TokenLiteral ¶
TokenLiteral implements Node for Array
type BlockStatement ¶
BlockStatement represents a block of statements surrounded by braces
func (*BlockStatement) Context ¶
func (bs *BlockStatement) Context() lexer.Context
Context implements Node for BlockStatement
func (*BlockStatement) String ¶
func (bs *BlockStatement) String() string
String implements Node for BlockStatement
func (*BlockStatement) TokenLiteral ¶
func (bs *BlockStatement) TokenLiteral() string
TokenLiteral implements Node for BlockStatement
type Bool ¶
Bool represents a boolean literal in the Monkey AST
func (*Bool) TokenLiteral ¶
TokenLiteral implements Node for Bool
type Declaration ¶
type Declaration interface { Node // contains filtered or unexported methods }
Declaration defines a top level declaration (e.g. class, fn)
type DotExpression ¶
type DotExpression struct { Token lexer.Token // Left can be any expression Left Expression // Right can only be a function call or a field Right Expression }
DotExpression defines a dot expression [EXPR].[EXPR]
func (*DotExpression) Context ¶
func (de *DotExpression) Context() lexer.Context
Context implements Node for DotExpression
func (*DotExpression) String ¶
func (de *DotExpression) String() string
String implements Node for DotExpression
func (*DotExpression) TokenLiteral ¶
func (de *DotExpression) TokenLiteral() string
TokenLiteral implements Node for DotExpression
type ExprStatement ¶
type ExprStatement struct { Token lexer.Token Expression Expression }
ExprStatement - represents a bare expression in Monkey
func (*ExprStatement) Context ¶
func (es *ExprStatement) Context() lexer.Context
Context implements Node for ExprStatement
func (*ExprStatement) String ¶
func (es *ExprStatement) String() string
func (*ExprStatement) TokenLiteral ¶
func (es *ExprStatement) TokenLiteral() string
TokenLiteral - Implements Node for ExpressionStatement
type Expression ¶
type Expression interface { Node // contains filtered or unexported methods }
Expression defines an expression in Monkey Syntax
type FnLiteral ¶
type FnLiteral struct { Token lexer.Token Params []*Identifier Body *BlockStatement }
FnLiteral represents a function declaration in Monkey
func (*FnLiteral) TokenLiteral ¶
TokenLiteral implements Node for FnLiteral
type FunctionCall ¶
type FunctionCall struct { Token lexer.Token Ident Expression Params []Expression }
FunctionCall defines a function call in Monkey
func (*FunctionCall) Context ¶
func (fc *FunctionCall) Context() lexer.Context
Context implements Node for FunctionCall
func (*FunctionCall) String ¶
func (fc *FunctionCall) String() string
String implements Node for FunctionCall
func (*FunctionCall) TokenLiteral ¶
func (fc *FunctionCall) TokenLiteral() string
TokenLiteral implements Node for FunctionCall
type FunctionDecl ¶
type FunctionDecl struct { Token lexer.Token Name *Identifier Params []*Identifier Body *BlockStatement }
FunctionDecl represents a function declaration
func (*FunctionDecl) Context ¶
func (fd *FunctionDecl) Context() lexer.Context
Context implements Node for FunctionDecl
func (*FunctionDecl) String ¶
func (fd *FunctionDecl) String() string
String implements Node for FunctionDecl
func (*FunctionDecl) TokenLiteral ¶
func (fd *FunctionDecl) TokenLiteral() string
TokenLiteral implements Node for FunctionDecl
type Identifier ¶
Identifier - represents a name bound to a function or a variable
func (*Identifier) Context ¶
func (i *Identifier) Context() lexer.Context
Context implements Node for Identifier
func (*Identifier) String ¶
func (i *Identifier) String() string
String - implements Node for Identifier
func (*Identifier) TokenLiteral ¶
func (i *Identifier) TokenLiteral() string
TokenLiteral - implements Node for Identifier
type IfExpression ¶
type IfExpression struct { Token lexer.Token Condition Expression Result *BlockStatement Alternative Node //! I don't like using a Node here, find a better alternative }
IfExpression represents an if statement/expr in Monkey
func (*IfExpression) Context ¶
func (ie *IfExpression) Context() lexer.Context
Context implements Node for IfExpression
func (*IfExpression) String ¶
func (ie *IfExpression) String() string
String implements Node for IfExpression
func (*IfExpression) TokenLiteral ¶
func (ie *IfExpression) TokenLiteral() string
TokenLiteral implements Node for IfExpression
type IndexExpr ¶
type IndexExpr struct { Token lexer.Token Left Expression Index Expression }
IndexExpr represents an index into an array or a map
func (*IndexExpr) TokenLiteral ¶
TokenLiteral implements Node for IndexExpr
type InfixExpr ¶
type InfixExpr struct { Token lexer.Token Left Expression Operator string Right Expression }
InfixExpr represents an expression with an infixed operator
func (*InfixExpr) TokenLiteral ¶
TokenLiteral implements Node for InfixExpr
type LetStatement ¶
type LetStatement struct { Token lexer.Token Name *Identifier Value Expression }
LetStatement - represents a let statement in the AST
func (*LetStatement) Context ¶
func (ls *LetStatement) Context() lexer.Context
Context implements Node for LetStatement
func (*LetStatement) String ¶
func (ls *LetStatement) String() string
func (*LetStatement) TokenLiteral ¶
func (ls *LetStatement) TokenLiteral() string
TokenLiteral - Implements Node for LetStatement
type Map ¶
type Map struct { Token lexer.Token Elements map[Expression]Expression }
Map represents a map literal
type PrefixExpr ¶
type PrefixExpr struct { Token lexer.Token Operator string Right Expression }
PrefixExpr represents a prefixed expression, such as ! or -
func (*PrefixExpr) Context ¶
func (pe *PrefixExpr) Context() lexer.Context
Context implements Node for PrefixExpr
func (*PrefixExpr) String ¶
func (pe *PrefixExpr) String() string
String implements Node for PrefixExpr
func (*PrefixExpr) TokenLiteral ¶
func (pe *PrefixExpr) TokenLiteral() string
TokenLiteral implements Node for PrefixExpr
type Program ¶
type Program struct { Statements []Statement Functions []*FunctionDecl }
Program represents the entire parsed program
func (*Program) TokenLiteral ¶
TokenLiteral implements Node for string
type ReturnStatement ¶
type ReturnStatement struct { Token lexer.Token Value Expression }
ReturnStatement - represents a return statement in the AST
func (*ReturnStatement) Context ¶
func (rs *ReturnStatement) Context() lexer.Context
Context implements Node for ReturnStatement
func (*ReturnStatement) String ¶
func (rs *ReturnStatement) String() string
func (*ReturnStatement) TokenLiteral ¶
func (rs *ReturnStatement) TokenLiteral() string
TokenLiteral - Implements Node for ReturnStatement
type Statement ¶
type Statement interface { Node // contains filtered or unexported methods }
Statement defines a statement in Monkey syntax
type WhileStatement ¶
type WhileStatement struct { Token lexer.Token Condition Expression Body *BlockStatement }
WhileStatement represents a while loop
func (*WhileStatement) Context ¶
func (ws *WhileStatement) Context() lexer.Context
Context implements Node for WhileStatement
func (*WhileStatement) String ¶
func (ws *WhileStatement) String() string
String implements Node for WhileStatement
func (*WhileStatement) TokenLiteral ¶
func (ws *WhileStatement) TokenLiteral() string
TokenLiteral implements Node for WhileStatement