1 // A Bison parser, made by GNU Bison 3.8.2. 2 3 // Skeleton implementation for Bison LALR(1) parsers in C++ 4 5 // Copyright (C) 2002-2015, 2018-2021 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 <https://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 // DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, 34 // especially those whose name start with YY_ or yy_. They are 35 // private implementation details that can be changed or removed. 36 37 // "%code top" blocks. 38 #line 28 "QLParser.yy" 39 40 #include <stdio.h> 41 #include <string.h> 42 #include <string> 43 44 #line 45 "QLParser.tab.cc" 45 46 47 48 49 #include "QLParser.tab.hh" 50 51 52 // Unqualified %code blocks. 53 #line 42 "QLParser.yy" 54 55 namespace QL 56 { 57 static QL::Parser::symbol_type yylex (QL::Result &result); 58 59 static Expression * processName(std::string str)60 processName (std::string str) 61 { 62 const char *name = str.c_str(); 63 int propID = dbeSession->getPropIdByName (name); 64 if (propID != PROP_NONE) 65 return new Expression (Expression::OP_NAME, 66 new Expression (Expression::OP_NUM, (uint64_t) propID)); 67 68 // If a name is not statically known try user defined objects 69 Expression *expr = dbeSession->findObjDefByName (name); 70 if (expr != NULL) 71 return expr->copy(); 72 73 throw Parser::syntax_error ("Name not found"); 74 } 75 } 76 77 #line 78 "QLParser.tab.cc" 78 79 80 #ifndef YY_ 81 # if defined YYENABLE_NLS && YYENABLE_NLS 82 # if ENABLE_NLS 83 # include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE. 84 # define YY_(msgid) dgettext ("bison-runtime", msgid) 85 # endif 86 # endif 87 # ifndef YY_ 88 # define YY_(msgid) msgid 89 # endif 90 #endif 91 92 93 // Whether we are compiled with exception support. 94 #ifndef YY_EXCEPTIONS 95 # if defined __GNUC__ && !defined __EXCEPTIONS 96 # define YY_EXCEPTIONS 0 97 # else 98 # define YY_EXCEPTIONS 1 99 # endif 100 #endif 101 102 103 104 // Enable debugging if requested. 105 #if YYDEBUG 106 107 // A pseudo ostream that takes yydebug_ into account. 108 # define YYCDEBUG if (yydebug_) (*yycdebug_) 109 110 # define YY_SYMBOL_PRINT(Title, Symbol) \ 111 do { \ 112 if (yydebug_) \ 113 { \ 114 *yycdebug_ << Title << ' '; \ 115 yy_print_ (*yycdebug_, Symbol); \ 116 *yycdebug_ << '\n'; \ 117 } \ 118 } while (false) 119 120 # define YY_REDUCE_PRINT(Rule) \ 121 do { \ 122 if (yydebug_) \ 123 yy_reduce_print_ (Rule); \ 124 } while (false) 125 126 # define YY_STACK_PRINT() \ 127 do { \ 128 if (yydebug_) \ 129 yy_stack_print_ (); \ 130 } while (false) 131 132 #else // !YYDEBUG 133 134 # define YYCDEBUG if (false) std::cerr 135 # define YY_SYMBOL_PRINT(Title, Symbol) YY_USE (Symbol) 136 # define YY_REDUCE_PRINT(Rule) static_cast<void> (0) 137 # define YY_STACK_PRINT() static_cast<void> (0) 138 139 #endif // !YYDEBUG 140 141 #define yyerrok (yyerrstatus_ = 0) 142 #define yyclearin (yyla.clear ()) 143 144 #define YYACCEPT goto yyacceptlab 145 #define YYABORT goto yyabortlab 146 #define YYERROR goto yyerrorlab 147 #define YYRECOVERING() (!!yyerrstatus_) 148 149 #line 67 "QLParser.yy" 150 namespace QL { 151 #line 152 "QLParser.tab.cc" 152 153 /// Build a parser object. Parser(QL::Result & result_yyarg)154 Parser::Parser (QL::Result &result_yyarg) 155 #if YYDEBUG 156 : yydebug_ (false), 157 yycdebug_ (&std::cerr), 158 #else 159 : 160 #endif 161 result (result_yyarg) 162 {} 163 ~Parser()164 Parser::~Parser () 165 {} 166 ~syntax_error()167 Parser::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW 168 {} 169 170 /*---------. 171 | symbol. | 172 `---------*/ 173 174 175 176 // by_state. by_state()177 Parser::by_state::by_state () YY_NOEXCEPT 178 : state (empty_state) 179 {} 180 by_state(const by_state & that)181 Parser::by_state::by_state (const by_state& that) YY_NOEXCEPT 182 : state (that.state) 183 {} 184 185 void clear()186 Parser::by_state::clear () YY_NOEXCEPT 187 { 188 state = empty_state; 189 } 190 191 void move(by_state & that)192 Parser::by_state::move (by_state& that) 193 { 194 state = that.state; 195 that.clear (); 196 } 197 by_state(state_type s)198 Parser::by_state::by_state (state_type s) YY_NOEXCEPT 199 : state (s) 200 {} 201 202 Parser::symbol_kind_type kind() const203 Parser::by_state::kind () const YY_NOEXCEPT 204 { 205 if (state == empty_state) 206 return symbol_kind::S_YYEMPTY; 207 else 208 return YY_CAST (symbol_kind_type, yystos_[+state]); 209 } 210 stack_symbol_type()211 Parser::stack_symbol_type::stack_symbol_type () 212 {} 213 stack_symbol_type(YY_RVREF (stack_symbol_type)that)214 Parser::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that) 215 : super_type (YY_MOVE (that.state)) 216 { 217 switch (that.kind ()) 218 { 219 case symbol_kind::S_exp: // exp 220 case symbol_kind::S_term: // term 221 value.YY_MOVE_OR_COPY< Expression * > (YY_MOVE (that.value)); 222 break; 223 224 case symbol_kind::S_NAME: // NAME 225 value.YY_MOVE_OR_COPY< std::string > (YY_MOVE (that.value)); 226 break; 227 228 case symbol_kind::S_NUM: // NUM 229 case symbol_kind::S_FNAME: // FNAME 230 case symbol_kind::S_JGROUP: // JGROUP 231 case symbol_kind::S_JPARENT: // JPARENT 232 case symbol_kind::S_QSTR: // QSTR 233 value.YY_MOVE_OR_COPY< uint64_t > (YY_MOVE (that.value)); 234 break; 235 236 default: 237 break; 238 } 239 240 #if 201103L <= YY_CPLUSPLUS 241 // that is emptied. 242 that.state = empty_state; 243 #endif 244 } 245 stack_symbol_type(state_type s,YY_MOVE_REF (symbol_type)that)246 Parser::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that) 247 : super_type (s) 248 { 249 switch (that.kind ()) 250 { 251 case symbol_kind::S_exp: // exp 252 case symbol_kind::S_term: // term 253 value.move< Expression * > (YY_MOVE (that.value)); 254 break; 255 256 case symbol_kind::S_NAME: // NAME 257 value.move< std::string > (YY_MOVE (that.value)); 258 break; 259 260 case symbol_kind::S_NUM: // NUM 261 case symbol_kind::S_FNAME: // FNAME 262 case symbol_kind::S_JGROUP: // JGROUP 263 case symbol_kind::S_JPARENT: // JPARENT 264 case symbol_kind::S_QSTR: // QSTR 265 value.move< uint64_t > (YY_MOVE (that.value)); 266 break; 267 268 default: 269 break; 270 } 271 272 // that is emptied. 273 that.kind_ = symbol_kind::S_YYEMPTY; 274 } 275 276 #if YY_CPLUSPLUS < 201103L 277 Parser::stack_symbol_type& operator =(const stack_symbol_type & that)278 Parser::stack_symbol_type::operator= (const stack_symbol_type& that) 279 { 280 state = that.state; 281 switch (that.kind ()) 282 { 283 case symbol_kind::S_exp: // exp 284 case symbol_kind::S_term: // term 285 value.copy< Expression * > (that.value); 286 break; 287 288 case symbol_kind::S_NAME: // NAME 289 value.copy< std::string > (that.value); 290 break; 291 292 case symbol_kind::S_NUM: // NUM 293 case symbol_kind::S_FNAME: // FNAME 294 case symbol_kind::S_JGROUP: // JGROUP 295 case symbol_kind::S_JPARENT: // JPARENT 296 case symbol_kind::S_QSTR: // QSTR 297 value.copy< uint64_t > (that.value); 298 break; 299 300 default: 301 break; 302 } 303 304 return *this; 305 } 306 307 Parser::stack_symbol_type& operator =(stack_symbol_type & that)308 Parser::stack_symbol_type::operator= (stack_symbol_type& that) 309 { 310 state = that.state; 311 switch (that.kind ()) 312 { 313 case symbol_kind::S_exp: // exp 314 case symbol_kind::S_term: // term 315 value.move< Expression * > (that.value); 316 break; 317 318 case symbol_kind::S_NAME: // NAME 319 value.move< std::string > (that.value); 320 break; 321 322 case symbol_kind::S_NUM: // NUM 323 case symbol_kind::S_FNAME: // FNAME 324 case symbol_kind::S_JGROUP: // JGROUP 325 case symbol_kind::S_JPARENT: // JPARENT 326 case symbol_kind::S_QSTR: // QSTR 327 value.move< uint64_t > (that.value); 328 break; 329 330 default: 331 break; 332 } 333 334 // that is emptied. 335 that.state = empty_state; 336 return *this; 337 } 338 #endif 339 340 template <typename Base> 341 void yy_destroy_(const char * yymsg,basic_symbol<Base> & yysym) const342 Parser::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const 343 { 344 if (yymsg) 345 YY_SYMBOL_PRINT (yymsg, yysym); 346 } 347 348 #if YYDEBUG 349 template <typename Base> 350 void yy_print_(std::ostream & yyo,const basic_symbol<Base> & yysym) const351 Parser::yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const 352 { 353 std::ostream& yyoutput = yyo; 354 YY_USE (yyoutput); 355 if (yysym.empty ()) 356 yyo << "empty symbol"; 357 else 358 { 359 symbol_kind_type yykind = yysym.kind (); 360 yyo << (yykind < YYNTOKENS ? "token" : "nterm") 361 << ' ' << yysym.name () << " ("; 362 YY_USE (yykind); 363 yyo << ')'; 364 } 365 } 366 #endif 367 368 void yypush_(const char * m,YY_MOVE_REF (stack_symbol_type)sym)369 Parser::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym) 370 { 371 if (m) 372 YY_SYMBOL_PRINT (m, sym); 373 yystack_.push (YY_MOVE (sym)); 374 } 375 376 void yypush_(const char * m,state_type s,YY_MOVE_REF (symbol_type)sym)377 Parser::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym) 378 { 379 #if 201103L <= YY_CPLUSPLUS 380 yypush_ (m, stack_symbol_type (s, std::move (sym))); 381 #else 382 stack_symbol_type ss (s, sym); 383 yypush_ (m, ss); 384 #endif 385 } 386 387 void yypop_(int n)388 Parser::yypop_ (int n) YY_NOEXCEPT 389 { 390 yystack_.pop (n); 391 } 392 393 #if YYDEBUG 394 std::ostream& debug_stream() const395 Parser::debug_stream () const 396 { 397 return *yycdebug_; 398 } 399 400 void set_debug_stream(std::ostream & o)401 Parser::set_debug_stream (std::ostream& o) 402 { 403 yycdebug_ = &o; 404 } 405 406 407 Parser::debug_level_type debug_level() const408 Parser::debug_level () const 409 { 410 return yydebug_; 411 } 412 413 void set_debug_level(debug_level_type l)414 Parser::set_debug_level (debug_level_type l) 415 { 416 yydebug_ = l; 417 } 418 #endif // YYDEBUG 419 420 Parser::state_type yy_lr_goto_state_(state_type yystate,int yysym)421 Parser::yy_lr_goto_state_ (state_type yystate, int yysym) 422 { 423 int yyr = yypgoto_[yysym - YYNTOKENS] + yystate; 424 if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate) 425 return yytable_[yyr]; 426 else 427 return yydefgoto_[yysym - YYNTOKENS]; 428 } 429 430 bool yy_pact_value_is_default_(int yyvalue)431 Parser::yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT 432 { 433 return yyvalue == yypact_ninf_; 434 } 435 436 bool yy_table_value_is_error_(int yyvalue)437 Parser::yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT 438 { 439 return yyvalue == yytable_ninf_; 440 } 441 442 int operator ()()443 Parser::operator() () 444 { 445 return parse (); 446 } 447 448 int parse()449 Parser::parse () 450 { 451 int yyn; 452 /// Length of the RHS of the rule being reduced. 453 int yylen = 0; 454 455 // Error handling. 456 int yynerrs_ = 0; 457 int yyerrstatus_ = 0; 458 459 /// The lookahead symbol. 460 symbol_type yyla; 461 462 /// The return value of parse (). 463 int yyresult; 464 465 #if YY_EXCEPTIONS 466 try 467 #endif // YY_EXCEPTIONS 468 { 469 YYCDEBUG << "Starting parse\n"; 470 471 472 /* Initialize the stack. The initial state will be set in 473 yynewstate, since the latter expects the semantical and the 474 location values to have been already stored, initialize these 475 stacks with a primary value. */ 476 yystack_.clear (); 477 yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla)); 478 479 /*-----------------------------------------------. 480 | yynewstate -- push a new symbol on the stack. | 481 `-----------------------------------------------*/ 482 yynewstate: 483 YYCDEBUG << "Entering state " << int (yystack_[0].state) << '\n'; 484 YY_STACK_PRINT (); 485 486 // Accept? 487 if (yystack_[0].state == yyfinal_) 488 YYACCEPT; 489 490 goto yybackup; 491 492 493 /*-----------. 494 | yybackup. | 495 `-----------*/ 496 yybackup: 497 // Try to take a decision without lookahead. 498 yyn = yypact_[+yystack_[0].state]; 499 if (yy_pact_value_is_default_ (yyn)) 500 goto yydefault; 501 502 // Read a lookahead token. 503 if (yyla.empty ()) 504 { 505 YYCDEBUG << "Reading a token\n"; 506 #if YY_EXCEPTIONS 507 try 508 #endif // YY_EXCEPTIONS 509 { 510 symbol_type yylookahead (yylex (result)); 511 yyla.move (yylookahead); 512 } 513 #if YY_EXCEPTIONS 514 catch (const syntax_error& yyexc) 515 { 516 YYCDEBUG << "Caught exception: " << yyexc.what() << '\n'; 517 error (yyexc); 518 goto yyerrlab1; 519 } 520 #endif // YY_EXCEPTIONS 521 } 522 YY_SYMBOL_PRINT ("Next token is", yyla); 523 524 if (yyla.kind () == symbol_kind::S_YYerror) 525 { 526 // The scanner already issued an error message, process directly 527 // to error recovery. But do not keep the error token as 528 // lookahead, it is too special and may lead us to an endless 529 // loop in error recovery. */ 530 yyla.kind_ = symbol_kind::S_YYUNDEF; 531 goto yyerrlab1; 532 } 533 534 /* If the proper action on seeing token YYLA.TYPE is to reduce or 535 to detect an error, take that action. */ 536 yyn += yyla.kind (); 537 if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind ()) 538 { 539 goto yydefault; 540 } 541 542 // Reduce or error. 543 yyn = yytable_[yyn]; 544 if (yyn <= 0) 545 { 546 if (yy_table_value_is_error_ (yyn)) 547 goto yyerrlab; 548 yyn = -yyn; 549 goto yyreduce; 550 } 551 552 // Count tokens shifted since error; after three, turn off error status. 553 if (yyerrstatus_) 554 --yyerrstatus_; 555 556 // Shift the lookahead token. 557 yypush_ ("Shifting", state_type (yyn), YY_MOVE (yyla)); 558 goto yynewstate; 559 560 561 /*-----------------------------------------------------------. 562 | yydefault -- do the default action for the current state. | 563 `-----------------------------------------------------------*/ 564 yydefault: 565 yyn = yydefact_[+yystack_[0].state]; 566 if (yyn == 0) 567 goto yyerrlab; 568 goto yyreduce; 569 570 571 /*-----------------------------. 572 | yyreduce -- do a reduction. | 573 `-----------------------------*/ 574 yyreduce: 575 yylen = yyr2_[yyn]; 576 { 577 stack_symbol_type yylhs; 578 yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]); 579 /* Variants are always initialized to an empty instance of the 580 correct type. The default '$$ = $1' action is NOT applied 581 when using variants. */ 582 switch (yyr1_[yyn]) 583 { 584 case symbol_kind::S_exp: // exp 585 case symbol_kind::S_term: // term 586 yylhs.value.emplace< Expression * > (); 587 break; 588 589 case symbol_kind::S_NAME: // NAME 590 yylhs.value.emplace< std::string > (); 591 break; 592 593 case symbol_kind::S_NUM: // NUM 594 case symbol_kind::S_FNAME: // FNAME 595 case symbol_kind::S_JGROUP: // JGROUP 596 case symbol_kind::S_JPARENT: // JPARENT 597 case symbol_kind::S_QSTR: // QSTR 598 yylhs.value.emplace< uint64_t > (); 599 break; 600 601 default: 602 break; 603 } 604 605 606 607 // Perform the reduction. 608 YY_REDUCE_PRINT (yyn); 609 #if YY_EXCEPTIONS 610 try 611 #endif // YY_EXCEPTIONS 612 { 613 switch (yyn) 614 { 615 case 2: // S: %empty 616 #line 120 "QLParser.yy" 617 { result.out = new Expression (Expression::OP_NUM, (uint64_t) 1); } 618 #line 619 "QLParser.tab.cc" 619 break; 620 621 case 3: // S: exp 622 #line 121 "QLParser.yy" 623 { result.out = yystack_[0].value.as < Expression * > (); } 624 #line 625 "QLParser.tab.cc" 625 break; 626 627 case 4: // exp: exp DEG exp 628 #line 123 "QLParser.yy" 629 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_DEG, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 630 #line 631 "QLParser.tab.cc" 631 break; 632 633 case 5: // exp: exp MUL exp 634 #line 124 "QLParser.yy" 635 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_MUL, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 636 #line 637 "QLParser.tab.cc" 637 break; 638 639 case 6: // exp: exp DIV exp 640 #line 125 "QLParser.yy" 641 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_DIV, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 642 #line 643 "QLParser.tab.cc" 643 break; 644 645 case 7: // exp: exp REM exp 646 #line 126 "QLParser.yy" 647 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_REM, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 648 #line 649 "QLParser.tab.cc" 649 break; 650 651 case 8: // exp: exp ADD exp 652 #line 127 "QLParser.yy" 653 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_ADD, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 654 #line 655 "QLParser.tab.cc" 655 break; 656 657 case 9: // exp: exp MINUS exp 658 #line 128 "QLParser.yy" 659 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_MINUS, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 660 #line 661 "QLParser.tab.cc" 661 break; 662 663 case 10: // exp: exp LS exp 664 #line 129 "QLParser.yy" 665 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_LS, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 666 #line 667 "QLParser.tab.cc" 667 break; 668 669 case 11: // exp: exp RS exp 670 #line 130 "QLParser.yy" 671 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_RS, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 672 #line 673 "QLParser.tab.cc" 673 break; 674 675 case 12: // exp: exp LT exp 676 #line 131 "QLParser.yy" 677 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_LT, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 678 #line 679 "QLParser.tab.cc" 679 break; 680 681 case 13: // exp: exp LE exp 682 #line 132 "QLParser.yy" 683 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_LE, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 684 #line 685 "QLParser.tab.cc" 685 break; 686 687 case 14: // exp: exp GT exp 688 #line 133 "QLParser.yy" 689 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_GT, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 690 #line 691 "QLParser.tab.cc" 691 break; 692 693 case 15: // exp: exp GE exp 694 #line 134 "QLParser.yy" 695 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_GE, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 696 #line 697 "QLParser.tab.cc" 697 break; 698 699 case 16: // exp: exp EQ exp 700 #line 135 "QLParser.yy" 701 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_EQ, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 702 #line 703 "QLParser.tab.cc" 703 break; 704 705 case 17: // exp: exp NE exp 706 #line 136 "QLParser.yy" 707 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_NE, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 708 #line 709 "QLParser.tab.cc" 709 break; 710 711 case 18: // exp: exp BITAND exp 712 #line 137 "QLParser.yy" 713 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_BITAND, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 714 #line 715 "QLParser.tab.cc" 715 break; 716 717 case 19: // exp: exp BITXOR exp 718 #line 138 "QLParser.yy" 719 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_BITXOR, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 720 #line 721 "QLParser.tab.cc" 721 break; 722 723 case 20: // exp: exp BITOR exp 724 #line 139 "QLParser.yy" 725 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_BITOR, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 726 #line 727 "QLParser.tab.cc" 727 break; 728 729 case 21: // exp: exp AND exp 730 #line 140 "QLParser.yy" 731 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_AND, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 732 #line 733 "QLParser.tab.cc" 733 break; 734 735 case 22: // exp: exp OR exp 736 #line 141 "QLParser.yy" 737 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_OR, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 738 #line 739 "QLParser.tab.cc" 739 break; 740 741 case 23: // exp: exp NEQV exp 742 #line 142 "QLParser.yy" 743 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_NEQV, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 744 #line 745 "QLParser.tab.cc" 745 break; 746 747 case 24: // exp: exp EQV exp 748 #line 143 "QLParser.yy" 749 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_EQV, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 750 #line 751 "QLParser.tab.cc" 751 break; 752 753 case 25: // exp: exp QWE exp COLON exp 754 #line 145 "QLParser.yy" 755 { 756 yylhs.value.as < Expression * > () = new Expression (Expression::OP_QWE, yystack_[4].value.as < Expression * > (), 757 new Expression (Expression::OP_COLON, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ())); 758 } 759 #line 760 "QLParser.tab.cc" 760 break; 761 762 case 26: // exp: exp COMMA exp 763 #line 149 "QLParser.yy" 764 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_COMMA, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 765 #line 766 "QLParser.tab.cc" 766 break; 767 768 case 27: // exp: exp IN exp 769 #line 150 "QLParser.yy" 770 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_IN, yystack_[2].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 771 #line 772 "QLParser.tab.cc" 772 break; 773 774 case 28: // exp: exp SOME IN exp 775 #line 151 "QLParser.yy" 776 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_SOMEIN, yystack_[3].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 777 #line 778 "QLParser.tab.cc" 778 break; 779 780 case 29: // exp: exp ORDR IN exp 781 #line 152 "QLParser.yy" 782 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_ORDRIN, yystack_[3].value.as < Expression * > (), yystack_[0].value.as < Expression * > ()); } 783 #line 784 "QLParser.tab.cc" 784 break; 785 786 case 30: // exp: term 787 #line 153 "QLParser.yy" 788 { yylhs.value.as < Expression * > () = yystack_[0].value.as < Expression * > (); } 789 #line 790 "QLParser.tab.cc" 790 break; 791 792 case 31: // term: MINUS term 793 #line 156 "QLParser.yy" 794 { 795 yylhs.value.as < Expression * > () = new Expression (Expression::OP_MINUS, 796 new Expression (Expression::OP_NUM, (uint64_t) 0), yystack_[0].value.as < Expression * > ()); 797 } 798 #line 799 "QLParser.tab.cc" 799 break; 800 801 case 32: // term: NOT term 802 #line 160 "QLParser.yy" 803 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_NOT, yystack_[0].value.as < Expression * > ()); } 804 #line 805 "QLParser.tab.cc" 805 break; 806 807 case 33: // term: BITNOT term 808 #line 161 "QLParser.yy" 809 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_BITNOT, yystack_[0].value.as < Expression * > ()); } 810 #line 811 "QLParser.tab.cc" 811 break; 812 813 case 34: // term: "(" exp ")" 814 #line 162 "QLParser.yy" 815 { yylhs.value.as < Expression * > () = yystack_[1].value.as < Expression * > (); } 816 #line 817 "QLParser.tab.cc" 817 break; 818 819 case 35: // term: FNAME "(" QSTR ")" 820 #line 164 "QLParser.yy" 821 { 822 yylhs.value.as < Expression * > () = new Expression (Expression::OP_FUNC, 823 new Expression (Expression::OP_NUM, yystack_[3].value.as < uint64_t > ()), 824 new Expression (Expression::OP_NUM, yystack_[1].value.as < uint64_t > ())); 825 } 826 #line 827 "QLParser.tab.cc" 827 break; 828 829 case 36: // term: HASPROP "(" NAME ")" 830 #line 170 "QLParser.yy" 831 { 832 yylhs.value.as < Expression * > () = new Expression (Expression::OP_HASPROP, 833 new Expression (Expression::OP_NUM, processName(yystack_[1].value.as < std::string > ()))); 834 } 835 #line 836 "QLParser.tab.cc" 836 break; 837 838 case 37: // term: JGROUP "(" QSTR ")" 839 #line 175 "QLParser.yy" 840 { 841 yylhs.value.as < Expression * > () = new Expression (Expression::OP_JAVA, 842 new Expression (Expression::OP_NUM, yystack_[3].value.as < uint64_t > ()), 843 new Expression (Expression::OP_NUM, yystack_[1].value.as < uint64_t > ())); 844 } 845 #line 846 "QLParser.tab.cc" 846 break; 847 848 case 38: // term: JPARENT "(" QSTR ")" 849 #line 181 "QLParser.yy" 850 { 851 yylhs.value.as < Expression * > () = new Expression (Expression::OP_JAVA, 852 new Expression (Expression::OP_NUM, yystack_[3].value.as < uint64_t > ()), 853 new Expression (Expression::OP_NUM, yystack_[1].value.as < uint64_t > ())); 854 } 855 #line 856 "QLParser.tab.cc" 856 break; 857 858 case 39: // term: FILEIOVFD "(" QSTR ")" 859 #line 187 "QLParser.yy" 860 { 861 yylhs.value.as < Expression * > () = new Expression (Expression::OP_FILE, 862 new Expression (Expression::OP_NUM, (uint64_t) 0), 863 new Expression (Expression::OP_NUM, yystack_[1].value.as < uint64_t > ())); 864 } 865 #line 866 "QLParser.tab.cc" 866 break; 867 868 case 40: // term: NUM 869 #line 192 "QLParser.yy" 870 { yylhs.value.as < Expression * > () = new Expression (Expression::OP_NUM, yystack_[0].value.as < uint64_t > ()); } 871 #line 872 "QLParser.tab.cc" 872 break; 873 874 case 41: // term: NAME 875 #line 193 "QLParser.yy" 876 { yylhs.value.as < Expression * > () = processName(yystack_[0].value.as < std::string > ()); } 877 #line 878 "QLParser.tab.cc" 878 break; 879 880 881 #line 882 "QLParser.tab.cc" 882 883 default: 884 break; 885 } 886 } 887 #if YY_EXCEPTIONS 888 catch (const syntax_error& yyexc) 889 { 890 YYCDEBUG << "Caught exception: " << yyexc.what() << '\n'; 891 error (yyexc); 892 YYERROR; 893 } 894 #endif // YY_EXCEPTIONS 895 YY_SYMBOL_PRINT ("-> $$ =", yylhs); 896 yypop_ (yylen); 897 yylen = 0; 898 899 // Shift the result of the reduction. 900 yypush_ (YY_NULLPTR, YY_MOVE (yylhs)); 901 } 902 goto yynewstate; 903 904 905 /*--------------------------------------. 906 | yyerrlab -- here on detecting error. | 907 `--------------------------------------*/ 908 yyerrlab: 909 // If not already recovering from an error, report this error. 910 if (!yyerrstatus_) 911 { 912 ++yynerrs_; 913 std::string msg = YY_("syntax error"); 914 error (YY_MOVE (msg)); 915 } 916 917 918 if (yyerrstatus_ == 3) 919 { 920 /* If just tried and failed to reuse lookahead token after an 921 error, discard it. */ 922 923 // Return failure if at end of input. 924 if (yyla.kind () == symbol_kind::S_YYEOF) 925 YYABORT; 926 else if (!yyla.empty ()) 927 { 928 yy_destroy_ ("Error: discarding", yyla); 929 yyla.clear (); 930 } 931 } 932 933 // Else will try to reuse lookahead token after shifting the error token. 934 goto yyerrlab1; 935 936 937 /*---------------------------------------------------. 938 | yyerrorlab -- error raised explicitly by YYERROR. | 939 `---------------------------------------------------*/ 940 yyerrorlab: 941 /* Pacify compilers when the user code never invokes YYERROR and 942 the label yyerrorlab therefore never appears in user code. */ 943 if (false) 944 YYERROR; 945 946 /* Do not reclaim the symbols of the rule whose action triggered 947 this YYERROR. */ 948 yypop_ (yylen); 949 yylen = 0; 950 YY_STACK_PRINT (); 951 goto yyerrlab1; 952 953 954 /*-------------------------------------------------------------. 955 | yyerrlab1 -- common code for both syntax error and YYERROR. | 956 `-------------------------------------------------------------*/ 957 yyerrlab1: 958 yyerrstatus_ = 3; // Each real token shifted decrements this. 959 // Pop stack until we find a state that shifts the error token. 960 for (;;) 961 { 962 yyn = yypact_[+yystack_[0].state]; 963 if (!yy_pact_value_is_default_ (yyn)) 964 { 965 yyn += symbol_kind::S_YYerror; 966 if (0 <= yyn && yyn <= yylast_ 967 && yycheck_[yyn] == symbol_kind::S_YYerror) 968 { 969 yyn = yytable_[yyn]; 970 if (0 < yyn) 971 break; 972 } 973 } 974 975 // Pop the current state because it cannot handle the error token. 976 if (yystack_.size () == 1) 977 YYABORT; 978 979 yy_destroy_ ("Error: popping", yystack_[0]); 980 yypop_ (); 981 YY_STACK_PRINT (); 982 } 983 { 984 stack_symbol_type error_token; 985 986 987 // Shift the error token. 988 error_token.state = state_type (yyn); 989 yypush_ ("Shifting", YY_MOVE (error_token)); 990 } 991 goto yynewstate; 992 993 994 /*-------------------------------------. 995 | yyacceptlab -- YYACCEPT comes here. | 996 `-------------------------------------*/ 997 yyacceptlab: 998 yyresult = 0; 999 goto yyreturn; 1000 1001 1002 /*-----------------------------------. 1003 | yyabortlab -- YYABORT comes here. | 1004 `-----------------------------------*/ 1005 yyabortlab: 1006 yyresult = 1; 1007 goto yyreturn; 1008 1009 1010 /*-----------------------------------------------------. 1011 | yyreturn -- parsing is finished, return the result. | 1012 `-----------------------------------------------------*/ 1013 yyreturn: 1014 if (!yyla.empty ()) 1015 yy_destroy_ ("Cleanup: discarding lookahead", yyla); 1016 1017 /* Do not reclaim the symbols of the rule whose action triggered 1018 this YYABORT or YYACCEPT. */ 1019 yypop_ (yylen); 1020 YY_STACK_PRINT (); 1021 while (1 < yystack_.size ()) 1022 { 1023 yy_destroy_ ("Cleanup: popping", yystack_[0]); 1024 yypop_ (); 1025 } 1026 1027 return yyresult; 1028 } 1029 #if YY_EXCEPTIONS 1030 catch (...) 1031 { 1032 YYCDEBUG << "Exception caught: cleaning lookahead and stack\n"; 1033 // Do not try to display the values of the reclaimed symbols, 1034 // as their printers might throw an exception. 1035 if (!yyla.empty ()) 1036 yy_destroy_ (YY_NULLPTR, yyla); 1037 1038 while (1 < yystack_.size ()) 1039 { 1040 yy_destroy_ (YY_NULLPTR, yystack_[0]); 1041 yypop_ (); 1042 } 1043 throw; 1044 } 1045 #endif // YY_EXCEPTIONS 1046 } 1047 1048 void error(const syntax_error & yyexc)1049 Parser::error (const syntax_error& yyexc) 1050 { 1051 error (yyexc.what ()); 1052 } 1053 1054 #if YYDEBUG || 0 1055 const char * symbol_name(symbol_kind_type yysymbol)1056 Parser::symbol_name (symbol_kind_type yysymbol) 1057 { 1058 return yytname_[yysymbol]; 1059 } 1060 #endif // #if YYDEBUG || 0 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 const signed char Parser::yypact_ninf_ = -3; 1071 1072 const signed char Parser::yytable_ninf_ = -1; 1073 1074 const short 1075 Parser::yypact_[] = 1076 { 1077 0, 0, -2, 1, -3, 8, 13, 14, -3, 0, 1078 0, 0, 2, 142, -3, 50, 6, 9, 10, 11, 1079 12, -3, -3, -3, -3, 0, 38, 39, 0, 0, 1080 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1081 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1082 0, -3, 15, 21, 22, 49, 51, 188, 0, 0, 1083 221, 96, 95, 95, 95, 95, 95, 95, 95, 141, 1084 141, 141, 141, 141, 141, 17, 17, 17, 17, 17, 1085 17, 17, 17, -3, -3, -3, -3, -3, 188, 188, 1086 0, 221 1087 }; 1088 1089 const signed char 1090 Parser::yydefact_[] = 1091 { 1092 2, 0, 0, 0, 40, 0, 0, 0, 41, 0, 1093 0, 0, 0, 3, 30, 0, 0, 0, 0, 0, 1094 0, 31, 32, 33, 1, 0, 0, 0, 0, 0, 1095 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1096 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1097 0, 34, 0, 0, 0, 0, 0, 27, 0, 0, 1098 26, 0, 21, 22, 24, 23, 18, 20, 19, 16, 1099 17, 12, 14, 13, 15, 10, 11, 8, 9, 5, 1100 6, 7, 4, 36, 39, 35, 37, 38, 28, 29, 1101 0, 25 1102 }; 1103 1104 const signed char 1105 Parser::yypgoto_[] = 1106 { 1107 -3, -3, -1, 4 1108 }; 1109 1110 const signed char 1111 Parser::yydefgoto_[] = 1112 { 1113 0, 12, 13, 14 1114 }; 1115 1116 const signed char 1117 Parser::yytable_[] = 1118 { 1119 15, 16, 24, 1, 17, 2, 3, 4, 5, 6, 1120 7, 18, 8, 21, 22, 23, 19, 20, 52, 83, 1121 53, 54, 55, 56, 57, 84, 85, 60, 61, 62, 1122 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 1123 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 1124 9, 58, 59, 86, 51, 87, 0, 88, 89, 10, 1125 0, 11, 0, 25, 26, 27, 28, 0, 29, 0, 1126 0, 0, 30, 0, 31, 50, 32, 33, 34, 35, 1127 36, 0, 37, 0, 38, 0, 39, 0, 40, 91, 1128 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 1129 46, 0, 47, 0, 48, 0, 49, 0, 50, 25, 1130 26, 27, 28, 0, 29, 0, 90, 0, 30, 0, 1131 31, 0, 32, 33, 34, 35, 36, 37, 37, 38, 1132 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 1133 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 1134 48, 49, 49, 50, 50, 25, 26, 27, 28, 0, 1135 29, 0, 0, 0, 30, 0, 31, 0, 32, 33, 1136 34, 35, 36, -1, 37, -1, 38, -1, 39, -1, 1137 40, -1, 41, -1, 42, 43, 43, 44, 44, 45, 1138 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 1139 50, -1, -1, -1, 28, 0, 29, 0, 0, 0, 1140 30, 0, 31, 0, 32, 33, 34, 35, 36, 0, 1141 37, 0, 38, 0, 39, 0, 40, 0, 41, 0, 1142 42, 0, 43, 0, 44, 0, 45, 0, 46, 29, 1143 47, 0, 48, 30, 49, 31, 50, 32, 33, 34, 1144 35, 36, 0, 37, 0, 38, 0, 39, 0, 40, 1145 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, 1146 0, 46, 0, 47, 0, 48, 0, 49, 0, 50 1147 }; 1148 1149 const signed char 1150 Parser::yycheck_[] = 1151 { 1152 1, 3, 0, 3, 3, 5, 6, 7, 8, 9, 1153 10, 3, 12, 9, 10, 11, 3, 3, 12, 4, 1154 11, 11, 11, 11, 25, 4, 4, 28, 29, 30, 1155 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 1156 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1157 50, 13, 13, 4, 4, 4, -1, 58, 59, 59, 1158 -1, 61, -1, 13, 14, 15, 16, -1, 18, -1, 1159 -1, -1, 22, -1, 24, 58, 26, 27, 28, 29, 1160 30, -1, 32, -1, 34, -1, 36, -1, 38, 90, 1161 40, -1, 42, -1, 44, -1, 46, -1, 48, -1, 1162 50, -1, 52, -1, 54, -1, 56, -1, 58, 13, 1163 14, 15, 16, -1, 18, -1, 20, -1, 22, -1, 1164 24, -1, 26, 27, 28, 29, 30, 32, 32, 34, 1165 34, 36, 36, 38, 38, 40, 40, 42, 42, 44, 1166 44, 46, 46, 48, 48, 50, 50, 52, 52, 54, 1167 54, 56, 56, 58, 58, 13, 14, 15, 16, -1, 1168 18, -1, -1, -1, 22, -1, 24, -1, 26, 27, 1169 28, 29, 30, 32, 32, 34, 34, 36, 36, 38, 1170 38, 40, 40, 42, 42, 44, 44, 46, 46, 48, 1171 48, 50, 50, 52, 52, 54, 54, 56, 56, 58, 1172 58, 13, 14, 15, 16, -1, 18, -1, -1, -1, 1173 22, -1, 24, -1, 26, 27, 28, 29, 30, -1, 1174 32, -1, 34, -1, 36, -1, 38, -1, 40, -1, 1175 42, -1, 44, -1, 46, -1, 48, -1, 50, 18, 1176 52, -1, 54, 22, 56, 24, 58, 26, 27, 28, 1177 29, 30, -1, 32, -1, 34, -1, 36, -1, 38, 1178 -1, 40, -1, 42, -1, 44, -1, 46, -1, 48, 1179 -1, 50, -1, 52, -1, 54, -1, 56, -1, 58 1180 }; 1181 1182 const signed char 1183 Parser::yystos_[] = 1184 { 1185 0, 3, 5, 6, 7, 8, 9, 10, 12, 50, 1186 59, 61, 64, 65, 66, 65, 3, 3, 3, 3, 1187 3, 66, 66, 66, 0, 13, 14, 15, 16, 18, 1188 22, 24, 26, 27, 28, 29, 30, 32, 34, 36, 1189 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 1190 58, 4, 12, 11, 11, 11, 11, 65, 13, 13, 1191 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 1192 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 1193 65, 65, 65, 4, 4, 4, 4, 4, 65, 65, 1194 20, 65 1195 }; 1196 1197 const signed char 1198 Parser::yyr1_[] = 1199 { 1200 0, 63, 64, 64, 65, 65, 65, 65, 65, 65, 1201 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 1202 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 1203 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 1204 66, 66 1205 }; 1206 1207 const signed char 1208 Parser::yyr2_[] = 1209 { 1210 0, 2, 0, 1, 3, 3, 3, 3, 3, 3, 1211 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1212 3, 3, 3, 3, 3, 5, 3, 3, 4, 4, 1213 1, 2, 2, 2, 3, 4, 4, 4, 4, 4, 1214 1, 1 1215 }; 1216 1217 1218 #if YYDEBUG 1219 // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. 1220 // First, the terminals, then, starting at \a YYNTOKENS, nonterminals. 1221 const char* 1222 const Parser::yytname_[] = 1223 { 1224 "YYEOF", "error", "\"invalid token\"", "\"(\"", "\")\"", "HASPROP", 1225 "FILEIOVFD", "NUM", "FNAME", "JGROUP", "JPARENT", "QSTR", "NAME", "IN", 1226 "SOME", "ORDR", "COMMA", "\",\"", "QWE", "\"?\"", "COLON", "\":\"", 1227 "AND", "\"&&\"", "OR", "\"|\"", "EQV", "NEQV", "BITAND", "BITOR", 1228 "BITXOR", "\"^\"", "EQ", "\"=\"", "NE", "\"!=\"", "LT", "\"<\"", "GT", 1229 "\">\"", "LE", "\"<=\"", "GE", "\">=\"", "LS", "\"<<\"", "RS", "\">>\"", 1230 "ADD", "\"+\"", "MINUS", "\"-\"", "MUL", "\"*\"", "DIV", "\"/\"", "REM", 1231 "\"%\"", "DEG", "NOT", "\"!\"", "BITNOT", "\"~\"", "$accept", "S", "exp", 1232 "term", YY_NULLPTR 1233 }; 1234 #endif 1235 1236 1237 #if YYDEBUG 1238 const unsigned char 1239 Parser::yyrline_[] = 1240 { 1241 0, 120, 120, 121, 123, 124, 125, 126, 127, 128, 1242 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 1243 139, 140, 141, 142, 143, 144, 149, 150, 151, 152, 1244 153, 155, 160, 161, 162, 163, 169, 174, 180, 186, 1245 192, 193 1246 }; 1247 1248 void yy_stack_print_() const1249 Parser::yy_stack_print_ () const 1250 { 1251 *yycdebug_ << "Stack now"; 1252 for (stack_type::const_iterator 1253 i = yystack_.begin (), 1254 i_end = yystack_.end (); 1255 i != i_end; ++i) 1256 *yycdebug_ << ' ' << int (i->state); 1257 *yycdebug_ << '\n'; 1258 } 1259 1260 void yy_reduce_print_(int yyrule) const1261 Parser::yy_reduce_print_ (int yyrule) const 1262 { 1263 int yylno = yyrline_[yyrule]; 1264 int yynrhs = yyr2_[yyrule]; 1265 // Print the symbols being reduced, and their result. 1266 *yycdebug_ << "Reducing stack by rule " << yyrule - 1 1267 << " (line " << yylno << "):\n"; 1268 // The symbols being reduced. 1269 for (int yyi = 0; yyi < yynrhs; yyi++) 1270 YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", 1271 yystack_[(yynrhs) - (yyi + 1)]); 1272 } 1273 #endif // YYDEBUG 1274 1275 1276 #line 67 "QLParser.yy" 1277 } // QL 1278 #line 1279 "QLParser.tab.cc" 1279 1280 #line 195 "QLParser.yy" 1281 1282 1283 namespace QL 1284 { 1285 static Parser::symbol_type unget_ret(std::istream & in,char c,Parser::symbol_type tok)1286 unget_ret (std::istream &in, char c, Parser::symbol_type tok) 1287 { 1288 in.putback (c); 1289 return tok; 1290 } 1291 1292 static Parser::symbol_type yylex(QL::Result & result)1293 yylex (QL::Result &result) 1294 { 1295 int base = 0; 1296 int c; 1297 1298 do 1299 c = result.in.get (); 1300 while (result.in && (c == ' ' || c == '\t')); 1301 if (!result.in) 1302 return Parser::make_YYEOF (); 1303 1304 switch (c) 1305 { 1306 case '\0': 1307 case '\n': return Parser::make_YYEOF (); 1308 case '(': return Parser::make_LPAR () ; 1309 case ')': return Parser::make_RPAR (); 1310 case ',': return Parser::make_COMMA (); 1311 case '%': return Parser::make_REM (); 1312 case '/': return Parser::make_DIV (); 1313 case '*': return Parser::make_MUL (); 1314 case '-': return Parser::make_MINUS (); 1315 case '+': return Parser::make_ADD (); 1316 case '~': return Parser::make_BITNOT (); 1317 case '^': return Parser::make_BITXOR (); 1318 case '?': return Parser::make_QWE (); 1319 case ':': return Parser::make_COLON (); 1320 case '|': 1321 c = result.in.get (); 1322 if (c == '|') 1323 return Parser::make_OR (); 1324 else 1325 return unget_ret (result.in, c, Parser::make_BITOR ()); 1326 case '&': 1327 c = result.in.get (); 1328 if (c == '&') 1329 return Parser::make_AND (); 1330 else 1331 return unget_ret (result.in, c, Parser::make_BITAND ()); 1332 case '!': 1333 c = result.in.get (); 1334 if (c == '=') 1335 return Parser::make_NE (); 1336 else 1337 return unget_ret (result.in, c, Parser::make_NOT ()); 1338 case '=': 1339 c = result.in.get (); 1340 if (c == '=') 1341 return Parser::make_EQ (); 1342 else 1343 throw Parser::syntax_error ("Syntax error after ="); 1344 case '<': 1345 c = result.in.get (); 1346 if (c == '=') 1347 return Parser::make_LE (); 1348 else if (c == '<') 1349 return Parser::make_LS (); 1350 else 1351 return unget_ret (result.in, c, Parser::make_LT ()); 1352 case '>': 1353 c = result.in.get (); 1354 if (c == '=') 1355 return Parser::make_GE (); 1356 else if (c == '>') 1357 return Parser::make_RS (); 1358 else 1359 return unget_ret (result.in, c, Parser::make_GT ()); 1360 case '"': 1361 { 1362 int maxsz = 16; 1363 char *str = (char *) malloc (maxsz); 1364 char *ptr = str; 1365 1366 for (;;) 1367 { 1368 c = result.in.get (); 1369 if (!result.in) 1370 { 1371 free (str); 1372 throw Parser::syntax_error ("Unclosed \""); 1373 } 1374 1375 switch (c) 1376 { 1377 case '"': 1378 *ptr = (char)0; 1379 // XXX omazur: need new string type 1380 return Parser::make_QSTR ((uint64_t) str); 1381 case 0: 1382 case '\n': 1383 free (str); 1384 throw Parser::syntax_error ("Multiline strings are not supported"); 1385 default: 1386 if (ptr - str >= maxsz) 1387 { 1388 size_t len = ptr - str; 1389 maxsz = maxsz > 8192 ? maxsz + 8192 : maxsz * 2; 1390 char *new_s = (char *) realloc (str, maxsz); 1391 str = new_s; 1392 ptr = str + len; 1393 } 1394 *ptr++ = c; 1395 } 1396 } 1397 } 1398 default: 1399 if (c == '0') 1400 { 1401 base = 8; 1402 c = result.in.get (); 1403 if ( c == 'x' ) 1404 { 1405 base = 16; 1406 c = result.in.get (); 1407 } 1408 } 1409 else if (c >= '1' && c <='9') 1410 base = 10; 1411 1412 if (base) 1413 { 1414 uint64_t lval = 0; 1415 for (;;) 1416 { 1417 int digit = -1; 1418 switch (c) 1419 { 1420 case '0': case '1': case '2': case '3': 1421 case '4': case '5': case '6': case '7': 1422 digit = c - '0'; 1423 break; 1424 case '8': case '9': 1425 if (base > 8) 1426 digit = c - '0'; 1427 break; 1428 case 'a': case 'b': case 'c': 1429 case 'd': case 'e': case 'f': 1430 if (base == 16) 1431 digit = c - 'a' + 10; 1432 break; 1433 case 'A': case 'B': case 'C': 1434 case 'D': case 'E': case 'F': 1435 if (base == 16) 1436 digit = c - 'A' + 10; 1437 break; 1438 } 1439 if (digit == -1) 1440 { 1441 result.in.putback (c); 1442 break; 1443 } 1444 lval = lval * base + digit; 1445 c = result.in.get (); 1446 } 1447 return Parser::make_NUM (lval); 1448 } 1449 1450 if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) 1451 { 1452 char name[32]; // omazur XXX: accept any length 1453 name[0] = (char)c; 1454 for (size_t i = 1; i < sizeof (name); i++) 1455 { 1456 c = result.in.get (); 1457 if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || 1458 (c >= '0' && c <= '9') || (c == '_')) 1459 name[i] = c; 1460 else 1461 { 1462 name[i] = (char)0; 1463 result.in.putback (c); 1464 break; 1465 } 1466 } 1467 1468 if (strcasecmp (name, NTXT ("IN")) == 0) 1469 return Parser::make_IN (); 1470 else if (strcasecmp (name, NTXT ("SOME")) == 0) 1471 return Parser::make_SOME (); 1472 else if (strcasecmp (name, NTXT ("ORDERED")) == 0) 1473 return Parser::make_ORDR (); 1474 else if (strcasecmp (name, NTXT ("TRUE")) == 0) 1475 return Parser::make_NUM ((uint64_t) 1); 1476 else if (strcasecmp (name, NTXT ("FALSE")) == 0) 1477 return Parser::make_NUM ((uint64_t) 0); 1478 else if (strcasecmp (name, NTXT ("FNAME")) == 0) 1479 return Parser::make_FNAME (Expression::FUNC_FNAME); 1480 else if (strcasecmp (name, NTXT ("HAS_PROP")) == 0) 1481 return Parser::make_HASPROP (); 1482 else if (strcasecmp (name, NTXT ("JGROUP")) == 0) 1483 return Parser::make_JGROUP (Expression::JAVA_JGROUP); 1484 else if (strcasecmp (name, NTXT ("JPARENT")) == 0 ) 1485 return Parser::make_JPARENT (Expression::JAVA_JPARENT); 1486 else if (strcasecmp (name, NTXT ("DNAME")) == 0) 1487 return Parser::make_FNAME (Expression::FUNC_DNAME); 1488 else if (strcasecmp (name, NTXT ("FILEIOVFD")) == 0 ) 1489 return Parser::make_FILEIOVFD (); 1490 1491 std::string nm = std::string (name); 1492 return Parser::make_NAME (nm); 1493 } 1494 1495 throw Parser::syntax_error ("Syntax error"); 1496 } 1497 } 1498 void error(const std::string &)1499 Parser::error (const std::string &) 1500 { 1501 // do nothing for now 1502 } 1503 } 1504 1505