From e084995a668960be1389f5a4913887abab01fb0e Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 21 Jul 2013 18:04:24 +1000 Subject: [PATCH] parsergen: change symset function to use 'unsigned short'. To make full use of all 16 bits of a sym, we should make sure we consistent use "unsigned". Signed-off-by: NeilBrown --- csrc/parsergen.mdc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/csrc/parsergen.mdc b/csrc/parsergen.mdc index 2c2e2a6..4ec6d66 100644 --- a/csrc/parsergen.mdc +++ b/csrc/parsergen.mdc @@ -636,7 +636,7 @@ allocated space as it can be derived directly from the current `cnt` using `((cnt - 1) | 7) + 1`. ###### functions - static void symset_add(struct symset *s, int key, int val) + static void symset_add(struct symset *s, unsigned short key, unsigned short val) { int i; int current = ((s->cnt-1) | 7) + 1; @@ -663,7 +663,7 @@ Finding a symbol (or item) in a `symset` uses a simple binary search. We return the index where the value was found (so data can be accessed), or `-1` to indicate failure. - static int symset_find(struct symset *ss, int key) + static int symset_find(struct symset *ss, unsigned short key) { int lo = 0; int hi = ss->cnt; @@ -695,7 +695,7 @@ can be optimised later. int added = 0; for (i = 0; i < b->cnt; i++) if (symset_find(a, b->syms[i]) < 0) { - int data = 0; + unsigned short data = 0; if (b->data != NO_DATA) data = b->data[i]; symset_add(a, b->syms[i], data); @@ -1168,7 +1168,7 @@ though. int p2; struct symbol *s; struct symset LA = INIT_SYMSET; - int sn = 0; + unsigned short sn = 0; if (bs == pr->body_size) continue; @@ -1226,7 +1226,7 @@ with a pre-existing itemset). // if they don't exist. for (i = 0; i < done.cnt; i++) { int j; - int state; + unsigned short state; struct symset newitemset = INIT_SYMSET; if (type >= LALR) newitemset = INIT_DATASET; @@ -1236,7 +1236,7 @@ with a pre-existing itemset). int p = item_prod(itm); int bp = item_index(itm); struct production *pr = g->productions[p]; - int la = 0; + unsigned short la = 0; int pos; if (bp == pr->body_size) @@ -1277,7 +1277,7 @@ with `TK_eof` as the LA set. struct symset first = INIT_SYMSET; struct itemset *is; int again; - int la = 0; + unsigned short la = 0; if (type >= LALR) { // LA set just has eof struct symset eof = INIT_SYMSET; @@ -1607,7 +1607,7 @@ between the two. continue; /* First collect the shifts */ for (j = 0; j < is->items.cnt; j++) { - int itm = is->items.syms[j]; + unsigned short itm = is->items.syms[j]; int p = item_prod(itm); int bp = item_index(itm); struct production *pr = g->productions[p]; @@ -1622,7 +1622,7 @@ between the two. } /* Now look for reduction and conflicts */ for (j = 0; j < is->items.cnt; j++) { - int itm = is->items.syms[j]; + unsigned short itm = is->items.syms[j]; int p = item_prod(itm); int bp = item_index(itm); struct production *pr = g->productions[p]; -- 2.43.0