Documentation ¶
Index ¶
- func Tree(node Node, indent int, name string) string
- type Block
- type Boolean
- type Break
- type Call
- type Export
- type Expression
- type ExpressionStatement
- type For
- type Identifier
- type If
- type Import
- type Infix
- type List
- type Map
- type Match
- type MatchBranch
- type Model
- type Next
- type Nil
- type Node
- type Number
- type Prefix
- type Program
- type Return
- type Statement
- type String
- type While
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Block ¶
type Block struct { Value []Statement // contains filtered or unexported fields }
A Block combines multiple statements into an expression.
type Boolean ¶
type Boolean struct { Value bool // contains filtered or unexported fields }
A Boolean represents a boolean literal.
type Break ¶
type Break struct {
// contains filtered or unexported fields
}
A Break statement exits out of a loop.
type Call ¶
type Call struct {
Function, Argument Expression
// contains filtered or unexported fields
}
A Call calls a function with the argument. If the argument is a tuple, each element of the tuple is passed as a separate argument.
type Export ¶
type Export struct { Names Expression // contains filtered or unexported fields }
An Export statement exposes variable(s) to the enclosing scope.
type Expression ¶
type Expression interface { Node Expr() }
An Expression is a node which evaluates to a value, for example a number literal.
type ExpressionStatement ¶
type ExpressionStatement struct { Expr Expression // contains filtered or unexported fields }
An ExpressionStatement is an expression which can take the place of a statement.
type For ¶
type For struct {
Var, Collection, Body Expression
// contains filtered or unexported fields
}
A For loop executes Body for each Var in Collection.
type Identifier ¶
type Identifier struct { Value string // contains filtered or unexported fields }
An Identifier represents a name in the variable store; evaluates to the value of that variable.
type If ¶
type If struct {
Condition, Consequence, Alternative Expression
// contains filtered or unexported fields
}
An If expression executes Consequence or Alternative based on Condition.
type Import ¶
type Import struct { Path string // contains filtered or unexported fields }
An Import statement imports the file or directory specified into the scope.
type Infix ¶
type Infix struct { Operator string Left, Right Expression // contains filtered or unexported fields }
An Infix is an infix operator expression, such as 1 + 2
type List ¶
type List struct { Value []Expression // contains filtered or unexported fields }
A List is a linked list of items.
type Map ¶
type Map struct { Value map[Expression]Expression // contains filtered or unexported fields }
A Map is a hashmap.
type Match ¶
type Match struct { Input Expression Branches []MatchBranch // contains filtered or unexported fields }
A Match executes a different piece of code based on the input value.
type MatchBranch ¶
type MatchBranch struct {
Condition, Body Expression
}
A MatchBranch is a condition -> body branch for use in a Match expression. Notice a MatchBranch isn't an Expression itself.
type Model ¶
type Model struct {
Parameters, Parent Expression
// contains filtered or unexported fields
}
A Model expression defines a new model. Parent is another model, since the syntax is `model dog (name) : animal (name, "dog")`.
type Next ¶
type Next struct {
// contains filtered or unexported fields
}
A Next statement jumps to the next iteration of a loop.
type Nil ¶
type Nil struct {
// contains filtered or unexported fields
}
Nil is the nil literal; the absence of a value.
type Number ¶
type Number struct { Value float64 // contains filtered or unexported fields }
A Number represents a number literal.
type Prefix ¶
type Prefix struct { Operator string Right Expression // contains filtered or unexported fields }
A Prefix is a prefix operator expression, such as -5.
type Program ¶
type Program struct {
Statements []Statement
}
A Program is a list of statements which, usually, represents an entire file.
type Return ¶
type Return struct { Value Expression // contains filtered or unexported fields }
A Return statement returns a value from a function.
type Statement ¶
type Statement interface { Node Stmt() }
A Statement is a node which doesn't evaluate to a value, for example a loop.
type String ¶
type String struct { Value string // contains filtered or unexported fields }
A String represents a unicode string literal.
type While ¶
type While struct {
Condition, Body Expression
// contains filtered or unexported fields
}
A While loop executes Body while Condition is true.