aboutsummaryrefslogtreecommitdiff
path: root/src/ast.h
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2023-06-17 23:42:31 +0300
committerkartofen <mladenovnasko0@gmail.com>2023-06-17 23:42:31 +0300
commitbcac686c1bf6a5c1dec2324269e2766babdc0fde (patch)
tree6483461015705efa8290a1ab05482a641739c1dd /src/ast.h
lexer - done
Diffstat (limited to 'src/ast.h')
-rw-r--r--src/ast.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/ast.h b/src/ast.h
new file mode 100644
index 0000000..bd2e628
--- /dev/null
+++ b/src/ast.h
@@ -0,0 +1,38 @@
+#ifndef AST_H
+#define AST_H
+
+#include "lexer.h"
+
+typedef struct node_t *ast_t;
+struct ast_node {
+ enum {
+ NODE_SEXP,
+ NODE_SYMBOL,
+ NODE_LITERAL,
+ } type;
+
+ union {
+ struct sexp {
+ struct ast_node **children;
+ size_t nchildren;
+ } sexp;
+
+ char *symbol;
+
+ union {
+ enum {
+ NODE_LITERAL_NUM,
+ NODE_LITERAL_STR,
+ } type;
+
+ int number;
+ char *string;
+ } literal;
+ };
+};
+
+ast_t ast_create();
+void ast_destroy(ast_t ast);
+int ast_parse_lexer(ast_t ast, lexer_t lex);
+
+#endif