/ Check-in [fdbb35c5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:In the LEMON-generated parser, avoid unnecessary tests for the acceptance state.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | lemon-improvements
Files: files | file ages | folders
SHA3-256: fdbb35c54f2b6cb65d04ac295f207ff3e69360e0558348c77eb5e62691807046
User & Date: drh 2017-12-25 00:10:05
Context
2017-12-25
04:15
Enhance LEMON so that it generates the action table in such a way that no range check is needed on the lookahead table to verify that the next input token is valid. This makes the lookahead table slightly larger (about 120 bytes) but helps the parser to run faster. check-in: 7eb0198d user: drh tags: lemon-improvements
00:10
In the LEMON-generated parser, avoid unnecessary tests for the acceptance state. check-in: fdbb35c5 user: drh tags: lemon-improvements
2017-12-24
23:38
In the LEMON-generated parser, rearrange the meanings of integer action codes so that reduce actions occur last. This means that the most common case (reduce actions) can be recognized with a single comparison operation, thus speeding up the main parser loop, slightly. check-in: 7bfe7a36 user: drh tags: lemon-improvements
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/lempar.c.

   468    468   static unsigned int yy_find_shift_action(
   469    469     yyParser *pParser,        /* The parser */
   470    470     YYCODETYPE iLookAhead     /* The look-ahead token */
   471    471   ){
   472    472     int i;
   473    473     int stateno = pParser->yytos->stateno;
   474    474    
   475         -  if( stateno>=YY_MIN_REDUCE ) return stateno;
          475  +  if( stateno>YY_MAX_SHIFT ) return stateno;
   476    476     assert( stateno <= YY_SHIFT_COUNT );
   477    477     do{
   478    478       i = yy_shift_ofst[stateno];
   479    479       assert( iLookAhead!=YYNOCODE );
   480    480       i += iLookAhead;
   481    481       if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
   482    482   #ifdef YYFALLBACK
................................................................................
   732    732     /* There are no SHIFTREDUCE actions on nonterminals because the table
   733    733     ** generator has simplified them to pure REDUCE actions. */
   734    734     assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );
   735    735   
   736    736     /* It is not possible for a REDUCE to be followed by an error */
   737    737     assert( yyact!=YY_ERROR_ACTION );
   738    738   
   739         -  if( yyact==YY_ACCEPT_ACTION ){
   740         -    yypParser->yytos += yysize;
   741         -    yy_accept(yypParser);
   742         -  }else{
   743         -    yymsp += yysize+1;
   744         -    yypParser->yytos = yymsp;
   745         -    yymsp->stateno = (YYACTIONTYPE)yyact;
   746         -    yymsp->major = (YYCODETYPE)yygoto;
   747         -    yyTraceShift(yypParser, yyact, "... then shift");
   748         -  }
          739  +  yymsp += yysize+1;
          740  +  yypParser->yytos = yymsp;
          741  +  yymsp->stateno = (YYACTIONTYPE)yyact;
          742  +  yymsp->major = (YYCODETYPE)yygoto;
          743  +  yyTraceShift(yypParser, yyact, "... then shift");
   749    744   }
   750    745   
   751    746   /*
   752    747   ** The following code executes when the parse fails
   753    748   */
   754    749   #ifndef YYNOERRORRECOVERY
   755    750   static void yy_parse_failed(
................................................................................
   872    867         yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,yyminor);
   873    868       }else if( yyact <= YY_MAX_SHIFTREDUCE ){
   874    869         yy_shift(yypParser,yyact,yymajor,yyminor);
   875    870   #ifndef YYNOERRORRECOVERY
   876    871         yypParser->yyerrcnt--;
   877    872   #endif
   878    873         yymajor = YYNOCODE;
          874  +    }else if( yyact==YY_ACCEPT_ACTION ){
          875  +      yypParser->yytos--;
          876  +      yy_accept(yypParser);
          877  +      return;
   879    878       }else{
   880    879         assert( yyact == YY_ERROR_ACTION );
   881    880         yyminorunion.yy0 = yyminor;
   882    881   #ifdef YYERRORSYMBOL
   883    882         int yymx;
   884    883   #endif
   885    884   #ifndef NDEBUG