summaryrefslogtreecommitdiff
path: root/ast.h
diff options
context:
space:
mode:
Diffstat (limited to 'ast.h')
-rw-r--r--ast.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/ast.h b/ast.h
new file mode 100644
index 0000000..84a3341
--- /dev/null
+++ b/ast.h
@@ -0,0 +1,39 @@
+#ifndef _ast_h
+#define _ast_h
+
+#include <stdlib.h>
+#include <stddef.h>
+
+typedef enum {
+ AST_NUM,
+ AST_LIST,
+} AstTy;
+
+struct _astnode;
+typedef struct _astnode AstNode;
+
+typedef struct {
+ size_t len;
+ size_t cap;
+ AstNode *vals;
+} AstVec;
+
+struct _astnode {
+ AstTy ty;
+ union {
+ int num;
+ AstVec list;
+ } as;
+};
+
+
+AstVec astvec_new();
+void astvec_append(AstVec *v, AstNode val);
+
+AstNode astnode_new_num(int n);
+AstNode astnode_new_list();
+
+
+
+
+#endif