]> ocean-lang.org Git - ocean/commitdiff
parsergen: change symset function to use 'unsigned short'.
authorNeilBrown <neilb@suse.de>
Sun, 21 Jul 2013 08:04:24 +0000 (18:04 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 21 Jul 2013 08:17:24 +0000 (18:17 +1000)
To make full use of all 16 bits of a sym, we should make sure
we consistent use "unsigned".

Signed-off-by: NeilBrown <neilb@suse.de>
csrc/parsergen.mdc

index 2c2e2a66dba6a90035a0d7584537bc0c0f978c5a..4ec6d6682339cca49b5c5de12858fdea3fe14f63 100644 (file)
@@ -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];