Added %expect directive, to consider a certain number of conflicts "correct."
This has the side effect of changing the process exit code to never overflow. FossilOrigin-Name: d8bab8cf0bc3fbd4c489c31a65d724dda2944d83
This commit is contained in:
parent
3e143bdfaf
commit
42585cf73a
38
manifest
38
manifest
@ -1,8 +1,8 @@
|
||||
-----BEGIN PGP SIGNED MESSAGE-----
|
||||
Hash: SHA1
|
||||
|
||||
C Added\s-T\soption,\sto\sspecify\sa\stemplate\sfilename\son\sthe\scommand\sline.\n\nThe\sdefault\sis\sstill\s"lempar.c",\sthough.
|
||||
D 2010-02-14T00:48:50
|
||||
C Added\s%expect\sdirective,\sto\sconsider\sa\scertain\snumber\sof\sconflicts\s"correct."\n\nThis\shas\sthe\sside\seffect\sof\schanging\sthe\sprocess\sexit\scode\sto\snever\soverflow.
|
||||
D 2010-02-14T05:19:56
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -765,7 +765,7 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
|
||||
F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439
|
||||
F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
|
||||
F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5
|
||||
F tool/lemon.c bcaf8e9233f3c569db307294d7c0682c07422305
|
||||
F tool/lemon.c 415104859db0e4badd3571dee4a60582297ebaaa
|
||||
F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc
|
||||
F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309
|
||||
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
|
||||
@ -790,24 +790,24 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P 942aa1f6a91655356cc32a8185cb447331d405dc
|
||||
R a533a4c38e9fa99b703ef96e4f6dcf6f
|
||||
P e6cbe1e5ee80db282a41951b805b7bd8b13adf28
|
||||
R a52aa69eba0e0915125e4230ac657715
|
||||
U icculus
|
||||
Z e5b091d7de3bf79941ed07e5df421450
|
||||
Z f5a330aab159045deb825a581ad23995
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
|
||||
|
||||
iQIcBAEBAgAGBQJLd0h3AAoJEDDcKcGyC63VJCEP/iB6JkpWd89cJLhAX/5u6uSx
|
||||
0tpH3TQktFJROv4gKMphq9ifUALpFVc3rD9k8dMCFh/jRQEABPRBb3cOTWv9Bx6y
|
||||
kziDeZGjEir/jTH0PzjG4Utxgceey2t4GtP9m/dnolGaJ7Mhjh6GKVYLKNG9+lrx
|
||||
FwH6fWz1y8RYVXUPSvTqMpx56dQKBdSlB8NuRAmPx5tuimI/gqnsOuVBW9Y7myjs
|
||||
PnI+SShYElRpDcbwjv/iAjKXQfEqGKmHutcsfSMoY4nNbiaa0AnMfl1Woxd5bEWP
|
||||
rj8zyUSNZLCa8cOWzhX2m+4kUZx/LLqlNqtRwb1Rw1YZWQbrtW1Oer4diI9zwl+/
|
||||
MNbAjVDlBuqpjs18QKAW2NIrGUzFTpvX674iYLuGTCc0iMLdXXAjrxFHhn2aw5kE
|
||||
rEcBaEG6jgdEu+eXaugEacujQEkYHMJoBYZE3zzM57vUIgU7qHYF74rGtM8GdDwv
|
||||
WBh5SKlKc3d5RXZ8csKaq1ly/NXAy20uNCPL8KjKm4H/oRn0saFPy0XeQLwpnW9o
|
||||
TBrco11gQWgKnvy/DgqdfVWvPC8E07XHw9Hc1rKarHKpr+Al8N9PyyPFoiztHn0r
|
||||
5U6A8jFYtfl/nrvCyEgSU3PWIhwSwkyEJYZp8HHWg2wvmwYbUQF4ZaEJ7nxV0Osw
|
||||
B+8d/ZJRPLRYPt2rsGo+
|
||||
=hP7c
|
||||
iQIcBAEBAgAGBQJLd4gDAAoJEDDcKcGyC63VQkkQAJmHE1TfQc5uu5XhBLZ+kexv
|
||||
dZ1QOkvx9yV2mX+2GG1QZgQpUaYaBIaP7rRtFuIZN+I8sqkcFxjG9SARWEYArtJj
|
||||
udPUnNn6CVmsp7isbBZYBDw2UhsH0B00uOQvxCdEDT36MUjtkxjiM2T1M8lp+aAH
|
||||
jmxilkTSVojq6WJE1/oTVNcMSJnNaEI7fi0GvmBzaxOGalxis8miiBwpVv/3CY39
|
||||
chkrTITynbJtwGMoUikNLlVYfuXAfTDBAQYAZT5b50QAYfA/S5l9g+C3KMY9ffNa
|
||||
XZwBZu9DCBtdv57D8koUoCYcA0bUr9dyT6GrTgJORq5ePqtoXU2rLB3F1ckkuN2a
|
||||
hkScfFj8TjYsik1Oou8GvN5CtUihq1ekCUFyh/M+vLHFbLVge+zgUNO57s3mK7e7
|
||||
D+2y9HcY2txBptzjMkNuZgV4DzIqAhjHIK9JmbR/oO2w+NAiYw3wfBiMOEq5kDKT
|
||||
X1u2kOEKFaJhOaGIYnCIjHH3yc9bqzHPIyrwpBoyjtqZnsQbnZZP7hZ2hmjKVXoT
|
||||
O0EQmNsxQw4z6/EFx2/OPr1IhIKON7rwIl2mb1hWczA1GDroNVi+zRDkabMCAWik
|
||||
Fwxwnf4IJsAgd4v8JQi22h+EudRP9s/O24MModCsahBX1xkQKoL3poXEQyYAE0Ki
|
||||
Fg8EO6hKudpsXjb09VvE
|
||||
=XLI+
|
||||
-----END PGP SIGNATURE-----
|
||||
|
@ -1 +1 @@
|
||||
e6cbe1e5ee80db282a41951b805b7bd8b13adf28
|
||||
d8bab8cf0bc3fbd4c489c31a65d724dda2944d83
|
40
tool/lemon.c
40
tool/lemon.c
@ -268,6 +268,7 @@ struct lemon {
|
||||
char *outname; /* Name of the current output file */
|
||||
char *tokenprefix; /* A prefix added to token names in the .h file */
|
||||
int nconflict; /* Number of parsing conflicts */
|
||||
int nexpected; /* Number of expected parsing conflicts */
|
||||
int tablesize; /* Size of the parse tables */
|
||||
int basisflag; /* Print only basis configurations */
|
||||
int has_fallback; /* True if any %fallback is seen in the grammar */
|
||||
@ -1466,6 +1467,7 @@ char **argv;
|
||||
{OPT_FLAG,0,0,0}
|
||||
};
|
||||
int i;
|
||||
int exitcode;
|
||||
struct lemon lem;
|
||||
|
||||
OptInit(argv,options,stderr);
|
||||
@ -1479,6 +1481,7 @@ char **argv;
|
||||
}
|
||||
memset(&lem, 0, sizeof(lem));
|
||||
lem.errorcnt = 0;
|
||||
lem.nexpected = -1;
|
||||
|
||||
/* Initialize the machine */
|
||||
Strsafe_init();
|
||||
@ -1564,11 +1567,17 @@ char **argv;
|
||||
printf(" %d states, %d parser table entries, %d conflicts\n",
|
||||
lem.nstate, lem.tablesize, lem.nconflict);
|
||||
}
|
||||
if( lem.nconflict ){
|
||||
fprintf(stderr,"%d parsing conflicts.\n",lem.nconflict);
|
||||
if( lem.nexpected < 0 ) {
|
||||
lem.nexpected = 0; /* grammar didn't have an %expect declaration. */
|
||||
}
|
||||
exit(lem.errorcnt + lem.nconflict);
|
||||
return (lem.errorcnt + lem.nconflict);
|
||||
if( lem.nconflict != lem.nexpected ){
|
||||
fprintf(stderr,"%d parsing conflicts (%d expected).\n",lem.nconflict,lem.nexpected);
|
||||
}
|
||||
|
||||
/* return 0 on success, 1 on failure. */
|
||||
exitcode = ((lem.errorcnt > 0) || (lem.nconflict != lem.nexpected)) ? 1 : 0;
|
||||
exit(exitcode);
|
||||
return (exitcode);
|
||||
}
|
||||
/******************** From the file "msort.c" *******************************/
|
||||
/*
|
||||
@ -2010,6 +2019,7 @@ struct pstate {
|
||||
WAITING_FOR_DESTRUCTOR_SYMBOL,
|
||||
WAITING_FOR_DATATYPE_SYMBOL,
|
||||
WAITING_FOR_FALLBACK_ID,
|
||||
WAITING_FOR_EXPECT_VALUE,
|
||||
WAITING_FOR_WILDCARD_ID
|
||||
} state; /* The state of the parser */
|
||||
struct symbol *fallback; /* The fallback token */
|
||||
@ -2033,6 +2043,7 @@ struct pstate {
|
||||
static void parseonetoken(psp)
|
||||
struct pstate *psp;
|
||||
{
|
||||
char *endptr;
|
||||
char *x;
|
||||
x = Strsafe(psp->tokenstart); /* Save the token permanently */
|
||||
#if 0
|
||||
@ -2317,6 +2328,14 @@ to follow the previous rule.");
|
||||
psp->state = WAITING_FOR_FALLBACK_ID;
|
||||
}else if( strcmp(x,"wildcard")==0 ){
|
||||
psp->state = WAITING_FOR_WILDCARD_ID;
|
||||
}else if( strcmp(x,"expect")==0 ){
|
||||
if (psp->gp->nexpected >= 0) {
|
||||
ErrorMsg(psp->filename,psp->tokenlineno, "Multiple %expect declarations.");
|
||||
psp->errorcnt++;
|
||||
psp->state = RESYNC_AFTER_DECL_ERROR;
|
||||
} else {
|
||||
psp->state = WAITING_FOR_EXPECT_VALUE;
|
||||
}
|
||||
}else{
|
||||
ErrorMsg(psp->filename,psp->tokenlineno,
|
||||
"Unknown declaration keyword: \"%%%s\".",x);
|
||||
@ -2344,6 +2363,19 @@ to follow the previous rule.");
|
||||
psp->state = WAITING_FOR_DECL_ARG;
|
||||
}
|
||||
break;
|
||||
case WAITING_FOR_EXPECT_VALUE:
|
||||
psp->gp->nexpected = (int) strtol(x, &endptr, 10);
|
||||
if( (*endptr != '\0') || (endptr == x) ) {
|
||||
ErrorMsg(psp->filename,psp->tokenlineno,
|
||||
"Integer expected after %%expect keyword");
|
||||
psp->errorcnt++;
|
||||
} else if (psp->gp->nexpected < 0) {
|
||||
ErrorMsg(psp->filename,psp->tokenlineno,
|
||||
"Integer can't be negative after %%expect keyword");
|
||||
psp->errorcnt++;
|
||||
}
|
||||
psp->state = WAITING_FOR_DECL_OR_RULE;
|
||||
break;
|
||||
case WAITING_FOR_DATATYPE_SYMBOL:
|
||||
if( !isalpha(x[0]) ){
|
||||
ErrorMsg(psp->filename,psp->tokenlineno,
|
||||
|
Loading…
Reference in New Issue
Block a user