aboutsummaryrefslogtreecommitdiffstats
path: root/src/nodes.h
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2022-03-31 08:18:36 +0200
committerBad Diode <bd@badd10de.dev>2022-03-31 08:18:36 +0200
commit483a64aa0c5ee8dc925b7957e39c42744b892288 (patch)
tree86564a19bfc3255a04872815f7e1ac76d3b19cdc /src/nodes.h
parent4d5d49b0d1282df08e3dc7dec3c550c544fbfccb (diff)
downloadbdl-483a64aa0c5ee8dc925b7957e39c42744b892288.tar.gz
bdl-483a64aa0c5ee8dc925b7957e39c42744b892288.zip
Add type signature to def statements
Currently mandatory, may be optional once we have type inference.
Diffstat (limited to 'src/nodes.h')
-rw-r--r--src/nodes.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/nodes.h b/src/nodes.h
new file mode 100644
index 0000000..e6ceb50
--- /dev/null
+++ b/src/nodes.h
@@ -0,0 +1,45 @@
1#ifndef BDL_NODES_H
2#define BDL_NODES_H
3
4typedef enum NodeType {
5 NODE_BUILTIN,
6 NODE_NUMBER,
7 NODE_BOOL,
8 NODE_STRING,
9 NODE_SYMBOL,
10 NODE_DEF,
11} NodeType;
12
13typedef struct Node {
14 NodeType type;
15
16 union {
17 // Numbers.
18 struct {
19 bool negative;
20 size_t integral;
21 size_t fractional;
22 } number;
23
24 // String/symbol.
25 StringView string;
26
27 // Boolean.
28 bool boolean;
29
30 // Builtin primitive.
31 struct {
32 TokenType type;
33 struct Node **args;
34 } builtin;
35
36 // Variable definition.
37 struct {
38 struct Node *symbol;
39 struct Node *value;
40 StringView type;
41 } def;
42 };
43} Node;
44
45#endif // BDL_NODES_H