| 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 ** This version of "lempar.c" is modified, slightly, for use by SQLite. | 4 ** This version of "lempar.c" is modified, slightly, for use by SQLite. |
| 5 ** The only modifications are the addition of a couple of NEVER() | 5 ** The only modifications are the addition of a couple of NEVER() |
| 6 ** macros to disable tests that are needed in the case of a general | 6 ** macros to disable tests that are needed in the case of a general |
| 7 ** LALR(1) grammar but which are always false in the | 7 ** LALR(1) grammar but which are always false in the |
| 8 ** specific grammar used by SQLite. | 8 ** specific grammar used by SQLite. |
| 9 */ | 9 */ |
| 10 /* First off, code is included that follows the "include" declaration | 10 /* First off, code is included that follows the "include" declaration |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 ** The only argument is a pointer to a function which works like | 264 ** The only argument is a pointer to a function which works like |
| 265 ** malloc. | 265 ** malloc. |
| 266 ** | 266 ** |
| 267 ** Inputs: | 267 ** Inputs: |
| 268 ** A pointer to the function used to allocate memory. | 268 ** A pointer to the function used to allocate memory. |
| 269 ** | 269 ** |
| 270 ** Outputs: | 270 ** Outputs: |
| 271 ** A pointer to a parser. This pointer is used in subsequent calls | 271 ** A pointer to a parser. This pointer is used in subsequent calls |
| 272 ** to Parse and ParseFree. | 272 ** to Parse and ParseFree. |
| 273 */ | 273 */ |
| 274 void *ParseAlloc(void *(*mallocProc)(size_t)){ | 274 void *ParseAlloc(void *(*mallocProc)(u64)){ |
| 275 yyParser *pParser; | 275 yyParser *pParser; |
| 276 pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); | 276 pParser = (yyParser*)(*mallocProc)( (u64)sizeof(yyParser) ); |
| 277 if( pParser ){ | 277 if( pParser ){ |
| 278 pParser->yyidx = -1; | 278 pParser->yyidx = -1; |
| 279 #ifdef YYTRACKMAXSTACKDEPTH | 279 #ifdef YYTRACKMAXSTACKDEPTH |
| 280 pParser->yyidxMax = 0; | 280 pParser->yyidxMax = 0; |
| 281 #endif | 281 #endif |
| 282 #if YYSTACKDEPTH<=0 | 282 #if YYSTACKDEPTH<=0 |
| 283 pParser->yystack = NULL; | 283 pParser->yystack = NULL; |
| 284 pParser->yystksz = 0; | 284 pParser->yystksz = 0; |
| 285 yyGrowStack(pParser); | 285 yyGrowStack(pParser); |
| 286 #endif | 286 #endif |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 /* Beginning here are the reduction cases. A typical example | 601 /* Beginning here are the reduction cases. A typical example |
| 602 ** follows: | 602 ** follows: |
| 603 ** case 0: | 603 ** case 0: |
| 604 ** #line <lineno> <grammarfile> | 604 ** #line <lineno> <grammarfile> |
| 605 ** { ... } // User supplied code | 605 ** { ... } // User supplied code |
| 606 ** #line <lineno> <thisfile> | 606 ** #line <lineno> <thisfile> |
| 607 ** break; | 607 ** break; |
| 608 */ | 608 */ |
| 609 %% | 609 %% |
| 610 }; | 610 }; |
| 611 assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) ); |
| 611 yygoto = yyRuleInfo[yyruleno].lhs; | 612 yygoto = yyRuleInfo[yyruleno].lhs; |
| 612 yysize = yyRuleInfo[yyruleno].nrhs; | 613 yysize = yyRuleInfo[yyruleno].nrhs; |
| 613 yypParser->yyidx -= yysize; | 614 yypParser->yyidx -= yysize; |
| 614 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); | 615 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); |
| 615 if( yyact < YYNSTATE ){ | 616 if( yyact < YYNSTATE ){ |
| 616 #ifdef NDEBUG | 617 #ifdef NDEBUG |
| 617 /* If we are not debugging and the reduce action popped at least | 618 /* If we are not debugging and the reduce action popped at least |
| 618 ** one element off the stack, then we can push the new element back | 619 ** one element off the stack, then we can push the new element back |
| 619 ** onto the stack here, and skip the stack overflow test in yy_shift(). | 620 ** onto the stack here, and skip the stack overflow test in yy_shift(). |
| 620 ** That gives a significant speed improvement. */ | 621 ** That gives a significant speed improvement. */ |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 ** None. | 710 ** None. |
| 710 */ | 711 */ |
| 711 void Parse( | 712 void Parse( |
| 712 void *yyp, /* The parser */ | 713 void *yyp, /* The parser */ |
| 713 int yymajor, /* The major token code number */ | 714 int yymajor, /* The major token code number */ |
| 714 ParseTOKENTYPE yyminor /* The value for the token */ | 715 ParseTOKENTYPE yyminor /* The value for the token */ |
| 715 ParseARG_PDECL /* Optional %extra_argument parameter */ | 716 ParseARG_PDECL /* Optional %extra_argument parameter */ |
| 716 ){ | 717 ){ |
| 717 YYMINORTYPE yyminorunion; | 718 YYMINORTYPE yyminorunion; |
| 718 int yyact; /* The parser action. */ | 719 int yyact; /* The parser action. */ |
| 720 #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) |
| 719 int yyendofinput; /* True if we are at the end of input */ | 721 int yyendofinput; /* True if we are at the end of input */ |
| 722 #endif |
| 720 #ifdef YYERRORSYMBOL | 723 #ifdef YYERRORSYMBOL |
| 721 int yyerrorhit = 0; /* True if yymajor has invoked an error */ | 724 int yyerrorhit = 0; /* True if yymajor has invoked an error */ |
| 722 #endif | 725 #endif |
| 723 yyParser *yypParser; /* The parser */ | 726 yyParser *yypParser; /* The parser */ |
| 724 | 727 |
| 725 /* (re)initialize the parser, if necessary */ | 728 /* (re)initialize the parser, if necessary */ |
| 726 yypParser = (yyParser*)yyp; | 729 yypParser = (yyParser*)yyp; |
| 727 if( yypParser->yyidx<0 ){ | 730 if( yypParser->yyidx<0 ){ |
| 728 #if YYSTACKDEPTH<=0 | 731 #if YYSTACKDEPTH<=0 |
| 729 if( yypParser->yystksz <=0 ){ | 732 if( yypParser->yystksz <=0 ){ |
| 730 /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/ | 733 /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/ |
| 731 yyminorunion = yyzerominor; | 734 yyminorunion = yyzerominor; |
| 732 yyStackOverflow(yypParser, &yyminorunion); | 735 yyStackOverflow(yypParser, &yyminorunion); |
| 733 return; | 736 return; |
| 734 } | 737 } |
| 735 #endif | 738 #endif |
| 736 yypParser->yyidx = 0; | 739 yypParser->yyidx = 0; |
| 737 yypParser->yyerrcnt = -1; | 740 yypParser->yyerrcnt = -1; |
| 738 yypParser->yystack[0].stateno = 0; | 741 yypParser->yystack[0].stateno = 0; |
| 739 yypParser->yystack[0].major = 0; | 742 yypParser->yystack[0].major = 0; |
| 740 } | 743 } |
| 741 yyminorunion.yy0 = yyminor; | 744 yyminorunion.yy0 = yyminor; |
| 745 #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) |
| 742 yyendofinput = (yymajor==0); | 746 yyendofinput = (yymajor==0); |
| 747 #endif |
| 743 ParseARG_STORE; | 748 ParseARG_STORE; |
| 744 | 749 |
| 745 #ifndef NDEBUG | 750 #ifndef NDEBUG |
| 746 if( yyTraceFILE ){ | 751 if( yyTraceFILE ){ |
| 747 fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); | 752 fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); |
| 748 } | 753 } |
| 749 #endif | 754 #endif |
| 750 | 755 |
| 751 do{ | 756 do{ |
| 752 yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); | 757 yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); |
| 753 if( yyact<YYNSTATE ){ | 758 if( yyact<YYNSTATE ){ |
| 754 assert( !yyendofinput ); /* Impossible to shift the $ token */ | |
| 755 yy_shift(yypParser,yyact,yymajor,&yyminorunion); | 759 yy_shift(yypParser,yyact,yymajor,&yyminorunion); |
| 756 yypParser->yyerrcnt--; | 760 yypParser->yyerrcnt--; |
| 757 yymajor = YYNOCODE; | 761 yymajor = YYNOCODE; |
| 758 }else if( yyact < YYNSTATE + YYNRULE ){ | 762 }else if( yyact < YYNSTATE + YYNRULE ){ |
| 759 yy_reduce(yypParser,yyact-YYNSTATE); | 763 yy_reduce(yypParser,yyact-YYNSTATE); |
| 760 }else{ | 764 }else{ |
| 761 assert( yyact == YY_ERROR_ACTION ); | 765 assert( yyact == YY_ERROR_ACTION ); |
| 762 #ifdef YYERRORSYMBOL | 766 #ifdef YYERRORSYMBOL |
| 763 int yymx; | 767 int yymx; |
| 764 #endif | 768 #endif |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); | 855 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
| 852 if( yyendofinput ){ | 856 if( yyendofinput ){ |
| 853 yy_parse_failed(yypParser); | 857 yy_parse_failed(yypParser); |
| 854 } | 858 } |
| 855 yymajor = YYNOCODE; | 859 yymajor = YYNOCODE; |
| 856 #endif | 860 #endif |
| 857 } | 861 } |
| 858 }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); | 862 }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); |
| 859 return; | 863 return; |
| 860 } | 864 } |
| OLD | NEW |