int config_parser::parse () { /// Lookahead and lookahead in internal form. int yychar = yyempty_; int yytoken = 0; /* State. */ int yyn; int yylen = 0; int yystate = 0; /* Error handling. */ int yynerrs_ = 0; int yyerrstatus_ = 0; /// Semantic value of the lookahead. semantic_type yylval; /// Location of the lookahead. location_type yylloc; /// The locations where the error started and ended. location_type yyerror_range[2]; /// $$. semantic_type yyval; /// @$. location_type yyloc; int yyresult; YYCDEBUG << "Starting parse" << std::endl; /* User initialization code. */ { // start // void yylloc.begin.filename = yylloc.end.filename = driver.getFileNamePtr(); //new string(driver.getFileName()); /* @$.begin.line = @$.end.line = 0; @$.begin.column = @$.end.column = 0; */ } /* Initialize the stacks. The initial state will be pushed in yynewstate, since the latter expects the semantical and the location values to have been already stored, initialize these stacks with a primary value. */ yystate_stack_ = state_stack_type (0); yysemantic_stack_ = semantic_stack_type (0); yylocation_stack_ = location_stack_type (0); yysemantic_stack_.push (yylval); yylocation_stack_.push (yylloc); /* New state. */ yynewstate: yystate_stack_.push (yystate); YYCDEBUG << "Entering state " << yystate << std::endl; /* Accept? */ if (yystate == yyfinal_) goto yyacceptlab; goto yybackup; /* Backup. */ yybackup: /* Try to take a decision without lookahead. */ yyn = yypact_[yystate]; if (yyn == yypact_ninf_) goto yydefault; /* Read a lookahead token. */ if (yychar == yyempty_) { YYCDEBUG << "Reading a token: "; yychar = yylex (&yylval, &yylloc); } /* Convert token to internal form. */ if (yychar <= yyeof_) { yychar = yytoken = yyeof_; YYCDEBUG << "Now at end of input." << std::endl; } else { yytoken = yytranslate_ (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) goto yydefault; /* Reduce or error. */ yyn = yytable_[yyn]; if (yyn <= 0) { if (yyn == 0 || yyn == yytable_ninf_) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the token being shifted. */ yychar = yyempty_; yysemantic_stack_.push (yylval); yylocation_stack_.push (yylloc); /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus_) --yyerrstatus_; yystate = yyn; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact_[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: yylen = yyr2_[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, use the top of the stack. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. */ if (yylen) yyval = yysemantic_stack_[yylen - 1]; else yyval = yysemantic_stack_[0]; { slice<location_type, location_stack_type> slice (yylocation_stack_, yylen); YYLLOC_DEFAULT (yyloc, slice, yylen); } YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: { driver.addBlockList((yysemantic_stack_[(1) - (1)].gc_block_list)); } break; case 4: { (yyval.gc_block_list) = new GConfigBlockList((yysemantic_stack_[(1) - (1)].gc_block)); } break; case 5: { (yysemantic_stack_[(2) - (1)].gc_block_list)->appendBlock((yysemantic_stack_[(2) - (2)].gc_block)); (yyval.gc_block_list) = (yysemantic_stack_[(2) - (1)].gc_block_list); } break; case 6: { (yyval.gc_block_header) = new GConfigBlockHeader((yysemantic_stack_[(5) - (1)].str_val), (yysemantic_stack_[(5) - (3)].gc_identifier), (yylocation_stack_[(5) - (1)])); free((yysemantic_stack_[(5) - (1)].str_val)); } break; case 7: { (yyval.gc_block_header) = new GConfigBlockHeader((yysemantic_stack_[(2) - (1)].str_val), (yylocation_stack_[(2) - (1)])); free((yysemantic_stack_[(2) - (1)].str_val)); } break; case 8: { (yyval.gc_block) = new GConfigBlock((yysemantic_stack_[(3) - (1)].gc_block_header), (yysemantic_stack_[(3) - (2)].gc_statement_list)); } break; case 9: { (yyval.gc_identifier) = new GConfigIdentifier((yysemantic_stack_[(1) - (1)].str_val), (yylocation_stack_[(1) - (1)])); free((yysemantic_stack_[(1) - (1)].str_val)); } break; case 10: { (yysemantic_stack_[(3) - (1)].gc_identifier)->appendString((yysemantic_stack_[(3) - (3)].str_val), (yylocation_stack_[(3) - (3)])); free((yysemantic_stack_[(3) - (3)].str_val)); (yyval.gc_identifier) = (yysemantic_stack_[(3) - (1)].gc_identifier); } break; case 11: { (yyval.gc_statement_list) = new GConfigStatementList((yysemantic_stack_[(1) - (1)].gc_statement)); } break; case 12: { (yysemantic_stack_[(2) - (1)].gc_statement_list)->appendStatement((yysemantic_stack_[(2) - (2)].gc_statement)); (yyval.gc_statement_list) = (yysemantic_stack_[(2) - (1)].gc_statement_list); } break; case 13: { (yyval.gc_statement) = (yysemantic_stack_[(1) - (1)].gc_block); } break; case 14: { (yyval.gc_statement) = (yysemantic_stack_[(1) - (1)].gc_function); } break; case 15: { (yyval.gc_statement) = (yysemantic_stack_[(1) - (1)].gc_variable); } break; case 16: { (yyval.gc_statement) = (yysemantic_stack_[(1) - (1)].gc_define); } break; case 17: { (yyval.gc_variable) = new GConfigVariableStatement((yysemantic_stack_[(4) - (1)].gc_identifier), (yysemantic_stack_[(4) - (3)].gc_argument)); } break; case 18: { (yyval.gc_define) = new GConfigDefineStatement((yysemantic_stack_[(2) - (1)].gc_identifier)); } break; case 19: { (yyval.gc_function) = new GConfigFunctionStatement((yysemantic_stack_[(5) - (1)].gc_identifier), (yysemantic_stack_[(5) - (3)].gc_argument_list)); } break; case 20: { (yyval.gc_argument) = new GConfigArgument((yysemantic_stack_[(1) - (1)].gc_scalar_val)); } break; case 21: { (yyval.gc_argument) = new GConfigArgument((yysemantic_stack_[(3) - (2)].gc_argument_list)); } break; case 22: { (yyval.gc_argument_list) = new GConfigArgumentList((yysemantic_stack_[(1) - (1)].gc_scalar_val)); } break; case 23: { (yysemantic_stack_[(3) - (1)].gc_argument_list)->appendArgument((yysemantic_stack_[(3) - (3)].gc_scalar_val)); (yyval.gc_argument_list) = (yysemantic_stack_[(3) - (1)].gc_argument_list); } break; case 24: { (yyval.gc_scalar_val) = new GConfigScalarVal((yysemantic_stack_[(1) - (1)].long_val), (yylocation_stack_[(1) - (1)])); } break; case 25: { (yyval.gc_scalar_val) = new GConfigScalarVal((yysemantic_stack_[(1) - (1)].double_val), (yylocation_stack_[(1) - (1)])); } break; case 26: { (yyval.gc_scalar_val) = new GConfigScalarVal((yysemantic_stack_[(1) - (1)].str_val), (yylocation_stack_[(1) - (1)])); free((yysemantic_stack_[(1) - (1)].str_val)); } break; case 27: { (yyval.gc_scalar_val) = new GConfigScalarVal((yysemantic_stack_[(1) - (1)].gc_identifier)); } break; default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); yypop_ (yylen); yylen = 0; YY_STACK_PRINT (); yysemantic_stack_.push (yyval); yylocation_stack_.push (yyloc); /* Shift the result of the reduction. */ yyn = yyr1_[yyn]; yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0]; if (0 <= yystate && yystate <= yylast_ && yycheck_[yystate] == yystate_stack_[0]) yystate = yytable_[yystate]; else yystate = yydefgoto_[yyn - yyntokens_]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus_) { ++yynerrs_; error (yylloc, yysyntax_error_ (yystate, yytoken)); } yyerror_range[0] = yylloc; if (yyerrstatus_ == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= yyeof_) { /* Return failure if at end of input. */ if (yychar == yyeof_) YYABORT; } else { yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); yychar = yyempty_; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (false) goto yyerrorlab; yyerror_range[0] = yylocation_stack_[yylen - 1]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ yypop_ (yylen); yylen = 0; yystate = yystate_stack_[0]; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus_ = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact_[yystate]; if (yyn != yypact_ninf_) { yyn += yyterror_; if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) { yyn = yytable_[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yystate_stack_.height () == 1) YYABORT; yyerror_range[0] = yylocation_stack_[0]; yydestruct_ ("Error: popping", yystos_[yystate], &yysemantic_stack_[0], &yylocation_stack_[0]); yypop_ (); yystate = yystate_stack_[0]; YY_STACK_PRINT (); } yyerror_range[1] = yylloc; // Using YYLLOC is tempting, but would change the location of // the lookahead. YYLOC is available though. YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); yysemantic_stack_.push (yylval); yylocation_stack_.push (yyloc); /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], &yysemantic_stack_[0], &yylocation_stack_[0]); yystate = yyn; goto yynewstate; /* Accept. */ yyacceptlab: yyresult = 0; goto yyreturn; /* Abort. */ yyabortlab: yyresult = 1; goto yyreturn; yyreturn: if (yychar != yyempty_) yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ yypop_ (yylen); while (yystate_stack_.height () != 1) { yydestruct_ ("Cleanup: popping", yystos_[yystate_stack_[0]], &yysemantic_stack_[0], &yylocation_stack_[0]); yypop_ (); } return yyresult; }
int Parser::parse () { /// Lookahead and lookahead in internal form. int yychar = yyempty_; int yytoken = 0; /* State. */ int yyn; int yylen = 0; int yystate = 0; /* Error handling. */ int yynerrs_ = 0; int yyerrstatus_ = 0; /// Semantic value of the lookahead. semantic_type yylval; /// Location of the lookahead. location_type yylloc; /// The locations where the error started and ended. location_type yyerror_range[2]; /// $$. semantic_type yyval; /// @$. location_type yyloc; int yyresult; YYCDEBUG << "Starting parse" << std::endl; /* Initialize the stacks. The initial state will be pushed in yynewstate, since the latter expects the semantical and the location values to have been already stored, initialize these stacks with a primary value. */ yystate_stack_ = state_stack_type (0); yysemantic_stack_ = semantic_stack_type (0); yylocation_stack_ = location_stack_type (0); yysemantic_stack_.push (yylval); yylocation_stack_.push (yylloc); /* New state. */ yynewstate: yystate_stack_.push (yystate); YYCDEBUG << "Entering state " << yystate << std::endl; /* Accept? */ if (yystate == yyfinal_) goto yyacceptlab; goto yybackup; /* Backup. */ yybackup: /* Try to take a decision without lookahead. */ yyn = yypact_[yystate]; if (yyn == yypact_ninf_) goto yydefault; /* Read a lookahead token. */ if (yychar == yyempty_) { YYCDEBUG << "Reading a token: "; yychar = yylex (&yylval, &yylloc, scanner); } /* Convert token to internal form. */ if (yychar <= yyeof_) { yychar = yytoken = yyeof_; YYCDEBUG << "Now at end of input." << std::endl; } else { yytoken = yytranslate_ (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) goto yydefault; /* Reduce or error. */ yyn = yytable_[yyn]; if (yyn <= 0) { if (yyn == 0 || yyn == yytable_ninf_) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the token being shifted. */ yychar = yyempty_; yysemantic_stack_.push (yylval); yylocation_stack_.push (yylloc); /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus_) --yyerrstatus_; yystate = yyn; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact_[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: yylen = yyr2_[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, use the top of the stack. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. */ if (yylen) yyval = yysemantic_stack_[yylen - 1]; else yyval = yysemantic_stack_[0]; { slice<location_type, location_stack_type> slice (yylocation_stack_, yylen); YYLLOC_DEFAULT (yyloc, slice, yylen); } YY_REDUCE_PRINT (yyn); switch (yyn) { case 21: /* Line 678 of lalr1.cc */ #line 79 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(3) - (2)]) ) ; configlines.push_back ( line ) ; } break; case 22: /* Line 678 of lalr1.cc */ #line 85 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(4) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(4) - (4)]) ) ; configlines.push_back ( line ) ; } break; case 23: /* Line 678 of lalr1.cc */ #line 93 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(5) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(5) - (4)]) ) ; line.push_back ( (yysemantic_stack_[(5) - (5)]) ) ; configlines.push_back ( line ) ; } break; case 24: /* Line 678 of lalr1.cc */ #line 101 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(6) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(6) - (4)]) ) ; line.push_back ( (yysemantic_stack_[(6) - (5)]) ) ; line.push_back ( (yysemantic_stack_[(6) - (6)]) ) ; configlines.push_back ( line ) ; } break; case 25: /* Line 678 of lalr1.cc */ #line 110 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(7) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(7) - (4)]) ) ; line.push_back ( (yysemantic_stack_[(7) - (5)]) ) ; line.push_back ( (yysemantic_stack_[(7) - (6)]) ) ; line.push_back ( (yysemantic_stack_[(7) - (7)]) ) ; configlines.push_back ( line ) ; } break; case 26: /* Line 678 of lalr1.cc */ #line 120 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(8) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(8) - (4)]) ) ; line.push_back ( (yysemantic_stack_[(8) - (5)]) ) ; line.push_back ( (yysemantic_stack_[(8) - (6)]) ) ; line.push_back ( (yysemantic_stack_[(8) - (7)]) ) ; line.push_back ( (yysemantic_stack_[(8) - (8)]) ) ; configlines.push_back ( line ) ; } break; case 27: /* Line 678 of lalr1.cc */ #line 131 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(9) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(9) - (4)]) ) ; line.push_back ( (yysemantic_stack_[(9) - (5)]) ) ; line.push_back ( (yysemantic_stack_[(9) - (6)]) ) ; line.push_back ( (yysemantic_stack_[(9) - (7)]) ) ; line.push_back ( (yysemantic_stack_[(9) - (8)]) ) ; line.push_back ( (yysemantic_stack_[(9) - (9)]) ) ; configlines.push_back ( line ) ; } break; case 28: /* Line 678 of lalr1.cc */ #line 143 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(10) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(10) - (4)]) ) ; line.push_back ( (yysemantic_stack_[(10) - (5)]) ) ; line.push_back ( (yysemantic_stack_[(10) - (6)]) ) ; line.push_back ( (yysemantic_stack_[(10) - (7)]) ) ; line.push_back ( (yysemantic_stack_[(10) - (8)]) ) ; line.push_back ( (yysemantic_stack_[(10) - (9)]) ) ; line.push_back ( (yysemantic_stack_[(10) - (10)]) ) ; configlines.push_back ( line ) ; } break; case 29: /* Line 678 of lalr1.cc */ #line 157 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(11) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(11) - (4)]) ) ; line.push_back ( (yysemantic_stack_[(11) - (5)]) ) ; line.push_back ( (yysemantic_stack_[(11) - (6)]) ) ; line.push_back ( (yysemantic_stack_[(11) - (7)]) ) ; line.push_back ( (yysemantic_stack_[(11) - (8)]) ) ; line.push_back ( (yysemantic_stack_[(11) - (9)]) ) ; line.push_back ( (yysemantic_stack_[(11) - (10)]) ) ; line.push_back ( (yysemantic_stack_[(11) - (11)]) ) ; configlines.push_back ( line ) ; } break; case 30: /* Line 678 of lalr1.cc */ #line 172 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(12) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(12) - (4)]) ) ; line.push_back ( (yysemantic_stack_[(12) - (5)]) ) ; line.push_back ( (yysemantic_stack_[(12) - (6)]) ) ; line.push_back ( (yysemantic_stack_[(12) - (7)]) ) ; line.push_back ( (yysemantic_stack_[(12) - (8)]) ) ; line.push_back ( (yysemantic_stack_[(12) - (9)]) ) ; line.push_back ( (yysemantic_stack_[(12) - (10)]) ) ; line.push_back ( (yysemantic_stack_[(12) - (11)]) ) ; line.push_back ( (yysemantic_stack_[(12) - (12)]) ) ; configlines.push_back ( line ) ; } break; case 31: /* Line 678 of lalr1.cc */ #line 189 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(13) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(13) - (4)]) ) ; line.push_back ( (yysemantic_stack_[(13) - (5)]) ) ; line.push_back ( (yysemantic_stack_[(13) - (6)]) ) ; line.push_back ( (yysemantic_stack_[(13) - (7)]) ) ; line.push_back ( (yysemantic_stack_[(13) - (8)]) ) ; line.push_back ( (yysemantic_stack_[(13) - (9)]) ) ; line.push_back ( (yysemantic_stack_[(13) - (10)]) ) ; line.push_back ( (yysemantic_stack_[(13) - (11)]) ) ; line.push_back ( (yysemantic_stack_[(13) - (12)]) ) ; line.push_back ( (yysemantic_stack_[(13) - (13)]) ) ; configlines.push_back ( line ) ; } break; case 32: /* Line 678 of lalr1.cc */ #line 207 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(14) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(14) - (4)]) ) ; line.push_back ( (yysemantic_stack_[(14) - (5)]) ) ; line.push_back ( (yysemantic_stack_[(14) - (6)]) ) ; line.push_back ( (yysemantic_stack_[(14) - (7)]) ) ; line.push_back ( (yysemantic_stack_[(14) - (8)]) ) ; line.push_back ( (yysemantic_stack_[(14) - (9)]) ) ; line.push_back ( (yysemantic_stack_[(14) - (10)]) ) ; line.push_back ( (yysemantic_stack_[(14) - (11)]) ) ; line.push_back ( (yysemantic_stack_[(14) - (12)]) ) ; line.push_back ( (yysemantic_stack_[(14) - (13)]) ) ; line.push_back ( (yysemantic_stack_[(14) - (14)]) ) ; configlines.push_back ( line ) ; } break; case 33: /* Line 678 of lalr1.cc */ #line 227 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(15) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(15) - (4)]) ) ; line.push_back ( (yysemantic_stack_[(15) - (5)]) ) ; line.push_back ( (yysemantic_stack_[(15) - (6)]) ) ; line.push_back ( (yysemantic_stack_[(15) - (7)]) ) ; line.push_back ( (yysemantic_stack_[(15) - (8)]) ) ; line.push_back ( (yysemantic_stack_[(15) - (9)]) ) ; line.push_back ( (yysemantic_stack_[(15) - (10)]) ) ; line.push_back ( (yysemantic_stack_[(15) - (11)]) ) ; line.push_back ( (yysemantic_stack_[(15) - (12)]) ) ; line.push_back ( (yysemantic_stack_[(15) - (13)]) ) ; line.push_back ( (yysemantic_stack_[(15) - (14)]) ) ; line.push_back ( (yysemantic_stack_[(15) - (15)]) ) ; configlines.push_back ( line ) ; } break; case 34: /* Line 678 of lalr1.cc */ #line 248 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(16) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(16) - (4)]) ) ; line.push_back ( (yysemantic_stack_[(16) - (5)]) ) ; line.push_back ( (yysemantic_stack_[(16) - (6)]) ) ; line.push_back ( (yysemantic_stack_[(16) - (7)]) ) ; line.push_back ( (yysemantic_stack_[(16) - (8)]) ) ; line.push_back ( (yysemantic_stack_[(16) - (9)]) ) ; line.push_back ( (yysemantic_stack_[(16) - (10)]) ) ; line.push_back ( (yysemantic_stack_[(16) - (11)]) ) ; line.push_back ( (yysemantic_stack_[(16) - (12)]) ) ; line.push_back ( (yysemantic_stack_[(16) - (13)]) ) ; line.push_back ( (yysemantic_stack_[(16) - (14)]) ) ; line.push_back ( (yysemantic_stack_[(16) - (15)]) ) ; line.push_back ( (yysemantic_stack_[(16) - (16)]) ) ; configlines.push_back ( line ) ; } break; case 35: /* Line 678 of lalr1.cc */ #line 270 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(17) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(17) - (4)]) ) ; line.push_back ( (yysemantic_stack_[(17) - (5)]) ) ; line.push_back ( (yysemantic_stack_[(17) - (6)]) ) ; line.push_back ( (yysemantic_stack_[(17) - (7)]) ) ; line.push_back ( (yysemantic_stack_[(17) - (8)]) ) ; line.push_back ( (yysemantic_stack_[(17) - (9)]) ) ; line.push_back ( (yysemantic_stack_[(17) - (10)]) ) ; line.push_back ( (yysemantic_stack_[(17) - (11)]) ) ; line.push_back ( (yysemantic_stack_[(17) - (12)]) ) ; line.push_back ( (yysemantic_stack_[(17) - (13)]) ) ; line.push_back ( (yysemantic_stack_[(17) - (14)]) ) ; line.push_back ( (yysemantic_stack_[(17) - (15)]) ) ; line.push_back ( (yysemantic_stack_[(17) - (16)]) ) ; line.push_back ( (yysemantic_stack_[(17) - (17)]) ) ; configlines.push_back ( line ) ; } break; case 36: /* Line 678 of lalr1.cc */ #line 293 "parser.ypp" { std::vector<std::string> line ; line.push_back ( (yysemantic_stack_[(18) - (2)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (4)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (5)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (6)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (7)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (8)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (9)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (10)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (11)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (12)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (13)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (14)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (15)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (16)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (17)]) ) ; line.push_back ( (yysemantic_stack_[(18) - (18)]) ) ; configlines.push_back ( line ) ; } break; case 37: /* Line 678 of lalr1.cc */ #line 317 "parser.ypp" { } break; /* Line 678 of lalr1.cc */ #line 695 "parser.tab.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); yypop_ (yylen); yylen = 0; YY_STACK_PRINT (); yysemantic_stack_.push (yyval); yylocation_stack_.push (yyloc); /* Shift the result of the reduction. */ yyn = yyr1_[yyn]; yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0]; if (0 <= yystate && yystate <= yylast_ && yycheck_[yystate] == yystate_stack_[0]) yystate = yytable_[yystate]; else yystate = yydefgoto_[yyn - yyntokens_]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus_) { ++yynerrs_; error (yylloc, yysyntax_error_ (yystate)); } yyerror_range[0] = yylloc; if (yyerrstatus_ == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= yyeof_) { /* Return failure if at end of input. */ if (yychar == yyeof_) YYABORT; } else { yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); yychar = yyempty_; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (false) goto yyerrorlab; yyerror_range[0] = yylocation_stack_[yylen - 1]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ yypop_ (yylen); yylen = 0; yystate = yystate_stack_[0]; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus_ = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact_[yystate]; if (yyn != yypact_ninf_) { yyn += yyterror_; if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) { yyn = yytable_[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yystate_stack_.height () == 1) YYABORT; yyerror_range[0] = yylocation_stack_[0]; yydestruct_ ("Error: popping", yystos_[yystate], &yysemantic_stack_[0], &yylocation_stack_[0]); yypop_ (); yystate = yystate_stack_[0]; YY_STACK_PRINT (); } yyerror_range[1] = yylloc; // Using YYLLOC is tempting, but would change the location of // the lookahead. YYLOC is available though. YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); yysemantic_stack_.push (yylval); yylocation_stack_.push (yyloc); /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], &yysemantic_stack_[0], &yylocation_stack_[0]); yystate = yyn; goto yynewstate; /* Accept. */ yyacceptlab: yyresult = 0; goto yyreturn; /* Abort. */ yyabortlab: yyresult = 1; goto yyreturn; yyreturn: if (yychar != yyempty_) yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ yypop_ (yylen); while (yystate_stack_.height () != 1) { yydestruct_ ("Cleanup: popping", yystos_[yystate_stack_[0]], &yysemantic_stack_[0], &yylocation_stack_[0]); yypop_ (); } return yyresult; }
int Parser::parse () { /// Lookahead and lookahead in internal form. int yychar = yyempty_; int yytoken = 0; /* State. */ int yyn; int yylen = 0; int yystate = 0; /* Error handling. */ int yynerrs_ = 0; int yyerrstatus_ = 0; /// Semantic value of the lookahead. semantic_type yylval; /// Location of the lookahead. location_type yylloc; /// The locations where the error started and ended. location_type yyerror_range[3]; /// $$. semantic_type yyval; /// @$. location_type yyloc; int yyresult; YYCDEBUG << "Starting parse" << std::endl; /* User initialization code. */ /* Line 565 of lalr1.cc */ #line 36 "parser.yy" { // initialize the initial location object yylloc.begin.filename = yylloc.end.filename = &driver.streamname; } /* Line 565 of lalr1.cc */ #line 352 "parser.cpp" /* Initialize the stacks. The initial state will be pushed in yynewstate, since the latter expects the semantical and the location values to have been already stored, initialize these stacks with a primary value. */ yystate_stack_ = state_stack_type (0); yysemantic_stack_ = semantic_stack_type (0); yylocation_stack_ = location_stack_type (0); yysemantic_stack_.push (yylval); yylocation_stack_.push (yylloc); /* New state. */ yynewstate: yystate_stack_.push (yystate); YYCDEBUG << "Entering state " << yystate << std::endl; /* Accept? */ if (yystate == yyfinal_) goto yyacceptlab; goto yybackup; /* Backup. */ yybackup: /* Try to take a decision without lookahead. */ yyn = yypact_[yystate]; if (yy_pact_value_is_default_ (yyn)) goto yydefault; /* Read a lookahead token. */ if (yychar == yyempty_) { YYCDEBUG << "Reading a token: "; yychar = yylex (&yylval, &yylloc); } /* Convert token to internal form. */ if (yychar <= yyeof_) { yychar = yytoken = yyeof_; YYCDEBUG << "Now at end of input." << std::endl; } else { yytoken = yytranslate_ (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) goto yydefault; /* Reduce or error. */ yyn = yytable_[yyn]; if (yyn <= 0) { if (yy_table_value_is_error_ (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the token being shifted. */ yychar = yyempty_; yysemantic_stack_.push (yylval); yylocation_stack_.push (yylloc); /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus_) --yyerrstatus_; yystate = yyn; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact_[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: yylen = yyr2_[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, use the top of the stack. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. */ if (yylen) yyval = yysemantic_stack_[yylen - 1]; else yyval = yysemantic_stack_[0]; { slice<location_type, location_stack_type> slice (yylocation_stack_, yylen); YYLLOC_DEFAULT (yyloc, slice, yylen); } YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: /* Line 690 of lalr1.cc */ #line 88 "parser.yy" { (yyval.querynode) = new query_true(); } break; case 3: /* Line 690 of lalr1.cc */ #line 92 "parser.yy" { (yyval.querynode) = new query_true(); } break; case 4: /* Line 690 of lalr1.cc */ #line 97 "parser.yy" { (yyval.stringVal) = (yysemantic_stack_[(1) - (1)].stringVal); } break; case 5: /* Line 690 of lalr1.cc */ #line 102 "parser.yy" { (yyval.stringVal) = (yysemantic_stack_[(1) - (1)].stringVal); } break; case 6: /* Line 690 of lalr1.cc */ #line 106 "parser.yy" { (yyval.stringVal) = (yysemantic_stack_[(1) - (1)].stringVal); } break; case 7: /* Line 690 of lalr1.cc */ #line 110 "parser.yy" { (yyval.stringVal) = (yysemantic_stack_[(1) - (1)].stringVal); } break; case 8: /* Line 690 of lalr1.cc */ #line 114 "parser.yy" { (yyval.stringVal) = (yysemantic_stack_[(1) - (1)].stringVal); } break; case 9: /* Line 690 of lalr1.cc */ #line 118 "parser.yy" { (yyval.stringVal) = (yysemantic_stack_[(1) - (1)].stringVal); } break; case 10: /* Line 690 of lalr1.cc */ #line 123 "parser.yy" { delete (yysemantic_stack_[(3) - (2)].stringVal); (yyval.querynode) = new query_tagged((yysemantic_stack_[(3) - (3)].stringVal)); } break; case 11: /* Line 690 of lalr1.cc */ #line 128 "parser.yy" { delete (yysemantic_stack_[(3) - (2)].stringVal); (yyval.querynode) = new query_field((yysemantic_stack_[(3) - (1)].unquotedstringVal)); } break; case 12: /* Line 690 of lalr1.cc */ #line 134 "parser.yy" { (yyval.querynode) = new query_field((yysemantic_stack_[(3) - (1)].unquotedstringVal), (yysemantic_stack_[(3) - (3)].stringVal), (yysemantic_stack_[(3) - (2)].stringVal)); } break; case 13: /* Line 690 of lalr1.cc */ #line 138 "parser.yy" { (yyval.querynode) = new query_field((yysemantic_stack_[(3) - (1)].unquotedstringVal), (yysemantic_stack_[(3) - (3)].integerVal), (yysemantic_stack_[(3) - (2)].stringVal)); } break; case 14: /* Line 690 of lalr1.cc */ #line 142 "parser.yy" { (yyval.querynode) = new query_field((yysemantic_stack_[(3) - (1)].unquotedstringVal), (yysemantic_stack_[(3) - (3)].doubleVal), (yysemantic_stack_[(3) - (2)].stringVal)); } break; case 15: /* Line 690 of lalr1.cc */ #line 147 "parser.yy" { (yyval.querynode) = (yysemantic_stack_[(3) - (2)].querynode); } break; case 16: /* Line 690 of lalr1.cc */ #line 151 "parser.yy" { (yyval.querynode) = new query_and((yysemantic_stack_[(3) - (1)].querynode), (yysemantic_stack_[(3) - (3)].querynode)); } break; case 17: /* Line 690 of lalr1.cc */ #line 155 "parser.yy" { (yyval.querynode) = new query_or((yysemantic_stack_[(3) - (1)].querynode), (yysemantic_stack_[(3) - (3)].querynode)); } break; case 18: /* Line 690 of lalr1.cc */ #line 159 "parser.yy" { (yyval.querynode) = new query_not((yysemantic_stack_[(2) - (2)].querynode)); } break; case 19: /* Line 690 of lalr1.cc */ #line 163 "parser.yy" { (yyval.querynode) = (yysemantic_stack_[(1) - (1)].querynode); } break; case 20: /* Line 690 of lalr1.cc */ #line 168 "parser.yy" { driver.query.set_expression((yysemantic_stack_[(1) - (1)].querynode)); } break; case 21: /* Line 690 of lalr1.cc */ #line 172 "parser.yy" { driver.query.set_expression((yysemantic_stack_[(1) - (1)].querynode)); } break; /* Line 690 of lalr1.cc */ #line 653 "parser.cpp" default: break; } /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. One alternative is translating here after every semantic action, but that translation would be missed if the semantic action invokes YYABORT, YYACCEPT, or YYERROR immediately after altering yychar. In the case of YYABORT or YYACCEPT, an incorrect destructor might then be invoked immediately. In the case of YYERROR, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); yypop_ (yylen); yylen = 0; YY_STACK_PRINT (); yysemantic_stack_.push (yyval); yylocation_stack_.push (yyloc); /* Shift the result of the reduction. */ yyn = yyr1_[yyn]; yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0]; if (0 <= yystate && yystate <= yylast_ && yycheck_[yystate] == yystate_stack_[0]) yystate = yytable_[yystate]; else yystate = yydefgoto_[yyn - yyntokens_]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = yytranslate_ (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus_) { ++yynerrs_; if (yychar == yyempty_) yytoken = yyempty_; error (yylloc, yysyntax_error_ (yystate, yytoken)); } yyerror_range[1] = yylloc; if (yyerrstatus_ == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= yyeof_) { /* Return failure if at end of input. */ if (yychar == yyeof_) YYABORT; } else { yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); yychar = yyempty_; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (false) goto yyerrorlab; yyerror_range[1] = yylocation_stack_[yylen - 1]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ yypop_ (yylen); yylen = 0; yystate = yystate_stack_[0]; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus_ = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact_[yystate]; if (!yy_pact_value_is_default_ (yyn)) { yyn += yyterror_; if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) { yyn = yytable_[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yystate_stack_.height () == 1) YYABORT; yyerror_range[1] = yylocation_stack_[0]; yydestruct_ ("Error: popping", yystos_[yystate], &yysemantic_stack_[0], &yylocation_stack_[0]); yypop_ (); yystate = yystate_stack_[0]; YY_STACK_PRINT (); } yyerror_range[2] = yylloc; // Using YYLLOC is tempting, but would change the location of // the lookahead. YYLOC is available though. YYLLOC_DEFAULT (yyloc, yyerror_range, 2); yysemantic_stack_.push (yylval); yylocation_stack_.push (yyloc); /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], &yysemantic_stack_[0], &yylocation_stack_[0]); yystate = yyn; goto yynewstate; /* Accept. */ yyacceptlab: yyresult = 0; goto yyreturn; /* Abort. */ yyabortlab: yyresult = 1; goto yyreturn; yyreturn: if (yychar != yyempty_) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = yytranslate_ (yychar); yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); } /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ yypop_ (yylen); while (yystate_stack_.height () != 1) { yydestruct_ ("Cleanup: popping", yystos_[yystate_stack_[0]], &yysemantic_stack_[0], &yylocation_stack_[0]); yypop_ (); } return yyresult; }