marianoguerra/wap/ast does not have a README file

    Span

    A source span, as byte offsets into the file the node came from.

    This is marianoguerra/error-report's span, so a wap diagnostic and a diagnostic from any other library that uses error-report render through the same code. nowhere is the span a generated node carries; the lowering gives those fresh synthetic locations so that two generated bindings never collide (see lower, and the AmbiguousBinding note in AGENTS.md).

    Arm

    One arm of a match.

    AssignOp

    pub(all) enum AssignOp {
    Set
    OpSet(BinOp)
    } derive(Eq,
    Debug
    )

    How an assignment combines with the old value.

    BinOp

    pub(all) enum BinOp {
    Add
    Sub
    Mul
    Div
    Rem
    Shl
    Shr
    BitAnd
    BitOr
    BitXor
    Eq
    Ne
    Lt
    Gt
    Le
    Ge
    } derive(Eq,
    Debug
    )

    A binary operator, before signedness is resolved.

    Div, Rem, Shr and the four comparisons become signed or unsigned wasm instructions according to the type of their operands; the parser never has to decide, and there is no wap spelling that lets it.

    Binder

    pub(all) struct Binder {
    name : String
    typ : Type?
    span :
    Span

    } derive(Eq,
    Debug
    )

    A let/var binding target.

    ConstDecl

    pub(all) struct ConstDecl {
    name : String
    typ : Type?
    value : Node
    export_name : String?
    import_name : String?
    is_pub : Bool
    span :
    Span

    } derive(Eq,
    Debug
    )

    A global constant.

    Decl

    pub(all) enum Decl {
    ModuleName(String)
    Import(Array[String])
    ImportWas(file~ : String, funcs~ : Array[FnDecl], consts~ : Array[ConstDecl])
    ImportHost(module_~ : String, funcs~ : Array[FnDecl], consts~ : Array[ConstDecl])
    Const(ConstDecl)
    TypeD(name~ : String, def~ : TypeDef, is_pub~ : Bool, span~ :
    Span
    )
    Fn(FnDecl)
    Impl(typ~ : String, methods~ : Array[FnDecl], span~ :
    Span
    )
    } derive(Eq,
    Debug
    )

    A top-level declaration.

    Expr

    pub(all) enum Expr {
    Int(String)
    Float(String)
    BoolLit(Bool)
    CharLit(Char)
    StrLit(String)
    Null
    TupleLit(Array[Node])
    SetLit(Array[Node])
    Var(String)
    Field(Node, String)
    Index(Node, Node)
    RecordLit(typ~ : String?, fields~ : Array[(String, Node?)])
    RecordDefault(typ~ : String?)
    ArrayLit(typ~ : String?, items~ : Array[Node])
    ArrayRepeat(typ~ : String?, value~ : Node, count~ : Node)
    Call(Node, Array[Node])
    MethodCall(Node, String, Array[Node])
    Bin(BinOp, Node, Node)
    Un(UnOp, Node)
    AndAlso(Node, Node)
    OrElse(Node, Node)
    InSet(Node, Node)
    Cast(Node, Type)
    Test(Node, Type)
    NonNull(Node)
    Bind(binders~ : Array[Binder], value~ : Node?, mutable~ : Bool)
    Assign(targets~ : Array[Node], op~ : AssignOp, value~ : Node)
    Block(Array[Node])
    If(arms~ : Array[(Node?, Array[Node])], typ~ : Type?)
    While(label~ : String?, cond~ : Node, step~ : Node?, body~ : Array[Node])
    ForRange(label~ : String?, var_~ : String, from~ : Node, to~ : Node, inclusive~ : Bool, by~ : Node?, body~ : Array[Node])
    ForIn(label~ : String?, var_~ : String, seq~ : Node, body~ : Array[Node])
    Loop(label~ : String?, body~ : Array[Node])
    Break(String?)
    Continue(String?)
    Return(Node?)
    Match(scrutinee~ : Node, arms~ : Array[Arm], typ~ : Type?)
    Unreachable
    Nop
    Drop(Node)
    } derive(Eq,
    Debug
    )

    Everything a wap body can contain.

    Field

    pub(all) struct Field {
    name : String
    mut_ : Bool
    typ : Type
    span :
    Span

    } derive(Eq,
    Debug
    )

    One field of a record.

    FnDecl

    pub(all) struct FnDecl {
    name : String
    receiver : String?
    params : Array[Param]
    results : Array[Type]
    body : Array[Node]?
    export_name : String?
    import_name : String?
    is_start : Bool
    is_pub : Bool
    span :
    Span

    } derive(Eq,
    Debug
    )

    A function or method, defined or merely declared.

    Module

    pub(all) struct Module {
    name : String
    decls : Array[Decl]
    } derive(Eq,
    Debug
    )

    A whole wap compilation unit.

    Node

    An expression with the span it was written at.

    Param

    pub(all) struct Param {
    name : String
    typ : Type
    span :
    Span

    } derive(Eq,
    Debug
    )

    One parameter.

    Pattern

    pub(all) enum Pattern {
    PType(name~ : String?, typ~ : Type)
    PNull
    PInt(String)
    PRange(low~ : String, high~ : String)
    PSet(Array[Pattern])
    PWild
    } derive(Eq,
    Debug
    )

    A match arm's pattern.

    Type

    pub(all) enum Type {
    I8
    I16
    I32
    I64
    U8
    U16
    U32
    U64
    F32
    F64
    Bool
    Char
    Named(String)
    Nullable(Type)
    ArrayOf(Type)
    Tuple(Array[Type])
    Func(params~ : Array[Type], results~ : Array[Type])
    Any
    Eq
    I31
    } derive(Eq,
    Debug
    )

    A wap type.

    The signed/unsigned distinction lives here rather than on the operators, which is the whole reason wap can spell integer comparison < where was has to spell it < or <$. U32 and I32 are both wasm i32; they differ only in which instruction an operator on them selects.

    TypeDef

    pub(all) enum TypeDef {
    Record(parent~ : String?, fields~ : Array[Field])
    Enum(Array[(String, Int?)])
    SetOf(String)
    Subrange(low~ : Int, high~ : Int)
    Alias(Type)
    } derive(Eq,
    Debug
    )

    What a type declaration introduces.

    UnOp

    pub(all) enum UnOp {
    Neg
    Not
    } derive(Eq,
    Debug
    )

    A prefix operator.

    has_source

    fn has_source(s :
    Span
    ) -> Bool

    True when a span points at real source text.

    nowhere

    The span of a node that was never written down.

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io