summaryrefslogtreecommitdiff
path: root/sym.c
diff options
context:
space:
mode:
Diffstat (limited to 'sym.c')
-rw-r--r--sym.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/sym.c b/sym.c
new file mode 100644
index 0000000..d84fec5
--- /dev/null
+++ b/sym.c
@@ -0,0 +1,33 @@
+#include <u.h>
+#include <libc.h>
+#include <geometry.h>
+#include "dat.h"
+#include "fns.h"
+
+static Symbol *symtab;
+
+Symbol *
+install(char *s, int t, double v)
+{
+ Symbol *sym;
+
+ sym = emalloc(sizeof(Symbol));
+ memset(sym, 0, sizeof *sym);
+ sym->name = estrdup(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;
+}