Added an option to strip the grammar from its actions
This commit is contained in:
parent
65353b1417
commit
d1435f4fc6
5 changed files with 14 additions and 0 deletions
|
@ -573,8 +573,10 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
|
||||||
register ch; /* Current char */
|
register ch; /* Current char */
|
||||||
register match; /* used to read strings */
|
register match; /* used to read strings */
|
||||||
int saved; /* save linecount */
|
int saved; /* save linecount */
|
||||||
|
int sav_strip = strip_grammar;
|
||||||
|
|
||||||
f = fact;
|
f = fact;
|
||||||
|
if (ch1 == '{' || flag != 1) strip_grammar = 0;
|
||||||
if (!level) {
|
if (!level) {
|
||||||
saved = linecount;
|
saved = linecount;
|
||||||
text_seen = 0;
|
text_seen = 0;
|
||||||
|
@ -591,6 +593,10 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
|
||||||
if (text_seen) nparams++;
|
if (text_seen) nparams++;
|
||||||
}
|
}
|
||||||
if (level || (flag & 1)) putc(ch,f);
|
if (level || (flag & 1)) putc(ch,f);
|
||||||
|
if (strip_grammar != sav_strip) {
|
||||||
|
if (ch1 == '{' || flag != 1) putchar(ch);
|
||||||
|
}
|
||||||
|
strip_grammar = sav_strip;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
|
@ -657,6 +663,7 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case EOF :
|
case EOF :
|
||||||
if (!level) error(saved,"Action does not terminate");
|
if (!level) error(saved,"Action does not terminate");
|
||||||
|
strip_grammar = sav_strip;
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
if (c_class[ch] != ISSPA) text_seen = 1;
|
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 min_cases_for_jmptable;
|
||||||
extern int jmptable_option;
|
extern int jmptable_option;
|
||||||
extern int ansi_c;
|
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 min_cases_for_jmptable = 8;
|
||||||
int jmptable_option;
|
int jmptable_option;
|
||||||
int ansi_c = 0;
|
int ansi_c = 0;
|
||||||
|
int strip_grammar = 0;
|
||||||
|
|
|
@ -103,6 +103,10 @@ main(argc,argv) register string argv[]; {
|
||||||
case 'A':
|
case 'A':
|
||||||
ansi_c = 1;
|
ansi_c = 1;
|
||||||
continue;
|
continue;
|
||||||
|
case 's':
|
||||||
|
case 'S':
|
||||||
|
strip_grammar = 1;
|
||||||
|
continue;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"illegal option : %c\n",*arg);
|
fprintf(stderr,"illegal option : %c\n",*arg);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -225,6 +225,7 @@ input() {
|
||||||
nonline = 1;
|
nonline = 1;
|
||||||
}
|
}
|
||||||
if (c == '\n') nonline = 0;
|
if (c == '\n') nonline = 0;
|
||||||
|
if (strip_grammar) putchar(c);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue