## std/ast: Exposes the AST for building and operating on with macros. pub type Ident = string pub type Number = int pub type Float = float pub type Char = char pub type String = str pub type Struct = list[struct[field: str, value: Expr]] pub type Tuple = list[struct[field: Option[string], value: Expr]] pub type List = list[Expr] pub type Let = struct id: Pattern kind: Option[Type] value: ref Expr pub type Var = struct id: Pattern kind: Option[Type] value: Option[ref Expr] # variable bindings can be delayed pub type Const = struct id: Pattern kind: Option[Type] value = ref Expr pub type FuncDecl = struct public: bool effect: Option[str] id: str generics: list[struct[id: str, kind: Option[Type]]] params: list[struct[id: str, kind: Type]] kind: Type body: list[Expr] pub type TypeDecl = struct id: str generics: list[str] alias: Type pub type Import = struct mod_from: Option[string] imports: list[str] alias: Option[str] pub type Module = struct id: str body: list[Expr] pub type Call = struct id: str params: list[Expr] pub type Cond = struct branches: list[struct[cond: Expr, body: list[Expr]]] else_body: Option[list[Expr]] pub type Try = struct body: list[Expr] catches: list[struct[exceptions: list[str], body: list[Expr]]] finally_body: Option[list[Expr]] pub type Match = struct item: ref Expr branches: list[struct[pattern: Pattern, guard: Option[Expr], body: list[Expr]]] pub type Block = struct id: Option[str] body: list[Expr] pub type Static = struct body: list[Expr] pub type For = struct binding: Pattern range: ref Expr body: list[Expr] pub type While = struct cond: ref Expr body: list[Expr] pub type Loop = struct body: list[Expr] # the first style of union. naming anonymous types. pub type Type = union Void, Never, Integer, Float, String, Func: struct[from, to: ref Type] # todo: multiple parameters Struct: list[struct[id: str, kind: Type]] Tuple: list[struct[id: Option[str], kind: Type]] Union: list[struct[id: str, kind: Type]] Interface: struct # todo: generics funcs: list[Signature] for_type: Option[ref Type] Array: struct[size: uint, kind: ref Type] List: ref Type Slice: ref Type # todo: plus ownership Alias: str # todo: params?? huh? Static: ref Type Mutable: ref Type Reference: ref Type pub type Signature = struct # todo: generics id: str effect: Option[str] params: list[Type] kind: Option[Type] pub type Pattern = union Ident: str Number: int, Float: float, Char: char, String: str Struct: struct[name: str, params: list[Pattern]] Tuple: list[Pattern] List: list[Pattern] # the second style of union. A union of literal types, no names. pub type Expr = union Ident, Number, Float, Char, String, Struct, Tuple, List, Let, Var, Const, FuncDecl, TypeDecl, Import, Module, Call, Cond, Try, Match, Block, Static, For, While, Loop, # todo: decide on a style of union # anonymous struct objects can be constructed with {} # anonymous tuple objects can be constructed with () # anonymous list objects can be constructed with [] # anonymous union *types* can be constructed with | (in parameters)