Documentation ¶
Overview ¶
Package ast provides structures for representing parsed source code.
The structures in this package will be initialized from the parser package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Array ¶
Array is zero or more elements.
func NewArrayNumbers ¶
NewArrayNumbers creates an Array with some number literal values.
type Assign ¶
type Assign struct { // There will always be at least one Lefts element. Lefts []Node // There may be one Right element, or the same number of elements as Lefts. Rights []Node }
Assign is a specific case of Binary, just for "=".
type Binary ¶
type Binary struct { // Op is TokenPlus, TokenMinusAssign, etc. It will never be TokenAssign, // this special case is handled in an Assign operation. Op string Left, Right Node }
Binary is an binary operator operation.
type Call ¶
type Call struct { // FunctionName is the name of the function being invoked. FunctionName string // Arguments contains zero or more elements that represent each of the // arguments respectively. Arguments []Node }
Call represents a function call with zero or more arguments.
type Case ¶
type Case struct { // Conditions will always contain at least one element. Conditions []Node // Statements may be nil. Statements []Node }
Case represents a switch case statement.
type Comment ¶
type Comment struct { Comment string // Func will be the name of the function this comment is attached to; // otherwise it will be empty. Func string }
Comment represents a single or multiline comment. All characters immediately following `//` are part of the comment (even the proceeding space) up to but not including the new line.
type For ¶
type For struct {
// All of Init, Condition and Next may be nil.
Init, Condition, Next Node
// Statements may be nil.
Statements []Node
}
For represents a for loop.
type Func ¶
type Func struct { // Name is the name of the function being declared. Name string // Arguments may contain zero or more elements. They will always be in the // order in which their are declared. Arguments []*Argument // Returns may contain zero or more types. They will always be in the order // in which they are declared. Returns []string // Statements can have zero or more elements for each of the ordered // discreet statements in the function. Statements []Node }
Func represents the definition of a function.
type Identifier ¶
type Identifier struct {
Name string
}
Identifier could refer to a variable, function, etc.
type KeyValue ¶
type KeyValue struct {
Key, Value Node
}
KeyValue represents a key-value pair used in maps and object initialization.
type Literal ¶
type Literal struct { Kind string Value string // Array is also used to hold the keys of the map. This is required for // iteration. Array []*Literal Map map[string]*Literal }
Literal represents a literal of any type.
func NewLiteralBool ¶
NewLiteralBool create a new literal representing a boolean value.
func NewLiteralChar ¶
NewLiteralChar create a new literal representing a character value.
func NewLiteralData ¶
NewLiteralData create a new literal representing a data value.
func NewLiteralNumber ¶
NewLiteralNumber create a new literal representing a number value.
func NewLiteralString ¶
NewLiteralString create a new literal representing a string value.
type Map ¶
Map is zero or more elements.
func NewMapNumbers ¶
NewMapNumbers creates a Map with some number literal values. This function is for convenience and should not be used for general production code.
type Return ¶
type Return struct { // Exprs can be zero or more elements. Exprs []Node }
Return is a statement to return values.