From b8445b011d9b2a287af0e014998c42525a7fd315 Mon Sep 17 00:00:00 2001 From: JJ Date: Fri, 29 Dec 2023 16:03:06 -0800 Subject: std: restructure, refactor std.ast --- std/fundamental/ast.pk | 113 ------------------------------------------------- 1 file changed, 113 deletions(-) delete mode 100644 std/fundamental/ast.pk (limited to 'std/fundamental/ast.pk') diff --git a/std/fundamental/ast.pk b/std/fundamental/ast.pk deleted file mode 100644 index 0529cbd..0000000 --- a/std/fundamental/ast.pk +++ /dev/null @@ -1,113 +0,0 @@ -## 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) -- cgit v1.2.3-70-g09d2