summaryrefslogtreecommitdiff
path: root/s4/sym.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-08-31 16:07:55 +0000
committerrodri <rgl@antares-labs.eu>2024-08-31 16:07:55 +0000
commitb94627b33d055c0d644480c9100d19c6318ed9c1 (patch)
tree90621333ad3865b1c2e675adf00d062f7907b566 /s4/sym.c
parent8cca4d1fe83f792d0f3c5dd897611ea2ff441de0 (diff)
downloadrhoc-b94627b33d055c0d644480c9100d19c6318ed9c1.tar.gz
rhoc-b94627b33d055c0d644480c9100d19c6318ed9c1.tar.bz2
rhoc-b94627b33d055c0d644480c9100d19c6318ed9c1.zip
stage 4 (incomplete).front
Diffstat (limited to 's4/sym.c')
-rw-r--r--s4/sym.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/s4/sym.c b/s4/sym.c
new file mode 100644
index 0000000..8749791
--- /dev/null
+++ b/s4/sym.c
@@ -0,0 +1,31 @@
+#include <u.h>
+#include <libc.h>
+#include "dat.h"
+#include "fns.h"
+
+static Symbol *symtab;
+
+Symbol *
+install(char *s, int t, double v)
+{
+ Symbol *sym;
+
+ sym = emalloc(sizeof(Symbol));
+ sym->name = strdup(s);
+ sym->type = t;
+ sym->u.val = v;
+ sym->next = symtab;
+ symtab = sym;
+ return sym;
+}
+
+Symbol *
+lookup(char *s)
+{
+ Symbol *sym;
+
+ for(sym = symtab; sym != nil; sym = sym->next)
+ if(strcmp(sym->name, s) == 0)
+ return sym;
+ return nil;
+}