/* ** Perform a shift action. */ static void yy_shift( yyParser *yypParser, /* The parser to be shifted */ int yyNewState, /* The new state to shift in */ int yyMajor, /* The major token to shift in */ sqlite3Fts5ParserTOKENTYPE yyMinor /* The minor token to shift in */ ){ yyStackEntry *yytos; yypParser->yyidx++; #ifdef YYTRACKMAXSTACKDEPTH if( yypParser->yyidx>yypParser->yyidxMax ){ yypParser->yyidxMax = yypParser->yyidx; } #endif #if YYSTACKDEPTH>0 if( yypParser->yyidx>=YYSTACKDEPTH ){ yyStackOverflow(yypParser); return; } #else if( yypParser->yyidx>=yypParser->yystksz ){ yyGrowStack(yypParser); if( yypParser->yyidx>=yypParser->yystksz ){ yyStackOverflow(yypParser); return; } } #endif yytos = &yypParser->yystack[yypParser->yyidx]; yytos->stateno = (YYACTIONTYPE)yyNewState; yytos->major = (YYCODETYPE)yyMajor; yytos->minor.yy0 = yyMinor; yyTraceShift(yypParser, yyNewState); }
/* ** Perform a reduce action and the shift that must immediately ** follow the reduce. */ static void yy_reduce( yyParser *yypParser, /* The parser */ int yyruleno /* Number of the rule by which to reduce */ ){ int yygoto; /* The next state */ int yyact; /* The next action */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ sqlite3Fts5ParserARG_FETCH; yymsp = &yypParser->yystack[yypParser->yyidx]; #ifndef NDEBUG if( yyTraceFILE && yyruleno>=0 && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ yysize = yyRuleInfo[yyruleno].nrhs; fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt, yyRuleName[yyruleno], yymsp[-yysize].stateno); } #endif /* NDEBUG */ /* Check that the stack is large enough to grow by a single entry ** if the RHS of the rule is empty. This ensures that there is room ** enough on the stack to push the LHS value */ if( yyRuleInfo[yyruleno].nrhs==0 ){ #ifdef YYTRACKMAXSTACKDEPTH if( yypParser->yyidx>yypParser->yyidxMax ){ yypParser->yyidxMax = yypParser->yyidx; } #endif #if YYSTACKDEPTH>0 if( yypParser->yyidx>=YYSTACKDEPTH-1 ){ yyStackOverflow(yypParser); return; } #else if( yypParser->yyidx>=yypParser->yystksz-1 ){ yyGrowStack(yypParser); if( yypParser->yyidx>=yypParser->yystksz-1 ){ yyStackOverflow(yypParser); return; } } #endif } switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** #line <lineno> <grammarfile> ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* input ::= expr */ #line 82 "fts5parse.y" { sqlite3Fts5ParseFinished(pParse, yymsp[0].minor.yy18); } #line 856 "fts5parse.c" break; case 1: /* expr ::= expr AND expr */ #line 92 "fts5parse.y" { yylhsminor.yy18 = sqlite3Fts5ParseNode(pParse, FTS5_AND, yymsp[-2].minor.yy18, yymsp[0].minor.yy18, 0); } #line 863 "fts5parse.c" yymsp[-2].minor.yy18 = yylhsminor.yy18; break; case 2: /* expr ::= expr OR expr */ #line 95 "fts5parse.y" { yylhsminor.yy18 = sqlite3Fts5ParseNode(pParse, FTS5_OR, yymsp[-2].minor.yy18, yymsp[0].minor.yy18, 0); } #line 871 "fts5parse.c" yymsp[-2].minor.yy18 = yylhsminor.yy18; break; case 3: /* expr ::= expr NOT expr */ #line 98 "fts5parse.y" { yylhsminor.yy18 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, yymsp[-2].minor.yy18, yymsp[0].minor.yy18, 0); } #line 879 "fts5parse.c" yymsp[-2].minor.yy18 = yylhsminor.yy18; break; case 4: /* expr ::= LP expr RP */ #line 102 "fts5parse.y" {yymsp[-2].minor.yy18 = yymsp[-1].minor.yy18;} #line 885 "fts5parse.c" break; case 5: /* expr ::= exprlist */ case 6: /* exprlist ::= cnearset */ yytestcase(yyruleno==6); #line 103 "fts5parse.y" {yylhsminor.yy18 = yymsp[0].minor.yy18;} #line 891 "fts5parse.c" yymsp[0].minor.yy18 = yylhsminor.yy18; break; case 7: /* exprlist ::= exprlist cnearset */ #line 106 "fts5parse.y" { yylhsminor.yy18 = sqlite3Fts5ParseNode(pParse, FTS5_AND, yymsp[-1].minor.yy18, yymsp[0].minor.yy18, 0); } #line 899 "fts5parse.c" yymsp[-1].minor.yy18 = yylhsminor.yy18; break; case 8: /* cnearset ::= nearset */ #line 110 "fts5parse.y" { yylhsminor.yy18 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, yymsp[0].minor.yy26); } #line 907 "fts5parse.c" yymsp[0].minor.yy18 = yylhsminor.yy18; break; case 9: /* cnearset ::= colset COLON nearset */ #line 113 "fts5parse.y" { sqlite3Fts5ParseSetColset(pParse, yymsp[0].minor.yy26, yymsp[-2].minor.yy3); yylhsminor.yy18 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, yymsp[0].minor.yy26); } #line 916 "fts5parse.c" yymsp[-2].minor.yy18 = yylhsminor.yy18; break; case 10: /* colset ::= LCP colsetlist RCP */ #line 123 "fts5parse.y" { yymsp[-2].minor.yy3 = yymsp[-1].minor.yy3; } #line 922 "fts5parse.c" break; case 11: /* colset ::= STRING */ #line 124 "fts5parse.y" { yylhsminor.yy3 = sqlite3Fts5ParseColset(pParse, 0, &yymsp[0].minor.yy0); } #line 929 "fts5parse.c" yymsp[0].minor.yy3 = yylhsminor.yy3; break; case 12: /* colsetlist ::= colsetlist STRING */ #line 128 "fts5parse.y" { yylhsminor.yy3 = sqlite3Fts5ParseColset(pParse, yymsp[-1].minor.yy3, &yymsp[0].minor.yy0); } #line 936 "fts5parse.c" yymsp[-1].minor.yy3 = yylhsminor.yy3; break; case 13: /* colsetlist ::= STRING */ #line 130 "fts5parse.y" { yylhsminor.yy3 = sqlite3Fts5ParseColset(pParse, 0, &yymsp[0].minor.yy0); } #line 944 "fts5parse.c" yymsp[0].minor.yy3 = yylhsminor.yy3; break; case 14: /* nearset ::= phrase */ #line 140 "fts5parse.y" { yylhsminor.yy26 = sqlite3Fts5ParseNearset(pParse, 0, yymsp[0].minor.yy11); } #line 950 "fts5parse.c" yymsp[0].minor.yy26 = yylhsminor.yy26; break; case 15: /* nearset ::= STRING LP nearphrases neardist_opt RP */ #line 141 "fts5parse.y" { sqlite3Fts5ParseNear(pParse, &yymsp[-4].minor.yy0); sqlite3Fts5ParseSetDistance(pParse, yymsp[-2].minor.yy26, &yymsp[-1].minor.yy0); yylhsminor.yy26 = yymsp[-2].minor.yy26; } #line 960 "fts5parse.c" yymsp[-4].minor.yy26 = yylhsminor.yy26; break; case 16: /* nearphrases ::= phrase */ #line 147 "fts5parse.y" { yylhsminor.yy26 = sqlite3Fts5ParseNearset(pParse, 0, yymsp[0].minor.yy11); } #line 968 "fts5parse.c" yymsp[0].minor.yy26 = yylhsminor.yy26; break; case 17: /* nearphrases ::= nearphrases phrase */ #line 150 "fts5parse.y" { yylhsminor.yy26 = sqlite3Fts5ParseNearset(pParse, yymsp[-1].minor.yy26, yymsp[0].minor.yy11); } #line 976 "fts5parse.c" yymsp[-1].minor.yy26 = yylhsminor.yy26; break; case 18: /* neardist_opt ::= */ #line 157 "fts5parse.y" { yymsp[1].minor.yy0.p = 0; yymsp[1].minor.yy0.n = 0; } #line 982 "fts5parse.c" break; case 19: /* neardist_opt ::= COMMA STRING */ #line 158 "fts5parse.y" { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } #line 987 "fts5parse.c" break; case 20: /* phrase ::= phrase PLUS STRING star_opt */ #line 170 "fts5parse.y" { yylhsminor.yy11 = sqlite3Fts5ParseTerm(pParse, yymsp[-3].minor.yy11, &yymsp[-1].minor.yy0, yymsp[0].minor.yy20); } #line 994 "fts5parse.c" yymsp[-3].minor.yy11 = yylhsminor.yy11; break; case 21: /* phrase ::= STRING star_opt */ #line 173 "fts5parse.y" { yylhsminor.yy11 = sqlite3Fts5ParseTerm(pParse, 0, &yymsp[-1].minor.yy0, yymsp[0].minor.yy20); } #line 1002 "fts5parse.c" yymsp[-1].minor.yy11 = yylhsminor.yy11; break; case 22: /* star_opt ::= STAR */ #line 182 "fts5parse.y" { yymsp[0].minor.yy20 = 1; } #line 1008 "fts5parse.c" break; case 23: /* star_opt ::= */ #line 183 "fts5parse.y" { yymsp[1].minor.yy20 = 0; } #line 1013 "fts5parse.c" break; default: break; /********** End reduce actions ************************************************/ }; assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) ); yygoto = yyRuleInfo[yyruleno].lhs; yysize = yyRuleInfo[yyruleno].nrhs; yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); if( yyact <= YY_MAX_SHIFTREDUCE ){ if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; yypParser->yyidx -= yysize - 1; yymsp -= yysize-1; yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yyTraceShift(yypParser, yyact); }else{ assert( yyact == YY_ACCEPT_ACTION ); yypParser->yyidx -= yysize; yy_accept(yypParser); } }
/* ** Perform a reduce action and the shift that must immediately ** follow the reduce. */ static void yy_reduce( yyParser *yypParser, /* The parser */ unsigned int yyruleno /* Number of the rule by which to reduce */ ){ int yygoto; /* The next state */ int yyact; /* The next action */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ Parser_v0_1_ARG_FETCH; yymsp = &yypParser->yystack[yypParser->yyidx]; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ yysize = yyRuleInfo[yyruleno].nrhs; fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt, yyRuleName[yyruleno], yymsp[-yysize].stateno); } #endif /* NDEBUG */ /* Check that the stack is large enough to grow by a single entry ** if the RHS of the rule is empty. This ensures that there is room ** enough on the stack to push the LHS value */ if( yyRuleInfo[yyruleno].nrhs==0 ){ #ifdef YYTRACKMAXSTACKDEPTH if( yypParser->yyidx>yypParser->yyidxMax ){ yypParser->yyidxMax = yypParser->yyidx; } #endif #if YYSTACKDEPTH>0 if( yypParser->yyidx>=YYSTACKDEPTH-1 ){ yyStackOverflow(yypParser); return; } #else if( yypParser->yyidx>=yypParser->yystksz-1 ){ yyGrowStack(yypParser); if( yypParser->yyidx>=yypParser->yystksz-1 ){ yyStackOverflow(yypParser); return; } } #endif } switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** #line <lineno> <grammarfile> ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* program ::= IDENTIFIER NUMBER types */ { *arg = yymsp[0].minor.yy11; } break; case 1: /* types ::= types type */ { yylhsminor.yy11 = yymsp[-1].minor.yy11; Add(yylhsminor.yy11, yymsp[0].minor.yy33); } yymsp[-1].minor.yy11 = yylhsminor.yy11; break; case 2: /* types ::= type */ { yylhsminor.yy11 = CreateProgramNode(); Add(yylhsminor.yy11, yymsp[0].minor.yy33); } yymsp[0].minor.yy11 = yylhsminor.yy11; break; case 3: /* type ::= IDENTIFIER LBRACE values RBRACE SEMICOLON */ { yylhsminor.yy33 = yymsp[-2].minor.yy33; SetIden(yylhsminor.yy33, yymsp[-4].minor.yy0); } yymsp[-4].minor.yy33 = yylhsminor.yy33; break; case 4: /* values ::= values value */ { yylhsminor.yy33 = yymsp[-1].minor.yy33; Add(yylhsminor.yy33, yymsp[0].minor.yy30); } yymsp[-1].minor.yy33 = yylhsminor.yy33; break; case 5: /* values ::= value */ { yylhsminor.yy33 = CreateTypeNode(); Add(yylhsminor.yy33, yymsp[0].minor.yy30); } yymsp[0].minor.yy33 = yylhsminor.yy33; break; case 6: /* value ::= IDENTIFIER COLON expression SEMICOLON */ { yylhsminor.yy30 = CreateAssignNode(yymsp[-3].minor.yy0, yymsp[-1].minor.yy37); } yymsp[-3].minor.yy30 = yylhsminor.yy30; break; case 7: /* expression ::= number */ { yylhsminor.yy37 = CreateExpressionNode(yymsp[0].minor.yy10); } yymsp[0].minor.yy37 = yylhsminor.yy37; break; case 8: /* expression ::= IDENTIFIER */ { yylhsminor.yy37 = CreateExpressionNode(yymsp[0].minor.yy0); } yymsp[0].minor.yy37 = yylhsminor.yy37; break; case 9: /* expression ::= IDENTIFIER vector */ { yylhsminor.yy37 = CreateColourNode(yymsp[-1].minor.yy0, yymsp[0].minor.yy6); } yymsp[-1].minor.yy37 = yylhsminor.yy37; break; case 10: /* expression ::= number IDENTIFIER */ { yylhsminor.yy37 = CreateUnitValueNode(yymsp[-1].minor.yy10, yymsp[0].minor.yy0); } yymsp[-1].minor.yy37 = yylhsminor.yy37; break; case 11: /* expression ::= vector */ { yylhsminor.yy37 = CreateVecExprNode(yymsp[0].minor.yy6); } yymsp[0].minor.yy37 = yylhsminor.yy37; break; case 12: /* vector ::= LESSER vector_vals GREATER */ { yymsp[-2].minor.yy6 = yymsp[-1].minor.yy6; } break; case 13: /* vector_vals ::= vector_vals COMMA number */ { yylhsminor.yy6 = yymsp[-2].minor.yy6; Add(yylhsminor.yy6, CreateExpressionNode(yymsp[0].minor.yy10)); } yymsp[-2].minor.yy6 = yylhsminor.yy6; break; case 14: /* vector_vals ::= number */ { yylhsminor.yy6 = CreateVectorNode(); Add(yylhsminor.yy6, CreateExpressionNode(yymsp[0].minor.yy10)); } yymsp[0].minor.yy6 = yylhsminor.yy6; break; case 15: /* number ::= HEXVAL */ case 16: /* number ::= NUMBER */ yytestcase(yyruleno==16); { yylhsminor.yy10 = yymsp[0].minor.yy0; } yymsp[0].minor.yy10 = yylhsminor.yy10; break; default: break; /********** End reduce actions ************************************************/ }; assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) ); yygoto = yyRuleInfo[yyruleno].lhs; yysize = yyRuleInfo[yyruleno].nrhs; yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); if( yyact <= YY_MAX_SHIFTREDUCE ){ if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; yypParser->yyidx -= yysize - 1; yymsp -= yysize-1; yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yyTraceShift(yypParser, yyact); }else{ assert( yyact == YY_ACCEPT_ACTION ); yypParser->yyidx -= yysize; yy_accept(yypParser); } }
/* ** Perform a reduce action and the shift that must immediately ** follow the reduce. */ static void yy_reduce( yyParser *yypParser, /* The parser */ int yyruleno /* Number of the rule by which to reduce */ ){ int yygoto; /* The next state */ int yyact; /* The next action */ YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ ParseARG_FETCH; yymsp = &yypParser->yystack[yypParser->yyidx]; #ifndef NDEBUG if( yyTraceFILE && yyruleno>=0 && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ yysize = yyRuleInfo[yyruleno].nrhs; fprintf(yyTraceFILE, "%sReduce [%s] -> state %d.\n", yyTracePrompt, yyRuleName[yyruleno], yymsp[-yysize].stateno); } #endif /* NDEBUG */ /* Silence complaints from purify about yygotominor being uninitialized ** in some cases when it is copied into the stack after the following ** switch. yygotominor is uninitialized when a rule reduces that does ** not set the value of its left-hand side nonterminal. Leaving the ** value of the nonterminal uninitialized is utterly harmless as long ** as the value is never used. So really the only thing this code ** accomplishes is to quieten purify. ** ** 2007-01-16: The wireshark project (www.wireshark.org) reports that ** without this code, their parser segfaults. I'm not sure what there ** parser is doing to make this happen. This is the second bug report ** from wireshark this week. Clearly they are stressing Lemon in ways ** that it has not been previously stressed... (SQLite ticket #2172) */ /*memset(&yygotominor, 0, sizeof(yygotominor));*/ yygotominor = yyzerominor; switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** #line <lineno> <grammarfile> ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ case 0: /* expression ::= expr */ #line 35 "/home/veei/git/calculator/expressions.grammar.y" { state->root = yymsp[0].minor.yy0; } #line 809 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 1: /* identifier ::= IDENTIFIER */ #line 38 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_identifier(yymsp[0].minor.yy0, state->vpool); add_to_temp_set(yygotominor.yy0, state->temp_set); } #line 817 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 2: /* identifier ::= identifier DOT IDENTIFIER */ #line 44 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_access_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); add_to_temp_set(yygotominor.yy0, state->temp_set); yy_destructor(yypParser,18,&yymsp[-1].minor); } #line 827 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 3: /* term ::= identifier */ case 8: /* expr ::= term */ yytestcase(yyruleno==8); #line 50 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = yymsp[0].minor.yy0; } #line 833 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 4: /* term ::= INTEGER */ #line 53 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_integer(yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); } #line 841 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 5: /* term ::= FLOAT */ #line 59 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_float(yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); } #line 849 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 6: /* term ::= BOOLEAN */ #line 65 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_boolean(yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); } #line 857 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 7: /* term ::= STRING */ #line 71 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_string(yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); } #line 865 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 9: /* expr ::= expr PLUS expr */ #line 79 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_add_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,11,&yymsp[-1].minor); } #line 876 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 10: /* expr ::= expr MINUS expr */ #line 87 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_sub_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,12,&yymsp[-1].minor); } #line 887 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 11: /* expr ::= expr DIVIDE expr */ #line 95 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_div_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,15,&yymsp[-1].minor); } #line 898 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 12: /* expr ::= expr MOD expr */ #line 103 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_mod_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,16,&yymsp[-1].minor); } #line 909 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 13: /* expr ::= expr TIMES expr */ #line 111 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_times_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,14,&yymsp[-1].minor); } #line 920 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 14: /* expr ::= LEFT_P expr RIGHT_P */ #line 119 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = yymsp[-1].minor.yy0; yy_destructor(yypParser,23,&yymsp[-2].minor); yy_destructor(yypParser,24,&yymsp[0].minor); } #line 929 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 15: /* expr ::= MINUS expr */ #line 124 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_minus_operator(yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,12,&yymsp[-1].minor); } #line 939 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 16: /* expr ::= NOT expr */ #line 131 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_not_operator(yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,4,&yymsp[-1].minor); } #line 949 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 17: /* expr ::= expr AND expr */ #line 138 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_and_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,2,&yymsp[-1].minor); } #line 960 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 18: /* expr ::= expr OR expr */ #line 146 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_or_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,3,&yymsp[-1].minor); } #line 971 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 19: /* expr ::= expr LESS expr */ #line 154 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_less_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,5,&yymsp[-1].minor); } #line 982 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 20: /* expr ::= expr LESS_OR_EQUAL expr */ #line 162 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_less_or_equal_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,6,&yymsp[-1].minor); } #line 993 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 21: /* expr ::= expr GREATER expr */ #line 170 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_greater_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,7,&yymsp[-1].minor); } #line 1004 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 22: /* expr ::= expr GREATER_OR_EQUAL expr */ #line 178 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_greater_or_equal_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,8,&yymsp[-1].minor); } #line 1015 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 23: /* expr ::= expr EQUAL expr */ #line 186 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_equal_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,9,&yymsp[-1].minor); } #line 1026 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 24: /* expr ::= expr NOT_EQUAL expr */ #line 194 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_not_equal_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,10,&yymsp[-1].minor); } #line 1037 "/home/veei/git/calculator/expressions.grammar.cpp" break; case 25: /* expr ::= identifier ASSIGN expr */ #line 202 "/home/veei/git/calculator/expressions.grammar.y" { yygotominor.yy0 = create_assignment_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0); add_to_temp_set(yygotominor.yy0, state->temp_set); remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set); remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set); yy_destructor(yypParser,1,&yymsp[-1].minor); } #line 1048 "/home/veei/git/calculator/expressions.grammar.cpp" break; default: break; }; yygoto = yyRuleInfo[yyruleno].lhs; yysize = yyRuleInfo[yyruleno].nrhs; yypParser->yyidx -= yysize; yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); if( yyact <= YY_MAX_SHIFTREDUCE ){ if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; /* If the reduce action popped at least ** one element off the stack, then we can push the new element back ** onto the stack here, and skip the stack overflow test in yy_shift(). ** That gives a significant speed improvement. */ if( yysize ){ yypParser->yyidx++; yymsp -= yysize-1; yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yymsp->minor = yygotominor; yyTraceShift(yypParser, yyact); }else{ yy_shift(yypParser,yyact,yygoto,&yygotominor); } }else{ assert( yyact == YY_ACCEPT_ACTION ); yy_accept(yypParser); } }
/* ** Perform a reduce action and the shift that must immediately ** follow the reduce. */ static void yy_reduce( yyParser *yypParser, /* The parser */ int yyruleno /* Number of the rule by which to reduce */ ){ int yygoto; /* The next state */ int yyact; /* The next action */ YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ ParseARG_FETCH; yymsp = &yypParser->yystack[yypParser->yyidx]; #ifndef NDEBUG if( yyTraceFILE && yyruleno>=0 && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ yysize = yyRuleInfo[yyruleno].nrhs; fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt, yyRuleName[yyruleno], yymsp[-yysize].stateno); } #endif /* NDEBUG */ yygotominor = yyzerominor; switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** #line <lineno> <grammarfile> ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ /********** Begin reduce actions **********************************************/ case 4: /* stmt ::= expr ENDS */ #line 49 "grammar.lemon" { pEval->parseSetResult(yymsp[-1].minor.yy0.valid ? yymsp[-1].minor.yy0.dValue : NAN); } #line 737 "grammar.c" break; case 5: /* stmt ::= expr SEMCOL */ #line 50 "grammar.lemon" { pEval->parseSetResult(NAN); } #line 742 "grammar.c" break; case 6: /* expr ::= VALUE */ #line 52 "grammar.lemon" { yygotominor.yy0.dValue = yymsp[0].minor.yy0.dValue; yygotominor.yy0.valid=true; } #line 747 "grammar.c" break; case 7: /* expr ::= expr UNIT */ #line 53 "grammar.lemon" { yygotominor.yy0.dValue = yymsp[-1].minor.yy0.dValue * yymsp[0].minor.yy0.dValue; yygotominor.yy0.valid=yymsp[-1].minor.yy0.valid; } #line 752 "grammar.c" break; case 8: /* expr ::= MINUS expr */ #line 54 "grammar.lemon" { yygotominor.yy0.dValue = -yymsp[0].minor.yy0.dValue; yygotominor.yy0.valid=yymsp[0].minor.yy0.valid; } #line 757 "grammar.c" break; case 9: /* expr ::= VAR */ #line 55 "grammar.lemon" { yygotominor.yy0.dValue = pEval->getVar(yymsp[0].minor.yy0.text); yygotominor.yy0.valid=true; } #line 762 "grammar.c" break; case 10: /* expr ::= VAR ASSIGN expr */ #line 56 "grammar.lemon" { pEval->setVar(yymsp[-2].minor.yy0.text, yymsp[0].minor.yy0.dValue); yygotominor.yy0.dValue = yymsp[0].minor.yy0.dValue; yygotominor.yy0.valid=false; } #line 767 "grammar.c" break; case 11: /* expr ::= expr PLUS expr */ #line 57 "grammar.lemon" { yygotominor.yy0.dValue = yymsp[-2].minor.yy0.dValue + yymsp[0].minor.yy0.dValue; yygotominor.yy0.valid=yymsp[0].minor.yy0.valid; } #line 772 "grammar.c" break; case 12: /* expr ::= expr MINUS expr */ #line 58 "grammar.lemon" { yygotominor.yy0.dValue = yymsp[-2].minor.yy0.dValue - yymsp[0].minor.yy0.dValue; yygotominor.yy0.valid=yymsp[0].minor.yy0.valid; } #line 777 "grammar.c" break; case 13: /* expr ::= expr MULT expr */ #line 59 "grammar.lemon" { yygotominor.yy0.dValue = yymsp[-2].minor.yy0.dValue * yymsp[0].minor.yy0.dValue; yygotominor.yy0.valid=yymsp[0].minor.yy0.valid; } #line 782 "grammar.c" break; case 14: /* expr ::= expr DIVIDE expr */ #line 60 "grammar.lemon" { if (yymsp[0].minor.yy0.dValue != 0.0) { yygotominor.yy0.dValue = yymsp[-2].minor.yy0.dValue / yymsp[0].minor.yy0.dValue; } else pEval->parseError("Div by zero"); yygotominor.yy0.valid=yymsp[0].minor.yy0.valid; } #line 793 "grammar.c" break; case 15: /* expr ::= PARENL expr PARENR */ #line 67 "grammar.lemon" { yygotominor.yy0.dValue = yymsp[-1].minor.yy0.dValue; yygotominor.yy0.valid=yymsp[-1].minor.yy0.valid; } #line 798 "grammar.c" break; default: /* (0) main ::= in */ yytestcase(yyruleno==0); /* (1) in ::= stmt */ yytestcase(yyruleno==1); /* (2) in ::= in stmt */ yytestcase(yyruleno==2); /* (3) stmt ::= ENDS */ yytestcase(yyruleno==3); break; /********** End reduce actions ************************************************/ }; assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) ); yygoto = yyRuleInfo[yyruleno].lhs; yysize = yyRuleInfo[yyruleno].nrhs; yypParser->yyidx -= yysize; yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); if( yyact <= YY_MAX_SHIFTREDUCE ){ if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; /* If the reduce action popped at least ** one element off the stack, then we can push the new element back ** onto the stack here, and skip the stack overflow test in yy_shift(). ** That gives a significant speed improvement. */ if( yysize ){ yypParser->yyidx++; yymsp -= yysize-1; yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yymsp->minor = yygotominor; yyTraceShift(yypParser, yyact); }else{ yy_shift(yypParser,yyact,yygoto,&yygotominor); } }else{ assert( yyact == YY_ACCEPT_ACTION ); yy_accept(yypParser); } }