00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #define yylex examplelex
00037
00038
00039
00040
00041 #line 4 "parser.yy"
00042
00043
00044 #include <stdio.h>
00045 #include <string>
00046 #include <vector>
00047
00048 #include "expression.h"
00049
00050
00051
00052
00053 #line 54 "parser.cc"
00054
00055
00056 #include "y.tab.h"
00057
00058
00059
00060
00061 #line 78 "parser.yy"
00062
00063
00064 #include "driver.h"
00065 #include "scanner.h"
00066
00067
00068
00069
00070 #undef yylex
00071 #define yylex driver.lexer->lex
00072
00073
00074
00075
00076 #line 77 "parser.cc"
00077
00078 #ifndef YY_
00079 # if YYENABLE_NLS
00080 # if ENABLE_NLS
00081 # include <libintl.h>
00082 # define YY_(msgid) dgettext ("bison-runtime", msgid)
00083 # endif
00084 # endif
00085 # ifndef YY_
00086 # define YY_(msgid) msgid
00087 # endif
00088 #endif
00089
00090
00091 #define YYUSE(e) ((void) (e))
00092
00093
00094 #if YYDEBUG
00095
00096
00097 # define YYCDEBUG if (yydebug_) (*yycdebug_)
00098
00099 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
00100 do { \
00101 if (yydebug_) \
00102 { \
00103 *yycdebug_ << Title << ' '; \
00104 yy_symbol_print_ ((Type), (Value), (Location)); \
00105 *yycdebug_ << std::endl; \
00106 } \
00107 } while (false)
00108
00109 # define YY_REDUCE_PRINT(Rule) \
00110 do { \
00111 if (yydebug_) \
00112 yy_reduce_print_ (Rule); \
00113 } while (false)
00114
00115 # define YY_STACK_PRINT() \
00116 do { \
00117 if (yydebug_) \
00118 yystack_print_ (); \
00119 } while (false)
00120
00121 #else
00122
00123 # define YYCDEBUG if (false) std::cerr
00124 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
00125 # define YY_REDUCE_PRINT(Rule)
00126 # define YY_STACK_PRINT()
00127
00128 #endif
00129
00130 #define yyerrok (yyerrstatus_ = 0)
00131 #define yyclearin (yychar = yyempty_)
00132
00133 #define YYACCEPT goto yyacceptlab
00134 #define YYABORT goto yyabortlab
00135 #define YYERROR goto yyerrorlab
00136 #define YYRECOVERING() (!!yyerrstatus_)
00137
00138
00139
00140 #line 1 "[Bison:b4_percent_define_default]"
00141
00142 namespace example {
00143
00144
00145 #line 146 "parser.cc"
00146 #if YYERROR_VERBOSE
00147
00148
00149
00150
00151
00152
00153 std::string
00154 Parser::yytnamerr_ (const char *yystr)
00155 {
00156 if (*yystr == '"')
00157 {
00158 std::string yyr = "";
00159 char const *yyp = yystr;
00160
00161 for (;;)
00162 switch (*++yyp)
00163 {
00164 case '\'':
00165 case ',':
00166 goto do_not_strip_quotes;
00167
00168 case '\\':
00169 if (*++yyp != '\\')
00170 goto do_not_strip_quotes;
00171
00172 default:
00173 yyr += *yyp;
00174 break;
00175
00176 case '"':
00177 return yyr;
00178 }
00179 do_not_strip_quotes: ;
00180 }
00181
00182 return yystr;
00183 }
00184
00185 #endif
00186
00188 Parser::Parser (class Driver& driver_yyarg)
00189 :
00190 #if YYDEBUG
00191 yydebug_ (false),
00192 yycdebug_ (&std::cerr),
00193 #endif
00194 driver (driver_yyarg)
00195 {
00196 }
00197
00198 Parser::~Parser ()
00199 {
00200 }
00201
00202 #if YYDEBUG
00203
00204
00205
00206
00207 inline void
00208 Parser::yy_symbol_value_print_ (int yytype,
00209 const semantic_type* yyvaluep, const location_type* yylocationp)
00210 {
00211 YYUSE (yylocationp);
00212 YYUSE (yyvaluep);
00213 switch (yytype)
00214 {
00215 default:
00216 break;
00217 }
00218 }
00219
00220
00221 void
00222 Parser::yy_symbol_print_ (int yytype,
00223 const semantic_type* yyvaluep, const location_type* yylocationp)
00224 {
00225 *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")
00226 << ' ' << yytname_[yytype] << " ("
00227 << *yylocationp << ": ";
00228 yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
00229 *yycdebug_ << ')';
00230 }
00231 #endif
00232
00233 void
00234 Parser::yydestruct_ (const char* yymsg,
00235 int yytype, semantic_type* yyvaluep, location_type* yylocationp)
00236 {
00237 YYUSE (yylocationp);
00238 YYUSE (yymsg);
00239 YYUSE (yyvaluep);
00240
00241 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
00242
00243 switch (yytype)
00244 {
00245 case 6:
00246
00247
00248 #line 72 "parser.yy"
00249 { delete (yyvaluep->stringVal); };
00250
00251
00252 #line 253 "parser.cc"
00253 break;
00254 case 18:
00255
00256
00257 #line 73 "parser.yy"
00258 { delete (yyvaluep->calcnode); };
00259
00260
00261 #line 262 "parser.cc"
00262 break;
00263 case 19:
00264
00265
00266 #line 73 "parser.yy"
00267 { delete (yyvaluep->calcnode); };
00268
00269
00270 #line 271 "parser.cc"
00271 break;
00272 case 20:
00273
00274
00275 #line 74 "parser.yy"
00276 { delete (yyvaluep->calcnode); };
00277
00278
00279 #line 280 "parser.cc"
00280 break;
00281 case 21:
00282
00283
00284 #line 74 "parser.yy"
00285 { delete (yyvaluep->calcnode); };
00286
00287
00288 #line 289 "parser.cc"
00289 break;
00290 case 22:
00291
00292
00293 #line 74 "parser.yy"
00294 { delete (yyvaluep->calcnode); };
00295
00296
00297 #line 298 "parser.cc"
00298 break;
00299 case 23:
00300
00301
00302 #line 74 "parser.yy"
00303 { delete (yyvaluep->calcnode); };
00304
00305
00306 #line 307 "parser.cc"
00307 break;
00308 case 24:
00309
00310
00311 #line 74 "parser.yy"
00312 { delete (yyvaluep->calcnode); };
00313
00314
00315 #line 316 "parser.cc"
00316 break;
00317 case 25:
00318
00319
00320 #line 74 "parser.yy"
00321 { delete (yyvaluep->calcnode); };
00322
00323
00324 #line 325 "parser.cc"
00325 break;
00326
00327 default:
00328 break;
00329 }
00330 }
00331
00332 void
00333 Parser::yypop_ (unsigned int n)
00334 {
00335 yystate_stack_.pop (n);
00336 yysemantic_stack_.pop (n);
00337 yylocation_stack_.pop (n);
00338 }
00339
00340 #if YYDEBUG
00341 std::ostream&
00342 Parser::debug_stream () const
00343 {
00344 return *yycdebug_;
00345 }
00346
00347 void
00348 Parser::set_debug_stream (std::ostream& o)
00349 {
00350 yycdebug_ = &o;
00351 }
00352
00353
00354 Parser::debug_level_type
00355 Parser::debug_level () const
00356 {
00357 return yydebug_;
00358 }
00359
00360 void
00361 Parser::set_debug_level (debug_level_type l)
00362 {
00363 yydebug_ = l;
00364 }
00365 #endif
00366
00367 int
00368 Parser::parse ()
00369 {
00371 int yychar = yyempty_;
00372 int yytoken = 0;
00373
00374
00375 int yyn;
00376 int yylen = 0;
00377 int yystate = 0;
00378
00379
00380 int yynerrs_ = 0;
00381 int yyerrstatus_ = 0;
00382
00384 semantic_type yylval;
00386 location_type yylloc;
00388 location_type yyerror_range[2];
00389
00391 semantic_type yyval;
00393 location_type yyloc;
00394
00395 int yyresult;
00396
00397 YYCDEBUG << "Starting parse" << std::endl;
00398
00399
00400
00401
00402
00403 #line 41 "parser.yy"
00404 {
00405
00406 yylloc.begin.filename = yylloc.end.filename = &driver.streamname;
00407 }
00408
00409
00410 #line 411 "parser.cc"
00411
00412
00413
00414
00415
00416 yystate_stack_ = state_stack_type (0);
00417 yysemantic_stack_ = semantic_stack_type (0);
00418 yylocation_stack_ = location_stack_type (0);
00419 yysemantic_stack_.push (yylval);
00420 yylocation_stack_.push (yylloc);
00421
00422
00423 yynewstate:
00424 yystate_stack_.push (yystate);
00425 YYCDEBUG << "Entering state " << yystate << std::endl;
00426
00427
00428 if (yystate == yyfinal_)
00429 goto yyacceptlab;
00430
00431 goto yybackup;
00432
00433
00434 yybackup:
00435
00436
00437 yyn = yypact_[yystate];
00438 if (yyn == yypact_ninf_)
00439 goto yydefault;
00440
00441
00442 if (yychar == yyempty_)
00443 {
00444 YYCDEBUG << "Reading a token: ";
00445 yychar = yylex (&yylval, &yylloc);
00446 }
00447
00448
00449
00450 if (yychar <= yyeof_)
00451 {
00452 yychar = yytoken = yyeof_;
00453 YYCDEBUG << "Now at end of input." << std::endl;
00454 }
00455 else
00456 {
00457 yytoken = yytranslate_ (yychar);
00458 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
00459 }
00460
00461
00462
00463 yyn += yytoken;
00464 if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
00465 goto yydefault;
00466
00467
00468 yyn = yytable_[yyn];
00469 if (yyn <= 0)
00470 {
00471 if (yyn == 0 || yyn == yytable_ninf_)
00472 goto yyerrlab;
00473 yyn = -yyn;
00474 goto yyreduce;
00475 }
00476
00477
00478 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
00479
00480
00481 yychar = yyempty_;
00482
00483 yysemantic_stack_.push (yylval);
00484 yylocation_stack_.push (yylloc);
00485
00486
00487
00488 if (yyerrstatus_)
00489 --yyerrstatus_;
00490
00491 yystate = yyn;
00492 goto yynewstate;
00493
00494
00495
00496
00497 yydefault:
00498 yyn = yydefact_[yystate];
00499 if (yyn == 0)
00500 goto yyerrlab;
00501 goto yyreduce;
00502
00503
00504
00505
00506 yyreduce:
00507 yylen = yyr2_[yyn];
00508
00509
00510
00511
00512
00513
00514 if (yylen)
00515 yyval = yysemantic_stack_[yylen - 1];
00516 else
00517 yyval = yysemantic_stack_[0];
00518
00519 {
00520 slice<location_type, location_stack_type> slice (yylocation_stack_, yylen);
00521 YYLLOC_DEFAULT (yyloc, slice, yylen);
00522 }
00523 YY_REDUCE_PRINT (yyn);
00524 switch (yyn)
00525 {
00526 case 2:
00527
00528
00529 #line 96 "parser.yy"
00530 {
00531 (yyval.calcnode) = new CNConstant((yysemantic_stack_[(1) - (1)].integerVal));
00532 }
00533 break;
00534
00535 case 3:
00536
00537
00538 #line 100 "parser.yy"
00539 {
00540 (yyval.calcnode) = new CNConstant((yysemantic_stack_[(1) - (1)].doubleVal));
00541 }
00542 break;
00543
00544 case 4:
00545
00546
00547 #line 105 "parser.yy"
00548 {
00549 if (!driver.calc.existsVariable(*(yysemantic_stack_[(1) - (1)].stringVal))) {
00550 error(yyloc, std::string("Unknown variable \"") + *(yysemantic_stack_[(1) - (1)].stringVal) + "\"");
00551 delete (yysemantic_stack_[(1) - (1)].stringVal);
00552 YYERROR;
00553 }
00554 else {
00555 (yyval.calcnode) = new CNConstant( driver.calc.getVariable(*(yysemantic_stack_[(1) - (1)].stringVal)) );
00556 delete (yysemantic_stack_[(1) - (1)].stringVal);
00557 }
00558 }
00559 break;
00560
00561 case 5:
00562
00563
00564 #line 118 "parser.yy"
00565 {
00566 (yyval.calcnode) = (yysemantic_stack_[(1) - (1)].calcnode);
00567 }
00568 break;
00569
00570 case 6:
00571
00572
00573 #line 122 "parser.yy"
00574 {
00575 (yyval.calcnode) = (yysemantic_stack_[(1) - (1)].calcnode);
00576 }
00577 break;
00578
00579 case 7:
00580
00581
00582 #line 126 "parser.yy"
00583 {
00584 (yyval.calcnode) = (yysemantic_stack_[(3) - (2)].calcnode);
00585 }
00586 break;
00587
00588 case 8:
00589
00590
00591 #line 131 "parser.yy"
00592 {
00593 (yyval.calcnode) = (yysemantic_stack_[(1) - (1)].calcnode);
00594 }
00595 break;
00596
00597 case 9:
00598
00599
00600 #line 135 "parser.yy"
00601 {
00602 (yyval.calcnode) = new CNPower((yysemantic_stack_[(3) - (1)].calcnode), (yysemantic_stack_[(3) - (3)].calcnode));
00603 }
00604 break;
00605
00606 case 10:
00607
00608
00609 #line 140 "parser.yy"
00610 {
00611 (yyval.calcnode) = (yysemantic_stack_[(1) - (1)].calcnode);
00612 }
00613 break;
00614
00615 case 11:
00616
00617
00618 #line 144 "parser.yy"
00619 {
00620 (yyval.calcnode) = (yysemantic_stack_[(2) - (2)].calcnode);
00621 }
00622 break;
00623
00624 case 12:
00625
00626
00627 #line 148 "parser.yy"
00628 {
00629 (yyval.calcnode) = new CNNegate((yysemantic_stack_[(2) - (2)].calcnode));
00630 }
00631 break;
00632
00633 case 13:
00634
00635
00636 #line 153 "parser.yy"
00637 {
00638 (yyval.calcnode) = (yysemantic_stack_[(1) - (1)].calcnode);
00639 }
00640 break;
00641
00642 case 14:
00643
00644
00645 #line 157 "parser.yy"
00646 {
00647 (yyval.calcnode) = new CNMultiply((yysemantic_stack_[(3) - (1)].calcnode), (yysemantic_stack_[(3) - (3)].calcnode));
00648 }
00649 break;
00650
00651 case 15:
00652
00653
00654 #line 161 "parser.yy"
00655 {
00656 (yyval.calcnode) = new CNDivide((yysemantic_stack_[(3) - (1)].calcnode), (yysemantic_stack_[(3) - (3)].calcnode));
00657 }
00658 break;
00659
00660 case 16:
00661
00662
00663 #line 165 "parser.yy"
00664 {
00665 (yyval.calcnode) = new CNModulo((yysemantic_stack_[(3) - (1)].calcnode), (yysemantic_stack_[(3) - (3)].calcnode));
00666 }
00667 break;
00668
00669 case 17:
00670
00671
00672 #line 170 "parser.yy"
00673 {
00674 (yyval.calcnode) = (yysemantic_stack_[(1) - (1)].calcnode);
00675 }
00676 break;
00677
00678 case 18:
00679
00680
00681 #line 174 "parser.yy"
00682 {
00683 (yyval.calcnode) = new CNAdd((yysemantic_stack_[(3) - (1)].calcnode), (yysemantic_stack_[(3) - (3)].calcnode));
00684 }
00685 break;
00686
00687 case 19:
00688
00689
00690 #line 178 "parser.yy"
00691 {
00692 (yyval.calcnode) = new CNSubtract((yysemantic_stack_[(3) - (1)].calcnode), (yysemantic_stack_[(3) - (3)].calcnode));
00693 }
00694 break;
00695
00696 case 20:
00697
00698
00699 #line 183 "parser.yy"
00700 {
00701 (yyval.calcnode) = (yysemantic_stack_[(1) - (1)].calcnode);
00702 }
00703 break;
00704
00705 case 21:
00706
00707
00708 #line 188 "parser.yy"
00709 {
00710 driver.calc.variables[*(yysemantic_stack_[(3) - (1)].stringVal)] = (yysemantic_stack_[(3) - (3)].calcnode)->evaluate();
00711 std::cout << "Setting variable " << *(yysemantic_stack_[(3) - (1)].stringVal)
00712 << " = " << driver.calc.variables[*(yysemantic_stack_[(3) - (1)].stringVal)] << "\n";
00713 delete (yysemantic_stack_[(3) - (1)].stringVal);
00714 delete (yysemantic_stack_[(3) - (3)].calcnode);
00715 }
00716 break;
00717
00718 case 28:
00719
00720
00721 #line 203 "parser.yy"
00722 {
00723 driver.calc.expressions.push_back((yysemantic_stack_[(3) - (2)].calcnode));
00724 }
00725 break;
00726
00727 case 29:
00728
00729
00730 #line 207 "parser.yy"
00731 {
00732 driver.calc.expressions.push_back((yysemantic_stack_[(3) - (2)].calcnode));
00733 }
00734 break;
00735
00736 case 30:
00737
00738
00739 #line 211 "parser.yy"
00740 {
00741 driver.calc.expressions.push_back((yysemantic_stack_[(3) - (2)].calcnode));
00742 }
00743 break;
00744
00745
00746
00747
00748 #line 749 "parser.cc"
00749 default:
00750 break;
00751 }
00752 YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
00753
00754 yypop_ (yylen);
00755 yylen = 0;
00756 YY_STACK_PRINT ();
00757
00758 yysemantic_stack_.push (yyval);
00759 yylocation_stack_.push (yyloc);
00760
00761
00762 yyn = yyr1_[yyn];
00763 yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0];
00764 if (0 <= yystate && yystate <= yylast_
00765 && yycheck_[yystate] == yystate_stack_[0])
00766 yystate = yytable_[yystate];
00767 else
00768 yystate = yydefgoto_[yyn - yyntokens_];
00769 goto yynewstate;
00770
00771
00772
00773
00774 yyerrlab:
00775
00776 if (!yyerrstatus_)
00777 {
00778 ++yynerrs_;
00779 error (yylloc, yysyntax_error_ (yystate, yytoken));
00780 }
00781
00782 yyerror_range[0] = yylloc;
00783 if (yyerrstatus_ == 3)
00784 {
00785
00786
00787
00788 if (yychar <= yyeof_)
00789 {
00790
00791 if (yychar == yyeof_)
00792 YYABORT;
00793 }
00794 else
00795 {
00796 yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc);
00797 yychar = yyempty_;
00798 }
00799 }
00800
00801
00802
00803 goto yyerrlab1;
00804
00805
00806
00807
00808
00809 yyerrorlab:
00810
00811
00812
00813
00814 if (false)
00815 goto yyerrorlab;
00816
00817 yyerror_range[0] = yylocation_stack_[yylen - 1];
00818
00819
00820 yypop_ (yylen);
00821 yylen = 0;
00822 yystate = yystate_stack_[0];
00823 goto yyerrlab1;
00824
00825
00826
00827
00828 yyerrlab1:
00829 yyerrstatus_ = 3;
00830
00831 for (;;)
00832 {
00833 yyn = yypact_[yystate];
00834 if (yyn != yypact_ninf_)
00835 {
00836 yyn += yyterror_;
00837 if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
00838 {
00839 yyn = yytable_[yyn];
00840 if (0 < yyn)
00841 break;
00842 }
00843 }
00844
00845
00846 if (yystate_stack_.height () == 1)
00847 YYABORT;
00848
00849 yyerror_range[0] = yylocation_stack_[0];
00850 yydestruct_ ("Error: popping",
00851 yystos_[yystate],
00852 &yysemantic_stack_[0], &yylocation_stack_[0]);
00853 yypop_ ();
00854 yystate = yystate_stack_[0];
00855 YY_STACK_PRINT ();
00856 }
00857
00858 yyerror_range[1] = yylloc;
00859
00860
00861 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
00862 yysemantic_stack_.push (yylval);
00863 yylocation_stack_.push (yyloc);
00864
00865
00866 YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],
00867 &yysemantic_stack_[0], &yylocation_stack_[0]);
00868
00869 yystate = yyn;
00870 goto yynewstate;
00871
00872
00873 yyacceptlab:
00874 yyresult = 0;
00875 goto yyreturn;
00876
00877
00878 yyabortlab:
00879 yyresult = 1;
00880 goto yyreturn;
00881
00882 yyreturn:
00883 if (yychar != yyempty_)
00884 yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
00885
00886
00887
00888 yypop_ (yylen);
00889 while (yystate_stack_.height () != 1)
00890 {
00891 yydestruct_ ("Cleanup: popping",
00892 yystos_[yystate_stack_[0]],
00893 &yysemantic_stack_[0],
00894 &yylocation_stack_[0]);
00895 yypop_ ();
00896 }
00897
00898 return yyresult;
00899 }
00900
00901
00902 std::string
00903 Parser::yysyntax_error_ (int yystate, int tok)
00904 {
00905 std::string res;
00906 YYUSE (yystate);
00907 #if YYERROR_VERBOSE
00908 int yyn = yypact_[yystate];
00909 if (yypact_ninf_ < yyn && yyn <= yylast_)
00910 {
00911
00912
00913 int yyxbegin = yyn < 0 ? -yyn : 0;
00914
00915
00916 int yychecklim = yylast_ - yyn + 1;
00917 int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
00918 int count = 0;
00919 for (int x = yyxbegin; x < yyxend; ++x)
00920 if (yycheck_[x + yyn] == x && x != yyterror_)
00921 ++count;
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931 res = "syntax error, unexpected ";
00932 res += yytnamerr_ (yytname_[tok]);
00933 if (count < 5)
00934 {
00935 count = 0;
00936 for (int x = yyxbegin; x < yyxend; ++x)
00937 if (yycheck_[x + yyn] == x && x != yyterror_)
00938 {
00939 res += (!count++) ? ", expecting " : " or ";
00940 res += yytnamerr_ (yytname_[x]);
00941 }
00942 }
00943 }
00944 else
00945 #endif
00946 res = YY_("syntax error");
00947 return res;
00948 }
00949
00950
00951
00952
00953 const signed char Parser::yypact_ninf_ = -9;
00954 const signed char
00955 Parser::yypact_[] =
00956 {
00957 -9, 2, -9, -9, -9, -9, 0, 24, 32, 32,
00958 -9, -9, -9, 31, -9, -9, 8, -7, 11, 16,
00959 24, -9, 25, -9, -9, 32, 24, 24, 24, 24,
00960 24, -9, -9, -9, -9, -9, -9, -9, -9, -9,
00961 -9, -9, -9, 8, 8
00962 };
00963
00964
00965
00966
00967 const unsigned char
00968 Parser::yydefact_[] =
00969 {
00970 22, 0, 1, 24, 2, 3, 4, 0, 0, 0,
00971 23, 5, 6, 8, 10, 13, 17, 20, 0, 0,
00972 0, 4, 0, 11, 12, 0, 0, 0, 0, 0,
00973 0, 30, 29, 28, 27, 26, 25, 21, 7, 9,
00974 14, 15, 16, 18, 19
00975 };
00976
00977
00978 const signed char
00979 Parser::yypgoto_[] =
00980 {
00981 -9, -9, -9, -9, -8, -2, 12, -9, 3, -9,
00982 -9
00983 };
00984
00985
00986 const signed char
00987 Parser::yydefgoto_[] =
00988 {
00989 -1, 11, 12, 13, 14, 15, 16, 17, 18, 19,
00990 1
00991 };
00992
00993
00994
00995
00996 const signed char Parser::yytable_ninf_ = -1;
00997 const unsigned char
00998 Parser::yytable_[] =
00999 {
01000 23, 24, 2, 29, 30, 3, 4, 5, 6, 7,
01001 22, 31, 8, 9, 32, 20, 34, 39, 10, 35,
01002 26, 27, 28, 37, 40, 41, 42, 33, 4, 5,
01003 21, 7, 36, 38, 8, 9, 4, 5, 21, 7,
01004 25, 43, 44
01005 };
01006
01007
01008 const unsigned char
01009 Parser::yycheck_[] =
01010 {
01011 8, 9, 0, 10, 11, 3, 4, 5, 6, 7,
01012 7, 0, 10, 11, 3, 15, 0, 25, 16, 3,
01013 12, 13, 14, 20, 26, 27, 28, 16, 4, 5,
01014 6, 7, 16, 8, 10, 11, 4, 5, 6, 7,
01015 9, 29, 30
01016 };
01017
01018
01019
01020 const unsigned char
01021 Parser::yystos_[] =
01022 {
01023 0, 27, 0, 3, 4, 5, 6, 7, 10, 11,
01024 16, 18, 19, 20, 21, 22, 23, 24, 25, 26,
01025 15, 6, 25, 21, 21, 9, 12, 13, 14, 10,
01026 11, 0, 3, 16, 0, 3, 16, 25, 8, 21,
01027 22, 22, 22, 23, 23
01028 };
01029
01030 #if YYDEBUG
01031
01032
01033 const unsigned short int
01034 Parser::yytoken_number_[] =
01035 {
01036 0, 256, 257, 258, 259, 260, 261, 40, 41, 94,
01037 43, 45, 42, 47, 37, 61, 59
01038 };
01039 #endif
01040
01041
01042 const unsigned char
01043 Parser::yyr1_[] =
01044 {
01045 0, 17, 18, 18, 19, 20, 20, 20, 21, 21,
01046 22, 22, 22, 23, 23, 23, 23, 24, 24, 24,
01047 25, 26, 27, 27, 27, 27, 27, 27, 27, 27,
01048 27
01049 };
01050
01051
01052 const unsigned char
01053 Parser::yyr2_[] =
01054 {
01055 0, 2, 1, 1, 1, 1, 1, 3, 1, 3,
01056 1, 2, 2, 1, 3, 3, 3, 1, 3, 3,
01057 1, 3, 0, 2, 2, 3, 3, 3, 3, 3,
01058 3
01059 };
01060
01061 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
01062
01063
01064 const char*
01065 const Parser::yytname_[] =
01066 {
01067 "\"end of file\"", "error", "$undefined", "\"end of line\"",
01068 "\"integer\"", "\"double\"", "\"string\"", "'('", "')'", "'^'", "'+'",
01069 "'-'", "'*'", "'/'", "'%'", "'='", "';'", "$accept", "constant",
01070 "variable", "atomexpr", "powexpr", "unaryexpr", "mulexpr", "addexpr",
01071 "expr", "assignment", "start", 0
01072 };
01073 #endif
01074
01075 #if YYDEBUG
01076
01077 const Parser::rhs_number_type
01078 Parser::yyrhs_[] =
01079 {
01080 27, 0, -1, 4, -1, 5, -1, 6, -1, 18,
01081 -1, 19, -1, 7, 25, 8, -1, 20, -1, 20,
01082 9, 21, -1, 21, -1, 10, 21, -1, 11, 21,
01083 -1, 22, -1, 23, 12, 22, -1, 23, 13, 22,
01084 -1, 23, 14, 22, -1, 23, -1, 24, 10, 23,
01085 -1, 24, 11, 23, -1, 24, -1, 6, 15, 25,
01086 -1, -1, 27, 16, -1, 27, 3, -1, 27, 26,
01087 16, -1, 27, 26, 3, -1, 27, 26, 0, -1,
01088 27, 25, 16, -1, 27, 25, 3, -1, 27, 25,
01089 0, -1
01090 };
01091
01092
01093
01094 const unsigned char
01095 Parser::yyprhs_[] =
01096 {
01097 0, 0, 3, 5, 7, 9, 11, 13, 17, 19,
01098 23, 25, 28, 31, 33, 37, 41, 45, 47, 51,
01099 55, 57, 61, 62, 65, 68, 72, 76, 80, 84,
01100 88
01101 };
01102
01103
01104 const unsigned char
01105 Parser::yyrline_[] =
01106 {
01107 0, 95, 95, 99, 104, 117, 121, 125, 130, 134,
01108 139, 143, 147, 152, 156, 160, 164, 169, 173, 177,
01109 182, 187, 196, 197, 198, 199, 200, 201, 202, 206,
01110 210
01111 };
01112
01113
01114 void
01115 Parser::yystack_print_ ()
01116 {
01117 *yycdebug_ << "Stack now";
01118 for (state_stack_type::const_iterator i = yystate_stack_.begin ();
01119 i != yystate_stack_.end (); ++i)
01120 *yycdebug_ << ' ' << *i;
01121 *yycdebug_ << std::endl;
01122 }
01123
01124
01125 void
01126 Parser::yy_reduce_print_ (int yyrule)
01127 {
01128 unsigned int yylno = yyrline_[yyrule];
01129 int yynrhs = yyr2_[yyrule];
01130
01131 *yycdebug_ << "Reducing stack by rule " << yyrule - 1
01132 << " (line " << yylno << "):" << std::endl;
01133
01134 for (int yyi = 0; yyi < yynrhs; yyi++)
01135 YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
01136 yyrhs_[yyprhs_[yyrule] + yyi],
01137 &(yysemantic_stack_[(yynrhs) - (yyi + 1)]),
01138 &(yylocation_stack_[(yynrhs) - (yyi + 1)]));
01139 }
01140 #endif // YYDEBUG
01141
01142
01143 Parser::token_number_type
01144 Parser::yytranslate_ (int t)
01145 {
01146 static
01147 const token_number_type
01148 translate_table[] =
01149 {
01150 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01151 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01152 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01153 2, 2, 2, 2, 2, 2, 2, 14, 2, 2,
01154 7, 8, 12, 10, 2, 11, 2, 13, 2, 2,
01155 2, 2, 2, 2, 2, 2, 2, 2, 2, 16,
01156 2, 15, 2, 2, 2, 2, 2, 2, 2, 2,
01157 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01158 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01159 2, 2, 2, 2, 9, 2, 2, 2, 2, 2,
01160 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01161 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01162 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01163 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01164 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01165 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01166 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01167 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01168 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01169 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01170 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01171 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01172 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01173 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01174 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
01175 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
01176 5, 6
01177 };
01178 if ((unsigned int) t <= yyuser_token_number_max_)
01179 return translate_table[t];
01180 else
01181 return yyundef_token_;
01182 }
01183
01184 const int Parser::yyeof_ = 0;
01185 const int Parser::yylast_ = 42;
01186 const int Parser::yynnts_ = 11;
01187 const int Parser::yyempty_ = -2;
01188 const int Parser::yyfinal_ = 2;
01189 const int Parser::yyterror_ = 1;
01190 const int Parser::yyerrcode_ = 256;
01191 const int Parser::yyntokens_ = 17;
01192
01193 const unsigned int Parser::yyuser_token_number_max_ = 261;
01194 const Parser::token_number_type Parser::yyundef_token_ = 2;
01195
01196
01197
01198 #line 1 "[Bison:b4_percent_define_default]"
01199
01200 }
01201
01202
01203 #line 1204 "parser.cc"
01204
01205
01206
01207 #line 217 "parser.yy"
01208
01209
01210 void example::Parser::error(const Parser::location_type& l,
01211 const std::string& m)
01212 {
01213 driver.error(l, m);
01214 }
01215