Documentation
¶
Index ¶
- func Inspect(node Node, visit func(Node) bool)
- func Walk(node Node, visit func(Node) bool)
- type ArrayLiteral
- type Assign
- type Await
- type AwaitAll
- type AwaitAny
- type AwaitRace
- type AwaitTimeout
- type BinOp
- type Block
- type Break
- type Call
- type Catch
- type ClassDefinition
- type Conditional
- type Continue
- type Decl
- type Echo
- type Exists
- type FieldAccess
- type Fn
- type For
- type Go
- type Ident
- type ImportSpec
- type Input
- type IsInstanceOf
- type Literal
- type MutableBinOp
- type Neg
- type Node
- type Not
- type Object
- type ObjectField
- type Operator
- type Package
- type Plus
- type Return
- type Slice
- type StringTemplate
- type Subscript
- type Switch
- type SwitchCase
- type Throw
- type While
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArrayLiteral ¶
ArrayLiteral is an array literal, `[a, b, c]`
func (ArrayLiteral) String ¶
func (node ArrayLiteral) String() string
String returns the literal as Evie source
type AwaitTimeout ¶
AwaitTimeout is `await.timeout(task, ms)`, which waits for the task for at most Timeout milliseconds
type BinOp ¶
type BinOp struct {
diag.Pos // [required]
Operator // [required]
Lhs Node // [required]
Rhs Node // [required]
}
BinOp is a binary expression such as `a + b` or `a < b`
type Catch ¶
Catch is `catch(expr)` or `catch { ... }`: it gives back the value of Action, or the error raised while running it
type ClassDefinition ¶
type ClassDefinition struct {
diag.Pos
Name string
NamePos diag.Pos // where the name is written; unknown for an unnamed class
Parent string
ParentPos diag.Pos // where the parent's name is written, when there is one
Args []string
ArgPos []diag.Pos // where each of Args is written
Action Node
}
ClassDefinition is a class declaration or expression: its constructor parameters, its optional parent and the body that declares its fields and methods
type Conditional ¶
type Conditional struct {
diag.Pos
Condition Node // [required]
Action Node // [required]
Otherwise Node // [optional]
}
Conditional is an if statement, with an optional else branch in Otherwise
func (Conditional) String ¶
func (node Conditional) String() string
String returns the statement as Evie source
type Decl ¶
Decl declares a binding: `x := v` and `const x := v` are static (immutable), `var x := v` is not
type FieldAccess ¶
type FieldAccess struct {
diag.Pos
Lhs Node
Rhs string
RhsPos diag.Pos // where the member's name is written
}
FieldAccess is `Lhs.Rhs`, reading a field, method or package member by name
func (FieldAccess) String ¶
func (fa FieldAccess) String() string
String returns the access as written, such as "user.name"
type Fn ¶
type Fn struct {
diag.Pos
Name string
NamePos diag.Pos // where the name is written; unknown for an unnamed fn
Args []string
ArgPos []diag.Pos // where each of Args is written
IsVariadic bool
Action Node
UsedAsExpr bool // if true then create and return, else declare
}
Fn is a function declaration, or a function expression when UsedAsExpr is set; with IsVariadic the last of Args collects any further arguments
type For ¶
type For struct {
diag.Pos
IndexVar string // optional, "" if none
IndexPos diag.Pos // where IndexVar is written, when there is one
ItemVar string // [required]
ItemPos diag.Pos // where ItemVar is written
Collection Node // [required]
Action Node // [required]
}
For is `for item in collection` or `for index, item in collection`
type ImportSpec ¶
type ImportSpec struct {
diag.Pos
Path string
Alias string // empty when not explicitly aliased
AliasPos diag.Pos // where the alias is written, when there is one
}
ImportSpec is one entry in `imports("path")` or `imports("path" as alias)`.
type IsInstanceOf ¶
IsInstanceOf is `Lhs is Rhs`, true when Lhs is of the type or class Rhs names
type MutableBinOp ¶
type MutableBinOp struct {
diag.Pos // [required]
Operator // [required]
Lhs Node // [required] can be e.g. Ident
Rhs Node // [required] can be e.g. Input[float64]
}
MutableBinOp is a compound assignment such as `x += 1`
func (MutableBinOp) String ¶
func (node MutableBinOp) String() string
String returns the assignment as Evie source
type Object ¶
type Object struct {
diag.Pos
Fields []ObjectField
End diag.Pos // the closing '}'
}
Object is an object literal, `{ key: value, ... }`
type ObjectField ¶
ObjectField is one `key: value` entry of an Object literal
func (ObjectField) String ¶
func (node ObjectField) String() string
String returns the entry as Evie source
type Operator ¶
type Operator int
Operator is a binary operator
type Package ¶
type Package struct {
diag.Pos
Name string
NamePos diag.Pos // where the package name is written
Imports []ImportSpec
Code []Node
}
Package is a parsed file: its package clause, its imports and its top-level code
type StringTemplate ¶
type StringTemplate struct {
diag.Pos
Parts []string // the literal text around the interpolations; one more than Args
Args []Node
}
StringTemplate is a backtick string with `{expr}` interpolations
func (StringTemplate) String ¶
func (node StringTemplate) String() string
String returns the template's text with each interpolation in braces
type Switch ¶
type Switch struct {
diag.Pos
Value Node // [optional] value to match against; nil for tagless switch
Cases []SwitchCase // list of case branches
Default Node // [optional] default action (ast.Block), nil if none
End diag.Pos // the closing '}'
}
Switch is a switch statement, matching Value against each case in order, or testing each case as a condition when Value is nil
type SwitchCase ¶
type SwitchCase struct {
diag.Pos
Values []Node // multiple case expressions e.g. case 1, 2, 3:
Action Node // body of the case (ast.Block)
}
SwitchCase is one `case a, b:` branch of a Switch