aboutsummaryrefslogtreecommitdiff
path: root/std/fundamental
diff options
context:
space:
mode:
authorJJ2023-12-30 00:03:06 +0000
committerJJ2023-12-30 00:03:06 +0000
commitb8445b011d9b2a287af0e014998c42525a7fd315 (patch)
tree1b1008c2df5902fae12f40a394113a6453da2a4b /std/fundamental
parent774a35ae21dada36af48ae32c862b22587fba107 (diff)
std: restructure, refactor std.ast
Diffstat (limited to 'std/fundamental')
-rw-r--r--std/fundamental/ast.pk113
-rw-r--r--std/fundamental/logs.pk1
-rw-r--r--std/fundamental/tests.pk5
3 files changed, 0 insertions, 119 deletions
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)
diff --git a/std/fundamental/logs.pk b/std/fundamental/logs.pk
deleted file mode 100644
index 7a0060f..0000000
--- a/std/fundamental/logs.pk
+++ /dev/null
@@ -1 +0,0 @@
-## std/logs: Utility macros and functions for logging.
diff --git a/std/fundamental/tests.pk b/std/fundamental/tests.pk
deleted file mode 100644
index 7eb00a8..0000000
--- a/std/fundamental/tests.pk
+++ /dev/null
@@ -1,5 +0,0 @@
-## std/tests: Utility macros and functions for testing.
-
-## A macro for runnable examples. Runs them on compilation.
-pub macro examples(body) =
- ...