summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-07-10 21:35:02 +0100
committerubq323 <ubq323@ubq323.website>2023-07-10 21:35:02 +0100
commit86c9a7e5c47c5c3eb70e06ea5e278de8022fd5b2 (patch)
tree4417af653c8619475ff818705760feb6edb83757
parentd28f04f44efffd61564951456c061ba14e1921eb (diff)
minor
-rw-r--r--.gitignore3
-rw-r--r--ast.c10
-rw-r--r--ast.h4
3 files changed, 13 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a470cdb
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+parser.c
+parser.h
+badthing
diff --git a/ast.c b/ast.c
index 07c0f34..94c0a66 100644
--- a/ast.c
+++ b/ast.c
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
+#include <assert.h>
AstVec astvec_new() {
AstNode *vals = malloc(2 * sizeof(AstNode));
@@ -23,6 +24,12 @@ void astvec_append(AstVec *v, AstNode val) {
v->len ++;
}
+void astnode_append(AstNode *l, AstNode val) {
+ printf(" astnode_append: %d\n",l->ty);
+ assert(l->ty == AST_LIST);
+ astvec_append(&l->as.list, val);
+}
+
AstNode astnode_new_num(int n) {
return (AstNode){
.ty = AST_NUM,
@@ -41,6 +48,3 @@ AstNode astnode_new_list() {
};
}
-
-
-
diff --git a/ast.h b/ast.h
index 84a3341..f352992 100644
--- a/ast.h
+++ b/ast.h
@@ -5,8 +5,9 @@
#include <stddef.h>
typedef enum {
- AST_NUM,
+ AST_NOTHING,
AST_LIST,
+ AST_NUM,
} AstTy;
struct _astnode;
@@ -29,6 +30,7 @@ struct _astnode {
AstVec astvec_new();
void astvec_append(AstVec *v, AstNode val);
+void astnode_append(AstNode *l, AstNode val);
AstNode astnode_new_num(int n);
AstNode astnode_new_list();