Module ast

Source
Expand description

§The Abstract Syntax Tree

Contains definitions of Conlang AST Nodes.

§Notable nodes

Structs§

AddrOf
An address-of expression: & mut? Expr
Alias
An alias to another Ty
Array
An Array literal: [ Expr (, Expr)* ]
ArrayRep
An Array literal constructed with repeat syntax [ Expr ; Literal ]
Assign
An Assignment expression: Expr (ModifyKind Expr)+
Attrs
A list of Meta decorators
Binary
A Binary expression: Expr (BinaryKind Expr)+
Block
A Block expression: { Stmt* Expr? }
Break
A Break expression: break Expr?
Cast
A cast expression: Expr as Ty
Closure
A Closure expression: | Expr | ( -> Ty)? Expr
Const
A compile-time constant
Else
The (optional) else clause of a While, If, or For expression
Enum
A user-defined sum type
Expr
An expression, the beating heart of the language
Fielder
A [Struct field initializer] expression: Sym (= Expr)?
File
A list of Items
For
A For expression: for Pattern in Expr Block Else?
Function
Code, and the interface to that code
Generics
A list of type variables to introduce
Group
A Grouping expression ( Expr )
If
An If expression: if Expr Block Else?
Impl
Sub-items (associated functions, etc.) for a Ty
Index
A repeated Index expression: a[10, 20, 30][40, 50, 60]
Item
Anything that can appear at the top level of a File
Let
A local variable declaration Stmt
Match
A match expression: match { (MatchArm ,)* MatchArm? }
MatchArm
A single arm of a Match expression: Pattern => Expr
Member
A Member access expression: Expr MemberKind*
Meta
A metadata decorator
Modify
A Modify-assignment expression: Expr (ModifyKind Expr)+
Module
An ordered collection of Items
Path
A path to an Item in the Module tree
Quote
A backtick-quoted subexpression-literal
Return
A Return expression return Expr?
Static
A static variable
Stmt
An abstract statement, and associated metadata
Struct
A user-defined product type
StructMember
The Visibility, Sym, and Type of a single Struct member
Structor
A Struct creation expression: Path { (Fielder ,)* Fielder? }
Tuple
A Tuple expression: ( Expr (, Expr)+ )
Ty
A type expression
TyArray
An array of T
TyFn
The args and return value for a function pointer Type
TyRef
A Type-reference expression as (number of &, Path)
TySlice
A Type slice expression: [T]
TyTuple
A tuple of Types
Unary
A Unary expression: UnaryKind* Expr
Use
An import of nonlocal Items
Variant
A single Enum variant
While
A While expression: while Expr Block Else?

Enums§

BinaryKind
A Binary operator
ExprKind
Any of the different Expressions
ImplKind
ItemKind
What kind of Item is this?
Literal
A Literal: 0x42, 1e123, 2.4, “Hello”
MemberKind
The kind of Member access
MetaKind
Information attached to Metadata
ModifyKind
Mutability
Whether a binding (Static or Let) or reference is mutable or not
PathPart
A single component of a Path
Pattern
A Pattern meta-expression (any ExprKind that fits pattern rules)
Semi
Whether or not a Stmt is followed by a semicolon
StmtKind
Whether the Stmt is a Let, Item, or Expr statement
StructKind
Either a Struct’s StructMembers or tuple Types, if present.
TyKind
Information about a Type expression
UnaryKind
A Unary operator
UseTree
A tree of Item imports
Visibility
Whether an Item is visible outside of the current Module

Type Aliases§

Sym
An Interned static str, used in place of an identifier