summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkugwa <kugwa2000@gmail.com>2015-10-21 14:54:34 +0800
committerkugwa <kugwa2000@gmail.com>2015-10-21 14:54:34 +0800
commite56bbe7525c971a4b918f815b1a572e7838f6b3c (patch)
treed8d97f871b735fe6767f53cfe6e11b1ec4a84135
parent0eef921b4e2620600d2ed77ac0adf737ba7d3fa2 (diff)
downloadcompiler2015-e56bbe7525c971a4b918f815b1a572e7838f6b3c.tar
compiler2015-e56bbe7525c971a4b918f815b1a572e7838f6b3c.tar.gz
compiler2015-e56bbe7525c971a4b918f815b1a572e7838f6b3c.tar.bz2
compiler2015-e56bbe7525c971a4b918f815b1a572e7838f6b3c.tar.lz
compiler2015-e56bbe7525c971a4b918f815b1a572e7838f6b3c.tar.xz
compiler2015-e56bbe7525c971a4b918f815b1a572e7838f6b3c.tar.zst
compiler2015-e56bbe7525c971a4b918f815b1a572e7838f6b3c.zip
Add fillTab() for hw2
-rw-r--r--symbol-table.c14
-rw-r--r--symbol-table.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/symbol-table.c b/symbol-table.c
index 785faf8..ca8dd3f 100644
--- a/symbol-table.c
+++ b/symbol-table.c
@@ -83,4 +83,18 @@ void printSymTab(void) {
}
}
+int fillTab(symtab **tp) {
+ int cnt = 0;
+ for (int i = 0; i < TABLE_SIZE; i++)
+ {
+ symtab *symptr = hash_table[i];
+ while (symptr != NULL)
+ {
+ tp[cnt++] = symptr;
+ symptr = symptr->front;
+ }
+ }
+ return cnt;
+}
+
// vim: set sw=4 ts=4 sts=4 et:
diff --git a/symbol-table.h b/symbol-table.h
index e234a43..c92986d 100644
--- a/symbol-table.h
+++ b/symbol-table.h
@@ -10,5 +10,6 @@ typedef struct symtab symtab;
symtab* lookup(char *name);
void insertID(char *name);
void printSymTab(void);
+int fillTab(symtab **tp);
// vim: set sw=4 ts=4 sts=4 et: