bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

19-fyi-more-deobf-conflicts.patch


From: Akim Demaille
Subject: 19-fyi-more-deobf-conflicts.patch
Date: Wed, 05 Dec 2001 08:25:37 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * src/state.h (SHIFT_SYMBOL): New.
        * src/conflicts.c: Use it to deobfuscate.
        
        
Index: src/conflicts.c
--- src/conflicts.c Sat, 01 Dec 2001 19:03:12 +0100 akim
+++ src/conflicts.c Sat, 01 Dec 2001 19:11:45 +0100 akim
@@ -184,7 +184,6 @@
 {
   int i, j;
   shifts *shiftp;
-  int symbol;
 
   if (state_table[state].consistent)
     return;
@@ -194,13 +193,8 @@
 
   shiftp = state_table[state].shift_table;
   if (shiftp)
-    for (i = 0; i < shiftp->nshifts; i++)
-      {
-       symbol = state_table[shiftp->shifts[i]].accessing_symbol;
-       if (ISVAR (symbol))
-         break;
-       SETBIT (lookaheadset, symbol);
-      }
+    for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
+      SETBIT (lookaheadset, SHIFT_SYMBOL (shiftp, i));
 
   /* Loop over all rules which require lookahead in this state.  First
      check for shift-reduce conflict, and try to resolve using
@@ -269,10 +263,7 @@
     }
 
   for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
-    {
-      int symbol = state_table[shiftp->shifts[i]].accessing_symbol;
-      SETBIT (shiftset, symbol);
-    }
+    SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
 
   for (i = state_table[state].lookaheads;
        i < state_table[state + 1].lookaheads;
@@ -451,7 +442,6 @@
 {
   int i;
   int j;
-  int symbol;
   int m;
   int n;
   shifts *shiftp;
@@ -463,18 +453,13 @@
 
   shiftp = state_table[state].shift_table;
   if (shiftp)
-    for (i = 0; i < shiftp->nshifts; i++)
+    for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
       {
-       if (!shiftp->shifts[i])
-         continue;
-       symbol = state_table[shiftp->shifts[i]].accessing_symbol;
-       if (ISVAR (symbol))
-         break;
-       /* if this state has a shift for the error token,
-          don't use a default rule.  */
-       if (symbol == error_token_number)
+       /* if this state has a shift for the error token, don't use a
+          default rule.  */
+       if (SHIFT_IS_ERROR (shiftp, i))
          nodefault = 1;
-       SETBIT (shiftset, symbol);
+       SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
       }
 
   errp = err_table[state];
@@ -538,15 +523,8 @@
        shiftset[i] = 0;
 
       if (shiftp)
-       for (i = 0; i < shiftp->nshifts; i++)
-         {
-           if (!shiftp->shifts[i])
-             continue;
-           symbol = state_table[shiftp->shifts[i]].accessing_symbol;
-           if (ISVAR (symbol))
-             break;
-           SETBIT (shiftset, symbol);
-         }
+       for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
+         SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
 
       for (i = 0; i < ntokens; i++)
        {
Index: src/state.h
--- src/state.h Sat, 01 Dec 2001 17:50:24 +0100 akim
+++ src/state.h Sat, 01 Dec 2001 19:08:27 +0100 akim
@@ -124,10 +124,17 @@
   (shifts *) xcalloc ((unsigned) (sizeof (shifts)                      \
                                   + (Nshifts - 1) * sizeof (short)), 1)
 
+/* What is the symbol which is shifted by SHIFTS->shifts[Shift]?  Can
+   be a token (amongst which the error token), or non terminals in
+   case of gotos.  */
+
+#define SHIFT_SYMBOL(Shifts, Shift) \
+  (state_table[Shifts->shifts[Shift]].accessing_symbol)
+
 /* Is the SHIFTS->shifts[Shift] a real shift? (as opposed to gotos.) */
 
 #define SHIFT_IS_SHIFT(Shifts, Shift) \
-  (ISTOKEN (state_table[Shifts->shifts[Shift]].accessing_symbol))
+  (ISTOKEN (SHIFT_SYMBOL (Shifts, Shift)))
 
 /* Is the SHIFTS->shifts[Shift] a goto?. */
 
@@ -137,7 +144,7 @@
 /* Is the SHIFTS->shifts[Shift] then handling of the error token?. */
 
 #define SHIFT_IS_ERROR(Shifts, Shift) \
-  (state_table[Shifts->shifts[Shift]].accessing_symbol == error_token_number)
+  (SHIFT_SYMBOL (Shifts, Shift) == error_token_number)
 
 
 /*-------.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]