From: ceriel Date: Fri, 24 Feb 1995 12:10:44 +0000 (+0000) Subject: Added an option to strip the grammar from its actions X-Git-Tag: release-5-5~136 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=d1435f4fc697aea8b0487dfdb6790abebef8dd2f;p=ack.git Added an option to strip the grammar from its actions --- diff --git a/util/LLgen/src/LLgen.g b/util/LLgen/src/LLgen.g index ff5f4f142..fcfab9210 100644 --- a/util/LLgen/src/LLgen.g +++ b/util/LLgen/src/LLgen.g @@ -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; diff --git a/util/LLgen/src/extern.h b/util/LLgen/src/extern.h index 343806a38..5895d1034 100644 --- a/util/LLgen/src/extern.h +++ b/util/LLgen/src/extern.h @@ -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; diff --git a/util/LLgen/src/global.c b/util/LLgen/src/global.c index 10f242905..b729fa50d 100644 --- a/util/LLgen/src/global.c +++ b/util/LLgen/src/global.c @@ -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; diff --git a/util/LLgen/src/main.c b/util/LLgen/src/main.c index f2b0e2ba5..e0e9eb34e 100644 --- a/util/LLgen/src/main.c +++ b/util/LLgen/src/main.c @@ -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); diff --git a/util/LLgen/src/tokens.g b/util/LLgen/src/tokens.g index b6813c0eb..39717d253 100644 --- a/util/LLgen/src/tokens.g +++ b/util/LLgen/src/tokens.g @@ -225,6 +225,7 @@ input() { nonline = 1; } if (c == '\n') nonline = 0; + if (strip_grammar) putchar(c); return c; }