summaryrefslogtreecommitdiff
path: root/basic.h
diff options
context:
space:
mode:
authorTom Harley2019-09-30 01:56:15 +0100
committerTom Harley2019-09-30 01:56:15 +0100
commitfbe39f58fc0d757f8ffe54c6dc96bbc690862ded (patch)
tree94d861774ded89f82363bcc2877ec2cc3f94c024 /basic.h
downloadsinter-fbe39f58fc0d757f8ffe54c6dc96bbc690862ded.tar.gz
sinter-fbe39f58fc0d757f8ffe54c6dc96bbc690862ded.zip

Initial commit

Diffstat (limited to 'basic.h')
-rw-r--r--basic.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/basic.h b/basic.h
new file mode 100644
index 0000000..679bf89
--- /dev/null
+++ b/basic.h
@@ -0,0 +1,28 @@
+#ifndef _BASIC_H
+#define _BASIC_H
+
+typedef struct sexpr {
+ int type;
+ union contents {
+ float f;
+ char *s;
+ int i;
+ struct node {
+ struct sexpr *l;
+ struct sexpr *r;
+ } n;
+ } contents;
+} sexpr;
+
+typedef struct node node;
+typedef union contents contents;
+
+sexpr *new_int(int num);
+sexpr *new_float(float num);
+sexpr *new_id(char *id);
+sexpr *new_node(sexpr *l, sexpr *r);
+
+void print_sexpr(sexpr *contents);
+void codegen(sexpr *sexpr);
+
+#endif /* _BASIC_H */