Documentation ¶
Index ¶
- type ArrayLiteral
- type AssignStatement
- type BlockStatement
- type Boolean
- type BreakStatement
- type CallExpression
- type CommandExpression
- type CompoundAssignment
- type ContinueStatement
- type CurrentArgsLiteral
- type Decorator
- type Deferrable
- type Deferred
- type Expression
- type ExpressionStatement
- type ForExpression
- type ForInExpression
- type FunctionLiteral
- type HashLiteral
- type Identifier
- type IfExpression
- type IndexExpression
- type InfixExpression
- type MethodExpression
- type Node
- type NullLiteral
- type NumberLiteral
- type Parameter
- type PrefixExpression
- type Program
- type PropertyExpression
- type ReturnStatement
- type Scenario
- 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 }
func (*ArrayLiteral) String ¶
func (al *ArrayLiteral) String() string
func (*ArrayLiteral) TokenLiteral ¶
func (al *ArrayLiteral) TokenLiteral() string
type AssignStatement ¶
type AssignStatement struct { Token token.Token // the token.ASSIGN token Name *Identifier Names []Expression Index *IndexExpression // support assignment to indexed expressions: a[0] = 1, h["a"] = 1 Property *PropertyExpression // support assignment to hash properties: h.a = 1 Value Expression }
Statements
func (*AssignStatement) String ¶
func (as *AssignStatement) String() string
func (*AssignStatement) TokenLiteral ¶
func (as *AssignStatement) TokenLiteral() string
type BlockStatement ¶
func (*BlockStatement) String ¶
func (bs *BlockStatement) String() string
func (*BlockStatement) TokenLiteral ¶
func (bs *BlockStatement) TokenLiteral() string
type Boolean ¶
func (*Boolean) TokenLiteral ¶
type BreakStatement ¶
func (*BreakStatement) String ¶
func (bs *BreakStatement) String() string
func (*BreakStatement) TokenLiteral ¶
func (bs *BreakStatement) TokenLiteral() string
type CallExpression ¶
type CallExpression struct { Token token.Token // The '(' token Function Expression // Identifier or FunctionLiteral Arguments []Expression Deferred }
func (*CallExpression) String ¶
func (ce *CallExpression) String() string
func (*CallExpression) TokenLiteral ¶
func (ce *CallExpression) TokenLiteral() string
type CommandExpression ¶
func (*CommandExpression) String ¶
func (ce *CommandExpression) String() string
func (*CommandExpression) TokenLiteral ¶
func (ce *CommandExpression) TokenLiteral() string
type CompoundAssignment ¶
type CompoundAssignment struct { Token token.Token // The operator token, e.g. + Left Expression Operator string Right Expression }
func (*CompoundAssignment) String ¶
func (ca *CompoundAssignment) String() string
func (*CompoundAssignment) TokenLiteral ¶
func (ca *CompoundAssignment) TokenLiteral() string
type ContinueStatement ¶
func (*ContinueStatement) String ¶
func (cs *ContinueStatement) String() string
func (*ContinueStatement) TokenLiteral ¶
func (cs *ContinueStatement) TokenLiteral() string
type CurrentArgsLiteral ¶
func (*CurrentArgsLiteral) String ¶
func (cal *CurrentArgsLiteral) String() string
func (*CurrentArgsLiteral) TokenLiteral ¶
func (cal *CurrentArgsLiteral) TokenLiteral() string
type Decorator ¶
type Decorator struct { Token token.Token // @ Expression Expression Decorated Expression }
func (*Decorator) TokenLiteral ¶
type Deferrable ¶
Deferrable is used to be able to check whether an expression needs to be executed now or at the end of the scope
type Deferred ¶
type Deferred struct {
// contains filtered or unexported fields
}
Deferred is a struct that can be embedded in order to define whether the current node needs to be executed right away or whether it should be deferred until the end of the current scope.
func (*Deferred) IsDeferred ¶
func (*Deferred) SetDeferred ¶
type Expression ¶
type Expression interface { Node // contains filtered or unexported methods }
All expression nodes implement this
type ExpressionStatement ¶
type ExpressionStatement struct { Token token.Token // the first token of the expression Expression Expression }
func (*ExpressionStatement) String ¶
func (es *ExpressionStatement) String() string
func (*ExpressionStatement) TokenLiteral ¶
func (es *ExpressionStatement) TokenLiteral() string
type ForExpression ¶
type ForExpression struct { Token token.Token // The 'for' token Identifier string // "x" Starter Statement // x = 0 Closer Statement // x++ Condition Expression // x < 1 Block *BlockStatement // The block executed inside the for loop }
func (*ForExpression) String ¶
func (fe *ForExpression) String() string
func (*ForExpression) TokenLiteral ¶
func (fe *ForExpression) TokenLiteral() string
type ForInExpression ¶
type ForInExpression struct { Token token.Token // The 'for' token Block *BlockStatement // The block executed inside the for loop Iterable Expression // An expression that should return an iterable ([1, 2, 3] or x in 1..10) Key string Value string Alternative *BlockStatement }
func (*ForInExpression) String ¶
func (fie *ForInExpression) String() string
func (*ForInExpression) TokenLiteral ¶
func (fie *ForInExpression) TokenLiteral() string
type FunctionLiteral ¶
type FunctionLiteral struct { Token token.Token // The 'fn' token Name string // identifier for this function Parameters []*Parameter Body *BlockStatement }
func (*FunctionLiteral) String ¶
func (fl *FunctionLiteral) String() string
func (*FunctionLiteral) TokenLiteral ¶
func (fl *FunctionLiteral) TokenLiteral() string
type HashLiteral ¶
type HashLiteral struct { Token token.Token // the '{' token Pairs map[Expression]Expression }
func (*HashLiteral) String ¶
func (hl *HashLiteral) String() string
func (*HashLiteral) TokenLiteral ¶
func (hl *HashLiteral) TokenLiteral() string
type Identifier ¶
Expressions
func (*Identifier) String ¶
func (i *Identifier) String() string
func (*Identifier) TokenLiteral ¶
func (i *Identifier) TokenLiteral() string
type IfExpression ¶
func (*IfExpression) String ¶
func (ie *IfExpression) String() string
func (*IfExpression) TokenLiteral ¶
func (ie *IfExpression) TokenLiteral() string
type IndexExpression ¶
type IndexExpression struct { Token token.Token // The [ token Left Expression // the argument on which the index is access eg array of array[1] Index Expression // the left-most index eg. 1 in array[1] or array[1:10] IsRange bool // whether the expression is a range (1:10) End Expression // the end of the range, if the expression is a range }
IndexExpression allows accessing a single index, or a range, over a string or an array.
array[1:10] -> left[index:end] array[1] -> left[index] string[1] -> left[index]
func (*IndexExpression) String ¶
func (ie *IndexExpression) String() string
func (*IndexExpression) TokenLiteral ¶
func (ie *IndexExpression) TokenLiteral() string
type InfixExpression ¶
type InfixExpression struct { Token token.Token // The operator token, e.g. + Left Expression Operator string Right Expression }
func (*InfixExpression) String ¶
func (ie *InfixExpression) String() string
func (*InfixExpression) TokenLiteral ¶
func (ie *InfixExpression) TokenLiteral() string
type MethodExpression ¶
type MethodExpression struct { Token token.Token // The operator token, e.g. . Object Expression Method Expression Arguments []Expression Optional bool Deferred }
func (*MethodExpression) String ¶
func (me *MethodExpression) String() string
func (*MethodExpression) TokenLiteral ¶
func (me *MethodExpression) TokenLiteral() string
type NullLiteral ¶
func (*NullLiteral) String ¶
func (nl *NullLiteral) String() string
func (*NullLiteral) TokenLiteral ¶
func (nl *NullLiteral) TokenLiteral() string
type NumberLiteral ¶
func (*NumberLiteral) String ¶
func (nl *NumberLiteral) String() string
func (*NumberLiteral) TokenLiteral ¶
func (nl *NumberLiteral) TokenLiteral() string
type Parameter ¶
type Parameter struct { *Identifier Default Expression }
Parameter is a function parameter fn(x, y = 2)
func (*Parameter) TokenLiteral ¶
type PrefixExpression ¶
type PrefixExpression struct { Token token.Token // The prefix token, e.g. ! Operator string Right Expression }
func (*PrefixExpression) String ¶
func (pe *PrefixExpression) String() string
func (*PrefixExpression) TokenLiteral ¶
func (pe *PrefixExpression) TokenLiteral() string
type Program ¶
type Program struct {
Statements []Statement
}
Represents the whole program as a bunch of statements
func (*Program) TokenLiteral ¶
type PropertyExpression ¶
type PropertyExpression struct { Token token.Token // The . token Object Expression Property Expression Optional bool }
func (*PropertyExpression) String ¶
func (pe *PropertyExpression) String() string
func (*PropertyExpression) TokenLiteral ¶
func (pe *PropertyExpression) TokenLiteral() string
type ReturnStatement ¶
type ReturnStatement struct { Token token.Token // the 'return' token ReturnValue Expression }
func (*ReturnStatement) String ¶
func (rs *ReturnStatement) String() string
func (*ReturnStatement) TokenLiteral ¶
func (rs *ReturnStatement) TokenLiteral() string
type Scenario ¶
type Scenario struct { Condition Expression Consequence *BlockStatement }
A scenario is used to represent a path within an IF block (if x = 2 { return x}). It has a condition (x = 2) and a consenquence (return x).
type Statement ¶
type Statement interface { Node // contains filtered or unexported methods }
All statement nodes implement this
type StringLiteral ¶
func (*StringLiteral) String ¶
func (sl *StringLiteral) String() string
func (*StringLiteral) TokenLiteral ¶
func (sl *StringLiteral) TokenLiteral() string
type WhileExpression ¶
type WhileExpression struct { Token token.Token // The 'while' token Condition Expression Consequence *BlockStatement }
func (*WhileExpression) String ¶
func (ie *WhileExpression) String() string
func (*WhileExpression) TokenLiteral ¶
func (ie *WhileExpression) TokenLiteral() string