1 /* A Bison parser, made by GNU Bison 2.5. */ 2 3 /* Skeleton implementation for Bison LALR(1) parsers in C++ 4 5 Copyright (C) 2002-2011 Free Software Foundation, Inc. 6 7 This program is free software: you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation, either version 3 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19 20 /* As a special exception, you may create a larger work that contains 21 part or all of the Bison parser skeleton and distribute that work 22 under terms of your choice, so long as that work isn't itself a 23 parser generator using the skeleton or a modified version thereof 24 as a parser skeleton. Alternatively, if you modify or redistribute 25 the parser skeleton itself, you may (at your option) remove this 26 special exception, which will cause the skeleton and the resulting 27 Bison output files to be licensed under the GNU General Public 28 License without this special exception. 29 30 This special exception was added by the Free Software Foundation in 31 version 2.2 of Bison. */ 32 33 34 /* First part of user declarations. */ 35 36 37 /* Line 293 of lalr1.cc */ 38 #line 39 "js_parser.tab.cc" 39 40 41 #include "js_parser.tab.hh" 42 43 /* User implementation prologue. */ 44 45 /* Line 299 of lalr1.cc */ 46 #line 52 "js_parser.yy" 47 48 extern int yylex(yy::JSCacheParser::semantic_type *yylval,yy::JSCacheParser::location_type *yylloc); 49 50 51 /* Line 299 of lalr1.cc */ 52 #line 53 "js_parser.tab.cc" 53 54 #ifndef YY_ 55 # if defined YYENABLE_NLS && YYENABLE_NLS 56 # if ENABLE_NLS 57 # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */ 58 # define YY_(msgid) dgettext ("bison-runtime", msgid) 59 # endif 60 # endif 61 # ifndef YY_ 62 # define YY_(msgid) msgid 63 # endif 64 #endif 65 66 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. 67 If N is 0, then set CURRENT to the empty location which ends 68 the previous symbol: RHS[0] (always defined). */ 69 70 #define YYRHSLOC(Rhs, K) ((Rhs)[K]) 71 #ifndef YYLLOC_DEFAULT 72 # define YYLLOC_DEFAULT(Current, Rhs, N) \ 73 do \ 74 if (N) \ 75 { \ 76 (Current).begin = YYRHSLOC (Rhs, 1).begin; \ 77 (Current).end = YYRHSLOC (Rhs, N).end; \ 78 } \ 79 else \ 80 { \ 81 (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ 82 } \ 83 while (false) 84 #endif 85 86 /* Suppress unused-variable warnings by "using" E. */ 87 #define YYUSE(e) ((void) (e)) 88 89 /* Enable debugging if requested. */ 90 #if YYDEBUG 91 92 /* A pseudo ostream that takes yydebug_ into account. */ 93 # define YYCDEBUG if (yydebug_) (*yycdebug_) 94 95 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ 96 do { \ 97 if (yydebug_) \ 98 { \ 99 *yycdebug_ << Title << ' '; \ 100 yy_symbol_print_ ((Type), (Value), (Location)); \ 101 *yycdebug_ << std::endl; \ 102 } \ 103 } while (false) 104 105 # define YY_REDUCE_PRINT(Rule) \ 106 do { \ 107 if (yydebug_) \ 108 yy_reduce_print_ (Rule); \ 109 } while (false) 110 111 # define YY_STACK_PRINT() \ 112 do { \ 113 if (yydebug_) \ 114 yystack_print_ (); \ 115 } while (false) 116 117 #else /* !YYDEBUG */ 118 119 # define YYCDEBUG if (false) std::cerr 120 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) 121 # define YY_REDUCE_PRINT(Rule) 122 # define YY_STACK_PRINT() 123 124 #endif /* !YYDEBUG */ 125 126 #define yyerrok (yyerrstatus_ = 0) 127 #define yyclearin (yychar = yyempty_) 128 129 #define YYACCEPT goto yyacceptlab 130 #define YYABORT goto yyabortlab 131 #define YYERROR goto yyerrorlab 132 #define YYRECOVERING() (!!yyerrstatus_) 133 134 135 namespace yy { 136 137 /* Line 382 of lalr1.cc */ 138 #line 139 "js_parser.tab.cc" 139 140 /// Build a parser object. JSCacheParser(JSSymbolsCache & symb_yyarg,QList<JSVarDescriptor> & tmp_yyarg)141 JSCacheParser::JSCacheParser (JSSymbolsCache& symb_yyarg, QList<JSVarDescriptor>& tmp_yyarg) 142 : 143 #if YYDEBUG 144 yydebug_ (false), 145 yycdebug_ (&std::cerr), 146 #endif 147 symb (symb_yyarg), 148 tmp (tmp_yyarg) 149 { 150 } 151 ~JSCacheParser()152 JSCacheParser::~JSCacheParser () 153 { 154 } 155 156 #if YYDEBUG 157 /*--------------------------------. 158 | Print this symbol on YYOUTPUT. | 159 `--------------------------------*/ 160 161 inline void yy_symbol_value_print_(int yytype,const semantic_type * yyvaluep,const location_type * yylocationp)162 JSCacheParser::yy_symbol_value_print_ (int yytype, 163 const semantic_type* yyvaluep, const location_type* yylocationp) 164 { 165 YYUSE (yylocationp); 166 YYUSE (yyvaluep); 167 switch (yytype) 168 { 169 default: 170 break; 171 } 172 } 173 174 175 void yy_symbol_print_(int yytype,const semantic_type * yyvaluep,const location_type * yylocationp)176 JSCacheParser::yy_symbol_print_ (int yytype, 177 const semantic_type* yyvaluep, const location_type* yylocationp) 178 { 179 *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm") 180 << ' ' << yytname_[yytype] << " (" 181 << *yylocationp << ": "; 182 yy_symbol_value_print_ (yytype, yyvaluep, yylocationp); 183 *yycdebug_ << ')'; 184 } 185 #endif 186 187 void yydestruct_(const char * yymsg,int yytype,semantic_type * yyvaluep,location_type * yylocationp)188 JSCacheParser::yydestruct_ (const char* yymsg, 189 int yytype, semantic_type* yyvaluep, location_type* yylocationp) 190 { 191 YYUSE (yylocationp); 192 YYUSE (yymsg); 193 YYUSE (yyvaluep); 194 195 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); 196 197 switch (yytype) 198 { 199 200 default: 201 break; 202 } 203 } 204 205 void yypop_(unsigned int n)206 JSCacheParser::yypop_ (unsigned int n) 207 { 208 yystate_stack_.pop (n); 209 yysemantic_stack_.pop (n); 210 yylocation_stack_.pop (n); 211 } 212 213 #if YYDEBUG 214 std::ostream& debug_stream() const215 JSCacheParser::debug_stream () const 216 { 217 return *yycdebug_; 218 } 219 220 void set_debug_stream(std::ostream & o)221 JSCacheParser::set_debug_stream (std::ostream& o) 222 { 223 yycdebug_ = &o; 224 } 225 226 227 JSCacheParser::debug_level_type debug_level() const228 JSCacheParser::debug_level () const 229 { 230 return yydebug_; 231 } 232 233 void set_debug_level(debug_level_type l)234 JSCacheParser::set_debug_level (debug_level_type l) 235 { 236 yydebug_ = l; 237 } 238 #endif 239 240 inline bool yy_pact_value_is_default_(int yyvalue)241 JSCacheParser::yy_pact_value_is_default_ (int yyvalue) 242 { 243 return yyvalue == yypact_ninf_; 244 } 245 246 inline bool yy_table_value_is_error_(int yyvalue)247 JSCacheParser::yy_table_value_is_error_ (int yyvalue) 248 { 249 return yyvalue == yytable_ninf_; 250 } 251 252 int parse()253 JSCacheParser::parse () 254 { 255 /// Lookahead and lookahead in internal form. 256 int yychar = yyempty_; 257 int yytoken = 0; 258 259 /* State. */ 260 int yyn; 261 int yylen = 0; 262 int yystate = 0; 263 264 /* Error handling. */ 265 int yynerrs_ = 0; 266 int yyerrstatus_ = 0; 267 268 /// Semantic value of the lookahead. 269 semantic_type yylval; 270 /// Location of the lookahead. 271 location_type yylloc; 272 /// The locations where the error started and ended. 273 location_type yyerror_range[3]; 274 275 /// $$. 276 semantic_type yyval; 277 /// @$. 278 location_type yyloc; 279 280 int yyresult; 281 282 YYCDEBUG << "Starting parse" << std::endl; 283 284 285 /* Initialize the stacks. The initial state will be pushed in 286 yynewstate, since the latter expects the semantical and the 287 location values to have been already stored, initialize these 288 stacks with a primary value. */ 289 yystate_stack_ = state_stack_type (0); 290 yysemantic_stack_ = semantic_stack_type (0); 291 yylocation_stack_ = location_stack_type (0); 292 yysemantic_stack_.push (yylval); 293 yylocation_stack_.push (yylloc); 294 295 /* New state. */ 296 yynewstate: 297 yystate_stack_.push (yystate); 298 YYCDEBUG << "Entering state " << yystate << std::endl; 299 300 /* Accept? */ 301 if (yystate == yyfinal_) 302 goto yyacceptlab; 303 304 goto yybackup; 305 306 /* Backup. */ 307 yybackup: 308 309 /* Try to take a decision without lookahead. */ 310 yyn = yypact_[yystate]; 311 if (yy_pact_value_is_default_ (yyn)) 312 goto yydefault; 313 314 /* Read a lookahead token. */ 315 if (yychar == yyempty_) 316 { 317 YYCDEBUG << "Reading a token: "; 318 yychar = yylex (&yylval, &yylloc); 319 } 320 321 322 /* Convert token to internal form. */ 323 if (yychar <= yyeof_) 324 { 325 yychar = yytoken = yyeof_; 326 YYCDEBUG << "Now at end of input." << std::endl; 327 } 328 else 329 { 330 yytoken = yytranslate_ (yychar); 331 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 332 } 333 334 /* If the proper action on seeing token YYTOKEN is to reduce or to 335 detect an error, take that action. */ 336 yyn += yytoken; 337 if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) 338 goto yydefault; 339 340 /* Reduce or error. */ 341 yyn = yytable_[yyn]; 342 if (yyn <= 0) 343 { 344 if (yy_table_value_is_error_ (yyn)) 345 goto yyerrlab; 346 yyn = -yyn; 347 goto yyreduce; 348 } 349 350 /* Shift the lookahead token. */ 351 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 352 353 /* Discard the token being shifted. */ 354 yychar = yyempty_; 355 356 yysemantic_stack_.push (yylval); 357 yylocation_stack_.push (yylloc); 358 359 /* Count tokens shifted since error; after three, turn off error 360 status. */ 361 if (yyerrstatus_) 362 --yyerrstatus_; 363 364 yystate = yyn; 365 goto yynewstate; 366 367 /*-----------------------------------------------------------. 368 | yydefault -- do the default action for the current state. | 369 `-----------------------------------------------------------*/ 370 yydefault: 371 yyn = yydefact_[yystate]; 372 if (yyn == 0) 373 goto yyerrlab; 374 goto yyreduce; 375 376 /*-----------------------------. 377 | yyreduce -- Do a reduction. | 378 `-----------------------------*/ 379 yyreduce: 380 yylen = yyr2_[yyn]; 381 /* If YYLEN is nonzero, implement the default value of the action: 382 `$$ = $1'. Otherwise, use the top of the stack. 383 384 Otherwise, the following line sets YYVAL to garbage. 385 This behavior is undocumented and Bison 386 users should not rely upon it. */ 387 if (yylen) 388 yyval = yysemantic_stack_[yylen - 1]; 389 else 390 yyval = yysemantic_stack_[0]; 391 392 { 393 slice<location_type, location_stack_type> slice (yylocation_stack_, yylen); 394 YYLLOC_DEFAULT (yyloc, slice, yylen); 395 } 396 YY_REDUCE_PRINT (yyn); 397 switch (yyn) 398 { 399 case 9: 400 401 /* Line 690 of lalr1.cc */ 402 #line 69 "js_parser.yy" 403 { 404 qDebug() << "Parsing Error Recovery!!!\n"; 405 } 406 break; 407 408 case 11: 409 410 /* Line 690 of lalr1.cc */ 411 #line 77 "js_parser.yy" 412 { 413 symb.pushFrame(); 414 } 415 break; 416 417 case 12: 418 419 /* Line 690 of lalr1.cc */ 420 #line 83 "js_parser.yy" 421 { 422 symb.popFrame(); 423 } 424 break; 425 426 case 13: 427 428 /* Line 690 of lalr1.cc */ 429 #line 89 "js_parser.yy" 430 { 431 JSVarDescriptor vd(*(yysemantic_stack_[(5) - (2)].s),(yysemantic_stack_[(5) - (3)].ftd)); 432 symb.currentFrame()[*(yysemantic_stack_[(5) - (2)].s)] = vd; 433 } 434 break; 435 436 case 14: 437 438 /* Line 690 of lalr1.cc */ 439 #line 96 "js_parser.yy" 440 { 441 442 } 443 break; 444 445 case 15: 446 447 /* Line 690 of lalr1.cc */ 448 #line 100 "js_parser.yy" 449 { 450 451 } 452 break; 453 454 case 20: 455 456 /* Line 690 of lalr1.cc */ 457 #line 114 "js_parser.yy" 458 { 459 (yyval.ftd) = (yysemantic_stack_[(2) - (2)].ftd); 460 } 461 break; 462 463 case 21: 464 465 /* Line 690 of lalr1.cc */ 466 #line 120 "js_parser.yy" 467 { 468 (yyval.ftd) = NULL; 469 } 470 break; 471 472 case 24: 473 474 /* Line 690 of lalr1.cc */ 475 #line 129 "js_parser.yy" 476 { 477 JSFunctionTypeDescriptor ftd(*(yysemantic_stack_[(6) - (2)].s)); 478 symb.globalFunType()[*(yysemantic_stack_[(6) - (2)].s)] = ftd; 479 } 480 break; 481 482 case 25: 483 484 /* Line 690 of lalr1.cc */ 485 #line 136 "js_parser.yy" 486 { 487 QString nm; 488 if (*(yysemantic_stack_[(5) - (2)].s) == "") 489 nm = QUuid::createUuid().toString(); 490 JSFunctionTypeDescriptor ftd(nm); 491 } 492 break; 493 494 case 27: 495 496 /* Line 690 of lalr1.cc */ 497 #line 146 "js_parser.yy" 498 { 499 symb.currentFrame()[*(yysemantic_stack_[(2) - (1)].s)] = JSVarDescriptor(*(yysemantic_stack_[(2) - (1)].s),NULL); 500 } 501 break; 502 503 case 29: 504 505 /* Line 690 of lalr1.cc */ 506 #line 153 "js_parser.yy" 507 { 508 symb.currentFrame()[*(yysemantic_stack_[(3) - (3)].s)] = JSVarDescriptor(*(yysemantic_stack_[(3) - (3)].s),NULL); 509 } 510 break; 511 512 case 30: 513 514 /* Line 690 of lalr1.cc */ 515 #line 159 "js_parser.yy" 516 { 517 (yyval.ftd) = NULL; 518 } 519 break; 520 521 case 31: 522 523 /* Line 690 of lalr1.cc */ 524 #line 163 "js_parser.yy" 525 { 526 (yyval.ftd) = NULL; 527 } 528 break; 529 530 case 32: 531 532 /* Line 690 of lalr1.cc */ 533 #line 167 "js_parser.yy" 534 { 535 536 (yyval.ftd) = (yysemantic_stack_[(1) - (1)].ftd); 537 } 538 break; 539 540 case 33: 541 542 /* Line 690 of lalr1.cc */ 543 #line 172 "js_parser.yy" 544 { 545 (yyval.ftd) = NULL; 546 } 547 break; 548 549 case 34: 550 551 /* Line 690 of lalr1.cc */ 552 #line 176 "js_parser.yy" 553 { 554 (yyval.ftd) = NULL; 555 } 556 break; 557 558 case 35: 559 560 /* Line 690 of lalr1.cc */ 561 #line 180 "js_parser.yy" 562 { 563 JSFunctionTypeDescriptor ftd(QUuid::createUuid().toString()); 564 for(int ii = 0;ii < tmp.size();++ii) 565 ftd.varmember[tmp[ii].name] = tmp[ii]; 566 tmp.clear(); 567 symb.globalFunType()[ftd.name] = ftd; 568 (yyval.ftd) = &symb.globalFunType()[ftd.name]; 569 } 570 break; 571 572 case 36: 573 574 /* Line 690 of lalr1.cc */ 575 #line 189 "js_parser.yy" 576 { 577 (yyval.ftd) = NULL; 578 } 579 break; 580 581 case 37: 582 583 /* Line 690 of lalr1.cc */ 584 #line 193 "js_parser.yy" 585 { 586 (yyval.ftd) = NULL; 587 } 588 break; 589 590 case 38: 591 592 /* Line 690 of lalr1.cc */ 593 #line 197 "js_parser.yy" 594 { 595 (yyval.ftd) = NULL; 596 } 597 break; 598 599 case 39: 600 601 /* Line 690 of lalr1.cc */ 602 #line 201 "js_parser.yy" 603 { 604 (yyval.ftd) = NULL; 605 } 606 break; 607 608 case 40: 609 610 /* Line 690 of lalr1.cc */ 611 #line 207 "js_parser.yy" 612 { 613 (yyval.s) = NULL; 614 } 615 break; 616 617 case 48: 618 619 /* Line 690 of lalr1.cc */ 620 #line 226 "js_parser.yy" 621 { 622 (yyval.ftd) = symb.getFunctionType(*(yysemantic_stack_[(5) - (2)].s)); 623 } 624 break; 625 626 case 49: 627 628 /* Line 690 of lalr1.cc */ 629 #line 233 "js_parser.yy" 630 { 631 632 633 } 634 break; 635 636 case 60: 637 638 /* Line 690 of lalr1.cc */ 639 #line 263 "js_parser.yy" 640 { 641 JSVarDescriptor vd(*(yysemantic_stack_[(6) - (2)].s),(yysemantic_stack_[(6) - (4)].ftd)); 642 tmp.push_back(vd); 643 } 644 break; 645 646 case 62: 647 648 /* Line 690 of lalr1.cc */ 649 #line 271 "js_parser.yy" 650 { 651 JSVarDescriptor vd(*(yysemantic_stack_[(5) - (3)].s),(yysemantic_stack_[(5) - (5)].ftd)); 652 tmp.push_back(vd); 653 } 654 break; 655 656 657 658 /* Line 690 of lalr1.cc */ 659 #line 660 "js_parser.tab.cc" 660 default: 661 break; 662 } 663 /* User semantic actions sometimes alter yychar, and that requires 664 that yytoken be updated with the new translation. We take the 665 approach of translating immediately before every use of yytoken. 666 One alternative is translating here after every semantic action, 667 but that translation would be missed if the semantic action 668 invokes YYABORT, YYACCEPT, or YYERROR immediately after altering 669 yychar. In the case of YYABORT or YYACCEPT, an incorrect 670 destructor might then be invoked immediately. In the case of 671 YYERROR, subsequent parser actions might lead to an incorrect 672 destructor call or verbose syntax error message before the 673 lookahead is translated. */ 674 YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); 675 676 yypop_ (yylen); 677 yylen = 0; 678 YY_STACK_PRINT (); 679 680 yysemantic_stack_.push (yyval); 681 yylocation_stack_.push (yyloc); 682 683 /* Shift the result of the reduction. */ 684 yyn = yyr1_[yyn]; 685 yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0]; 686 if (0 <= yystate && yystate <= yylast_ 687 && yycheck_[yystate] == yystate_stack_[0]) 688 yystate = yytable_[yystate]; 689 else 690 yystate = yydefgoto_[yyn - yyntokens_]; 691 goto yynewstate; 692 693 /*------------------------------------. 694 | yyerrlab -- here on detecting error | 695 `------------------------------------*/ 696 yyerrlab: 697 /* Make sure we have latest lookahead translation. See comments at 698 user semantic actions for why this is necessary. */ 699 yytoken = yytranslate_ (yychar); 700 701 /* If not already recovering from an error, report this error. */ 702 if (!yyerrstatus_) 703 { 704 ++yynerrs_; 705 if (yychar == yyempty_) 706 yytoken = yyempty_; 707 error (yylloc, yysyntax_error_ (yystate, yytoken)); 708 } 709 710 yyerror_range[1] = yylloc; 711 if (yyerrstatus_ == 3) 712 { 713 /* If just tried and failed to reuse lookahead token after an 714 error, discard it. */ 715 716 if (yychar <= yyeof_) 717 { 718 /* Return failure if at end of input. */ 719 if (yychar == yyeof_) 720 YYABORT; 721 } 722 else 723 { 724 yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); 725 yychar = yyempty_; 726 } 727 } 728 729 /* Else will try to reuse lookahead token after shifting the error 730 token. */ 731 goto yyerrlab1; 732 733 734 /*---------------------------------------------------. 735 | yyerrorlab -- error raised explicitly by YYERROR. | 736 `---------------------------------------------------*/ 737 yyerrorlab: 738 739 /* Pacify compilers like GCC when the user code never invokes 740 YYERROR and the label yyerrorlab therefore never appears in user 741 code. */ 742 if (false) 743 goto yyerrorlab; 744 745 yyerror_range[1] = yylocation_stack_[yylen - 1]; 746 /* Do not reclaim the symbols of the rule which action triggered 747 this YYERROR. */ 748 yypop_ (yylen); 749 yylen = 0; 750 yystate = yystate_stack_[0]; 751 goto yyerrlab1; 752 753 /*-------------------------------------------------------------. 754 | yyerrlab1 -- common code for both syntax error and YYERROR. | 755 `-------------------------------------------------------------*/ 756 yyerrlab1: 757 yyerrstatus_ = 3; /* Each real token shifted decrements this. */ 758 759 for (;;) 760 { 761 yyn = yypact_[yystate]; 762 if (!yy_pact_value_is_default_ (yyn)) 763 { 764 yyn += yyterror_; 765 if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) 766 { 767 yyn = yytable_[yyn]; 768 if (0 < yyn) 769 break; 770 } 771 } 772 773 /* Pop the current state because it cannot handle the error token. */ 774 if (yystate_stack_.height () == 1) 775 YYABORT; 776 777 yyerror_range[1] = yylocation_stack_[0]; 778 yydestruct_ ("Error: popping", 779 yystos_[yystate], 780 &yysemantic_stack_[0], &yylocation_stack_[0]); 781 yypop_ (); 782 yystate = yystate_stack_[0]; 783 YY_STACK_PRINT (); 784 } 785 786 yyerror_range[2] = yylloc; 787 // Using YYLLOC is tempting, but would change the location of 788 // the lookahead. YYLOC is available though. 789 YYLLOC_DEFAULT (yyloc, yyerror_range, 2); 790 yysemantic_stack_.push (yylval); 791 yylocation_stack_.push (yyloc); 792 793 /* Shift the error token. */ 794 YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], 795 &yysemantic_stack_[0], &yylocation_stack_[0]); 796 797 yystate = yyn; 798 goto yynewstate; 799 800 /* Accept. */ 801 yyacceptlab: 802 yyresult = 0; 803 goto yyreturn; 804 805 /* Abort. */ 806 yyabortlab: 807 yyresult = 1; 808 goto yyreturn; 809 810 yyreturn: 811 if (yychar != yyempty_) 812 { 813 /* Make sure we have latest lookahead translation. See comments 814 at user semantic actions for why this is necessary. */ 815 yytoken = yytranslate_ (yychar); 816 yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, 817 &yylloc); 818 } 819 820 /* Do not reclaim the symbols of the rule which action triggered 821 this YYABORT or YYACCEPT. */ 822 yypop_ (yylen); 823 while (yystate_stack_.height () != 1) 824 { 825 yydestruct_ ("Cleanup: popping", 826 yystos_[yystate_stack_[0]], 827 &yysemantic_stack_[0], 828 &yylocation_stack_[0]); 829 yypop_ (); 830 } 831 832 return yyresult; 833 } 834 835 // Generate an error message. 836 std::string yysyntax_error_(int,int)837 JSCacheParser::yysyntax_error_ (int, int) 838 { 839 return YY_("syntax error"); 840 } 841 842 843 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 844 STATE-NUM. */ 845 const signed char JSCacheParser::yypact_ninf_ = -46; 846 const signed char 847 JSCacheParser::yypact_[] = 848 { 849 -46, 17, 85, -46, 5, 32, -46, -46, -46, -46, 850 -46, -46, -46, -46, -46, -46, 32, -46, -46, 8, 851 37, 29, -46, -46, 40, 47, 37, 47, 32, 100, 852 42, 43, 32, -46, 32, -46, -46, -46, -46, -46, 853 -46, 32, -46, -46, -46, -46, -46, 2, -46, -46, 854 13, 40, 32, -46, -46, -46, -46, -46, 100, -46, 855 -46, 48, 45, -46, 3, 40, -46, -46, 60, 47, 856 100, 100, 40, -46, -46, 54, 62, 32, -46, 32, 857 100, -46, -46, 45, 45, 32, 28, -46, 32, 37, 858 45, -46, 67, -46, -46, -46, 45, 100, -46, -46, 859 -46, -46, -46, 11, 69, -46, -46, 32, -46, 32, 860 74, -46, 100, -46 861 }; 862 863 /* YYDEFACT[S] -- default reduction number in state S. Performed when 864 YYTABLE doesn't specify something else to do. Zero means the 865 default is an error. */ 866 const unsigned char 867 JSCacheParser::yydefact_[] = 868 { 869 3, 0, 0, 1, 0, 0, 46, 11, 45, 18, 870 19, 4, 5, 3, 7, 8, 0, 6, 3, 0, 871 0, 0, 42, 9, 0, 0, 21, 0, 0, 0, 872 0, 0, 0, 64, 26, 12, 10, 22, 16, 23, 873 43, 40, 66, 47, 38, 37, 39, 0, 3, 20, 874 30, 31, 0, 32, 33, 34, 35, 36, 0, 14, 875 15, 44, 0, 28, 0, 0, 41, 59, 0, 0, 876 0, 0, 0, 53, 65, 0, 27, 0, 13, 26, 877 0, 49, 53, 0, 0, 55, 0, 24, 0, 21, 878 0, 61, 52, 50, 51, 57, 0, 0, 67, 63, 879 29, 17, 25, 0, 56, 48, 54, 0, 60, 0, 880 0, 58, 0, 62 881 }; 882 883 /* YYPGOTO[NTERM-NUM]. */ 884 const signed char 885 JSCacheParser::yypgoto_[] = 886 { 887 -46, -46, -9, -46, -46, 1, -25, -46, -46, -46, 888 -46, 26, -8, -46, -46, -46, 9, -46, -28, -46, 889 6, 10, -46, -5, -46, -46, -46, -46, 16, 0, 890 -46, -46, -46, -46, -46, -45, -34, -46, -46 891 }; 892 893 /* YYDEFGOTO[NTERM-NUM]. */ 894 const signed char 895 JSCacheParser::yydefgoto_[] = 896 { 897 -1, 1, 2, 11, 12, 47, 36, 14, 15, 64, 898 16, 37, 38, 17, 18, 48, 62, 76, 82, 65, 899 50, 51, 21, 22, 52, 53, 54, 55, 83, 86, 900 96, 104, 56, 103, 57, 34, 75, 58, 99 901 }; 902 903 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 904 positive, shift that token. If negative, reduce the rule which 905 number is the opposite. If YYTABLE_NINF_, syntax error. */ 906 const signed char JSCacheParser::yytable_ninf_ = -3; 907 const signed char 908 JSCacheParser::yytable_[] = 909 { 910 24, 49, 39, 13, 25, 70, 71, 77, 19, 27, 911 6, 26, 20, 28, 29, 107, 35, 3, 28, 78, 912 79, 23, 67, 40, 33, 35, 13, 85, 13, 63, 913 73, 19, 97, 19, 32, 20, 66, 20, 61, 69, 914 6, 98, 68, 29, 81, 30, 31, 72, 4, 93, 915 94, 33, 91, 28, 5, 6, 102, 7, 59, 60, 916 74, 35, 105, 80, 7, 8, 88, 9, 10, 106, 917 13, 97, 89, 109, 63, 19, 87, 112, 108, 20, 918 95, 101, 92, 100, 113, -2, 4, 84, 90, 0, 919 0, 0, 5, 6, 0, 7, 0, 0, 0, 0, 920 0, 0, 110, 8, 111, 9, 10, 41, 6, 42, 921 7, 0, 43, 0, 0, 0, 0, 44, 8, 45, 922 0, 0, 46 923 }; 924 925 /* YYCHECK. */ 926 const signed char 927 JSCacheParser::yycheck_[] = 928 { 929 5, 29, 27, 2, 13, 50, 51, 4, 2, 18, 930 8, 16, 2, 5, 6, 4, 14, 0, 5, 16, 931 65, 16, 47, 28, 11, 14, 25, 72, 27, 34, 932 58, 25, 4, 27, 5, 25, 41, 27, 32, 48, 933 8, 13, 47, 6, 69, 19, 20, 52, 1, 83, 934 84, 11, 80, 5, 7, 8, 90, 10, 16, 16, 935 15, 14, 96, 3, 10, 18, 4, 20, 21, 97, 936 69, 4, 77, 4, 79, 69, 75, 3, 103, 69, 937 85, 89, 82, 88, 112, 0, 1, 71, 79, -1, 938 -1, -1, 7, 8, -1, 10, -1, -1, -1, -1, 939 -1, -1, 107, 18, 109, 20, 21, 7, 8, 9, 940 10, -1, 12, -1, -1, -1, -1, 17, 18, 19, 941 -1, -1, 22 942 }; 943 944 /* STOS_[STATE-NUM] -- The (internal number of the) accessing 945 symbol of state STATE-NUM. */ 946 const unsigned char 947 JSCacheParser::yystos_[] = 948 { 949 0, 24, 25, 0, 1, 7, 8, 10, 18, 20, 950 21, 26, 27, 28, 30, 31, 33, 36, 37, 43, 951 44, 45, 46, 16, 46, 25, 46, 25, 5, 6, 952 34, 34, 5, 11, 58, 14, 29, 34, 35, 29, 953 46, 7, 9, 12, 17, 19, 22, 28, 38, 41, 954 43, 44, 47, 48, 49, 50, 55, 57, 60, 16, 955 16, 43, 39, 46, 32, 42, 46, 29, 46, 25, 956 58, 58, 46, 41, 15, 59, 40, 4, 16, 58, 957 3, 29, 41, 51, 51, 58, 52, 28, 4, 46, 958 39, 41, 52, 59, 59, 46, 53, 4, 13, 61, 959 46, 35, 59, 56, 54, 59, 41, 4, 29, 4, 960 46, 46, 3, 41 961 }; 962 963 #if YYDEBUG 964 /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding 965 to YYLEX-NUM. */ 966 const unsigned short int 967 JSCacheParser::yytoken_number_[] = 968 { 969 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 970 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 971 275, 276, 277 972 }; 973 #endif 974 975 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 976 const unsigned char 977 JSCacheParser::yyr1_[] = 978 { 979 0, 23, 24, 25, 25, 26, 26, 26, 26, 26, 980 27, 28, 29, 30, 31, 31, 32, 32, 33, 33, 981 34, 35, 35, 36, 37, 38, 39, 39, 40, 40, 982 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 983 42, 42, 43, 43, 44, 45, 46, 47, 48, 49, 984 50, 50, 51, 52, 52, 53, 53, 54, 54, 55, 985 55, 56, 56, 57, 58, 59, 60, 61 986 }; 987 988 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 989 const unsigned char 990 JSCacheParser::yyr2_[] = 991 { 992 0, 2, 1, 0, 2, 1, 1, 1, 1, 2, 993 3, 1, 1, 5, 3, 3, 0, 4, 1, 1, 994 2, 0, 1, 3, 6, 5, 0, 2, 0, 3, 995 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 996 0, 1, 1, 3, 3, 1, 1, 1, 5, 3, 997 4, 4, 2, 0, 3, 0, 2, 0, 3, 2, 998 6, 0, 5, 4, 1, 1, 1, 1 999 }; 1000 1001 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE 1002 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. 1003 First, the terminals, then, starting at \a yyntokens_, nonterminals. */ 1004 const char* 1005 const JSCacheParser::yytname_[] = 1006 { 1007 "$end", "error", "$undefined", "T_COLON", "T_COMMA", "T_DOT", "T_EQ", 1008 "T_FUNCTION", "T_IDENTIFIER", "T_LBRACE", "T_LBRACKET", "T_LPAREN", 1009 "T_NEW", "T_RBRACE", "T_RBRACKET", "T_RPAREN", "T_SEMICOLON", 1010 "T_STRING_LITERAL", "T_THIS", "T_NULL", "T_VAR", "T_CONST", 1011 "T_NUMERIC_LITERAL", "$accept", "Program", "StatementList", "Statement", 1012 "Block", "OpenBlock", "CloseBlock", "VariableDeclStatement", 1013 "AssignmentStatement", "OtherDeclOpt", "DeclTok", "Assignment", 1014 "InitOpt", "FunctionDecl", "StartFun", "StartOptFun", "OptParamList", 1015 "OtherOptParamList", "Expression", "OptIdTok", "MemberExpr", "ThisExpr", 1016 "ThisTok", "IdTok", "NewTok", "NewExpr", "FunctionExpr", "FunctionCall", 1017 "OptExpressionList", "OtherOptExpressionList", "OptArgumentList", 1018 "OtherOptArgumentList", "ObjConstExpr", "OtherOptFields", "ArrayExpr", 1019 "OpenBracket", "CloseBracket", "OpenArrBracket", "CloseArrBracket", 0 1020 }; 1021 #endif 1022 1023 #if YYDEBUG 1024 /* YYRHS -- A `-1'-separated list of the rules' RHS. */ 1025 const JSCacheParser::rhs_number_type 1026 JSCacheParser::yyrhs_[] = 1027 { 1028 24, 0, -1, 25, -1, -1, 25, 26, -1, 27, 1029 -1, 36, -1, 30, -1, 31, -1, 1, 16, -1, 1030 28, 25, 29, -1, 10, -1, 14, -1, 33, 46, 1031 35, 32, 16, -1, 43, 34, 16, -1, 44, 34, 1032 16, -1, -1, 32, 4, 46, 35, -1, 20, -1, 1033 21, -1, 6, 41, -1, -1, 34, -1, 37, 25, 1034 29, -1, 7, 46, 58, 39, 59, 28, -1, 7, 1035 42, 58, 39, 59, -1, -1, 46, 40, -1, -1, 1036 40, 4, 46, -1, 43, -1, 44, -1, 48, -1, 1037 49, -1, 50, -1, 55, -1, 57, -1, 19, -1, 1038 17, -1, 22, -1, -1, 46, -1, 46, -1, 43, 1039 5, 46, -1, 45, 5, 43, -1, 18, -1, 8, 1040 -1, 12, -1, 47, 46, 58, 53, 59, -1, 38, 1041 25, 29, -1, 43, 58, 51, 59, -1, 44, 58, 1042 51, 59, -1, 41, 52, -1, -1, 52, 4, 41, 1043 -1, -1, 46, 54, -1, -1, 54, 4, 46, -1, 1044 28, 29, -1, 28, 46, 3, 41, 56, 29, -1, 1045 -1, 56, 4, 46, 3, 41, -1, 60, 41, 52, 1046 61, -1, 11, -1, 15, -1, 9, -1, 13, -1 1047 }; 1048 1049 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in 1050 YYRHS. */ 1051 const unsigned char 1052 JSCacheParser::yyprhs_[] = 1053 { 1054 0, 0, 3, 5, 6, 9, 11, 13, 15, 17, 1055 20, 24, 26, 28, 34, 38, 42, 43, 48, 50, 1056 52, 55, 56, 58, 62, 69, 75, 76, 79, 80, 1057 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 1058 104, 105, 107, 109, 113, 117, 119, 121, 123, 129, 1059 133, 138, 143, 146, 147, 151, 152, 155, 156, 160, 1060 163, 170, 171, 177, 182, 184, 186, 188 1061 }; 1062 1063 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ 1064 const unsigned short int 1065 JSCacheParser::yyrline_[] = 1066 { 1067 0, 58, 58, 60, 61, 64, 65, 66, 67, 68, 1068 74, 76, 82, 88, 95, 99, 105, 106, 109, 110, 1069 113, 120, 123, 127, 128, 135, 144, 145, 151, 152, 1070 158, 162, 166, 171, 175, 179, 188, 192, 196, 200, 1071 207, 210, 213, 214, 217, 219, 221, 223, 225, 232, 1072 239, 240, 245, 248, 249, 253, 254, 257, 258, 261, 1073 262, 269, 270, 277, 279, 281, 283, 285 1074 }; 1075 1076 // Print the state stack on the debug stream. 1077 void yystack_print_()1078 JSCacheParser::yystack_print_ () 1079 { 1080 *yycdebug_ << "Stack now"; 1081 for (state_stack_type::const_iterator i = yystate_stack_.begin (); 1082 i != yystate_stack_.end (); ++i) 1083 *yycdebug_ << ' ' << *i; 1084 *yycdebug_ << std::endl; 1085 } 1086 1087 // Report on the debug stream that the rule \a yyrule is going to be reduced. 1088 void yy_reduce_print_(int yyrule)1089 JSCacheParser::yy_reduce_print_ (int yyrule) 1090 { 1091 unsigned int yylno = yyrline_[yyrule]; 1092 int yynrhs = yyr2_[yyrule]; 1093 /* Print the symbols being reduced, and their result. */ 1094 *yycdebug_ << "Reducing stack by rule " << yyrule - 1 1095 << " (line " << yylno << "):" << std::endl; 1096 /* The symbols being reduced. */ 1097 for (int yyi = 0; yyi < yynrhs; yyi++) 1098 YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", 1099 yyrhs_[yyprhs_[yyrule] + yyi], 1100 &(yysemantic_stack_[(yynrhs) - (yyi + 1)]), 1101 &(yylocation_stack_[(yynrhs) - (yyi + 1)])); 1102 } 1103 #endif // YYDEBUG 1104 1105 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 1106 JSCacheParser::token_number_type yytranslate_(int t)1107 JSCacheParser::yytranslate_ (int t) 1108 { 1109 static 1110 const token_number_type 1111 translate_table[] = 1112 { 1113 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1114 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1115 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1116 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1117 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1118 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1119 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1120 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1121 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1122 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1123 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1124 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1125 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1126 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1127 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1128 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1129 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1130 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1131 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1132 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1133 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1134 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1135 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1136 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1137 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1138 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 1139 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1140 15, 16, 17, 18, 19, 20, 21, 22 1141 }; 1142 if ((unsigned int) t <= yyuser_token_number_max_) 1143 return translate_table[t]; 1144 else 1145 return yyundef_token_; 1146 } 1147 1148 const int JSCacheParser::yyeof_ = 0; 1149 const int JSCacheParser::yylast_ = 122; 1150 const int JSCacheParser::yynnts_ = 39; 1151 const int JSCacheParser::yyempty_ = -2; 1152 const int JSCacheParser::yyfinal_ = 3; 1153 const int JSCacheParser::yyterror_ = 1; 1154 const int JSCacheParser::yyerrcode_ = 256; 1155 const int JSCacheParser::yyntokens_ = 23; 1156 1157 const unsigned int JSCacheParser::yyuser_token_number_max_ = 277; 1158 const JSCacheParser::token_number_type JSCacheParser::yyundef_token_ = 2; 1159 1160 1161 } // yy 1162 1163 /* Line 1136 of lalr1.cc */ 1164 #line 1165 "js_parser.tab.cc" 1165 1166 1167 /* Line 1138 of lalr1.cc */ 1168 #line 287 "js_parser.yy" 1169 1170 1171 namespace yy 1172 { error(location const & loc,const std::string & s)1173 void JSCacheParser::error(location const& loc, const std::string& s) 1174 { 1175 //std::cerr << "error at " << loc << ": " << s << "\n"; 1176 } 1177 } 1178 1179