From 483a64aa0c5ee8dc925b7957e39c42744b892288 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Thu, 31 Mar 2022 08:18:36 +0200 Subject: Add type signature to def statements Currently mandatory, may be optional once we have type inference. --- src/nodes.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/nodes.h (limited to 'src/nodes.h') 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 @@ +#ifndef BDL_NODES_H +#define BDL_NODES_H + +typedef enum NodeType { + NODE_BUILTIN, + NODE_NUMBER, + NODE_BOOL, + NODE_STRING, + NODE_SYMBOL, + NODE_DEF, +} NodeType; + +typedef struct Node { + NodeType type; + + union { + // Numbers. + struct { + bool negative; + size_t integral; + size_t fractional; + } number; + + // String/symbol. + StringView string; + + // Boolean. + bool boolean; + + // Builtin primitive. + struct { + TokenType type; + struct Node **args; + } builtin; + + // Variable definition. + struct { + struct Node *symbol; + struct Node *value; + StringView type; + } def; + }; +} Node; + +#endif // BDL_NODES_H -- cgit v1.2.1