std/jule/ast
Index
struct AST
struct Node
struct Directive
struct Type
struct IdentType
struct SubIdentType
struct NamespaceType
struct ChanType
struct SptrType
struct SliceType
struct TupleType
struct PtrType
fn IsUnsafe(self): bool
struct ArrayType
fn AutoSized(self): bool
struct MapType
struct RetType
struct Expr
struct ChanRecv
struct RangeExpr
struct UseExpr
struct TupleExpr
struct LitExpr
struct UnsafeExpr
struct IdentExpr
fn IsSelf(self): bool
struct UnaryExpr
struct VariadicExpr
struct CastExpr
struct NamespaceExpr
struct SubIdentExpr
struct BinaryExpr
struct FuncCallExpr
fn Unhandled(self): bool
fn Ignored(self): bool
struct FieldExprPair
fn IsTargeted(self): bool
struct TypedBraceLit
struct BraceLit
fn IsEmpty(self): bool
struct KeyValPair
struct SliceExpr
fn IsEmpty(self): bool
struct IndexingExpr
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 IsRef(self): bool
struct Func
fn IsAnon(self): bool
struct Var
struct Ret
struct Iter
fn IsInf(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 AutoExpr(self): bool
struct Enum
fn DefaultTyped(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 TypeKind: type
enum ExprData: type
enum StmtData: type
enum IterKind: type
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.
Type
struct Type {
Token: &token::Token
Kind: TypeKind
}
Type declaration. Also represents type expression.
For primitive types:
- Represented by IdentType.
- Token's identity is data type.
- Primitive type kind is Ident.
For function types:
- Function types represented by &Func.
IdentType
struct IdentType {
Token: &token::Token
Ident: str
Binded: bool
Generics: []&Type
}
Identifier type.
SubIdentType
struct SubIdentType {
Idents: []&IdentType
}
Sub-identifier type.
NamespaceType
struct NamespaceType {
Namespace: &token::Token // Namespace token.
Kind: &Type // Type of identifier.
}
Namespace chain type.
ChanType
struct ChanType {
Recv: bool
Send: bool
Elem: &Type
}
Channel type.
SptrType
struct SptrType {
Elem: &Type
}
Smart pointer type.
SliceType
struct SliceType {
Elem: &Type
}
Slice type.
TupleType
struct TupleType {
Types: []&Type
}
Tuple type.
PtrType
struct PtrType {
Elem: &Type
}
Pointer type.
IsUnsafe
fn IsUnsafe(self): bool
Reports whether pointer is unsafe pointer (*unsafe).
ArrayType
struct ArrayType {
Elem: &Type
Size: &Expr
}
Array type. Size expression is nil for auto-sized array.
AutoSized
fn AutoSized(self): bool
Reports whether array is auto-sized.
MapType
struct MapType {
Key: &Type
Val: &Type
}
Map type.
RetType
struct RetType {
Kind: &Type
Idents: []&token::Token
}
Return type. Kind and Idents is nil for void type.
Expr
struct Expr {
Token: &token::Token
End: &token::Token
Kind: ExprData
}
Expression.
ChanRecv
struct ChanRecv {
Expr: &Expr
}
Channel receive expression.
RangeExpr
struct RangeExpr {
Expr: &Expr
}
Range expression between parentheses.
UseExpr
struct UseExpr {
Token: &token::Token
Expr: &Expr
}
Use expression.
TupleExpr
struct TupleExpr {
Expr: []&Expr
}
Tuple expression.
LitExpr
struct LitExpr {
Token: &token::Token
Value: str
}
Literal expression.
UnsafeExpr
struct UnsafeExpr {
Token: &token::Token // Token of unsafe keyword.
Expr: &Expr
}
Unsafe expression.
IdentExpr
struct IdentExpr {
Token: &token::Token // Token of identifier.
Ident: str
Binded: bool
}
Identifier expression.
IsSelf
fn IsSelf(self): bool
Reports whether identifier is self keyword.
UnaryExpr
struct UnaryExpr {
Op: &token::Token
Expr: &Expr
}
Unary expression.
VariadicExpr
struct VariadicExpr {
Token: &token::Token
Expr: &Expr
}
Variadiced expression.
CastExpr
struct CastExpr {
Kind: &Type
Expr: &Expr
}
Casting expression.
NamespaceExpr
struct NamespaceExpr {
Namespace: &token::Token // Tokens of namespace identifier.
Ident: &token::Token // Token of selected identifier.
}
Namespace identifier selection expression.
SubIdentExpr
struct SubIdentExpr {
Expr: &Expr // Selected object.
Ident: &token::Token // Token of selected identifier.
}
Object sub identifier selection expression.
BinaryExpr
struct BinaryExpr {
Left: &Expr
Right: &Expr
Op: &token::Token
}
Binary operation.
FuncCallExpr
struct FuncCallExpr {
Token: &token::Token
Expr: &Expr
Args: []&Expr
Exception: &ScopeTree // Exception handling scope.
IsCo: bool
}
Function call expression kind.
Unhandled
fn Unhandled(self): bool
Reports whether exception is not handled.
Ignored
fn Ignored(self): bool
Reports whether exception is ignored.
FieldExprPair
struct FieldExprPair {
Field: &token::Token // Field identifier token.
Expr: &Expr
}
Field-Expression pair.
IsTargeted
fn IsTargeted(self): bool
Reports whether pair targeted field.
TypedBraceLit
struct TypedBraceLit {
Kind: &Type
Lit: &BraceLit
}
Typed brace instantiating expression.
BraceLit
struct BraceLit {
Token: &token::Token
End: &token::Token
Exprs: []&Expr
}
Anonymous brace instantiating expression.
IsEmpty
fn IsEmpty(self): bool
Reports whether literal is empty ( {} ).
KeyValPair
struct KeyValPair {
Key: &Expr
Val: &Expr
Colon: &token::Token
}
Key-value pair expression.
SliceExpr
struct SliceExpr {
Token: &token::Token
End: &token::Token
Exprs: []&Expr
}
Slice initiating expression. Also represents array initiating expression.
IsEmpty
fn IsEmpty(self): bool
Reports whether slice is empty.
IndexingExpr
struct IndexingExpr {
Token: &token::Token
End: &token::Token
Expr: &Expr // Value expression to indexing.
Index: &Expr // Index value expression.
}
Indexing expression.
SlicingExpr
struct SlicingExpr {
Token: &token::Token
End: &token::Token
Expr: &Expr // Value expression to slicing.
Start: &Expr // Start index value expression.
To: &Expr // To index value expression.
Cap: &Expr // Cap index value expression.
}
Slicing expression.
Constraint
struct Constraint {
Mask: []&Type
}
Constraint.
Generic
struct Generic {
Token: &token::Token
Ident: str
Constraint: &Constraint
}
Generic type declaration.
Label
struct Label {
Token: &token::Token
Ident: 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
Ident: str
Expr: &Expr
}
Left expression of assign statement.
Assign
struct Assign {
Declarative: bool
Setter: &token::Token
Left: []&AssignLeft
Right: &Expr
}
Assign statement.
Stmt
struct Stmt {
Token: &token::Token
End: &token::Token
Data: StmtData
}
Statement.
ScopeTree
struct ScopeTree {
Parent: &ScopeTree // Nil if scope is root.
Unsafety: bool
Deferred: bool
Stmts: []Stmt
End: &token::Token
}
Scope tree.
ChanSend
struct ChanSend {
Chan: &Expr
Data: &Expr
}
Channel send data statement.
Param
struct Param {
Token: &token::Token
Mutable: bool
Variadic: bool
Reference: bool
Kind: &Type
Ident: str
}
Parameter.
IsSelf
fn IsSelf(self): bool
Reports whether parameter is self (receiver) parameter.
IsRef
fn IsRef(self): bool
Reports whether self (receiver) parameter is reference.
Func
struct Func {
Token: &token::Token
Global: bool
Unsafety: bool
Public: bool
Binded: bool
Statically: bool
Exceptional: bool
Ident: str
Directives: []&Directive
Scope: &ScopeTree
Generics: []&Generic
Result: &RetType
Params: []&Param
}
Function declaration. Also represents anonymous function expression.
IsAnon
fn IsAnon(self): bool
Reports whether function is anonymous.
Var
struct Var {
Scope: &ScopeTree // nil for global scopes
Token: &token::Token
Setter: &token::Token
Ident: str
Binded: bool
Public: bool
Mutable: bool
Constant: bool
Statically: bool
Reference: bool
Directives: []&Directive
Kind: &Type // nil for type inferred
Expr: &Expr
}
Variable declaration.
Ret
struct Ret {
Token: &token::Token
Expr: &Expr
}
Return statement.
Iter
struct Iter {
Comptime: bool
Token: &token::Token
Kind: IterKind
Scope: &ScopeTree
}
Iteration.
IsInf
fn IsInf(self): bool
Reports whether iteration is infinity.
WhileKind
struct WhileKind {
Expr: &Expr
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
Expr: &Expr
KeyA: &Var // first key of range
KeyB: &Var // second key of range
}
Range iteration kind.
Break
struct Break {
Token: &token::Token
Label: &token::Token
}
Break statement.
Continue
struct Continue {
Token: &token::Token
Label: &token::Token
}
Continue statement.
If
struct If {
Token: &token::Token
Expr: &Expr
Scope: &ScopeTree
}
If condition.
Else
struct Else {
Token: &token::Token
Scope: &ScopeTree
}
Else condition.
Conditional
struct Conditional {
Head: &If
Tail: []&If
Default: &Else
}
Condition chain.
TypeAlias
struct TypeAlias {
Scope: &ScopeTree
Public: bool
Binded: bool
Token: &token::Token
Ident: str
Strict: bool
Kind: &Type
}
Type alias declaration.
Case
struct Case {
Token: &token::Token
Scope: &ScopeTree
// Holds expression.
// Expressions holds *Type if If type matching.
Exprs: []&Expr
}
Case of match-case.
Match
struct Match {
Comptime: bool
Token: &token::Token
End: &token::Token
TypeMatch: bool
Expr: &Expr
Cases: []&Case
Default: &Else
}
Match statement.
Select
struct Select {
Token: &token::Token
End: &token::Token
Cases: []&Case
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.
Binded: bool // Bind use declaration.
}
Use declaration statement.
EnumItem
struct EnumItem {
Token: &token::Token
Ident: str
Expr: &Expr // Nil for auto expression.
}
Enum item.
AutoExpr
fn AutoExpr(self): bool
Reports whether item has auto expression.
Enum
struct Enum {
Token: &token::Token
Public: bool
Ident: str
Kind: &Type
Items: []&EnumItem
End: &token::Token
}
Enum declaration.
DefaultTyped
fn DefaultTyped(self): bool
Reports whether enum's type is default.
TypeEnumItem
struct TypeEnumItem {
Token: &token::Token
Ident: str
Kind: &Type
}
TypeEnum item.
TypeEnum
struct TypeEnum {
Token: &token::Token
Public: bool
Ident: str
Items: []&TypeEnumItem
End: &token::Token
}
TypeEnum declaration.
Field
struct Field {
Token: &token::Token
Public: bool
Mutable: bool // Interior mutability.
Ident: str
Kind: &Type
Default: &Expr // Nil if not given.
}
Field declaration.
Struct
struct Struct {
Token: &token::Token
End: &token::Token
Ident: str
Fields: []&Field
Public: bool
Binded: bool
Directives: []&Directive
Generics: []&Generic
}
Structure declaration.
Trait
struct Trait {
// Trait declaration.
Token: &token::Token
End: &token::Token
Ident: str
Public: bool
Inherits: []&Type
Methods: []&Func
}
Impl
struct Impl {
End: &token::Token
// This token available for these cases:
// - Implementation trait to structure, represents trait's type.
Base: &Type
// This token available for these cases:
// - Implementation trait to structure, represents structure's type.
// - Implementation to structure, represents structure's type.
Dest: &Type
// 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.
TypeKind
enum TypeKind: type {
&IdentType,
&SubIdentType,
&SptrType,
&PtrType,
&SliceType,
&ArrayType,
&MapType,
&TupleType,
&Func,
&NamespaceType,
&ChanType,
}
Kind type of type declarations.
ExprData
enum ExprData: type {
&RangeExpr,
&TupleExpr,
&LitExpr,
&Type,
&IdentExpr,
&UnaryExpr,
&SubIdentExpr,
&NamespaceExpr,
&VariadicExpr,
&CastExpr,
&FuncCallExpr,
&TypedBraceLit,
&BraceLit,
&SlicingExpr,
&SliceExpr,
&BinaryExpr,
&UnsafeExpr,
&IndexingExpr,
&Func,
&FieldExprPair,
&KeyValPair,
&ChanRecv,
&ChanSend,
}
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.