std/jule/ast
Structs
struct AST {
File: &token::Fileset
TopDirectives: []&Directive
UseDecls: []&UseDecl
Nodes: []Node
}
Abstract syntax tree.
struct Node {
Token: &token::Token
Data: NodeData
}
AST Node.
struct Directive {
Tag: &token::Token
Args: []&token::Token
}
Directive.
struct TypeDecl {
Token: &token::Token
Kind: TypeDeclKind
}
Type declaration.
Also represents type expression.
For primitive types:
- Represented by IdentTypeDecl
- Token's identity is data type
- Primitive type kind is Ident
For function types:
- Function types represented by &FnDecl
struct IdentTypeDecl {
Token: &token::Token
Ident: str
Binded: bool
Generics: []&TypeDecl
}
Identifier type.
struct SubIdentTypeDecl {
Idents: []&IdentTypeDecl
}
Sub-identifier type.
struct NamespaceTypeDecl {
Namespace: &token::Token // Namespace token.
Kind: &TypeDecl // Type of identifier.
}
Namespace chain type.
struct SptrTypeDecl {
Elem: &TypeDecl
}
Smart pointer type.
struct SlcTypeDecl {
Elem: &TypeDecl
}
Slice type.
struct TupleTypeDecl {
Types: []&TypeDecl
}
Tuple type.
struct PtrTypeDecl {
Elem: &TypeDecl
}
Pointer type.
Methods:
fn IsUnsafe(self): bool
Reports whether pointer is unsafe pointer (*unsafe).
struct ArrTypeDecl {
Elem: &TypeDecl
Size: &Expr
}
Array type.
Size expression is nil for auto-sized array.
Methods:
AutoSized(self): bool
Reports whether array is auto-sized.
struct MapTypeDecl {
Key: &TypeDecl
Val: &TypeDecl
}
Map type.
struct RetTypeDecl {
Kind: &TypeDecl
Idents: []&token::Token
}
Return type.
Kind and Idents is nil for void type.
struct Expr {
Token: &token::Token
End: &token::Token
Kind: ExprData
}
Expression.
struct RangeExpr {
Expr: &Expr
}
Range expression between parentheses.
struct UseExpr {
Token: &token::Token
Expr: &Expr
}
Use expression.
struct TupleExpr {
Expr: []&Expr
}
Tuple expression.
struct LitExpr {
Token: &token::Token
Value: str
}
Literal expression.
struct UnsafeExpr {
Token: &token::Token
Expr: &Expr
}
Unsafe expression.
struct IdentExpr {
Token: &token::Token
Ident: str
Binded: bool
}
Methods:
fn IsSelf(self): bool
Reports whether identifier is self keyword.
struct UnaryExpr {
Op: &token::Token
Expr: &Expr
}
struct VariadicExpr {
Token: &token::Token
Expr: &Expr
}
Variadiced expression.
struct CastExpr {
Kind: &TypeDecl
Expr: &Expr
}
Casting expression.
struct NamespaceExpr {
Namespace: &token::Token // Tokens of namespace identifier.
Ident: &token::Token // Token of selected identifier.
}
Namespace identifier selection expression.
struct SubIdentExpr {
Expr: &Expr
Ident: &token::Token
}
Object sub identifier selection expression.
struct BinaryExpr {
Left: &Expr
Right: &Expr
Op: &token::Token
}
Binary operation.
struct FnCallExpr {
Token: &token::Token
Expr: &Expr
Args: []&Expr
Exception: &ScopeTree
IsCo: bool
}
Function call expression kind.
Methods:
fn Unhandled(self): bool
Reports whether exception is not handled.
fn Ignored(self): bool
Reports whether exception is ignored.
struct FieldExprPair {
Field: &token::Token
Expr: &Expr
}
Field-Expression pair.
Methods:
fn IsTargeted(self): bool
Reports whether pair targeted field.
struct StructLit {
End: &token::Token
Kind: &TypeDecl
Exprs: []ExprData
}
Struct literal instiating expression.
struct BraceLit {
Token: &token::Token
End: &token::Token
Exprs: []ExprData
}
Anonymous brace instiating expression.
Methods:
fn IsEmpty(self): bool
Reports whether literal is empty.
struct KeyValPair {
Key: &Expr
Val: &Expr
Colon: &token::Token
}
Key-value pair expression.
struct SliceExpr {
Token: &token::Token
End: &token::Token
Exprs: []&Expr
}
Slice initiating expression.
Also represents array initiating expression.
Methods:
fn IsEmpty(self): bool
Reports whether slice is empty.
struct IndexingExpr {
Token: &token::Token
End: &token::Token
Expr: &Expr
Index: &Expr
}
Indexing expression.
struct SlicingExpr {
Token: &token::Token
End: &token::Token
Expr: &Expr
Start: &Expr
To: &Expr
}
Slicing expression.
struct Constraint {
Mask: []&TypeDecl
}
Constraint.
struct GenericDecl {
Token: &token::Token
Ident: str
Constraint: &Constraint
}
Generic type declaration.
struct LabelSt {
Token: &token::Token
Ident: str
}
Label statement.
struct GotoSt {
Token: &token::Token
Label: &token::Token
}
Goto statement.
struct FallSt {
Token: &token::Token
}
Fall statement.
struct AssignLeft {
Token: &token::Token
Mutable: bool
Reference: bool
Ident: str
Expr: &Expr
}
Left expression of assign statement.
struct AssignSt {
Declarative: bool
Setter: &token::Token
Left: []&AssignLeft
Right: &Expr
}
Assign statement.
struct Stmt {
Token: &token::Token
End: &token::Token
Data: StmtData
}
struct ScopeTree {
Parent: &ScopeTree
Unsafety: bool
Deferred: bool
Stmts: []Stmt
End: &token::Token
}
Scope tree.
struct ParamDecl {
Token: &token::Token
Mutable: bool
Variadic: bool
Reference: bool
Kind: &TypeDecl
Ident: str
}
Parameter.
Methods:
fn IsSelf(self): bool
Reports whether parameter is self (receiver) parameter.
fn IsRef(self): bool
Reports whether self (receivers) parameter is reference.
struct FnDecl {
Token: &token::Token
Global: bool
Unsafety: bool
Public: bool
Binded: bool
Statically: bool
Exceptional: bool
Ident: str
Directives: []&Directive
Scope: &ScopeTree
Generics: []&GenericDecl
Result: &RetTypeDecl
Params: []&ParamDecl
}
Function declaration.
Also represents anonymous function expression.
Methods:
fn IsAnon(self): bool
Reports whether function is anonymous.
struct VarDecl {
Scope: &ScopeTree // nil for global scopes
Token: &token::Token
Setter: &token::Token
Ident: str
Binded: bool
Public: bool
Mutable: bool
Constant: bool
Statically: bool
Directives: []&Directive
Kind: &TypeDecl // nil for auto-typed
Expr: &Expr
}
Variable declaration.
struct RetSt {
Token: &token::Token
Expr: &Expr
}
Return statement.
struct Iter {
Comptime: bool
Token: &token::Token
Kind: IterKind
Scope: &ScopeTree
}
Iteration.
Methods:
fn IsInf(self): bool
Reports whether iteration is infinity.
struct WhileKind {
Expr: &Expr
Next: StmtData // Nil if kind is while-next iteration.
NextToken: &token::Token
}
While iteration kind.
Methods:
fn IsWhileNext(self): bool
Reports whether kind is while-next iteration.
struct RangeKind {
InToken: &token::Token // Token of "in" keyword
Expr: &Expr
KeyA: &VarDecl // first key of range
KeyB: &VarDecl // second key of range
}
Range iteration kind.
struct BreakSt {
Token: &token::Token
Label: &token::Token
}
Break statement.
struct ContSt {
Token: &token::Token
Label: &token::Token
}
Continue statement.
struct If {
Token: &token::Token
Expr: &Expr
Scope: &ScopeTree
}
If condition.
struct Else {
Token: &token::Token
Scope: &ScopeTree
}
Else condition.
struct Conditional {
Head: &If
Tail: []&If
Default: &Else
}
Condition chain.
struct TypeAliasDecl {
Scope: &ScopeTree
Public: bool
Binded: bool
Token: &token::Token
Ident: str
Kind: &TypeDecl
}
Type alias declaration.
struct Case {
Token: &token::Token
Scope: &ScopeTree
Exprs: []&Expr
}
Case of match-case.
struct MatchCase {
Token: &token::Token
End: &token::Token
TypeMatch: bool
Expr: &Expr
Cases: []&Case
Default: &Else
}
Match-Case.
struct UseDecl {
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.
struct EnumItemDecl {
Token: &token::Token
Ident: str
Expr: &Expr // Nil for auto expression.
}
Enum item.
Methods:
fn AutoExpr(self): bool
Reports whether item has auto expression.
struct EnumDecl {
Token: &token::Token
Public: bool
Ident: str
Kind: &TypeDecl
Items: []&EnumItemDecl
End: &token::Token
}
Enum declaration.
Methods:
fn DefaultTyped(self): bool
Reports whether enum's type is default.
struct TypeEnumItemDecl {
Token: &token::Token
Ident: str
Kind: &TypeDecl
}
TypeEnum item.
// TypeEnum declaration.
struct TypeEnumDecl {
Token: &token::Token
Public: bool
Ident: str
Items: []&TypeEnumItemDecl
End: &token::Token
}
TypeEnum declaration.
struct FieldDecl {
Token: &token::Token
Public: bool
Mutable: bool // Interior mutability.
Ident: str
Kind: &TypeDecl
Default: &Expr
}
Field declaration.
struct StructDecl {
Token: &token::Token
End: &token::Token
Ident: str
Fields: []&FieldDecl
Public: bool
Binded: bool
Directives: []&Directive
Generics: []&GenericDecl
}
Structure declaration.
struct TraitDecl {
Token: &token::Token
End: &token::Token
Ident: str
Public: bool
Inherits: []&TypeDecl
Methods: []&FnDecl
}
Trait declaration.
struct Impl {
End: &token::Token
// This Token available for these cases:
// - Implementation trait to structure, represents trait's type.
Base: &TypeDecl
// This Token available for these cases:
// - Implementation trait to structure, represents structure's type.
// - Implementation to structure, represents structure's type.
Dest: &TypeDecl
// Given methods to implement.
Methods: []&FnDecl
// Static varaibles to implement.
Statics: []&VarDecl
}
Implementation.
Methods:
fn IsTraitImpl(self): bool
Reports whether implementation type is trait to structure.
fn IsStructImpl(self): bool
Reports whether implementation type is append to destination structure.
Enums
enum NodeData: type
Type of AST Node's data.
Fields:
&EnumDecl
&TypeEnumDecl
&FnDecl
&StructDecl
&TraitDecl
&TypeAliasDecl
&VarDecl
&Impl
enum ExprData: type
Type of Expr's data.
Fields:
&RangeExpr
&TupleExpr
&LitExpr
&TypeDecl
&IdentExpr
&UnaryExpr
&SubIdentExpr
&NamespaceExpr
&VariadicExpr
&CastExpr
&FnCallExpr
&StructLit
&BraceLit
&SlicingExpr
&SliceExpr
&BinaryExpr
&UnsafeExpr
&IndexingExpr
&FnDecl
&FieldExprPair
&KeyValPair
enum StmtData: type
Type of Stmt's data.
Fields:
&VarDecl
&RetSt
&GotoSt
&BreakSt
&ContSt
&Expr
&Conditional
&MatchCase
&Iter
&AssignSt
&FallSt
&LabelSt
&ScopeTree
&TypeAliasDecl
&UseExpr
emum IterKind: type
Type of Iter's kind.
Fields:
&WhileKind
&RangeKind
enum TypeDeclKind: type
Kind type of type declarations.
Fields:
&IdentTypeDecl
&SubIdentTypeDecl
&SptrTypeDecl
&PtrTypeDecl
&SlcTypeDecl
&ArrTypeDecl
&MapTypeDecl
&TupleTypeDecl
&FnDecl
&NamespaceTypeDecl