Update LLgen.g and regenerate LLgen.c with it.

This commit is contained in:
Manoel Trapier 2013-03-07 18:56:36 +01:00 committed by Manoël Trapier
parent f1cd17c51e
commit 498d867bc3
2 changed files with 113 additions and 115 deletions

View File

@ -78,6 +78,7 @@ extern LLnc_recover();
# include <stdlib.h> # include <stdlib.h>
# include <string.h> # include <string.h>
# include "types.h" # include "types.h"
# include "io.h" # include "io.h"
# include "extern.h" # include "extern.h"
@ -140,19 +141,19 @@ static void LL2_rule(void);
static void LL3_listel(void); static void LL3_listel(void);
static void LL4_firsts(void); static void LL4_firsts(void);
static void LL5_productions( static void LL5_productions(
# line 246 "LLgen.g" # line 233 "LLgen.g"
p_gram *p) ; p_gram *p) ;
static void LL6_simpleproduction( static void LL6_simpleproduction(
# line 332 "LLgen.g" # line 318 "LLgen.g"
p_gram *p ,register int *conflres) ; p_gram *p ,register int *conflres) ;
static void LL7_elem( static void LL7_elem(
# line 480 "LLgen.g" # line 465 "LLgen.g"
register p_gram pres) ; register p_gram pres) ;
static void LL8_repeats( static void LL8_repeats(
# line 602 "LLgen.g" # line 587 "LLgen.g"
int *kind ,int *cnt) ; int *kind ,int *cnt) ;
static void LL9_number( static void LL9_number(
# line 619 "LLgen.g" # line 604 "LLgen.g"
int *t) ; int *t) ;
#else #else
static LL1_def(); static LL1_def();
@ -174,7 +175,7 @@ void
#endif #endif
) { ) {
LLsincr(0); LLsincr(0);
# line 96 "LLgen.g" # line 84 "LLgen.g"
{ acount = 0; p_init(); } { acount = 0; p_init(); }
for (;;) { for (;;) {
goto L_1; goto L_1;
@ -202,7 +203,7 @@ continue;
LLsdecr(0); LLsdecr(0);
break; break;
} }
# line 98 "LLgen.g" # line 86 "LLgen.g"
{ /* { /*
* Put an endmarker in temporary file * Put an endmarker in temporary file
*/ */
@ -221,7 +222,7 @@ LL1_def(
void void
#endif #endif
) { ) {
# line 108 "LLgen.g" # line 96 "LLgen.g"
register string p; register string p;
switch(LLcsymb) { switch(LLcsymb) {
case /* C_IDENT */ 2 : ; case /* C_IDENT */ 2 : ;
@ -262,13 +263,13 @@ LLtincr(2);
LLtincr(24); LLtincr(24);
LL_SAFE(C_START); LL_SAFE(C_START);
LL_NOSCANDONE(C_IDENT); LL_NOSCANDONE(C_IDENT);
# line 118 "LLgen.g" # line 106 "LLgen.g"
{ p = store(lextoken.t_string); } { p = store(lextoken.t_string); }
LLtdecr(23); LLtdecr(23);
LL_NOSCANDONE(','); LL_NOSCANDONE(',');
LLtdecr(2); LLtdecr(2);
LL_NOSCANDONE(C_IDENT); LL_NOSCANDONE(C_IDENT);
# line 123 "LLgen.g" # line 111 "LLgen.g"
{ /* { /*
* Put the declaration in the list * Put the declaration in the list
* of start symbols * of start symbols
@ -296,7 +297,7 @@ case /* C_LEXICAL */ 14 : ;
LLtincr(24); LLtincr(24);
LL_SAFE(C_LEXICAL); LL_SAFE(C_LEXICAL);
LL_NOSCANDONE(C_IDENT); LL_NOSCANDONE(C_IDENT);
# line 149 "LLgen.g" # line 137 "LLgen.g"
{ if (!lexical) { { if (!lexical) {
lexical = store(lextoken.t_string); lexical = store(lextoken.t_string);
} }
@ -309,7 +310,7 @@ case /* C_PREFIX */ 15 : ;
LLtincr(24); LLtincr(24);
LL_SAFE(C_PREFIX); LL_SAFE(C_PREFIX);
LL_NOSCANDONE(C_IDENT); LL_NOSCANDONE(C_IDENT);
# line 159 "LLgen.g" # line 147 "LLgen.g"
{ if (!prefix) { { if (!prefix) {
prefix = store(lextoken.t_string); prefix = store(lextoken.t_string);
if (strlen(prefix) > 6) { if (strlen(prefix) > 6) {
@ -327,7 +328,7 @@ case /* C_ONERROR */ 16 : ;
LLtincr(24); LLtincr(24);
LL_SAFE(C_ONERROR); LL_SAFE(C_ONERROR);
LL_NOSCANDONE(C_IDENT); LL_NOSCANDONE(C_IDENT);
# line 171 "LLgen.g" # line 159 "LLgen.g"
{ {
#ifdef NON_CORRECTING #ifdef NON_CORRECTING
if (non_corr) { if (non_corr) {
@ -345,7 +346,7 @@ LL_NOSCANDONE(';');
break; break;
default: default:
LL_SSCANDONE(C_ACTION); LL_SSCANDONE(C_ACTION);
# line 184 "LLgen.g" # line 172 "LLgen.g"
{ acount++; } { acount++; }
break; break;
case /* C_FIRST */ 13 : ; case /* C_FIRST */ 13 : ;
@ -363,7 +364,7 @@ void
#endif #endif
) { ) {
LL_NOSCANDONE(C_IDENT); LL_NOSCANDONE(C_IDENT);
# line 194 "LLgen.g" # line 182 "LLgen.g"
{ p_gram temp = search(TERMINAL,lextoken.t_string,ENTERING); { p_gram temp = search(TERMINAL,lextoken.t_string,ENTERING);
newtorder(g_getcont(temp)); newtorder(g_getcont(temp));
tokens[g_getcont(temp)].t_lineno = linecount; tokens[g_getcont(temp)].t_lineno = linecount;
@ -378,7 +379,7 @@ LL2_rule(
void void
#endif #endif
) { ) {
# line 200 "LLgen.g" # line 188 "LLgen.g"
register p_nont p; register p_nont p;
p_gram rr; p_gram rr;
register p_gram temp; register p_gram temp;
@ -389,12 +390,11 @@ LLtincr(25);
LLsincr(1); LLsincr(1);
LLtincr(24); LLtincr(24);
LL_SAFE(C_IDENT); LL_SAFE(C_IDENT);
# line 207 "LLgen.g" # line 195 "LLgen.g"
{ temp = search(NONTERM,lextoken.t_string,BOTH); { temp = search(NONTERM,lextoken.t_string,BOTH);
p = &nonterms[g_getcont(temp)]; p = &nonterms[g_getcont(temp)];
if (p->n_rule) { if (p->n_rule) {
error(linecount, error(linecount, "Nonterminal %s already defined", lextoken.t_string, NULL);
"Nonterminal %s already defined", lextoken.t_string, NULL);
} }
/* /*
* Remember the order in which the nonterminals * Remember the order in which the nonterminals
@ -424,7 +424,7 @@ else if (LL_3 & 1) goto L_1;}
case /* C_PARAMS */ 6 : ; case /* C_PARAMS */ 6 : ;
LLtdecr(6); LLtdecr(6);
LL_SAFE(C_PARAMS); LL_SAFE(C_PARAMS);
# line 225 "LLgen.g" # line 212 "LLgen.g"
{ if (lextoken.t_num > 0) { { if (lextoken.t_num > 0) {
p->n_flags |= PARAMS; p->n_flags |= PARAMS;
if (lextoken.t_num > 15) { if (lextoken.t_num > 15) {
@ -450,25 +450,25 @@ else if (LL_4 & 1) goto L_2;}
case /* C_ACTION */ 7 : ; case /* C_ACTION */ 7 : ;
LLtdecr(7); LLtdecr(7);
LL_SAFE(C_ACTION); LL_SAFE(C_ACTION);
# line 234 "LLgen.g" # line 221 "LLgen.g"
{ p->n_flags |= LOCALS; } { p->n_flags |= LOCALS; }
LLread(); LLread();
} }
} }
LLtdecr(25); LLtdecr(25);
LL_SCANDONE(':'); LL_SCANDONE(':');
# line 236 "LLgen.g" # line 223 "LLgen.g"
{ in_production = 1; } { in_production = 1; }
LLread(); LLread();
LLsdecr(1); LLsdecr(1);
LL5_productions( LL5_productions(
# line 237 "LLgen.g" # line 224 "LLgen.g"
&rr); &rr);
LLtdecr(24); LLtdecr(24);
LL_SCANDONE(';'); LL_SCANDONE(';');
# line 238 "LLgen.g" # line 225 "LLgen.g"
{ in_production = 0; } { in_production = 0; }
# line 243 "LLgen.g" # line 230 "LLgen.g"
{ nonterms[g_getcont(temp)].n_rule = rr;} { nonterms[g_getcont(temp)].n_rule = rr;}
} }
static static
@ -477,14 +477,14 @@ void
#endif #endif
LL5_productions( LL5_productions(
#if LL_ANSI_C #if LL_ANSI_C
# line 246 "LLgen.g" # line 233 "LLgen.g"
p_gram *p) p_gram *p)
#else #else
# line 246 "LLgen.g" # line 233 "LLgen.g"
p) p_gram *p; p) p_gram *p;
#endif #endif
{ {
# line 250 "LLgen.g" # line 237 "LLgen.g"
p_gram prod; p_gram prod;
int conflres = 0; int conflres = 0;
int t = 0; int t = 0;
@ -493,12 +493,12 @@ p_gram *p)
int o_lc, n_lc; int o_lc, n_lc;
LLtincr(26); LLtincr(26);
# line 257 "LLgen.g" # line 244 "LLgen.g"
{ o_lc = linecount; } { o_lc = linecount; }
LL6_simpleproduction( LL6_simpleproduction(
# line 258 "LLgen.g" # line 245 "LLgen.g"
p,&conflres); p,&conflres);
# line 259 "LLgen.g" # line 246 "LLgen.g"
{ if (conflres & DEF) haddefault = 1; } { if (conflres & DEF) haddefault = 1; }
goto L_2; /* so that the label is used for certain */ goto L_2; /* so that the label is used for certain */
L_2: ; L_2: ;
@ -510,13 +510,13 @@ LLsdecr(1);
LLtincr(26); LLtincr(26);
for (;;) { for (;;) {
LL_SAFE('|'); LL_SAFE('|');
# line 261 "LLgen.g" # line 248 "LLgen.g"
{ n_lc = linecount; } { n_lc = linecount; }
LLread(); LLread();
LL6_simpleproduction( LL6_simpleproduction(
# line 262 "LLgen.g" # line 249 "LLgen.g"
&prod,&t); &prod,&t);
# line 263 "LLgen.g" # line 250 "LLgen.g"
{ if (n_alts >= max_alts-2) { { if (n_alts >= max_alts-2) {
alt_table = (p_gram ) ralloc( alt_table = (p_gram ) ralloc(
(p_mem) alt_table, (p_mem) alt_table,
@ -553,7 +553,7 @@ continue;
LLtdecr(26); LLtdecr(26);
break; break;
} }
# line 282 "LLgen.g" # line 269 "LLgen.g"
{ if (conflres & (COND|PREFERING|AVOIDING)) { { if (conflres & (COND|PREFERING|AVOIDING)) {
error(n_lc, error(n_lc,
"Resolver on last alternative not allowed", NULL, NULL); "Resolver on last alternative not allowed", NULL, NULL);
@ -569,7 +569,7 @@ case /* ']' */ 28 : ;
goto L_3; goto L_3;
L_3: ; L_3: ;
LLtdecr(26); LLtdecr(26);
# line 292 "LLgen.g" # line 279 "LLgen.g"
{ if (conflres & (COND|PREFERING|AVOIDING)) { { if (conflres & (COND|PREFERING|AVOIDING)) {
error(o_lc, error(o_lc,
"No alternation conflict resolver allowed here", NULL, NULL); "No alternation conflict resolver allowed here", NULL, NULL);
@ -577,7 +577,7 @@ LLtdecr(26);
/* /*
if (conflres & DEF) { if (conflres & DEF) {
error(o_lc, error(o_lc,
"No %%default allowed here"); "No %%default allowed here", NULL, NULL);
} }
*/ */
} }
@ -585,10 +585,10 @@ break;
default: if (LLskip()) goto L_2; default: if (LLskip()) goto L_2;
goto L_3; goto L_3;
} }
# line 304 "LLgen.g" # line 291 "LLgen.g"
{ n_alts -= altcnt; } { n_alts -= altcnt; }
} }
# line 306 "LLgen.g" # line 293 "LLgen.g"
STATIC void mkalt(p_gram prod, int condition, int lc, p_gram res) { STATIC void mkalt(p_gram prod, int condition, int lc, p_gram res) {
@ -618,14 +618,14 @@ void
#endif #endif
LL6_simpleproduction( LL6_simpleproduction(
#if LL_ANSI_C #if LL_ANSI_C
# line 332 "LLgen.g" # line 318 "LLgen.g"
p_gram *p ,register int *conflres) p_gram *p ,register int *conflres)
#else #else
# line 332 "LLgen.g" # line 318 "LLgen.g"
p,conflres) p_gram *p; register int *conflres; p,conflres) p_gram *p; register int *conflres;
#endif #endif
{ {
# line 333 "LLgen.g" # line 319 "LLgen.g"
t_gram elem; t_gram elem;
int elmcnt = 0; int elmcnt = 0;
int cnt, kind; int cnt, kind;
@ -661,7 +661,7 @@ else if (LL_6 & 1) goto L_1;}
case /* C_DEFAULT */ 19 : ; case /* C_DEFAULT */ 19 : ;
LLtdecr(19); LLtdecr(19);
LL_SAFE(C_DEFAULT); LL_SAFE(C_DEFAULT);
# line 338 "LLgen.g" # line 324 "LLgen.g"
{ *conflres |= DEF; } { *conflres |= DEF; }
LLread(); LLread();
} }
@ -694,17 +694,17 @@ switch(LLcsymb) {
case /* C_IF */ 10 : ; case /* C_IF */ 10 : ;
LL_SAFE(C_IF); LL_SAFE(C_IF);
LL_NOSCANDONE(C_EXPR); LL_NOSCANDONE(C_EXPR);
# line 344 "LLgen.g" # line 330 "LLgen.g"
{ *conflres |= COND; } { *conflres |= COND; }
break; break;
default: default:
LL_SAFE(C_PREFER); LL_SAFE(C_PREFER);
# line 345 "LLgen.g" # line 331 "LLgen.g"
{ *conflres |= PREFERING; } { *conflres |= PREFERING; }
break; break;
case /* C_AVOID */ 17 : ; case /* C_AVOID */ 17 : ;
LL_SAFE(C_AVOID); LL_SAFE(C_AVOID);
# line 346 "LLgen.g" # line 332 "LLgen.g"
{ *conflres |= AVOIDING; } { *conflres |= AVOIDING; }
break; break;
} }
@ -733,7 +733,7 @@ else if (LL_8 & 1) goto L_6;}
case /* C_ILLEGAL */ 22 : ; case /* C_ILLEGAL */ 22 : ;
LLtdecr(22); LLtdecr(22);
LL_SAFE(C_ILLEGAL); LL_SAFE(C_ILLEGAL);
# line 348 "LLgen.g" # line 334 "LLgen.g"
{ {
#ifdef NON_CORRECTING #ifdef NON_CORRECTING
if (n_rules >= max_rules-2) { if (n_rules >= max_rules-2) {
@ -776,9 +776,9 @@ case /* '*' */ 30 : ;
case /* '+' */ 31 : ; case /* '+' */ 31 : ;
LLsincr(4); LLsincr(4);
LL7_elem( LL7_elem(
# line 364 "LLgen.g" # line 350 "LLgen.g"
&elem); &elem);
# line 365 "LLgen.g" # line 351 "LLgen.g"
{ if (n_rules >= max_rules-2) { { if (n_rules >= max_rules-2) {
rule_table = (p_gram) ralloc( rule_table = (p_gram) ralloc(
(p_mem) rule_table, (p_mem) rule_table,
@ -796,9 +796,9 @@ case /* '*' */ 30 : ;
case /* '+' */ 31 : ; case /* '+' */ 31 : ;
LLsdecr(4); LLsdecr(4);
LL8_repeats( LL8_repeats(
# line 373 "LLgen.g" # line 359 "LLgen.g"
&kind, &cnt); &kind, &cnt);
# line 374 "LLgen.g" # line 360 "LLgen.g"
{ if (g_gettype(&elem) != TERM) { { if (g_gettype(&elem) != TERM) {
rule_table[n_rules] = elem; rule_table[n_rules] = elem;
g_settype((&rule_table[n_rules+1]),EORULE); g_settype((&rule_table[n_rules+1]),EORULE);
@ -821,7 +821,7 @@ case /* ']' */ 28 : ;
goto L_10; goto L_10;
L_10: ; L_10: ;
LLsdecr(4); LLsdecr(4);
# line 384 "LLgen.g" # line 370 "LLgen.g"
{ if (g_gettype(&elem) == TERM) { { if (g_gettype(&elem) == TERM) {
register p_term q = g_getterm(&elem); register p_term q = g_getterm(&elem);
@ -853,7 +853,7 @@ break;
default: if (LLskip()) goto L_9; default: if (LLskip()) goto L_9;
goto L_10; goto L_10;
} }
# line 411 "LLgen.g" # line 397 "LLgen.g"
{ if (!termdeleted && g_gettype(&elem) == TERM) { { if (!termdeleted && g_gettype(&elem) == TERM) {
register p_term q; register p_term q;
@ -872,7 +872,7 @@ goto L_10;
if ((q->t_flags & PERSISTENT) && if ((q->t_flags & PERSISTENT) &&
kind == FIXED) { kind == FIXED) {
error(linecount, error(linecount,
"Illegal %%persistent"); "Illegal %%persistent", NULL, NULL);
} }
*/ */
} }
@ -886,7 +886,7 @@ continue;
LLsdecr(3); LLsdecr(3);
break; break;
} }
# line 437 "LLgen.g" # line 423 "LLgen.g"
{ register p_term q; { register p_term q;
g_settype((&rule_table[n_rules]),EORULE); g_settype((&rule_table[n_rules]),EORULE);
@ -904,7 +904,7 @@ break;
elmcnt+1); elmcnt+1);
} }
} }
# line 454 "LLgen.g" # line 440 "LLgen.g"
STATIC void mkterm(p_gram prod, int flags, int lc, p_gram result) { STATIC void mkterm(p_gram prod, int flags, int lc, p_gram result) {
@ -934,14 +934,14 @@ void
#endif #endif
LL7_elem( LL7_elem(
#if LL_ANSI_C #if LL_ANSI_C
# line 480 "LLgen.g" # line 465 "LLgen.g"
register p_gram pres) register p_gram pres)
#else #else
# line 480 "LLgen.g" # line 465 "LLgen.g"
pres) register p_gram pres; pres) register p_gram pres;
#endif #endif
{ {
# line 481 "LLgen.g" # line 466 "LLgen.g"
register int t = 0; register int t = 0;
p_gram p1; p_gram p1;
int ln; int ln;
@ -957,7 +957,7 @@ LLtincr(12);
LLsincr(1); LLsincr(1);
LLtincr(28); LLtincr(28);
LL_SAFE('['); LL_SAFE('[');
# line 489 "LLgen.g" # line 474 "LLgen.g"
{ ln = linecount; } { ln = linecount; }
LLread(); LLread();
goto L_4; goto L_4;
@ -988,7 +988,7 @@ case /* C_WHILE */ 11 : ;
LLtdecr(11); LLtdecr(11);
LL_SAFE(C_WHILE); LL_SAFE(C_WHILE);
LL_NOSCANDONE(C_EXPR); LL_NOSCANDONE(C_EXPR);
# line 490 "LLgen.g" # line 475 "LLgen.g"
{ t |= RESOLVER; } { t |= RESOLVER; }
LLread(); LLread();
} }
@ -1019,18 +1019,18 @@ else if (LL_11 & 1) goto L_5;}
case /* C_PERSISTENT */ 12 : ; case /* C_PERSISTENT */ 12 : ;
LLtdecr(12); LLtdecr(12);
LL_SAFE(C_PERSISTENT); LL_SAFE(C_PERSISTENT);
# line 492 "LLgen.g" # line 477 "LLgen.g"
{ t |= PERSISTENT; } { t |= PERSISTENT; }
LLread(); LLread();
} }
} }
LLsdecr(1); LLsdecr(1);
LL5_productions( LL5_productions(
# line 494 "LLgen.g" # line 479 "LLgen.g"
&p1); &p1);
LLtdecr(28); LLtdecr(28);
LL_SCANDONE(']'); LL_SCANDONE(']');
# line 495 "LLgen.g" # line 480 "LLgen.g"
{ {
mkterm(p1,t,ln,pres); mkterm(p1,t,ln,pres);
} }
@ -1046,7 +1046,7 @@ default:
break; break;
case /* C_ERRONEOUS */ 21 : ; case /* C_ERRONEOUS */ 21 : ;
LL_SAFE(C_ERRONEOUS); LL_SAFE(C_ERRONEOUS);
# line 499 "LLgen.g" # line 484 "LLgen.g"
{ {
#ifdef NON_CORRECTING #ifdef NON_CORRECTING
erroneous = 1; erroneous = 1;
@ -1064,7 +1064,7 @@ L_9: ;
LLsdecr(5); LLsdecr(5);
LLtincr(6); LLtincr(6);
LL_SSCANDONE(C_IDENT); LL_SSCANDONE(C_IDENT);
# line 507 "LLgen.g" # line 492 "LLgen.g"
{ pe = search(UNKNOWN,lextoken.t_string,BOTH); { pe = search(UNKNOWN,lextoken.t_string,BOTH);
*pres = *pe; *pres = *pe;
#ifdef NON_CORRECTING #ifdef NON_CORRECTING
@ -1107,7 +1107,7 @@ else if (LL_12 & 1) goto L_10;}
case /* C_PARAMS */ 6 : ; case /* C_PARAMS */ 6 : ;
LLtdecr(6); LLtdecr(6);
LL_SAFE(C_PARAMS); LL_SAFE(C_PARAMS);
# line 522 "LLgen.g" # line 507 "LLgen.g"
{ if (lextoken.t_num > 15) { { if (lextoken.t_num > 15) {
error(linecount,"Too many parameters", NULL, NULL); error(linecount,"Too many parameters", NULL, NULL);
} else g_setnpar(pres,lextoken.t_num); } else g_setnpar(pres,lextoken.t_num);
@ -1125,7 +1125,7 @@ goto L_9;
case /* C_LITERAL */ 4 : ; case /* C_LITERAL */ 4 : ;
LLsdecr(5); LLsdecr(5);
LL_SAFE(C_LITERAL); LL_SAFE(C_LITERAL);
# line 531 "LLgen.g" # line 516 "LLgen.g"
{ pe = search(LITERAL,lextoken.t_string,BOTH); { pe = search(LITERAL,lextoken.t_string,BOTH);
*pres = *pe; *pres = *pe;
#ifdef NON_CORRECTING #ifdef NON_CORRECTING
@ -1139,7 +1139,7 @@ break;
break; break;
default: default:
LLtincr(7); LLtincr(7);
# line 539 "LLgen.g" # line 524 "LLgen.g"
{ g_settype(pres,ACTION); { g_settype(pres,ACTION);
pres->g_lineno = linecount; pres->g_lineno = linecount;
#ifdef NON_CORRECTING #ifdef NON_CORRECTING
@ -1154,14 +1154,14 @@ case /* C_SUBSTART */ 20 : ;
LLtincr(23); LLtincr(23);
LLtincr(24); LLtincr(24);
LL_SAFE(C_SUBSTART); LL_SAFE(C_SUBSTART);
# line 548 "LLgen.g" # line 533 "LLgen.g"
{ {
#ifdef NON_CORRECTING #ifdef NON_CORRECTING
nsubstarts++; nsubstarts++;
#endif #endif
} }
LL_NOSCANDONE(C_IDENT); LL_NOSCANDONE(C_IDENT);
# line 555 "LLgen.g" # line 540 "LLgen.g"
{ {
#ifdef NON_CORRECTING #ifdef NON_CORRECTING
register p_gram temp; register p_gram temp;
@ -1190,7 +1190,7 @@ else if (LL_13 & 1) goto L_12;}
case /* ',' */ 23 : ; case /* ',' */ 23 : ;
LL_SAFE(','); LL_SAFE(',');
LL_NOSCANDONE(C_IDENT); LL_NOSCANDONE(C_IDENT);
# line 571 "LLgen.g" # line 556 "LLgen.g"
{ {
#ifdef NON_CORRECTING #ifdef NON_CORRECTING
register p_gram temp; register p_gram temp;
@ -1239,19 +1239,19 @@ void
#endif #endif
LL8_repeats( LL8_repeats(
#if LL_ANSI_C #if LL_ANSI_C
# line 602 "LLgen.g" # line 587 "LLgen.g"
int *kind ,int *cnt) int *kind ,int *cnt)
#else #else
# line 602 "LLgen.g" # line 587 "LLgen.g"
kind,cnt) int *kind; int *cnt; kind,cnt) int *kind; int *cnt;
#endif #endif
{ {
# line 602 "LLgen.g" # line 587 "LLgen.g"
int t1 = 0; int t1 = 0;
switch(LLcsymb) { switch(LLcsymb) {
default: default:
LL_SAFE('?'); LL_SAFE('?');
# line 604 "LLgen.g" # line 589 "LLgen.g"
{ *kind = OPT; } { *kind = OPT; }
LLread(); LLread();
break; break;
@ -1261,12 +1261,12 @@ LLtincr(3);
switch(LLcsymb) { switch(LLcsymb) {
default: default:
LL_SAFE('*'); LL_SAFE('*');
# line 605 "LLgen.g" # line 590 "LLgen.g"
{ *kind = STAR; } { *kind = STAR; }
break; break;
case /* '+' */ 31 : ; case /* '+' */ 31 : ;
LL_SAFE('+'); LL_SAFE('+');
# line 606 "LLgen.g" # line 591 "LLgen.g"
{ *kind = PLUS; } { *kind = PLUS; }
break; break;
} }
@ -1293,12 +1293,12 @@ else if (LL_14 & 1) goto L_7;}
case /* C_NUMBER */ 3 : ; case /* C_NUMBER */ 3 : ;
LLtdecr(3); LLtdecr(3);
LL9_number( LL9_number(
# line 608 "LLgen.g" # line 593 "LLgen.g"
&t1); &t1);
LLread(); LLread();
} }
} }
# line 609 "LLgen.g" # line 594 "LLgen.g"
{ if (t1 == 1) { { if (t1 == 1) {
t1 = 0; t1 = 0;
if (*kind == STAR) *kind = OPT; if (*kind == STAR) *kind = OPT;
@ -1308,12 +1308,12 @@ LLread();
break; break;
case /* C_NUMBER */ 3 : ; case /* C_NUMBER */ 3 : ;
LL9_number( LL9_number(
# line 615 "LLgen.g" # line 600 "LLgen.g"
&t1); &t1);
LLread(); LLread();
break; break;
} }
# line 616 "LLgen.g" # line 601 "LLgen.g"
{ *cnt = t1; } { *cnt = t1; }
} }
static static
@ -1322,15 +1322,15 @@ void
#endif #endif
LL9_number( LL9_number(
#if LL_ANSI_C #if LL_ANSI_C
# line 619 "LLgen.g" # line 604 "LLgen.g"
int *t) int *t)
#else #else
# line 619 "LLgen.g" # line 604 "LLgen.g"
t) int *t; t) int *t;
#endif #endif
{ {
LL_SAFE(C_NUMBER); LL_SAFE(C_NUMBER);
# line 621 "LLgen.g" # line 606 "LLgen.g"
{ *t = lextoken.t_num; { *t = lextoken.t_num;
if (*t <= 0 || *t >= 8192) { if (*t <= 0 || *t >= 8192) {
error(linecount,"Illegal number", NULL, NULL); error(linecount,"Illegal number", NULL, NULL);
@ -1346,14 +1346,14 @@ LL4_firsts(
void void
#endif #endif
) { ) {
# line 628 "LLgen.g" # line 613 "LLgen.g"
register string p; register string p;
LLtincr(23); LLtincr(23);
LLtincr(2); LLtincr(2);
LLtincr(24); LLtincr(24);
LL_SAFE(C_FIRST); LL_SAFE(C_FIRST);
LL_NOSCANDONE(C_IDENT); LL_NOSCANDONE(C_IDENT);
# line 630 "LLgen.g" # line 615 "LLgen.g"
{ p = store(lextoken.t_string); } { p = store(lextoken.t_string); }
LLtdecr(23); LLtdecr(23);
LL_NOSCANDONE(','); LL_NOSCANDONE(',');
@ -1361,7 +1361,7 @@ LLtdecr(2);
LL_NOSCANDONE(C_IDENT); LL_NOSCANDONE(C_IDENT);
LLtdecr(24); LLtdecr(24);
LL_NOSCANDONE(';'); LL_NOSCANDONE(';');
# line 632 "LLgen.g" # line 617 "LLgen.g"
{ /* { /*
* Store this %first in the list belonging * Store this %first in the list belonging
* to this input file * to this input file
@ -1378,7 +1378,7 @@ LL_NOSCANDONE(';');
} }
} }
# line 647 "LLgen.g" # line 632 "LLgen.g"
STATIC p_gram STATIC p_gram

View File

@ -20,6 +20,7 @@
{ {
# include <stdlib.h> # include <stdlib.h>
# include <string.h> # include <string.h>
# include "types.h" # include "types.h"
# include "io.h" # include "io.h"
# include "extern.h" # include "extern.h"
@ -120,9 +121,9 @@ def { register string p; }
ff->ff_name = p; ff->ff_name = p;
ff->ff_next = start; ff->ff_next = start;
start = ff; start = ff;
while (ff = ff->ff_next) { while ((ff = ff->ff_next)) {
if (! strcmp(p, ff->ff_name)) { if (! strcmp(p, ff->ff_name)) {
error(linecount, "\"%s\" already used in a %%start", p); error(linecount, "\"%s\" already used in a %%start", p, NULL);
break; break;
} }
} }
@ -136,7 +137,7 @@ def { register string p; }
{ if (!lexical) { { if (!lexical) {
lexical = store(lextoken.t_string); lexical = store(lextoken.t_string);
} }
else error(linecount,"Duplicate %%lexical"); else error(linecount,"Duplicate %%lexical", NULL, NULL);
} }
';' ';'
| C_PREFIX C_IDENT | C_PREFIX C_IDENT
@ -147,25 +148,25 @@ def { register string p; }
prefix = store(lextoken.t_string); prefix = store(lextoken.t_string);
if (strlen(prefix) > 6) { if (strlen(prefix) > 6) {
error(linecount, error(linecount,
"%%prefix too long"); "%%prefix too long", NULL, NULL);
prefix[6] = 0; prefix[6] = 0;
} }
} }
else error(linecount,"Duplicate %%prefix"); else error(linecount,"Duplicate %%prefix", NULL, NULL);
} }
';' ';'
| C_ONERROR C_IDENT | C_ONERROR C_IDENT
{ {
#ifdef NON_CORRECTING #ifdef NON_CORRECTING
if (non_corr) { if (non_corr) {
warning(linecount, "%%onerror conflicts with -n option"); warning(linecount, "%%onerror conflicts with -n option", NULL, NULL);
} }
else else
#endif #endif
if (! onerror) { if (! onerror) {
onerror = store(lextoken.t_string); onerror = store(lextoken.t_string);
} }
else error(linecount,"Duplicate %%onerror"); else error(linecount,"Duplicate %%onerror", NULL, NULL);
} }
';' ';'
| C_ACTION { acount++; } | C_ACTION { acount++; }
@ -194,8 +195,7 @@ rule { register p_nont p;
C_IDENT { temp = search(NONTERM,lextoken.t_string,BOTH); C_IDENT { temp = search(NONTERM,lextoken.t_string,BOTH);
p = &nonterms[g_getcont(temp)]; p = &nonterms[g_getcont(temp)];
if (p->n_rule) { if (p->n_rule) {
error(linecount, error(linecount, "Nonterminal %s already defined", lextoken.t_string, NULL);
"Nonterminal %s already defined", lextoken.t_string);
} }
/* /*
* Remember the order in which the nonterminals * Remember the order in which the nonterminals
@ -212,7 +212,7 @@ rule { register p_nont p;
[ C_PARAMS { if (lextoken.t_num > 0) { [ C_PARAMS { if (lextoken.t_num > 0) {
p->n_flags |= PARAMS; p->n_flags |= PARAMS;
if (lextoken.t_num > 15) { if (lextoken.t_num > 15) {
error(linecount,"Too many parameters"); error(linecount,"Too many parameters", NULL, NULL);
} }
else setntparams(p,lextoken.t_num); else setntparams(p,lextoken.t_num);
} }
@ -255,7 +255,7 @@ productions(p_gram *p;)
if (t & DEF) { if (t & DEF) {
if (haddefault) { if (haddefault) {
error(n_lc, error(n_lc,
"More than one %%default in alternation"); "More than one %%default in alternation", NULL, NULL);
} }
haddefault = 1; haddefault = 1;
} }
@ -268,7 +268,7 @@ productions(p_gram *p;)
} }
]+ { if (conflres & (COND|PREFERING|AVOIDING)) { ]+ { if (conflres & (COND|PREFERING|AVOIDING)) {
error(n_lc, error(n_lc,
"Resolver on last alternative not allowed"); "Resolver on last alternative not allowed", NULL, NULL);
} }
mkalt(*p,conflres,n_lc,&alt_table[n_alts++]); mkalt(*p,conflres,n_lc,&alt_table[n_alts++]);
altcnt++; altcnt++;
@ -278,12 +278,12 @@ productions(p_gram *p;)
| |
{ if (conflres & (COND|PREFERING|AVOIDING)) { { if (conflres & (COND|PREFERING|AVOIDING)) {
error(o_lc, error(o_lc,
"No alternation conflict resolver allowed here"); "No alternation conflict resolver allowed here", NULL, NULL);
} }
/* /*
if (conflres & DEF) { if (conflres & DEF) {
error(o_lc, error(o_lc,
"No %%default allowed here"); "No %%default allowed here", NULL, NULL);
} }
*/ */
} }
@ -292,8 +292,7 @@ productions(p_gram *p;)
; ;
{ {
STATIC STATIC void mkalt(p_gram prod, int condition, int lc, p_gram res) {
mkalt(prod,condition,lc,res) p_gram prod; register p_gram res; {
/* /*
* Create an alternation and initialise it. * Create an alternation and initialise it.
*/ */
@ -343,7 +342,7 @@ simpleproduction(p_gram *p; register int *conflres;)
rule_table[n_rules++] = rule_table[n_rules++] =
*search(TERMINAL, "LLILLEGAL", BOTH); *search(TERMINAL, "LLILLEGAL", BOTH);
if (*conflres & DEF) { if (*conflres & DEF) {
error(linecount, "%%illegal not allowed in %%default rule"); error(linecount, "%%illegal not allowed in %%default rule", NULL, NULL);
} }
#endif #endif
} }
@ -404,7 +403,7 @@ simpleproduction(p_gram *p; register int *conflres;)
if ((q->t_flags & RESOLVER) && if ((q->t_flags & RESOLVER) &&
(kind == PLUS || kind == FIXED)) { (kind == PLUS || kind == FIXED)) {
error(linecount, error(linecount,
"%%while not allowed in this term"); "%%while not allowed in this term", NULL, NULL);
} }
/* /*
* A persistent fixed term is the same * A persistent fixed term is the same
@ -413,7 +412,7 @@ simpleproduction(p_gram *p; register int *conflres;)
if ((q->t_flags & PERSISTENT) && if ((q->t_flags & PERSISTENT) &&
kind == FIXED) { kind == FIXED) {
error(linecount, error(linecount,
"Illegal %%persistent"); "Illegal %%persistent", NULL, NULL);
} }
*/ */
} }
@ -440,8 +439,7 @@ simpleproduction(p_gram *p; register int *conflres;)
; ;
{ {
STATIC STATIC void mkterm(p_gram prod, int flags, int lc, p_gram result) {
mkterm(prod,flags,lc,result) p_gram prod; register p_gram result; {
/* /*
* Create a term, initialise it and return * Create a term, initialise it and return
* a grammar element containing it * a grammar element containing it
@ -497,7 +495,7 @@ elem (register p_gram pres;)
if (erroneous) { if (erroneous) {
if (g_gettype(pres) != TERMINAL){ if (g_gettype(pres) != TERMINAL){
warning(linecount, warning(linecount,
"Erroneous only allowed on terminal"); "Erroneous only allowed on terminal", NULL, NULL);
erroneous = 0; erroneous = 0;
} }
else else
@ -507,11 +505,11 @@ elem (register p_gram pres;)
} }
[ C_PARAMS { if (lextoken.t_num > 15) { [ C_PARAMS { if (lextoken.t_num > 15) {
error(linecount,"Too many parameters"); error(linecount,"Too many parameters", NULL, NULL);
} else g_setnpar(pres,lextoken.t_num); } else g_setnpar(pres,lextoken.t_num);
if (g_gettype(pres) == TERMINAL) { if (g_gettype(pres) == TERMINAL) {
error(linecount, error(linecount,
"Terminal with parameters"); "Terminal with parameters", NULL, NULL);
} }
} }
]? ]?
@ -565,7 +563,7 @@ elem (register p_gram pres;)
ff = g_getsubparse(pres); ff = g_getsubparse(pres);
while (ff) { while (ff) {
if (ff->ff_nont == g_getcont(temp)) { if (ff->ff_nont == g_getcont(temp)) {
warning(linecount, "\"%s\" used twice in %%substart", lextoken.t_string); warning(linecount, "\"%s\" used twice in %%substart", lextoken.t_string, NULL);
break; break;
} }
ff = ff->ff_next; ff = ff->ff_next;
@ -607,7 +605,7 @@ number(int *t;)
: C_NUMBER : C_NUMBER
{ *t = lextoken.t_num; { *t = lextoken.t_num;
if (*t <= 0 || *t >= 8192) { if (*t <= 0 || *t >= 8192) {
error(linecount,"Illegal number"); error(linecount,"Illegal number", NULL, NULL);
} }
} }
; ;