std/jule/ast
Index
Variables
fn Unparen(mut e: &Expr): &Expr
struct AST
struct Node
struct Directive
struct ChanType
struct SliceType
struct ArrayType
fn IsAutoSized(*self): bool
struct MapType
struct RetType
struct Expr
struct RangeExpr
struct UseExpr
struct TupleExpr
struct LitExpr
struct UnsafeExpr
struct NameExpr
fn IsSelf(*self): bool
struct UnaryExpr
fn IsUnsafePtr(*self): bool
struct VariadicExpr
struct TypeAssertionExpr
struct NamespaceExpr
struct SelectorExpr
struct BinaryExpr
struct CallExpr
fn Unhandled(*self): bool
struct TypedBraceLit
struct BraceLit
fn IsEmpty(*self): bool
struct KeyValueExpr
struct SliceExpr
fn IsEmpty(*self): bool
struct IndexExpr
struct SlicingExpr
struct Constraint
struct Generic
struct Label
struct Goto
struct Fall
struct AssignLeft
struct Assign
struct Stmt
struct ScopeTree
struct ChanSend
struct Param
fn IsSelf(*self): bool
fn IsSmartptr(*self): bool
fn IsRefptr(*self): bool
struct Func
fn IsAnon(*self): bool
fn IsShort(*self): bool
fn IsDecl(*self): bool
struct Var
struct Ret
struct Iter
fn IsInfinite(*self): bool
struct WhileKind
fn IsWhileNext(*self): bool
struct RangeKind
struct Break
struct Continue
struct If
struct Else
struct Conditional
struct TypeAlias
struct Case
struct Match
struct Select
struct Use
struct EnumItem
fn IsAutoExpr(*self): bool
struct Enum
fn IsDefaultTyped(*self): bool
struct TypeEnumItem
struct TypeEnum
struct Field
struct Struct
struct Trait
struct Impl
fn IsTraitImpl(*self): bool
fn IsStructImpl(*self): bool
enum NodeData: type
enum ExprData: type
enum StmtData: type
enum IterKind: type
Variables
const (
SEND = 1 << iota
RECV
)
Channel directions.
let mut Ignored = new(ScopeTree) // Exception is ignored, like foo()!
let mut Forwarded = new(ScopeTree) // Exception is forwarded, like foo()?
Special exceptional handler scopes.
Unparen
fn Unparen(mut e: &Expr): &Expr
Returns the expression with any enclosing parentheses removed.
AST
struct AST {
File: &token::FileSet
TopDirectives: []&Directive
UseDecls: []&Use
Nodes: []Node
}
Abstract syntax tree.
Node
struct Node {
Token: &token::Token
Data: NodeData
}
AST Node.
Directive
struct Directive {
Tag: &token::Token
Args: []&token::Token
}
Directive.
ChanType
struct ChanType {
Arrow: &token::Token // Token of arrow.
Dir: int // Direction.
Value: &Expr // Value type.
}
Channel type.
SliceType
struct SliceType {
Value: &Expr // Value type.
}
Slice type.
ArrayType
struct ArrayType {
Value: &Expr // Value type.
Size: &Expr
}
Array type. Size expression is nil for auto-sized array.
IsAutoSized
fn IsAutoSized(*self): bool
Reports whether array is auto-sized.
MapType
struct MapType {
Key: &Expr
Value: &Expr
}
Map type.
RetType
struct RetType {
Type: &Expr
Names: []&token::Token
}
Return type. Field are nil for the void type.
Expr
struct Expr {
Token: &token::Token
End: &token::Token
Data: ExprData
}
Expression.
RangeExpr
struct RangeExpr {
X: &Expr // Expression.
}
Range expression represents an expression between parentheses.
UseExpr
struct UseExpr {
Token: &token::Token
X: &Expr // Expression.
}
Use expression.
TupleExpr
struct TupleExpr {
X: []&Expr // Expressions.
}
Tuple expression.
LitExpr
struct LitExpr {
Token: &token::Token
Value: str
}
Literal expression.
UnsafeExpr
struct UnsafeExpr {
Token: &token::Token // Token of the unsafe keyword.
X: &Expr // Expression.
}
Unsafe expression.
NameExpr
struct NameExpr {
Token: &token::Token // Token of identifier.
Name: str // The name.
Bind: bool // It is in the bind namespace.
}
Identifier expression.
IsSelf
fn IsSelf(*self): bool
Reports whether identifier is self keyword.
UnaryExpr
struct UnaryExpr {
Op: &token::Token // Token of the operator.
X: &Expr // Expression.
}
Unary expression. For the unsafe pointer (*unsafe) type, Op is star and Expr is nil.
IsUnsafePtr
fn IsUnsafePtr(*self): bool
Reports whether the unary expression is the unsafe pointer type declaration.
VariadicExpr
struct VariadicExpr {
Token: &token::Token
X: &Expr // Expression to variadic.
}
Variadiced expression.
TypeAssertionExpr
struct TypeAssertionExpr {
Type: &Expr
X: &Expr // Expression to assert.
}
Type assertion expression.
NamespaceExpr
struct NamespaceExpr {
Namespace: &token::Token // Tokens of the namespace identifier.
Name: &token::Token // Token of the selected identifier.
}
Namespace identifier selection expression.
SelectorExpr
struct SelectorExpr {
X: &Expr // Memory selection based on.
Name: &token::Token // Token of the selected identifier.
}
Identifier selector expression.
BinaryExpr
struct BinaryExpr {
X: &Expr // Left operand.
Y: &Expr // Right operand.
Op: &token::Token // Operator.
}
Binary operation.
CallExpr
struct CallExpr {
Token: &token::Token
Func: &Expr // Function expression.
Args: []&Expr // Function arguments, or nil.
Exception: &ScopeTree // Exception handling scope, or nil.
IsCo: bool // Whether this is the concurrent call.
}
Function call expression kind.
Unhandled
fn Unhandled(*self): bool
Reports whether exception is not handled.
TypedBraceLit
struct TypedBraceLit {
Type: &Expr
Lit: &BraceLit
}
Typed brace instantiating expression.
BraceLit
struct BraceLit {
Token: &token::Token
End: &token::Token
X: []&Expr // Expression.
}
Anonymous brace instantiating expression.
IsEmpty
fn IsEmpty(*self): bool
Reports whether literal is empty ( {} ).
KeyValueExpr
struct KeyValueExpr {
Key: &Expr
Value: &Expr
Colon: &token::Token
}
Key-value expression.
SliceExpr
struct SliceExpr {
Token: &token::Token
End: &token::Token
X: []&Expr // Elements.
}
Slice initiating expression. Also represents array initiating expression. For array-fill initiating expression; len(X)=2 and the second element is a VariadicExpr with nil expression.
IsEmpty
fn IsEmpty(*self): bool
Reports whether slice is empty.
IndexExpr
struct IndexExpr {
Token: &token::Token
End: &token::Token
X: &Expr // Value expression to indexing.
Index: &Expr // Index value expression.
}
Index expression.
SlicingExpr
struct SlicingExpr {
Token: &token::Token
End: &token::Token
X: &Expr // Value expression to slicing.
Low: &Expr // Low index value expression, or nil.
High: &Expr // High index value expression, or nil.
Max: &Expr // Max index value expression, or nil.
}
Slicing expression.
Constraint
struct Constraint {
Mask: []&Expr
}
Constraint.
Generic
struct Generic {
Token: &token::Token
Name: str
Constraint: &Constraint
}
Generic type declaration.
Label
struct Label {
Token: &token::Token
Name: str
}
Label statement.
Goto
struct Goto {
Token: &token::Token
Label: &token::Token
}
Goto statement.
Fall
struct Fall {
Token: &token::Token
}
Fall statement.
AssignLeft
struct AssignLeft {
Token: &token::Token
Mutable: bool
Reference: bool
Name: str
X: &Expr // Expression.
}
Left expression of assign statement.
Assign
struct Assign {
Decl: bool // Whether the assignment may declare variable.
Op: &token::Token // Setter operator.
X: []&AssignLeft // Lvalue expressions.
Y: &Expr // Expression to be assigned.
}
Assign statement.
Stmt
struct Stmt {
Token: &token::Token
End: &token::Token
Data: StmtData
}
Statement.
ScopeTree
struct ScopeTree {
Parent: &ScopeTree // Nil if scope is root.
Unsafe: bool
Deferred: bool
Stmts: []Stmt
End: &token::Token
}
Scope tree.
ChanSend
struct ChanSend {
Chan: &Expr
X: &Expr // Expression.
}
Channel send data statement.
Param
struct Param {
Token: &token::Token
Mutable: bool
Variadic: bool
Reference: bool
Type: &Expr
Name: str
}
Parameter.
IsSelf
fn IsSelf(*self): bool
Reports whether parameter is self (receiver) parameter.
IsSmartptr
fn IsSmartptr(*self): bool
Reports whether self (receiver) parameter is smart pointer.
IsRefptr
fn IsRefptr(*self): bool
Reports whether self (receiver) parameter is reference pointer.
Func
struct Func {
Token: &token::Token
Global: bool
Unsafe: bool
Public: bool
Bind: bool
Short: bool // Whether this function is an anonymous function, defined by short literal.
Static: bool
Exceptional: bool
Name: str
Directives: []&Directive
Scope: &ScopeTree
Generics: []&Generic
Result: &RetType
Params: []&Param
}
Function declaration. Also represents anonymous function expression and function type declarations.. For short function literals, Scope will be deferred to represent one-line body.
IsAnon
fn IsAnon(*self): bool
Reports whether the function is anonymous.
IsShort
fn IsShort(*self): bool
Reports whether the function is anonymous and defined in short way.
IsDecl
fn IsDecl(*self): bool
Reports whether the function is type declaration.
Var
struct Var {
Scope: &ScopeTree // nil for global scopes
Token: &token::Token
Op: &token::Token // Expression assign operator token.
Name: str
Bind: bool
Public: bool
Mutable: bool
Const: bool
Static: bool
Reference: bool
Directives: []&Directive
Type: &Expr // Type declaration, or nil if type inferred.
X: &Expr // Initializer expression, or nil.
// See developer reference (12).
GroupIndex: int // Index of variable in the group, if variable is grouped.
Group: []&Var // All variables of group in define order, if variable is grouped.
}
Variable declaration.
Ret
struct Ret {
Token: &token::Token
X: &Expr // Expression.
}
Return statement.
Iter
struct Iter {
Comptime: bool
Token: &token::Token
Kind: IterKind
Scope: &ScopeTree
}
Iteration.
IsInfinite
fn IsInfinite(*self): bool
Reports whether iteration is infinite.
WhileKind
struct WhileKind {
X: &Expr // Condition expression.
Next: StmtData // Nil if kind is while-next iteration.
NextToken: &token::Token
}
While iteration kind.
IsWhileNext
fn IsWhileNext(*self): bool
Reports whether kind is while-next iteration.
RangeKind
struct RangeKind {
InToken: &token::Token // Token of "in" keyword
X: &Expr // Range expression.
A: &Var // First key of range.
B: &Var // Second key of range.
}
Range iteration kind.
Break
struct Break {
Token: &token::Token
Label: &token::Token // Label to break, or nil.
}
Break statement.
Continue
struct Continue {
Token: &token::Token
Label: &token::Token // Label to continue, or nil.
}
Continue statement.
If
struct If {
Token: &token::Token
Scope: &ScopeTree
X: &Expr
}
If condition.
Else
struct Else {
Token: &token::Token
Scope: &ScopeTree
}
Else condition.
Conditional
struct Conditional {
Tail: []&If // First one is the head condition.
Default: &Else
}
Condition chain.
TypeAlias
struct TypeAlias {
Scope: &ScopeTree
Public: bool
Bind: bool
Token: &token::Token
Name: str
Strict: bool
Type: &Expr
}
Type alias declaration.
Case
struct Case {
Token: &token::Token
Scope: &ScopeTree
// Holds expression.
// Expressions holds *Type if If type matching.
X: []&Expr
}
Case of match-case.
Match
struct Match {
Comptime: bool
Token: &token::Token
End: &token::Token
Type: bool // Type matching.
X: &Expr // Expression to match.
Cases: []&Case // First one is the head case.
Default: &Else
}
Match statement.
Select
struct Select {
Token: &token::Token
End: &token::Token
Cases: []&Case // First one is the head condition.
Default: &Else
}
Select statement.
Use
struct Use {
Token: &token::Token
Path: &token::Token // Use declaration path token.
Alias: &token::Token // Custom alias. Nil if not given.
Bind: bool // Bind use declaration.
}
Use declaration statement.
EnumItem
struct EnumItem {
Token: &token::Token
Name: str
X: &Expr // Nil for auto expression.
}
Enum item.
IsAutoExpr
fn IsAutoExpr(*self): bool
Reports whether item has auto expression.
Enum
struct Enum {
Token: &token::Token
Public: bool
Name: str
Type: &Expr
Items: []&EnumItem
End: &token::Token
}
Enum declaration.
IsDefaultTyped
fn IsDefaultTyped(*self): bool
Reports whether enum's type is default.
TypeEnumItem
struct TypeEnumItem {
Token: &token::Token
Type: &Expr
}
TypeEnum item.
TypeEnum
struct TypeEnum {
Token: &token::Token
Public: bool
Name: str
Items: []&TypeEnumItem
End: &token::Token
}
TypeEnum declaration.
Field
struct Field {
Token: &token::Token
Public: bool
Mutable: bool // Interior mutability.
Name: str
Type: &Expr
Tag: &token::Token // Nil if not given.
}
Field declaration.
Struct
struct Struct {
Token: &token::Token
End: &token::Token
Name: str
Fields: []&Field
Public: bool
Bind: bool
Directives: []&Directive
Generics: []&Generic
}
Structure declaration.
Trait
struct Trait {
// Trait declaration.
Token: &token::Token
End: &token::Token
Name: str
Public: bool
Inherits: []&Expr
Methods: []&Func
}
Impl
struct Impl {
End: &token::Token
// This token available for these cases:
// - Implementation trait to structure, represents trait's type.
Base: &Expr
// This token available for these cases:
// - Implementation trait to structure, represents structure's type.
// - Implementation to structure, represents structure's type.
Dest: &Expr
// Given methods to implement.
Methods: []&Func
}
Implementation.
IsTraitImpl
fn IsTraitImpl(*self): bool
Reports whether implementation type is trait to structure.
IsStructImpl
fn IsStructImpl(*self): bool
Reports whether implementation type is append to destination structure.
NodeData
enum NodeData: type {
&Enum,
&TypeEnum,
&Func,
&Struct,
&Trait,
&TypeAlias,
&Var,
&Impl,
}
Type of AST Node's data.
ExprData
enum ExprData: type {
&RangeExpr,
&TupleExpr,
&LitExpr,
&NameExpr,
&UnaryExpr,
&SelectorExpr,
&NamespaceExpr,
&VariadicExpr,
&CallExpr,
&TypedBraceLit,
&BraceLit,
&SlicingExpr,
&SliceExpr,
&BinaryExpr,
&UnsafeExpr,
&IndexExpr,
&Func,
&KeyValueExpr,
&ChanSend,
&TypeAssertionExpr,
&ChanType,
&ArrayType,
&MapType,
&SliceType,
}
Type of Expr's data.
StmtData
enum StmtData: type {
&Var,
&Ret,
&Goto,
&Break,
&Continue,
&Expr,
&Conditional,
&Match,
&Iter,
&Assign,
&Fall,
&Label,
&ScopeTree,
&TypeAlias,
&UseExpr,
&Select,
}
Type of Stmt's data.
IterKind
enum IterKind: type {
&WhileKind,
&RangeKind,
}
Type of Iter's kind.