From d3ec02d38e704f93edcbc162c614523b9fc6f7f0 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 12 Jun 2009 02:27:14 +0000 Subject: [PATCH] Modifications to the parser to eliminate unreachable code. (CVS 6749) FossilOrigin-Name: 457e0b245b1833c0d297bc6f4ff9785e6a2cee02 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/parse.y | 12 +++++++++--- tool/lempar.c | 14 ++++++++++++++ 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 8419bf4776..6bd0ad70f3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Honor\sthe\sSQLITE_OPEN_READONLY\sflag\seven\son\sa\s:memory:\sor\stemporary\sdatabase,\neven\sthough\ssuch\sa\sdatabase\sis\spointless.\s\sTicket\s#3908.\s(CVS\s6748) -D 2009-06-11T17:32:45 +C Modifications\sto\sthe\sparser\sto\seliminate\sunreachable\scode.\s(CVS\s6749) +D 2009-06-12T02:27:15 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 8b8fb7823264331210cddf103831816c286ba446 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -148,7 +148,7 @@ F src/os_unix.c e55d977c516ed880a2f83f0610b019efd9f8bc06 F src/os_win.c 725c38a524d168ce280446ad8761d731bc516405 F src/pager.c efdd56a49622fe87d5cf4b6e69aeb62b45bcb9b0 F src/pager.h 73f481a308a873ccd626d97331c081db3b53e2e5 -F src/parse.y 07690df997d50b3fdb5e5121e5a27f1a080db13d +F src/parse.y 5d6ab0304cdbe6f156e763adba9b95bac2800a10 F src/pcache.c 395f752a13574120bd7513a400ba02a265aaa76d F src/pcache.h 9b927ccc5a538e31b4c3bc7eec4f976db42a1324 F src/pcache1.c 97e7e8e6e34026fb43b47d08532b0c02e959c26c @@ -714,7 +714,7 @@ F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 405a43d54f1646bfaa7a84b03bb959aef62a3a49 F tool/lemon.c 1a94e70103e59f20df8f81539a453629df2aa523 -F tool/lempar.c aeba88b8566ff66f8a67c96b3eb2dd95e7d8908d +F tool/lempar.c d2fbe360eb398075947ba6de9197f99247d3d5a8 F tool/mkkeywordhash.c 511a848b2ac7a3d93f36adc1e1086b4c5741224b F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 @@ -733,7 +733,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746 -P 1fdb3e1e9af0672072f133dde06594fea2ef13c5 -R 823b08d915257a93dc411921f9d74d82 +P 73ba841ac1ed39fb09b3917bafe0ce349e88eb04 +R 75fd71147dd2bc566349956acaaf3bc9 U drh -Z ad0e99c3cc9d6218240a0d7748e56426 +Z c4d949dc1090f86c65a60e0c95668a95 diff --git a/manifest.uuid b/manifest.uuid index 8edfb50ab6..2447cc1304 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -73ba841ac1ed39fb09b3917bafe0ce349e88eb04 \ No newline at end of file +457e0b245b1833c0d297bc6f4ff9785e6a2cee02 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index d30f89f269..9401e13cd4 100644 --- a/src/parse.y +++ b/src/parse.y @@ -14,7 +14,7 @@ ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** -** @(#) $Id: parse.y,v 1.278 2009/05/28 01:00:55 drh Exp $ +** @(#) $Id: parse.y,v 1.279 2009/06/12 02:27:15 drh Exp $ */ // All token codes are small integers with #defines that begin with "TK_" @@ -53,6 +53,12 @@ %include { #include "sqliteInt.h" +/* +** Disable all error recovery processing in the parser push-down +** automaton. +*/ +#define YYNOERRORRECOVERY 1 + /* ** An instance of this structure holds information about the ** LIMIT clause of a SELECT statement. @@ -479,7 +485,7 @@ from(A) ::= FROM seltablist(X). { // stl_prefix(A) ::= seltablist(X) joinop(Y). { A = X; - if( A && A->nSrc>0 ) A->a[A->nSrc-1].jointype = (u8)Y; + if( ALWAYS(A && A->nSrc>0) ) A->a[A->nSrc-1].jointype = (u8)Y; } stl_prefix(A) ::= . {A = 0;} seltablist(A) ::= stl_prefix(X) nm(Y) dbnm(D) as(Z) indexed_opt(I) on_opt(N) using_opt(U). { @@ -573,7 +579,7 @@ sortlist(A) ::= sortlist(X) COMMA sortitem(Y) sortorder(Z). { } sortlist(A) ::= sortitem(Y) sortorder(Z). { A = sqlite3ExprListAppend(pParse,0,Y); - if( A && A->a ) A->a[0].sortOrder = (u8)Z; + if( A && ALWAYS(A->a) ) A->a[0].sortOrder = (u8)Z; } sortitem(A) ::= expr(X). {A = X.pExpr;} diff --git a/tool/lempar.c b/tool/lempar.c index 8ca1e3b9eb..4ab90c2479 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -608,6 +608,7 @@ static void yy_reduce( /* ** The following code executes when the parse fails */ +#ifndef YYNOERRORRECOVERY static void yy_parse_failed( yyParser *yypParser /* The parser */ ){ @@ -623,6 +624,7 @@ static void yy_parse_failed( %% ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } +#endif /* YYNOERRORRECOVERY */ /* ** The following code executes when a syntax error first occurs. @@ -790,6 +792,18 @@ void Parse( } yypParser->yyerrcnt = 3; yyerrorhit = 1; +#elif defined(YYNOERRORRECOVERY) + /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to + ** do any kind of error recovery. Instead, simply invoke the syntax + ** error routine and continue going as if nothing had happened. + ** + ** Applications can set this macro (for example inside %include) if + ** they intend to abandon the parse upon the first syntax error seen. + */ + yy_syntax_error(yypParser,yymajor,yyminorunion); + yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); + yymajor = YYNOCODE; + #else /* YYERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: **