Added an option to strip the grammar from its actions
This commit is contained in:
parent
65353b1417
commit
d1435f4fc6
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -225,6 +225,7 @@ input() {
|
|||
nonline = 1;
|
||||
}
|
||||
if (c == '\n') nonline = 0;
|
||||
if (strip_grammar) putchar(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue