adapted to allow for user intervention before error recovery
This commit is contained in:
parent
255884b3fb
commit
3f6a8abe1b
5 changed files with 22 additions and 7 deletions
|
@ -127,16 +127,23 @@ def { register string p; }
|
||||||
start = ff;
|
start = ff;
|
||||||
}
|
}
|
||||||
| C_LEXICAL C_IDENT
|
| C_LEXICAL C_IDENT
|
||||||
|
/*
|
||||||
|
* Declaration of a name for the lexical analyser.
|
||||||
|
* May appear only once
|
||||||
|
*/
|
||||||
{ if (!lexical) {
|
{ if (!lexical) {
|
||||||
lexical = store(lextoken.t_string);
|
lexical = store(lextoken.t_string);
|
||||||
}
|
}
|
||||||
else error(linecount,"Duplicate %%lexical");
|
else error(linecount,"Duplicate %%lexical");
|
||||||
}
|
}
|
||||||
';'
|
';'
|
||||||
/*
|
| C_ONERROR C_IDENT
|
||||||
* Declaration of a name for the lexical analyser.
|
{ if (! onerror) {
|
||||||
* May appear only once
|
onerror = store(lextoken.t_string);
|
||||||
*/
|
}
|
||||||
|
else error(linecount,"Duplicate %%onerror");
|
||||||
|
}
|
||||||
|
';'
|
||||||
| action(0) { acount++; }
|
| action(0) { acount++; }
|
||||||
/*
|
/*
|
||||||
* A global C-declaration
|
* A global C-declaration
|
||||||
|
|
|
@ -63,6 +63,7 @@ extern struct order *sorder, *porder;
|
||||||
extern string e_noopen; /* Error message string used often */
|
extern string e_noopen; /* Error message string used often */
|
||||||
extern int verbose; /* Level of verbosity */
|
extern int verbose; /* Level of verbosity */
|
||||||
extern string lexical; /* name of lexical analyser */
|
extern string lexical; /* name of lexical analyser */
|
||||||
|
extern string onerror; /* name of user error handler */
|
||||||
extern int ntneeded; /* ntneeded = 1 if nonterminals are included
|
extern int ntneeded; /* ntneeded = 1 if nonterminals are included
|
||||||
* in the sets.
|
* in the sets.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -168,12 +168,13 @@ genrecovery() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i = maxptr - setptr;
|
i = maxptr - setptr;
|
||||||
fprintf(fpars,
|
fprintf(f,
|
||||||
"#define LL_LEXI %s\n#define LL_SSIZE %d\n#define LL_NSETS %d\n#define LL_NTERMINALS %d\n",
|
"#define LL_LEXI %s\n#define LL_SSIZE %d\n#define LL_NSETS %d\n#define LL_NTERMINALS %d\n",
|
||||||
lexical,
|
lexical,
|
||||||
nbytes,
|
nbytes,
|
||||||
i > 0 ? i : 1,
|
i > 0 ? i : 1,
|
||||||
ntokens);
|
ntokens);
|
||||||
|
if (onerror) fprintf(f,"#define LL_USERHOOK %s\n", onerror);
|
||||||
/* Now generate the routines that call the startsymbols */
|
/* Now generate the routines that call the startsymbols */
|
||||||
for (st = start; st; st = st->ff_next) {
|
for (st = start; st; st = st->ff_next) {
|
||||||
fputs(st->ff_name, f);
|
fputs(st->ff_name, f);
|
||||||
|
@ -471,8 +472,11 @@ rulecode(p,safety,mustscan,mustpop) register p_gram p; {
|
||||||
genpop(findindex(n->n_contains));
|
genpop(findindex(n->n_contains));
|
||||||
}
|
}
|
||||||
if (g_gettype(n->n_rule) == EORULE &&
|
if (g_gettype(n->n_rule) == EORULE &&
|
||||||
safety == getntout(n) &&
|
safety <= getntout(n) &&
|
||||||
! g_getnpar(p)) break;
|
! g_getnpar(p)) {
|
||||||
|
safety = getntout(n);
|
||||||
|
break;
|
||||||
|
}
|
||||||
fprintf(f,"L%d_%s(\n",g_getnont(p), n->n_name);
|
fprintf(f,"L%d_%s(\n",g_getnont(p), n->n_name);
|
||||||
if (g_getnpar(p)) {
|
if (g_getnpar(p)) {
|
||||||
controlline();
|
controlline();
|
||||||
|
|
|
@ -58,6 +58,7 @@ string f_input;
|
||||||
string e_noopen = "Cannot open %s";
|
string e_noopen = "Cannot open %s";
|
||||||
int verbose;
|
int verbose;
|
||||||
string lexical;
|
string lexical;
|
||||||
|
string onerror;
|
||||||
int ntneeded;
|
int ntneeded;
|
||||||
int ntprint;
|
int ntprint;
|
||||||
# ifndef NDEBUG
|
# ifndef NDEBUG
|
||||||
|
|
|
@ -67,6 +67,7 @@ STATIC string vallookup();
|
||||||
%token C_PERSISTENT ;
|
%token C_PERSISTENT ;
|
||||||
%token C_FIRST ;
|
%token C_FIRST ;
|
||||||
%token C_LEXICAL ;
|
%token C_LEXICAL ;
|
||||||
|
%token C_ONERROR ;
|
||||||
%token C_AVOID ;
|
%token C_AVOID ;
|
||||||
%token C_PREFER ;
|
%token C_PREFER ;
|
||||||
%token C_DEFAULT ;
|
%token C_DEFAULT ;
|
||||||
|
@ -100,6 +101,7 @@ static t_keyw resword[] = {
|
||||||
{ "first", C_FIRST },
|
{ "first", C_FIRST },
|
||||||
{ "start", C_START },
|
{ "start", C_START },
|
||||||
{ "lexical", C_LEXICAL },
|
{ "lexical", C_LEXICAL },
|
||||||
|
{ "onerror", C_ONERROR },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue