| OLD | NEW | 
|    1 /* Driver template for the LEMON parser generator. |    1 /* Driver template for the LEMON parser generator. | 
|    2 ** The author disclaims copyright to this source code. |    2 ** The author disclaims copyright to this source code. | 
|    3 */ |    3 */ | 
|    4 /* First off, code is included that follows the "include" declaration |    4 /* First off, code is included that follows the "include" declaration | 
|    5 ** in the input grammar file. */ |    5 ** in the input grammar file. */ | 
|    6 #include <stdio.h> |    6 #include <stdio.h> | 
|    7 %% |    7 %% | 
|    8 /* Next is all token values, in a form suitable for use by makeheaders. |    8 /* Next is all token values, in a form suitable for use by makeheaders. | 
|    9 ** This section will be null unless lemon is run with the -m switch. |    9 ** This section will be null unless lemon is run with the -m switch. | 
|   10 */ |   10 */ | 
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  118 **  yy_action[]        A single table containing all actions. |  118 **  yy_action[]        A single table containing all actions. | 
|  119 **  yy_lookahead[]     A table containing the lookahead for each entry in |  119 **  yy_lookahead[]     A table containing the lookahead for each entry in | 
|  120 **                     yy_action.  Used to detect hash collisions. |  120 **                     yy_action.  Used to detect hash collisions. | 
|  121 **  yy_shift_ofst[]    For each state, the offset into yy_action for |  121 **  yy_shift_ofst[]    For each state, the offset into yy_action for | 
|  122 **                     shifting terminals. |  122 **                     shifting terminals. | 
|  123 **  yy_reduce_ofst[]   For each state, the offset into yy_action for |  123 **  yy_reduce_ofst[]   For each state, the offset into yy_action for | 
|  124 **                     shifting non-terminals after a reduce. |  124 **                     shifting non-terminals after a reduce. | 
|  125 **  yy_default[]       Default action for each state. |  125 **  yy_default[]       Default action for each state. | 
|  126 */ |  126 */ | 
|  127 %% |  127 %% | 
|  128 #define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0])) |  | 
|  129  |  128  | 
|  130 /* The next table maps tokens into fallback tokens.  If a construct |  129 /* The next table maps tokens into fallback tokens.  If a construct | 
|  131 ** like the following: |  130 ** like the following: | 
|  132 **  |  131 **  | 
|  133 **      %fallback ID X Y Z. |  132 **      %fallback ID X Y Z. | 
|  134 ** |  133 ** | 
|  135 ** appears in the grammar, then ID becomes a fallback token for X, Y, |  134 ** appears in the grammar, then ID becomes a fallback token for X, Y, | 
|  136 ** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser |  135 ** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser | 
|  137 ** but it does not parse, the type of the token is changed to ID and |  136 ** but it does not parse, the type of the token is changed to ID and | 
|  138 ** the parse is retried before an error is thrown. |  137 ** the parse is retried before an error is thrown. | 
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  379 ** independent of the look-ahead.  If it is, return the action, otherwise |  378 ** independent of the look-ahead.  If it is, return the action, otherwise | 
|  380 ** return YY_NO_ACTION. |  379 ** return YY_NO_ACTION. | 
|  381 */ |  380 */ | 
|  382 static int yy_find_shift_action( |  381 static int yy_find_shift_action( | 
|  383   yyParser *pParser,        /* The parser */ |  382   yyParser *pParser,        /* The parser */ | 
|  384   YYCODETYPE iLookAhead     /* The look-ahead token */ |  383   YYCODETYPE iLookAhead     /* The look-ahead token */ | 
|  385 ){ |  384 ){ | 
|  386   int i; |  385   int i; | 
|  387   int stateno = pParser->yystack[pParser->yyidx].stateno; |  386   int stateno = pParser->yystack[pParser->yyidx].stateno; | 
|  388   |  387   | 
|  389   if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){ |  388   if( stateno>YY_SHIFT_COUNT | 
 |  389    || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){ | 
|  390     return yy_default[stateno]; |  390     return yy_default[stateno]; | 
|  391   } |  391   } | 
|  392   assert( iLookAhead!=YYNOCODE ); |  392   assert( iLookAhead!=YYNOCODE ); | 
|  393   i += iLookAhead; |  393   i += iLookAhead; | 
|  394   if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ |  394   if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ | 
|  395     if( iLookAhead>0 ){ |  395     if( iLookAhead>0 ){ | 
|  396 #ifdef YYFALLBACK |  396 #ifdef YYFALLBACK | 
|  397       YYCODETYPE iFallback;            /* Fallback token */ |  397       YYCODETYPE iFallback;            /* Fallback token */ | 
|  398       if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) |  398       if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) | 
|  399              && (iFallback = yyFallback[iLookAhead])!=0 ){ |  399              && (iFallback = yyFallback[iLookAhead])!=0 ){ | 
|  400 #ifndef NDEBUG |  400 #ifndef NDEBUG | 
|  401         if( yyTraceFILE ){ |  401         if( yyTraceFILE ){ | 
|  402           fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", |  402           fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", | 
|  403              yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); |  403              yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); | 
|  404         } |  404         } | 
|  405 #endif |  405 #endif | 
|  406         return yy_find_shift_action(pParser, iFallback); |  406         return yy_find_shift_action(pParser, iFallback); | 
|  407       } |  407       } | 
|  408 #endif |  408 #endif | 
|  409 #ifdef YYWILDCARD |  409 #ifdef YYWILDCARD | 
|  410       { |  410       { | 
|  411         int j = i - iLookAhead + YYWILDCARD; |  411         int j = i - iLookAhead + YYWILDCARD; | 
|  412         if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){ |  412         if(  | 
 |  413 #if YY_SHIFT_MIN+YYWILDCARD<0 | 
 |  414           j>=0 && | 
 |  415 #endif | 
 |  416 #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT | 
 |  417           j<YY_ACTTAB_COUNT && | 
 |  418 #endif | 
 |  419           yy_lookahead[j]==YYWILDCARD | 
 |  420         ){ | 
|  413 #ifndef NDEBUG |  421 #ifndef NDEBUG | 
|  414           if( yyTraceFILE ){ |  422           if( yyTraceFILE ){ | 
|  415             fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", |  423             fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", | 
|  416                yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); |  424                yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); | 
|  417           } |  425           } | 
|  418 #endif /* NDEBUG */ |  426 #endif /* NDEBUG */ | 
|  419           return yy_action[j]; |  427           return yy_action[j]; | 
|  420         } |  428         } | 
|  421       } |  429       } | 
|  422 #endif /* YYWILDCARD */ |  430 #endif /* YYWILDCARD */ | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|  434 ** If the look-ahead token is YYNOCODE, then check to see if the action is |  442 ** If the look-ahead token is YYNOCODE, then check to see if the action is | 
|  435 ** independent of the look-ahead.  If it is, return the action, otherwise |  443 ** independent of the look-ahead.  If it is, return the action, otherwise | 
|  436 ** return YY_NO_ACTION. |  444 ** return YY_NO_ACTION. | 
|  437 */ |  445 */ | 
|  438 static int yy_find_reduce_action( |  446 static int yy_find_reduce_action( | 
|  439   int stateno,              /* Current state number */ |  447   int stateno,              /* Current state number */ | 
|  440   YYCODETYPE iLookAhead     /* The look-ahead token */ |  448   YYCODETYPE iLookAhead     /* The look-ahead token */ | 
|  441 ){ |  449 ){ | 
|  442   int i; |  450   int i; | 
|  443 #ifdef YYERRORSYMBOL |  451 #ifdef YYERRORSYMBOL | 
|  444   if( stateno>YY_REDUCE_MAX ){ |  452   if( stateno>YY_REDUCE_COUNT ){ | 
|  445     return yy_default[stateno]; |  453     return yy_default[stateno]; | 
|  446   } |  454   } | 
|  447 #else |  455 #else | 
|  448   assert( stateno<=YY_REDUCE_MAX ); |  456   assert( stateno<=YY_REDUCE_COUNT ); | 
|  449 #endif |  457 #endif | 
|  450   i = yy_reduce_ofst[stateno]; |  458   i = yy_reduce_ofst[stateno]; | 
|  451   assert( i!=YY_REDUCE_USE_DFLT ); |  459   assert( i!=YY_REDUCE_USE_DFLT ); | 
|  452   assert( iLookAhead!=YYNOCODE ); |  460   assert( iLookAhead!=YYNOCODE ); | 
|  453   i += iLookAhead; |  461   i += iLookAhead; | 
|  454 #ifdef YYERRORSYMBOL |  462 #ifdef YYERRORSYMBOL | 
|  455   if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ |  463   if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ | 
|  456     return yy_default[stateno]; |  464     return yy_default[stateno]; | 
|  457   } |  465   } | 
|  458 #else |  466 #else | 
|  459   assert( i>=0 && i<YY_SZ_ACTTAB ); |  467   assert( i>=0 && i<YY_ACTTAB_COUNT ); | 
|  460   assert( yy_lookahead[i]==iLookAhead ); |  468   assert( yy_lookahead[i]==iLookAhead ); | 
|  461 #endif |  469 #endif | 
|  462   return yy_action[i]; |  470   return yy_action[i]; | 
|  463 } |  471 } | 
|  464  |  472  | 
|  465 /* |  473 /* | 
|  466 ** The following routine is called if the stack overflows. |  474 ** The following routine is called if the stack overflows. | 
|  467 */ |  475 */ | 
|  468 static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){ |  476 static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){ | 
|  469    ParseARG_FETCH; |  477    ParseARG_FETCH; | 
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  833       yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |  841       yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); | 
|  834       if( yyendofinput ){ |  842       if( yyendofinput ){ | 
|  835         yy_parse_failed(yypParser); |  843         yy_parse_failed(yypParser); | 
|  836       } |  844       } | 
|  837       yymajor = YYNOCODE; |  845       yymajor = YYNOCODE; | 
|  838 #endif |  846 #endif | 
|  839     } |  847     } | 
|  840   }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); |  848   }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); | 
|  841   return; |  849   return; | 
|  842 } |  850 } | 
| OLD | NEW |