Added an option to strip the grammar from its actions
authorceriel <none@none>
Fri, 24 Feb 1995 12:10:44 +0000 (12:10 +0000)
committerceriel <none@none>
Fri, 24 Feb 1995 12:10:44 +0000 (12:10 +0000)
util/LLgen/src/LLgen.g
util/LLgen/src/extern.h
util/LLgen/src/global.c
util/LLgen/src/main.c
util/LLgen/src/tokens.g

index ff5f4f1..fcfab92 100644 (file)
@@ -573,8 +573,10 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
        register        ch;             /* Current char */
        register        match;          /* used to read strings */
        int             saved;          /* save linecount */
+       int             sav_strip = strip_grammar;
 
        f = fact;
+       if (ch1 == '{' || flag != 1) strip_grammar = 0;
        if (!level) {
                saved = linecount;
                text_seen = 0;
@@ -591,6 +593,10 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
                                if (text_seen) nparams++;
                        }
                        if (level || (flag & 1)) putc(ch,f);
+                       if (strip_grammar != sav_strip) {
+                               if (ch1 == '{' || flag != 1) putchar(ch);
+                       }
+                       strip_grammar = sav_strip;
                        return;
                }
                switch(ch) {
@@ -657,6 +663,7 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
                        /* Fall through */
                    case EOF :
                        if (!level) error(saved,"Action does not terminate");
+                       strip_grammar = sav_strip;
                        return;
                    default:
                        if (c_class[ch] != ISSPA) text_seen = 1;
index 343806a..5895d10 100644 (file)
@@ -76,3 +76,4 @@ extern int    low_percentage, high_percentage;
 extern int     min_cases_for_jmptable;
 extern int     jmptable_option;
 extern int     ansi_c;
+extern int     strip_grammar;
index 10f2429..b729fa5 100644 (file)
@@ -67,3 +67,4 @@ int   low_percentage = 10, high_percentage = 30;
 int    min_cases_for_jmptable = 8;
 int    jmptable_option;
 int    ansi_c = 0;
+int    strip_grammar = 0;
index f2b0e2b..e0e9eb3 100644 (file)
@@ -103,6 +103,10 @@ main(argc,argv) register string    argv[]; {
                          case 'A':
                                ansi_c = 1;
                                continue;
+                         case 's':
+                         case 'S':
+                               strip_grammar = 1;
+                               continue;
                          default:
                                fprintf(stderr,"illegal option : %c\n",*arg);
                                exit(1);
index b6813c0..39717d2 100644 (file)
@@ -225,6 +225,7 @@ input() {
                nonline = 1;
        }
        if (c == '\n') nonline = 0;
+       if (strip_grammar) putchar(c);
        return c;
 }