1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef YY_YY_YACC_PARSER_HPP_INCLUDED 17 #define YY_YY_YACC_PARSER_HPP_INCLUDED 18 // "%code requires" blocks. 19 20 #include <cmath> 21 #include <iostream> 22 #include <stdint.h> 23 #include <string> 24 #include <vector> 25 #include "location.hh" 26 #include "script_expression.h" 27 #include "script_function.h" 28 #include "script_param.h" 29 #include "script_statement.h" 30 31 using std::string; 32 namespace uscript { 33 class Scanner; 34 class ScriptInterpreter; 35 } 36 37 #include <cstdlib> // std::abort 38 #include <iostream> 39 #include <stdexcept> 40 #include <string> 41 #include <vector> 42 43 #if defined __cplusplus 44 # define YY_CPLUSPLUS __cplusplus 45 #else 46 # define YY_CPLUSPLUS 199711L 47 #endif 48 49 // Support move semantics when possible. 50 #if 201103L <= YY_CPLUSPLUS 51 # define YY_MOVE std::move 52 # define YY_MOVE_OR_COPY move 53 # define YY_MOVE_REF(Type) Type&& 54 # define YY_RVREF(Type) Type&& 55 # define YY_COPY(Type) Type 56 #else 57 # define YY_MOVE 58 # define YY_MOVE_OR_COPY copy 59 # define YY_MOVE_REF(Type) Type& 60 # define YY_RVREF(Type) const Type& 61 # define YY_COPY(Type) const Type& 62 #endif 63 64 // Support noexcept when possible. 65 #if 201103L <= YY_CPLUSPLUS 66 # define YY_NOEXCEPT noexcept 67 # define YY_NOTHROW 68 #else 69 # define YY_NOEXCEPT 70 # define YY_NOTHROW throw () 71 #endif 72 73 // Support constexpr when possible. 74 #if 201703 <= YY_CPLUSPLUS 75 # define YY_CONSTEXPR constexpr 76 #else 77 # define YY_CONSTEXPR 78 #endif 79 # include "location.hh" 80 81 #ifndef YY_ASSERT 82 # include <cassert> 83 # define YY_ASSERT assert 84 #endif 85 86 #ifndef YY_ATTRIBUTE_PURE 87 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) 88 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) 89 # else 90 # define YY_ATTRIBUTE_PURE 91 # endif 92 #endif 93 94 #ifndef YY_ATTRIBUTE_UNUSED 95 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) 96 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) 97 # else 98 # define YY_ATTRIBUTE_UNUSED 99 # endif 100 #endif 101 102 /* Suppress unused-variable warnings by "using" E. */ 103 #if ! defined lint || defined __GNUC__ 104 # define YYUSE(E) ((void) (E)) 105 #else 106 # define YYUSE(E) /* empty */ 107 #endif 108 109 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ 110 /* Suppress an incorrect diagnostic about yylval being uninitialized. */ 111 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ 112 _Pragma ("GCC diagnostic push") \ 113 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ 114 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") 115 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ 116 _Pragma ("GCC diagnostic pop") 117 #else 118 # define YY_INITIAL_VALUE(Value) Value 119 #endif 120 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 121 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 122 # define YY_IGNORE_MAYBE_UNINITIALIZED_END 123 #endif 124 #ifndef YY_INITIAL_VALUE 125 # define YY_INITIAL_VALUE(Value) /* Nothing. */ 126 #endif 127 128 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ 129 # define YY_IGNORE_USELESS_CAST_BEGIN \ 130 _Pragma ("GCC diagnostic push") \ 131 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") 132 # define YY_IGNORE_USELESS_CAST_END \ 133 _Pragma ("GCC diagnostic pop") 134 #endif 135 #ifndef YY_IGNORE_USELESS_CAST_BEGIN 136 # define YY_IGNORE_USELESS_CAST_BEGIN 137 # define YY_IGNORE_USELESS_CAST_END 138 #endif 139 140 # ifndef YY_CAST 141 # ifdef __cplusplus 142 # define YY_CAST(Type, Val) static_cast<Type> (Val) 143 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val) 144 # else 145 # define YY_CAST(Type, Val) ((Type) (Val)) 146 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) 147 # endif 148 # endif 149 # ifndef YY_NULLPTR 150 # if defined __cplusplus 151 # if 201103L <= __cplusplus 152 # define YY_NULLPTR nullptr 153 # else 154 # define YY_NULLPTR 0 155 # endif 156 # else 157 # define YY_NULLPTR ((void*)0) 158 # endif 159 # endif 160 161 /* Debug traces. */ 162 #ifndef YYDEBUG 163 # define YYDEBUG 0 164 #endif 165 166 namespace uscript { 167 /// A Bison parser. 168 class Parser { 169 public: 170 #ifndef YYSTYPE 171 /// A buffer to store and retrieve objects. 172 /// 173 /// Sort of a variant, but does not keep track of the nature 174 /// of the stored data, since that knowledge is available 175 /// via the current parser state. 176 class semantic_type { 177 public: 178 /// Type of *this. 179 typedef semantic_type self_type; 180 /// Empty construction. semantic_type()181 semantic_type () YY_NOEXCEPT 182 : yybuffer_ () 183 {} 184 /// Construct and fill. 185 template <typename T> semantic_type(YY_RVREF (T)t)186 semantic_type (YY_RVREF (T)t) 187 { 188 YY_ASSERT (sizeof (T) <= size); 189 new (yyas_<T> ()) T (YY_MOVE (t)); 190 } 191 #if 201103L <= YY_CPLUSPLUS 192 /// Non copyable. 193 semantic_type (const self_type&) = delete; 194 /// Non copyable. 195 self_type& operator= (const self_type&) = delete; 196 #endif 197 /// Destruction, allowed only if empty. ~semantic_type()198 ~semantic_type () YY_NOEXCEPT {} 199 # if 201103L <= YY_CPLUSPLUS 200 /// Instantiate a \a T in here from \a t. 201 template <typename T, typename... U> emplace(U &&...u)202 T& emplace (U&&... u) 203 { 204 return *new (yyas_<T> ()) T (std::forward <U>(u)...); 205 } 206 # else 207 /// Instantiate an empty \a T in here. 208 template <typename T> emplace()209 T& emplace () 210 { 211 return *new (yyas_<T> ()) T (); 212 } 213 /// Instantiate a \a T in here from \a t. 214 template <typename T> emplace(const T & t)215 T& emplace (const T& t) 216 { 217 return *new (yyas_<T> ()) T (t); 218 } 219 # endif 220 /// Instantiate an empty \a T in here. 221 /// Obsolete, use emplace. 222 template <typename T> build()223 T& build () 224 { 225 return emplace<T> (); 226 } 227 /// Instantiate a \a T in here from \a t. 228 /// Obsolete, use emplace. 229 template <typename T> build(const T & t)230 T& build (const T& t) 231 { 232 return emplace<T> (t); 233 } 234 /// Accessor to a built \a T. 235 template <typename T> as()236 T& as () YY_NOEXCEPT 237 { 238 return *yyas_<T> (); 239 } 240 /// Const accessor to a built \a T (for %printer). 241 template <typename T> as() const242 const T& as () const YY_NOEXCEPT 243 { 244 return *yyas_<T> (); 245 } 246 247 /// Swap the content with \a that, of same type. 248 /// 249 /// Both variants must be built beforehand, because swapping the actual 250 /// data requires reading it (with as()), and this is not possible on 251 /// unconstructed variants: it would require some dynamic testing, which 252 /// should not be the variant's responsibility. 253 /// Swapping between built and (possibly) non-built is done with 254 /// self_type::move (). 255 template <typename T> swap(self_type & that)256 void swap (self_type& that) YY_NOEXCEPT 257 { 258 std::swap (as<T> (), that.as<T> ()); 259 } 260 /// Move the content of \a that to this. 261 /// 262 /// Destroys \a that. 263 template <typename T> move(self_type & that)264 void move (self_type& that) 265 { 266 # if 201103L <= YY_CPLUSPLUS 267 emplace<T> (std::move (that.as<T> ())); 268 # else 269 emplace<T> (); 270 swap<T> (that); 271 # endif 272 that.destroy<T> (); 273 } 274 # if 201103L <= YY_CPLUSPLUS 275 /// Move the content of \a that to this. 276 template <typename T> move(self_type && that)277 void move (self_type&& that) 278 { 279 emplace<T> (std::move (that.as<T> ())); 280 that.destroy<T> (); 281 } 282 #endif 283 /// Copy the content of \a that to this. 284 template <typename T> copy(const self_type & that)285 void copy (const self_type& that) 286 { 287 emplace<T> (that.as<T> ()); 288 } 289 /// Destroy the stored \a T. 290 template <typename T> destroy()291 void destroy () 292 { 293 as<T> ().~T (); 294 } 295 296 private: 297 #if YY_CPLUSPLUS < 201103L 298 /// Non copyable. 299 semantic_type (const self_type&); 300 /// Non copyable. 301 self_type& operator= (const self_type&); 302 #endif 303 /// Accessor to raw memory as \a T. 304 template <typename T> 305 T* yyas_()306 yyas_ () YY_NOEXCEPT 307 { 308 void *yyp = yybuffer_.yyraw; 309 return static_cast<T*> (yyp); 310 } 311 /// Const accessor to raw memory as \a T. 312 template <typename T> 313 const T* yyas_() const314 yyas_ () const YY_NOEXCEPT 315 { 316 const void *yyp = yybuffer_.yyraw; 317 return static_cast<const T*> (yyp); 318 } 319 320 /// An auxiliary type to compute the largest semantic type. 321 union union_type { 322 // function_definition 323 char dummy1[sizeof (ScriptFunction*)]; 324 // arglist 325 char dummy2[sizeof (ScriptParams*)]; 326 // definition_or_statement 327 // expression 328 // value_expression 329 // compare_expression 330 // add_sub_expression 331 // mul_div_expression 332 // primary_expression 333 // arg 334 // expression_option 335 char dummy3[sizeof (UScriptExpression*)]; 336 // statement 337 // expression_statement 338 // for_statement 339 // while_statement 340 // if_statement 341 // break_statement 342 // continue_statement 343 // return_statement 344 char dummy4[sizeof (UScriptStatement*)]; 345 // statement_list 346 // block 347 char dummy5[sizeof (UScriptStatementList*)]; 348 // FLOAT 349 char dummy6[sizeof (float)]; 350 // NUMBER 351 char dummy7[sizeof (int)]; 352 // VAR 353 // FUNCTION 354 // GLOBAL 355 // FOR 356 // WHILE 357 // IF 358 // ELSE 359 // ADD 360 // SUB 361 // MUL 362 // DIV 363 // ASSIGN 364 // AND 365 // OR 366 // EQ 367 // NE 368 // GT 369 // GE 370 // LT 371 // LE 372 // LP 373 // RP 374 // LC 375 // RC 376 // SEMICOLON 377 // IDENTIFIER 378 // BREAK 379 // CONTINUE 380 // RETURN 381 // COMMA 382 // STRING 383 char dummy8[sizeof(string)]; 384 }; 385 /// The size of the largest semantic type. 386 enum {size = sizeof(union_type)}; 387 /// A buffer to store semantic values. 388 union { 389 /// Strongest alignment constraints. 390 long double yyalign_me; 391 /// A buffer large enough to store any of the semantic values. 392 char yyraw[size]; 393 }yybuffer_; 394 }; 395 396 #else 397 typedef YYSTYPE semantic_type; 398 #endif 399 /// Symbol locations. 400 typedef location location_type; 401 402 /// Syntax errors thrown from user actions. 403 struct syntax_error : std::runtime_error 404 { syntax_erroruscript::Parser::syntax_error405 syntax_error(const location_type& l, const std::string& m) 406 : std::runtime_error(m), location(l) {} syntax_erroruscript::Parser::syntax_error407 syntax_error (const syntax_error& s) 408 : std::runtime_error(s.what()), location(s.location) {} 409 ~syntax_error ()YY_NOEXCEPT YY_NOTHROW; 410 location_type location; 411 }; 412 413 /// Token kinds. 414 struct token { 415 enum token_kind_type { 416 TOKEN_YYEMPTY = -2, 417 TOKEN_END = 0, // END 418 TOKEN_YYerror = 256, // error 419 TOKEN_YYUNDEF = 257, // "invalid token" 420 TOKEN_NUMBER = 258, // NUMBER 421 TOKEN_FLOAT = 259, // FLOAT 422 TOKEN_EOL = 260, // EOL 423 TOKEN_VAR = 261, // VAR 424 TOKEN_FUNCTION = 262, // FUNCTION 425 TOKEN_GLOBAL = 263, // GLOBAL 426 TOKEN_FOR = 264, // FOR 427 TOKEN_WHILE = 265, // WHILE 428 TOKEN_IF = 266, // IF 429 TOKEN_ELSE = 267, // ELSE 430 TOKEN_ADD = 268, // ADD 431 TOKEN_SUB = 269, // SUB 432 TOKEN_MUL = 270, // MUL 433 TOKEN_DIV = 271, // DIV 434 TOKEN_ASSIGN = 272, // ASSIGN 435 TOKEN_AND = 273, // AND 436 TOKEN_OR = 274, // OR 437 TOKEN_EQ = 275, // EQ 438 TOKEN_NE = 276, // NE 439 TOKEN_GT = 277, // GT 440 TOKEN_GE = 278, // GE 441 TOKEN_LT = 279, // LT 442 TOKEN_LE = 280, // LE 443 TOKEN_LP = 281, // LP 444 TOKEN_RP = 282, // RP 445 TOKEN_LC = 283, // LC 446 TOKEN_RC = 284, // RC 447 TOKEN_SEMICOLON = 285, // SEMICOLON 448 TOKEN_IDENTIFIER = 286, // IDENTIFIER 449 TOKEN_BREAK = 287, // BREAK 450 TOKEN_CONTINUE = 288, // CONTINUE 451 TOKEN_RETURN = 289, // RETURN 452 TOKEN_COMMA = 290, // COMMA 453 TOKEN_STRING = 291 // STRING 454 }; 455 /// Backward compatibility alias (Bison 3.6). 456 typedef token_kind_type yytokentype; 457 }; 458 459 /// Token kind, as returned by yylex. 460 typedef token::yytokentype token_kind_type; 461 /// Backward compatibility alias (Bison 3.6). 462 typedef token_kind_type token_type; 463 /// Symbol kinds. 464 struct symbol_kind { 465 enum symbol_kind_type { 466 YYNTOKENS = 37, ///< Number of tokens. 467 S_YYEMPTY = -2, 468 S_YYEOF = 0, // END 469 S_YYerror = 1, // error 470 S_YYUNDEF = 2, // "invalid token" 471 S_NUMBER = 3, // NUMBER 472 S_FLOAT = 4, // FLOAT 473 S_EOL = 5, // EOL 474 S_VAR = 6, // VAR 475 S_FUNCTION = 7, // FUNCTION 476 S_GLOBAL = 8, // GLOBAL 477 S_FOR = 9, // FOR 478 S_WHILE = 10, // WHILE 479 S_IF = 11, // IF 480 S_ELSE = 12, // ELSE 481 S_ADD = 13, // ADD 482 S_SUB = 14, // SUB 483 S_MUL = 15, // MUL 484 S_DIV = 16, // DIV 485 S_ASSIGN = 17, // ASSIGN 486 S_AND = 18, // AND 487 S_OR = 19, // OR 488 S_EQ = 20, // EQ 489 S_NE = 21, // NE 490 S_GT = 22, // GT 491 S_GE = 23, // GE 492 S_LT = 24, // LT 493 S_LE = 25, // LE 494 S_LP = 26, // LP 495 S_RP = 27, // RP 496 S_LC = 28, // LC 497 S_RC = 29, // RC 498 S_SEMICOLON = 30, // SEMICOLON 499 S_IDENTIFIER = 31, // IDENTIFIER 500 S_BREAK = 32, // BREAK 501 S_CONTINUE = 33, // CONTINUE 502 S_RETURN = 34, // RETURN 503 S_COMMA = 35, // COMMA 504 S_STRING = 36, // STRING 505 S_YYACCEPT = 37, // $accept 506 S_translation_unit = 38, // translation_unit 507 S_definition_or_statement = 39, // definition_or_statement 508 S_function_definition = 40, // function_definition 509 S_statement = 41, // statement 510 S_expression_statement = 42, // expression_statement 511 S_expression = 43, // expression 512 S_value_expression = 44, // value_expression 513 S_compare_expression = 45, // compare_expression 514 S_add_sub_expression = 46, // add_sub_expression 515 S_mul_div_expression = 47, // mul_div_expression 516 S_primary_expression = 48, // primary_expression 517 S_statement_list = 49, // statement_list 518 S_block = 50, // block 519 S_arglist = 51, // arglist 520 S_arg = 52, // arg 521 S_expression_option = 53, // expression_option 522 S_for_statement = 54, // for_statement 523 S_while_statement = 55, // while_statement 524 S_if_statement = 56, // if_statement 525 S_break_statement = 57, // break_statement 526 S_continue_statement = 58, // continue_statement 527 S_return_statement = 59 // return_statement 528 }; 529 }; 530 531 /// (Internal) symbol kind. 532 typedef symbol_kind::symbol_kind_type symbol_kind_type; 533 /// The number of tokens. 534 static const symbol_kind_type YYNTOKENS = symbol_kind::YYNTOKENS; 535 /// A complete symbol. 536 /// 537 /// Expects its Base type to provide access to the symbol kind 538 /// via kind (). 539 /// 540 /// Provide access to semantic value and location. 541 template <typename Base> 542 struct basic_symbol : Base { 543 /// Alias to Base. 544 typedef Base super_type; 545 /// Default constructor. basic_symboluscript::Parser::basic_symbol546 basic_symbol() 547 : value(), location() {} 548 #if 201103L <= YY_CPLUSPLUS 549 /// Move constructor. basic_symboluscript::Parser::basic_symbol550 basic_symbol(basic_symbol&& that) 551 : Base(std::move (that)), value (), location(std::move (that.location)) 552 { 553 switch (this->kind ()) { 554 case symbol_kind::S_function_definition: // function_definition 555 value.move<ScriptFunction*>(std::move(that.value)); 556 break; 557 case symbol_kind::S_arglist: // arglist 558 value.move<ScriptParams*>(std::move(that.value)); 559 break; 560 case symbol_kind::S_definition_or_statement: // definition_or_statement 561 case symbol_kind::S_expression: // expression 562 case symbol_kind::S_value_expression: // value_expression 563 case symbol_kind::S_compare_expression: // compare_expression 564 case symbol_kind::S_add_sub_expression: // add_sub_expression 565 case symbol_kind::S_mul_div_expression: // mul_div_expression 566 case symbol_kind::S_primary_expression: // primary_expression 567 case symbol_kind::S_arg: // arg 568 case symbol_kind::S_expression_option: // expression_option 569 value.move<UScriptExpression*>(std::move(that.value)); 570 break; 571 case symbol_kind::S_statement: // statement 572 case symbol_kind::S_expression_statement: // expression_statement 573 case symbol_kind::S_for_statement: // for_statement 574 case symbol_kind::S_while_statement: // while_statement 575 case symbol_kind::S_if_statement: // if_statement 576 case symbol_kind::S_break_statement: // break_statement 577 case symbol_kind::S_continue_statement: // continue_statement 578 case symbol_kind::S_return_statement: // return_statement 579 value.move<UScriptStatement*>(std::move(that.value)); 580 break; 581 case symbol_kind::S_statement_list: // statement_list 582 case symbol_kind::S_block: // block 583 value.move<UScriptStatementList*>(std::move(that.value)); 584 break; 585 case symbol_kind::S_FLOAT: // FLOAT 586 value.move<float>(std::move(that.value)); 587 break; 588 case symbol_kind::S_NUMBER: // NUMBER 589 value.move<int> (std::move(that.value)); 590 break; 591 case symbol_kind::S_VAR: // VAR 592 case symbol_kind::S_FUNCTION: // FUNCTION 593 case symbol_kind::S_GLOBAL: // GLOBAL 594 case symbol_kind::S_FOR: // FOR 595 case symbol_kind::S_WHILE: // WHILE 596 case symbol_kind::S_IF: // IF 597 case symbol_kind::S_ELSE: // ELSE 598 case symbol_kind::S_ADD: // ADD 599 case symbol_kind::S_SUB: // SUB 600 case symbol_kind::S_MUL: // MUL 601 case symbol_kind::S_DIV: // DIV 602 case symbol_kind::S_ASSIGN: // ASSIGN 603 case symbol_kind::S_AND: // AND 604 case symbol_kind::S_OR: // OR 605 case symbol_kind::S_EQ: // EQ 606 case symbol_kind::S_NE: // NE 607 case symbol_kind::S_GT: // GT 608 case symbol_kind::S_GE: // GE 609 case symbol_kind::S_LT: // LT 610 case symbol_kind::S_LE: // LE 611 case symbol_kind::S_LP: // LP 612 case symbol_kind::S_RP: // RP 613 case symbol_kind::S_LC: // LC 614 case symbol_kind::S_RC: // RC 615 case symbol_kind::S_SEMICOLON: // SEMICOLON 616 case symbol_kind::S_IDENTIFIER: // IDENTIFIER 617 case symbol_kind::S_BREAK: // BREAK 618 case symbol_kind::S_CONTINUE: // CONTINUE 619 case symbol_kind::S_RETURN: // RETURN 620 case symbol_kind::S_COMMA: // COMMA 621 case symbol_kind::S_STRING: // STRING 622 value.move<string>(std::move(that.value)); 623 break; 624 default: 625 break; 626 } 627 } 628 #endif 629 /// Copy constructor. 630 basic_symbol(const basic_symbol& that); 631 /// Constructor for valueless symbols, and symbols from each type. 632 #if 201103L <= YY_CPLUSPLUS basic_symboluscript::Parser::basic_symbol633 basic_symbol(typename Base::kind_type t, location_type&& l) 634 : Base (t), location (std::move (l)) {} 635 #else basic_symboluscript::Parser::basic_symbol636 basic_symbol(typename Base::kind_type t, const location_type& l) 637 : Base (t), location (l) {} 638 #endif 639 #if 201103L <= YY_CPLUSPLUS basic_symboluscript::Parser::basic_symbol640 basic_symbol(typename Base::kind_type t, ScriptFunction*&& v, location_type&& l) 641 : Base (t), value (std::move (v)), location (std::move (l)) {} 642 #else basic_symboluscript::Parser::basic_symbol643 basic_symbol(typename Base::kind_type t, const ScriptFunction*& v, const location_type& l) 644 : Base (t), value (v), location (l) {} 645 #endif 646 #if 201103L <= YY_CPLUSPLUS basic_symboluscript::Parser::basic_symbol647 basic_symbol(typename Base::kind_type t, ScriptParams*&& v, location_type&& l) 648 : Base (t), value (std::move (v)), location (std::move (l)) {} 649 #else basic_symboluscript::Parser::basic_symbol650 basic_symbol(typename Base::kind_type t, const ScriptParams*& v, const location_type& l) 651 : Base (t), value (v), location (l) {} 652 #endif 653 #if 201103L <= YY_CPLUSPLUS basic_symboluscript::Parser::basic_symbol654 basic_symbol(typename Base::kind_type t, UScriptExpression*&& v, location_type&& l) 655 : Base (t), value (std::move (v)), location (std::move (l)) {} 656 #else basic_symboluscript::Parser::basic_symbol657 basic_symbol(typename Base::kind_type t, const UScriptExpression*& v, const location_type& l) 658 : Base (t), value (v), location (l) {} 659 #endif 660 #if 201103L <= YY_CPLUSPLUS basic_symboluscript::Parser::basic_symbol661 basic_symbol(typename Base::kind_type t, UScriptStatement*&& v, location_type&& l) 662 : Base(t), value(std::move(v)), location(std::move(l)) {} 663 #else basic_symboluscript::Parser::basic_symbol664 basic_symbol(typename Base::kind_type t, const UScriptStatement*& v, const location_type& l) 665 : Base(t), value(v), location(l) {} 666 #endif 667 #if 201103L <= YY_CPLUSPLUS basic_symboluscript::Parser::basic_symbol668 basic_symbol(typename Base::kind_type t, UScriptStatementList*&& v, location_type&& l) 669 : Base(t), value(std::move(v)), location(std::move(l)) 670 {} 671 #else basic_symboluscript::Parser::basic_symbol672 basic_symbol(typename Base::kind_type t, const UScriptStatementList*& v, const location_type& l) 673 : Base(t), value(v), location(l) {} 674 #endif 675 #if 201103L <= YY_CPLUSPLUS basic_symboluscript::Parser::basic_symbol676 basic_symbol(typename Base::kind_type t, float&& v, location_type&& l) 677 : Base(t), value(std::move(v)), location(std::move(l)) {} 678 #else basic_symboluscript::Parser::basic_symbol679 basic_symbol(typename Base::kind_type t, const float& v, const location_type& l) 680 : Base(t), value(v), location(l) {} 681 #endif 682 #if 201103L <= YY_CPLUSPLUS basic_symboluscript::Parser::basic_symbol683 basic_symbol(typename Base::kind_type t, int&& v, location_type&& l) 684 : Base(t), value(std::move(v)), location(std::move(l)) {} 685 #else basic_symboluscript::Parser::basic_symbol686 basic_symbol(typename Base::kind_type t, const int& v, const location_type& l) 687 : Base(t), value(v), location(l) {} 688 #endif 689 #if 201103L <= YY_CPLUSPLUS basic_symboluscript::Parser::basic_symbol690 basic_symbol(typename Base::kind_type t, string&& v, location_type&& l) 691 : Base(t), value(std::move(v)), location(std::move(l)) {} 692 #else basic_symboluscript::Parser::basic_symbol693 basic_symbol(typename Base::kind_type t, const string& v, const location_type& l) 694 : Base(t), value(v), location(l) {} 695 #endif 696 697 /// Destroy the symbol. ~basic_symboluscript::Parser::basic_symbol698 ~basic_symbol() 699 { 700 clear(); 701 } 702 /// Destroy contents, and record that is empty. clearuscript::Parser::basic_symbol703 void clear() 704 { 705 // User destructor. 706 symbol_kind_type yykind = this->kind(); 707 basic_symbol<Base>& yysym = *this; 708 (void) yysym; 709 switch (yykind) { 710 default: 711 break; 712 } 713 714 // Value type destructor. 715 switch (yykind) { 716 case symbol_kind::S_function_definition: // function_definition 717 value.template destroy<ScriptFunction*>(); 718 break; 719 case symbol_kind::S_arglist: // arglist 720 value.template destroy<ScriptParams*>(); 721 break; 722 case symbol_kind::S_definition_or_statement: // definition_or_statement 723 case symbol_kind::S_expression: // expression 724 case symbol_kind::S_value_expression: // value_expression 725 case symbol_kind::S_compare_expression: // compare_expression 726 case symbol_kind::S_add_sub_expression: // add_sub_expression 727 case symbol_kind::S_mul_div_expression: // mul_div_expression 728 case symbol_kind::S_primary_expression: // primary_expression 729 case symbol_kind::S_arg: // arg 730 case symbol_kind::S_expression_option: // expression_option 731 value.template destroy<UScriptExpression*>(); 732 break; 733 case symbol_kind::S_statement: // statement 734 case symbol_kind::S_expression_statement: // expression_statement 735 case symbol_kind::S_for_statement: // for_statement 736 case symbol_kind::S_while_statement: // while_statement 737 case symbol_kind::S_if_statement: // if_statement 738 case symbol_kind::S_break_statement: // break_statement 739 case symbol_kind::S_continue_statement: // continue_statement 740 case symbol_kind::S_return_statement: // return_statement 741 value.template destroy< UScriptStatement* > (); 742 break; 743 case symbol_kind::S_statement_list: // statement_list 744 case symbol_kind::S_block: // block 745 value.template destroy< UScriptStatementList* > (); 746 break; 747 case symbol_kind::S_FLOAT: // FLOAT 748 value.template destroy< float > (); 749 break; 750 case symbol_kind::S_NUMBER: // NUMBER 751 value.template destroy< int > (); 752 break; 753 case symbol_kind::S_VAR: // VAR 754 case symbol_kind::S_FUNCTION: // FUNCTION 755 case symbol_kind::S_GLOBAL: // GLOBAL 756 case symbol_kind::S_FOR: // FOR 757 case symbol_kind::S_WHILE: // WHILE 758 case symbol_kind::S_IF: // IF 759 case symbol_kind::S_ELSE: // ELSE 760 case symbol_kind::S_ADD: // ADD 761 case symbol_kind::S_SUB: // SUB 762 case symbol_kind::S_MUL: // MUL 763 case symbol_kind::S_DIV: // DIV 764 case symbol_kind::S_ASSIGN: // ASSIGN 765 case symbol_kind::S_AND: // AND 766 case symbol_kind::S_OR: // OR 767 case symbol_kind::S_EQ: // EQ 768 case symbol_kind::S_NE: // NE 769 case symbol_kind::S_GT: // GT 770 case symbol_kind::S_GE: // GE 771 case symbol_kind::S_LT: // LT 772 case symbol_kind::S_LE: // LE 773 case symbol_kind::S_LP: // LP 774 case symbol_kind::S_RP: // RP 775 case symbol_kind::S_LC: // LC 776 case symbol_kind::S_RC: // RC 777 case symbol_kind::S_SEMICOLON: // SEMICOLON 778 case symbol_kind::S_IDENTIFIER: // IDENTIFIER 779 case symbol_kind::S_BREAK: // BREAK 780 case symbol_kind::S_CONTINUE: // CONTINUE 781 case symbol_kind::S_RETURN: // RETURN 782 case symbol_kind::S_COMMA: // COMMA 783 case symbol_kind::S_STRING: // STRING 784 value.template destroy< string > (); 785 break; 786 default: 787 break; 788 } 789 Base::clear (); 790 } 791 /// The user-facing name of this symbol. nameuscript::Parser::basic_symbol792 std::string name() const YY_NOEXCEPT 793 { 794 return Parser::symbol_name (this->kind ()); 795 } 796 /// Backward compatibility (Bison 3.6). 797 symbol_kind_type type_get() const YY_NOEXCEPT; 798 /// Whether empty. 799 bool empty() const YY_NOEXCEPT; 800 /// Destructive move, \a s is emptied into this. 801 void move(basic_symbol& s); 802 /// The semantic value. 803 semantic_type value; 804 /// The location. 805 location_type location; 806 private: 807 #if YY_CPLUSPLUS < 201103L 808 /// Assignment operator. 809 basic_symbol& operator= (const basic_symbol& that); 810 #endif 811 }; 812 /// Type access provider for token (enum) based symbols. 813 struct by_kind { 814 /// Default constructor. 815 by_kind (); 816 #if 201103L <= YY_CPLUSPLUS 817 /// Move constructor. 818 by_kind (by_kind&& that); 819 #endif 820 /// Copy constructor. 821 by_kind (const by_kind& that); 822 /// The symbol kind as needed by the constructor. 823 typedef token_kind_type kind_type; 824 /// Constructor from (external) token numbers. 825 by_kind (kind_type t); 826 /// Record that this symbol is empty. 827 void clear (); 828 /// Steal the symbol kind from \a that. 829 void move (by_kind& that); 830 /// The (internal) type number (corresponding to \a type). 831 /// \a empty when empty. 832 symbol_kind_type kind () const YY_NOEXCEPT; 833 /// Backward compatibility (Bison 3.6). 834 symbol_kind_type type_get () const YY_NOEXCEPT; 835 /// The symbol kind. 836 /// \a S_YYEMPTY when empty. 837 symbol_kind_type kind_; 838 }; 839 840 /// Backward compatibility for a private implementation detail (Bison 3.6). 841 typedef by_kind by_type; 842 /// "External" symbols: returned by the scanner. 843 struct symbol_type : basic_symbol<by_kind> { 844 /// Superclass. 845 typedef basic_symbol<by_kind> super_type; 846 /// Empty symbol. symbol_typeuscript::Parser::symbol_type847 symbol_type() {} 848 /// Constructor for valueless symbols, and symbols from each type. 849 #if 201103L <= YY_CPLUSPLUS symbol_typeuscript::Parser::symbol_type850 symbol_type(int tok, location_type l) 851 : super_type(token_type (tok), std::move (l)) 852 { 853 YY_ASSERT(tok == token::TOKEN_END || tok == token::TOKEN_YYerror || 854 tok == token::TOKEN_YYUNDEF || tok == token::TOKEN_EOL); 855 } 856 #else symbol_typeuscript::Parser::symbol_type857 symbol_type(int tok, const location_type& l) 858 : super_type(token_type (tok), l) 859 { 860 YY_ASSERT(tok == token::TOKEN_END || tok == token::TOKEN_YYerror || 861 tok == token::TOKEN_YYUNDEF || tok == token::TOKEN_EOL); 862 } 863 #endif 864 #if 201103L <= YY_CPLUSPLUS symbol_typeuscript::Parser::symbol_type865 symbol_type(int tok, float v, location_type l) 866 : super_type(token_type (tok), std::move (v), std::move (l)) 867 { 868 YY_ASSERT(tok == token::TOKEN_FLOAT); 869 } 870 #else symbol_typeuscript::Parser::symbol_type871 symbol_type(int tok, const float& v, const location_type& l) 872 : super_type(token_type (tok), v, l) 873 { 874 YY_ASSERT(tok == token::TOKEN_FLOAT); 875 } 876 #endif 877 #if 201103L <= YY_CPLUSPLUS symbol_typeuscript::Parser::symbol_type878 symbol_type(int tok, int v, location_type l) 879 : super_type(token_type (tok), std::move (v), std::move (l)) 880 { 881 YY_ASSERT(tok == token::TOKEN_NUMBER); 882 } 883 #else symbol_typeuscript::Parser::symbol_type884 symbol_type(int tok, const int& v, const location_type& l) 885 : super_type(token_type (tok), v, l) 886 { 887 YY_ASSERT(tok == token::TOKEN_NUMBER); 888 } 889 #endif 890 #if 201103L <= YY_CPLUSPLUS symbol_typeuscript::Parser::symbol_type891 symbol_type(int tok, string v, location_type l) 892 : super_type(token_type (tok), std::move (v), std::move (l)) 893 { 894 YY_ASSERT(tok == token::TOKEN_VAR || tok == token::TOKEN_FUNCTION || tok == token::TOKEN_GLOBAL || 895 tok == token::TOKEN_FOR || tok == token::TOKEN_WHILE || tok == token::TOKEN_IF || 896 tok == token::TOKEN_ELSE || tok == token::TOKEN_ADD || tok == token::TOKEN_SUB || 897 tok == token::TOKEN_MUL || tok == token::TOKEN_DIV || tok == token::TOKEN_ASSIGN || 898 tok == token::TOKEN_AND || tok == token::TOKEN_OR || tok == token::TOKEN_EQ || 899 tok == token::TOKEN_NE || tok == token::TOKEN_GT || tok == token::TOKEN_GE || 900 tok == token::TOKEN_LT || tok == token::TOKEN_LE || tok == token::TOKEN_LP || 901 tok == token::TOKEN_RP || tok == token::TOKEN_LC || tok == token::TOKEN_RC || 902 tok == token::TOKEN_SEMICOLON || tok == token::TOKEN_IDENTIFIER || tok == token::TOKEN_BREAK || 903 tok == token::TOKEN_CONTINUE || tok == token::TOKEN_RETURN || tok == token::TOKEN_COMMA || 904 tok == token::TOKEN_STRING); 905 } 906 #else symbol_typeuscript::Parser::symbol_type907 symbol_type(int tok, const string& v, const location_type& l) 908 : super_type(token_type (tok), v, l) 909 { 910 YY_ASSERT(tok == token::TOKEN_VAR || tok == token::TOKEN_FUNCTION || 911 tok == token::TOKEN_GLOBAL || tok == token::TOKEN_FOR || tok == token::TOKEN_WHILE || 912 tok == token::TOKEN_IF || tok == token::TOKEN_ELSE || tok == token::TOKEN_ADD || 913 tok == token::TOKEN_SUB || tok == token::TOKEN_MUL || tok == token::TOKEN_DIV || 914 tok == token::TOKEN_ASSIGN || tok == token::TOKEN_AND || tok == token::TOKEN_OR || 915 tok == token::TOKEN_EQ || tok == token::TOKEN_NE || tok == token::TOKEN_GT || 916 tok == token::TOKEN_GE || tok == token::TOKEN_LT || tok == token::TOKEN_LE || 917 tok == token::TOKEN_LP || tok == token::TOKEN_RP || tok == token::TOKEN_LC || 918 tok == token::TOKEN_RC || tok == token::TOKEN_SEMICOLON || tok == token::TOKEN_IDENTIFIER || 919 tok == token::TOKEN_BREAK || tok == token::TOKEN_CONTINUE || tok == token::TOKEN_RETURN || 920 tok == token::TOKEN_COMMA || tok == token::TOKEN_STRING); 921 } 922 #endif 923 }; 924 /// Build a parser object. 925 Parser(uscript::Scanner* scanner_yyarg, uscript::ScriptInterpreter* interpreter_yyarg); 926 virtual ~ Parser(); 927 #if 201103L <= YY_CPLUSPLUS 928 /// Non copyable. 929 Parser(const Parser &) = delete; 930 /// Non copyable. 931 Parser& operator=(const Parser&) = delete; 932 #endif 933 /// Parse. An alias for parse (). 934 /// \returns 0 iff parsing succeeded. 935 int operator() (); 936 /// Parse. 937 /// \returns 0 iff parsing succeeded. 938 virtual int parse(); 939 940 #if YYDEBUG 941 /// The current debugging stream. 942 std::ostream& debug_stream () const YY_ATTRIBUTE_PURE; 943 /// Set the current debugging stream. 944 void set_debug_stream (std::ostream &); 945 /// Type for debugging levels. 946 typedef int debug_level_type; 947 /// The current debugging level. 948 debug_level_type debug_level() const YY_ATTRIBUTE_PURE; 949 /// Set the current debugging level. 950 void set_debug_level(debug_level_type l); 951 #endif 952 953 /// Report a syntax error. 954 /// \param loc where the syntax error is found. 955 /// \param msg a description of the syntax error. 956 virtual void error(const location_type& loc, const std::string& msg); 957 /// Report a syntax error. 958 void error(const syntax_error& err); 959 /// The user-facing name of the symbol whose (internal) number is 960 /// YYSYMBOL. No bounds checking. 961 static std::string symbol_name(symbol_kind_type yysymbol); 962 963 // Implementation of make_symbol for each symbol type. 964 #if 201103L <= YY_CPLUSPLUS make_END(location_type l)965 static symbol_type make_END(location_type l) 966 { 967 return symbol_type(token::TOKEN_END, std::move (l)); 968 } 969 #else make_END(const location_type & l)970 static symbol_type make_END(const location_type& l) 971 { 972 return symbol_type(token::TOKEN_END, l); 973 } 974 #endif 975 #if 201103L <= YY_CPLUSPLUS make_YYerror(location_type l)976 static symbol_type make_YYerror(location_type l) 977 { 978 return symbol_type(token::TOKEN_YYerror, std::move (l)); 979 } 980 #else make_YYerror(const location_type & l)981 static symbol_type make_YYerror(const location_type& l) 982 { 983 return symbol_type(token::TOKEN_YYerror, l); 984 } 985 #endif 986 #if 201103L <= YY_CPLUSPLUS make_YYUNDEF(location_type l)987 static symbol_type make_YYUNDEF(location_type l) 988 { 989 return symbol_type(token::TOKEN_YYUNDEF, std::move (l)); 990 } 991 #else make_YYUNDEF(const location_type & l)992 static symbol_type make_YYUNDEF(const location_type& l) 993 { 994 return symbol_type(token::TOKEN_YYUNDEF, l); 995 } 996 #endif 997 #if 201103L <= YY_CPLUSPLUS make_NUMBER(int v,location_type l)998 static symbol_type make_NUMBER(int v, location_type l) 999 { 1000 return symbol_type(token::TOKEN_NUMBER, std::move (v), std::move (l)); 1001 } 1002 #else make_NUMBER(const int & v,const location_type & l)1003 static symbol_type make_NUMBER (const int& v, const location_type& l) 1004 { 1005 return symbol_type(token::TOKEN_NUMBER, v, l); 1006 } 1007 #endif 1008 #if 201103L <= YY_CPLUSPLUS make_FLOAT(float v,location_type l)1009 static symbol_type make_FLOAT (float v, location_type l) 1010 { 1011 return symbol_type(token::TOKEN_FLOAT, std::move (v), std::move (l)); 1012 } 1013 #else make_FLOAT(const float & v,const location_type & l)1014 static symbol_type make_FLOAT (const float& v, const location_type& l) 1015 { 1016 return symbol_type(token::TOKEN_FLOAT, v, l); 1017 } 1018 #endif 1019 #if 201103L <= YY_CPLUSPLUS make_EOL(location_type l)1020 static symbol_type make_EOL (location_type l) 1021 { 1022 return symbol_type(token::TOKEN_EOL, std::move (l)); 1023 } 1024 #else make_EOL(const location_type & l)1025 static symbol_type make_EOL (const location_type& l) 1026 { 1027 return symbol_type(token::TOKEN_EOL, l); 1028 } 1029 #endif 1030 #if 201103L <= YY_CPLUSPLUS make_VAR(string v,location_type l)1031 static symbol_type make_VAR (string v, location_type l) 1032 { 1033 return symbol_type(token::TOKEN_VAR, std::move (v), std::move (l)); 1034 } 1035 #else make_VAR(const string & v,const location_type & l)1036 static symbol_type make_VAR (const string& v, const location_type& l) 1037 { 1038 return symbol_type(token::TOKEN_VAR, v, l); 1039 } 1040 #endif 1041 #if 201103L <= YY_CPLUSPLUS make_FUNCTION(string v,location_type l)1042 static symbol_type make_FUNCTION (string v, location_type l) 1043 { 1044 return symbol_type(token::TOKEN_FUNCTION, std::move (v), std::move (l)); 1045 } 1046 #else make_FUNCTION(const string & v,const location_type & l)1047 static symbol_type make_FUNCTION (const string& v, const location_type& l) 1048 { 1049 return symbol_type(token::TOKEN_FUNCTION, v, l); 1050 } 1051 #endif 1052 #if 201103L <= YY_CPLUSPLUS make_GLOBAL(string v,location_type l)1053 static symbol_type make_GLOBAL (string v, location_type l) 1054 { 1055 return symbol_type(token::TOKEN_GLOBAL, std::move (v), std::move (l)); 1056 } 1057 #else make_GLOBAL(const string & v,const location_type & l)1058 static symbol_type make_GLOBAL (const string& v, const location_type& l) 1059 { 1060 return symbol_type(token::TOKEN_GLOBAL, v, l); 1061 } 1062 #endif 1063 #if 201103L <= YY_CPLUSPLUS make_FOR(string v,location_type l)1064 static symbol_type make_FOR (string v, location_type l) 1065 { 1066 return symbol_type(token::TOKEN_FOR, std::move (v), std::move (l)); 1067 } 1068 #else make_FOR(const string & v,const location_type & l)1069 static symbol_type make_FOR (const string& v, const location_type& l) 1070 { 1071 return symbol_type(token::TOKEN_FOR, v, l); 1072 } 1073 #endif 1074 #if 201103L <= YY_CPLUSPLUS make_WHILE(string v,location_type l)1075 static symbol_type make_WHILE (string v, location_type l) 1076 { 1077 return symbol_type(token::TOKEN_WHILE, std::move (v), std::move (l)); 1078 } 1079 #else make_WHILE(const string & v,const location_type & l)1080 static symbol_type make_WHILE (const string& v, const location_type& l) 1081 { 1082 return symbol_type(token::TOKEN_WHILE, v, l); 1083 } 1084 #endif 1085 #if 201103L <= YY_CPLUSPLUS make_IF(string v,location_type l)1086 static symbol_type make_IF (string v, location_type l) 1087 { 1088 return symbol_type(token::TOKEN_IF, std::move (v), std::move (l)); 1089 } 1090 #else make_IF(const string & v,const location_type & l)1091 static symbol_type make_IF (const string& v, const location_type& l) 1092 { 1093 return symbol_type(token::TOKEN_IF, v, l); 1094 } 1095 #endif 1096 #if 201103L <= YY_CPLUSPLUS make_ELSE(string v,location_type l)1097 static symbol_type make_ELSE (string v, location_type l) 1098 { 1099 return symbol_type(token::TOKEN_ELSE, std::move (v), std::move (l)); 1100 } 1101 #else make_ELSE(const string & v,const location_type & l)1102 static symbol_type make_ELSE (const string& v, const location_type& l) 1103 { 1104 return symbol_type(token::TOKEN_ELSE, v, l); 1105 } 1106 #endif 1107 #if 201103L <= YY_CPLUSPLUS make_ADD(string v,location_type l)1108 static symbol_type make_ADD (string v, location_type l) 1109 { 1110 return symbol_type(token::TOKEN_ADD, std::move (v), std::move (l)); 1111 } 1112 #else make_ADD(const string & v,const location_type & l)1113 static symbol_type make_ADD (const string& v, const location_type& l) 1114 { 1115 return symbol_type(token::TOKEN_ADD, v, l); 1116 } 1117 #endif 1118 #if 201103L <= YY_CPLUSPLUS make_SUB(string v,location_type l)1119 static symbol_type make_SUB (string v, location_type l) 1120 { 1121 return symbol_type(token::TOKEN_SUB, std::move (v), std::move (l)); 1122 } 1123 #else make_SUB(const string & v,const location_type & l)1124 static symbol_type make_SUB (const string& v, const location_type& l) 1125 { 1126 return symbol_type(token::TOKEN_SUB, v, l); 1127 } 1128 #endif 1129 #if 201103L <= YY_CPLUSPLUS make_MUL(string v,location_type l)1130 static symbol_type make_MUL (string v, location_type l) 1131 { 1132 return symbol_type(token::TOKEN_MUL, std::move (v), std::move (l)); 1133 } 1134 #else make_MUL(const string & v,const location_type & l)1135 static symbol_type make_MUL (const string& v, const location_type& l) 1136 { 1137 return symbol_type(token::TOKEN_MUL, v, l); 1138 } 1139 #endif 1140 #if 201103L <= YY_CPLUSPLUS make_DIV(string v,location_type l)1141 static symbol_type make_DIV (string v, location_type l) 1142 { 1143 return symbol_type(token::TOKEN_DIV, std::move (v), std::move (l)); 1144 } 1145 #else make_DIV(const string & v,const location_type & l)1146 static symbol_type make_DIV (const string& v, const location_type& l) 1147 { 1148 return symbol_type(token::TOKEN_DIV, v, l); 1149 } 1150 #endif 1151 #if 201103L <= YY_CPLUSPLUS make_ASSIGN(string v,location_type l)1152 static symbol_type make_ASSIGN (string v, location_type l) 1153 { 1154 return symbol_type(token::TOKEN_ASSIGN, std::move (v), std::move (l)); 1155 } 1156 #else make_ASSIGN(const string & v,const location_type & l)1157 static symbol_type make_ASSIGN (const string& v, const location_type& l) 1158 { 1159 return symbol_type(token::TOKEN_ASSIGN, v, l); 1160 } 1161 #endif 1162 #if 201103L <= YY_CPLUSPLUS make_AND(string v,location_type l)1163 static symbol_type make_AND (string v, location_type l) 1164 { 1165 return symbol_type(token::TOKEN_AND, std::move (v), std::move (l)); 1166 } 1167 #else make_AND(const string & v,const location_type & l)1168 static symbol_type make_AND (const string& v, const location_type& l) 1169 { 1170 return symbol_type(token::TOKEN_AND, v, l); 1171 } 1172 #endif 1173 #if 201103L <= YY_CPLUSPLUS make_OR(string v,location_type l)1174 static symbol_type make_OR (string v, location_type l) 1175 { 1176 return symbol_type(token::TOKEN_OR, std::move (v), std::move (l)); 1177 } 1178 #else make_OR(const string & v,const location_type & l)1179 static symbol_type make_OR (const string& v, const location_type& l) 1180 { 1181 return symbol_type(token::TOKEN_OR, v, l); 1182 } 1183 #endif 1184 #if 201103L <= YY_CPLUSPLUS make_EQ(string v,location_type l)1185 static symbol_type make_EQ (string v, location_type l) 1186 { 1187 return symbol_type(token::TOKEN_EQ, std::move (v), std::move (l)); 1188 } 1189 #else make_EQ(const string & v,const location_type & l)1190 static symbol_type make_EQ (const string& v, const location_type& l) 1191 { 1192 return symbol_type(token::TOKEN_EQ, v, l); 1193 } 1194 #endif 1195 #if 201103L <= YY_CPLUSPLUS make_NE(string v,location_type l)1196 static symbol_type make_NE (string v, location_type l) 1197 { 1198 return symbol_type(token::TOKEN_NE, std::move (v), std::move (l)); 1199 } 1200 #else make_NE(const string & v,const location_type & l)1201 static symbol_type make_NE (const string& v, const location_type& l) 1202 { 1203 return symbol_type(token::TOKEN_NE, v, l); 1204 } 1205 #endif 1206 #if 201103L <= YY_CPLUSPLUS make_GT(string v,location_type l)1207 static symbol_type make_GT (string v, location_type l) 1208 { 1209 return symbol_type(token::TOKEN_GT, std::move (v), std::move (l)); 1210 } 1211 #else make_GT(const string & v,const location_type & l)1212 static symbol_type make_GT (const string& v, const location_type& l) 1213 { 1214 return symbol_type(token::TOKEN_GT, v, l); 1215 } 1216 #endif 1217 #if 201103L <= YY_CPLUSPLUS make_GE(string v,location_type l)1218 static symbol_type make_GE (string v, location_type l) 1219 { 1220 return symbol_type(token::TOKEN_GE, std::move (v), std::move (l)); 1221 } 1222 #else make_GE(const string & v,const location_type & l)1223 static symbol_type make_GE (const string& v, const location_type& l) 1224 { 1225 return symbol_type(token::TOKEN_GE, v, l); 1226 } 1227 #endif 1228 #if 201103L <= YY_CPLUSPLUS make_LT(string v,location_type l)1229 static symbol_type make_LT (string v, location_type l) 1230 { 1231 return symbol_type(token::TOKEN_LT, std::move (v), std::move (l)); 1232 } 1233 #else make_LT(const string & v,const location_type & l)1234 static symbol_type make_LT (const string& v, const location_type& l) 1235 { 1236 return symbol_type(token::TOKEN_LT, v, l); 1237 } 1238 #endif 1239 #if 201103L <= YY_CPLUSPLUS make_LE(string v,location_type l)1240 static symbol_type make_LE (string v, location_type l) 1241 { 1242 return symbol_type(token::TOKEN_LE, std::move (v), std::move (l)); 1243 } 1244 #else make_LE(const string & v,const location_type & l)1245 static symbol_type make_LE (const string& v, const location_type& l) 1246 { 1247 return symbol_type(token::TOKEN_LE, v, l); 1248 } 1249 #endif 1250 #if 201103L <= YY_CPLUSPLUS make_LP(string v,location_type l)1251 static symbol_type make_LP (string v, location_type l) 1252 { 1253 return symbol_type(token::TOKEN_LP, std::move (v), std::move (l)); 1254 } 1255 #else make_LP(const string & v,const location_type & l)1256 static symbol_type make_LP (const string& v, const location_type& l) 1257 { 1258 return symbol_type(token::TOKEN_LP, v, l); 1259 } 1260 #endif 1261 #if 201103L <= YY_CPLUSPLUS make_RP(string v,location_type l)1262 static symbol_type make_RP (string v, location_type l) 1263 { 1264 return symbol_type(token::TOKEN_RP, std::move (v), std::move (l)); 1265 } 1266 #else make_RP(const string & v,const location_type & l)1267 static symbol_type make_RP (const string& v, const location_type& l) 1268 { 1269 return symbol_type(token::TOKEN_RP, v, l); 1270 } 1271 #endif 1272 #if 201103L <= YY_CPLUSPLUS make_LC(string v,location_type l)1273 static symbol_type make_LC (string v, location_type l) 1274 { 1275 return symbol_type(token::TOKEN_LC, std::move (v), std::move (l)); 1276 } 1277 #else make_LC(const string & v,const location_type & l)1278 static symbol_type make_LC (const string& v, const location_type& l) 1279 { 1280 return symbol_type(token::TOKEN_LC, v, l); 1281 } 1282 #endif 1283 #if 201103L <= YY_CPLUSPLUS make_RC(string v,location_type l)1284 static symbol_type make_RC (string v, location_type l) 1285 { 1286 return symbol_type(token::TOKEN_RC, std::move (v), std::move (l)); 1287 } 1288 #else make_RC(const string & v,const location_type & l)1289 static symbol_type make_RC (const string& v, const location_type& l) 1290 { 1291 return symbol_type(token::TOKEN_RC, v, l); 1292 } 1293 #endif 1294 #if 201103L <= YY_CPLUSPLUS make_SEMICOLON(string v,location_type l)1295 static symbol_type make_SEMICOLON (string v, location_type l) 1296 { 1297 return symbol_type(token::TOKEN_SEMICOLON, std::move (v), std::move (l)); 1298 } 1299 #else make_SEMICOLON(const string & v,const location_type & l)1300 static symbol_type make_SEMICOLON (const string& v, const location_type& l) 1301 { 1302 return symbol_type(token::TOKEN_SEMICOLON, v, l); 1303 } 1304 #endif 1305 #if 201103L <= YY_CPLUSPLUS make_IDENTIFIER(string v,location_type l)1306 static symbol_type make_IDENTIFIER (string v, location_type l) 1307 { 1308 return symbol_type(token::TOKEN_IDENTIFIER, std::move (v), std::move (l)); 1309 } 1310 #else make_IDENTIFIER(const string & v,const location_type & l)1311 static symbol_type make_IDENTIFIER (const string& v, const location_type& l) 1312 { 1313 return symbol_type(token::TOKEN_IDENTIFIER, v, l); 1314 } 1315 #endif 1316 #if 201103L <= YY_CPLUSPLUS make_BREAK(string v,location_type l)1317 static symbol_type make_BREAK (string v, location_type l) 1318 { 1319 return symbol_type(token::TOKEN_BREAK, std::move (v), std::move (l)); 1320 } 1321 #else make_BREAK(const string & v,const location_type & l)1322 static symbol_type make_BREAK (const string& v, const location_type& l) 1323 { 1324 return symbol_type(token::TOKEN_BREAK, v, l); 1325 } 1326 #endif 1327 #if 201103L <= YY_CPLUSPLUS make_CONTINUE(string v,location_type l)1328 static symbol_type make_CONTINUE (string v, location_type l) 1329 { 1330 return symbol_type(token::TOKEN_CONTINUE, std::move (v), std::move (l)); 1331 } 1332 #else make_CONTINUE(const string & v,const location_type & l)1333 static symbol_type make_CONTINUE (const string& v, const location_type& l) 1334 { 1335 return symbol_type(token::TOKEN_CONTINUE, v, l); 1336 } 1337 #endif 1338 #if 201103L <= YY_CPLUSPLUS make_RETURN(string v,location_type l)1339 static symbol_type make_RETURN (string v, location_type l) 1340 { 1341 return symbol_type(token::TOKEN_RETURN, std::move (v), std::move (l)); 1342 } 1343 #else make_RETURN(const string & v,const location_type & l)1344 static symbol_type make_RETURN (const string& v, const location_type& l) 1345 { 1346 return symbol_type(token::TOKEN_RETURN, v, l); 1347 } 1348 #endif 1349 #if 201103L <= YY_CPLUSPLUS make_COMMA(string v,location_type l)1350 static symbol_type make_COMMA (string v, location_type l) 1351 { 1352 return symbol_type(token::TOKEN_COMMA, std::move (v), std::move (l)); 1353 } 1354 #else make_COMMA(const string & v,const location_type & l)1355 static symbol_type make_COMMA (const string& v, const location_type& l) 1356 { 1357 return symbol_type(token::TOKEN_COMMA, v, l); 1358 } 1359 #endif 1360 #if 201103L <= YY_CPLUSPLUS make_STRING(string v,location_type l)1361 static symbol_type make_STRING (string v, location_type l) 1362 { 1363 return symbol_type(token::TOKEN_STRING, std::move (v), std::move (l)); 1364 } 1365 #else make_STRING(const string & v,const location_type & l)1366 static symbol_type make_STRING (const string& v, const location_type& l) 1367 { 1368 return symbol_type(token::TOKEN_STRING, v, l); 1369 } 1370 #endif 1371 class context { 1372 public: 1373 context (const Parser & yyparser, const symbol_type& yyla); lookahead() const1374 const symbol_type& lookahead () const { return yyla_; } token() const1375 symbol_kind_type token () const { return yyla_.kind (); } location() const1376 const location_type& location () const { return yyla_.location; } 1377 1378 /// Put in YYARG at most YYARGN of the expected tokens, and return the 1379 /// number of tokens stored in YYARG. If YYARG is null, return the 1380 /// number of expected tokens (guaranteed to be less than YYNTOKENS). 1381 int expected_tokens (symbol_kind_type yyarg[], int yyargn) const; 1382 private: 1383 const Parser &yyparser_; 1384 const symbol_type &yyla_; 1385 }; 1386 private: 1387 #if YY_CPLUSPLUS < 201103L 1388 /// Non copyable. 1389 Parser(const Parser &); 1390 /// Non copyable. 1391 Parser& operator= (const Parser &); 1392 #endif 1393 /// Stored state numbers (used for stacks). 1394 typedef signed char state_type; 1395 /// The arguments of the error message. 1396 int yy_syntax_error_arguments_ (const context& yyctx, 1397 symbol_kind_type yyarg[], int yyargn) const; 1398 /// Generate an error message. 1399 /// \param yyctx the context in which the error occurred. 1400 virtual std::string yysyntax_error_ (const context& yyctx) const; 1401 /// Compute post-reduction state. 1402 /// \param yystate the current state 1403 /// \param yysym the nonterminal to push on the stack 1404 static state_type yy_lr_goto_state_ (state_type yystate, int yysym); 1405 /// Whether the given \c yypact_ value indicates a defaulted state. 1406 /// \param yyvalue the value to check 1407 static bool yy_pact_value_is_default_ (int yyvalue); 1408 /// Whether the given \c yytable_ value indicates a syntax error. 1409 /// \param yyvalue the value to check 1410 static bool yy_table_value_is_error_ (int yyvalue); 1411 static const signed char yypact_ninf_; 1412 static const signed char yytable_ninf_; 1413 /// Convert a scanner token kind \a t to a symbol kind. 1414 /// In theory \a t should be a token_kind_type, but character literals 1415 /// are valid, yet not members of the token_type enum. 1416 static symbol_kind_type yytranslate_ (int t); 1417 /// Convert the symbol name \a n to a form suitable for a diagnostic. 1418 static std::string yytnamerr_ (const char *yystr); 1419 /// For a symbol, its name in clear. 1420 static const char* const yytname_[]; 1421 // Tables. 1422 // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 1423 // STATE-NUM. 1424 static const short yypact_[]; 1425 // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. 1426 // Performed when YYTABLE does not specify something else to do. Zero 1427 // means the default is an error. 1428 static const signed char yydefact_[]; 1429 // YYPGOTO[NTERM-NUM]. 1430 static const short yypgoto_[]; 1431 // YYDEFGOTO[NTERM-NUM]. 1432 static const signed char yydefgoto_[]; 1433 // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If 1434 // positive, shift that token. If negative, reduce the rule whose 1435 // number is the opposite. If YYTABLE_NINF, syntax error. 1436 static const signed char yytable_[]; 1437 static const signed char yycheck_[]; 1438 // YYSTOS[STATE-NUM] -- The (internal number of the) accessing 1439 // symbol of state STATE-NUM. 1440 static const signed char yystos_[]; 1441 // YYR1[YYN] -- Symbol number of symbol that rule YYN derives. 1442 static const signed char yyr1_[]; 1443 // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. 1444 static const signed char yyr2_[]; 1445 1446 #if YYDEBUG 1447 // YYRLINE[YYN] -- Source line where rule number YYN was defined. 1448 static const short yyrline_[]; 1449 /// Report on the debug stream that the rule \a r is going to be reduced. 1450 virtual void yy_reduce_print_ (int r) const; 1451 /// Print the state stack on the debug stream. 1452 virtual void yy_stack_print_ () const; 1453 1454 /// Debugging level. 1455 int yydebug_; 1456 /// Debug stream. 1457 std::ostream* yycdebug_; 1458 1459 /// \brief Display a symbol kind, value and location. 1460 /// \param yyo The output stream. 1461 /// \param yysym The symbol. 1462 template <typename Base> 1463 void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const; 1464 #endif 1465 1466 /// \brief Reclaim the memory associated to a symbol. 1467 /// \param yymsg Why this token is reclaimed. 1468 /// If null, print nothing. 1469 /// \param yysym The symbol. 1470 template <typename Base> 1471 void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const; 1472 1473 private: 1474 /// Type access provider for state based symbols. 1475 struct by_state { 1476 /// Default constructor. 1477 by_state () YY_NOEXCEPT; 1478 /// The symbol kind as needed by the constructor. 1479 typedef state_type kind_type; 1480 /// Constructor. 1481 by_state (kind_type s) YY_NOEXCEPT; 1482 /// Copy constructor. 1483 by_state (const by_state& that) YY_NOEXCEPT; 1484 /// Record that this symbol is empty. 1485 void clear () YY_NOEXCEPT; 1486 /// Steal the symbol kind from \a that. 1487 void move (by_state& that); 1488 /// The symbol kind (corresponding to \a state). 1489 /// \a symbol_kind::S_YYEMPTY when empty. 1490 symbol_kind_type kind () const YY_NOEXCEPT; 1491 /// The state number used to denote an empty symbol. 1492 /// We use the initial state, as it does not have a value. 1493 enum { empty_state = 0 }; 1494 /// The state. 1495 /// \a empty when empty. 1496 state_type state; 1497 }; 1498 1499 /// "Internal" symbol: element of the stack. 1500 struct stack_symbol_type : basic_symbol<by_state> { 1501 /// Superclass. 1502 typedef basic_symbol<by_state> super_type; 1503 /// Construct an empty symbol. 1504 stack_symbol_type(); 1505 /// Move or copy construction. 1506 stack_symbol_type(YY_RVREF (stack_symbol_type) that); 1507 /// Steal the contents from \a sym to build this. 1508 stack_symbol_type(state_type s, YY_MOVE_REF (symbol_type) sym); 1509 #if YY_CPLUSPLUS < 201103L 1510 /// Assignment, needed by push_back by some old implementations. 1511 /// Moves the contents of that. 1512 stack_symbol_type& operator= (stack_symbol_type& that); 1513 1514 /// Assignment, needed by push_back by other implementations. 1515 /// Needed by some other old implementations. 1516 stack_symbol_type& operator= (const stack_symbol_type& that); 1517 #endif 1518 }; 1519 1520 /// A stack with random access from its top. 1521 template <typename T, typename S = std::vector<T> > 1522 class stack { 1523 public: 1524 // Hide our reversed order. 1525 typedef typename S::iterator iterator; 1526 typedef typename S::const_iterator const_iterator; 1527 typedef typename S::size_type size_type; 1528 typedef typename std::ptrdiff_t index_type; stack(size_type n=200)1529 stack (size_type n = 200) : seq_(n) {} 1530 #if 201103L <= YY_CPLUSPLUS 1531 /// Non copyable. 1532 stack (const stack&) = delete; 1533 /// Non copyable. 1534 stack& operator= (const stack&) = delete; 1535 #endif 1536 /// Random access. 1537 /// 1538 /// Index 0 returns the topmost element. operator [](index_type i) const1539 const T& operator[] (index_type i) const 1540 { 1541 return seq_[size_type (size () - 1 - i)]; 1542 } 1543 /// Random access. 1544 /// 1545 /// Index 0 returns the topmost element. operator [](index_type i)1546 T& operator[] (index_type i) 1547 { 1548 return seq_[size_type (size () - 1 - i)]; 1549 } 1550 /// Steal the contents of \a t. 1551 /// 1552 /// Close to move-semantics. push(YY_MOVE_REF (T)t)1553 void push (YY_MOVE_REF (T) t) 1554 { 1555 seq_.push_back (T ()); 1556 operator[] (0).move (t); 1557 } 1558 /// Pop elements from the stack. pop(std::ptrdiff_t n=1)1559 void pop (std::ptrdiff_t n = 1) YY_NOEXCEPT 1560 { 1561 for (; 0 < n; --n) { 1562 seq_.pop_back (); 1563 } 1564 } 1565 /// Pop all elements from the stack. clear()1566 void clear() YY_NOEXCEPT 1567 { 1568 seq_.clear (); 1569 } 1570 /// Number of elements on the stack. size() const1571 index_type size() const YY_NOEXCEPT 1572 { 1573 return index_type (seq_.size ()); 1574 } 1575 /// Iterator on top of the stack (going downwards). begin() const1576 const_iterator begin() const YY_NOEXCEPT 1577 { 1578 return seq_.begin(); 1579 } 1580 /// Bottom of the stack. end() const1581 const_iterator end() const YY_NOEXCEPT 1582 { 1583 return seq_.end(); 1584 } 1585 1586 /// Present a slice of the top of a stack. 1587 class slice 1588 { 1589 public: slice(const stack & stack,index_type range)1590 slice(const stack& stack, index_type range) : stack_(stack) , range_(range) {} operator [](index_type i) const1591 const T& operator[] (index_type i) const 1592 { 1593 return stack_[range_ - i]; 1594 } 1595 private: 1596 const stack& stack_; 1597 index_type range_; 1598 }; 1599 private: 1600 #if YY_CPLUSPLUS < 201103L 1601 /// Non copyable. 1602 stack (const stack&); 1603 /// Non copyable. 1604 stack& operator= (const stack&); 1605 #endif 1606 /// The wrapped container. 1607 S seq_; 1608 }; 1609 1610 /// Stack type. 1611 typedef stack<stack_symbol_type> stack_type; 1612 /// The stack. 1613 stack_type yystack_; 1614 /// Push a new state on the stack. 1615 /// \param m a debug message to display 1616 /// if null, no trace is output. 1617 /// \param sym the symbol 1618 /// \warning the contents of \a s.value is stolen. 1619 void yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym); 1620 /// Push a new look ahead token on the state on the stack. 1621 /// \param m a debug message to display 1622 /// if null, no trace is output. 1623 /// \param s the state 1624 /// \param sym the symbol (for its value and location). 1625 /// \warning the contents of \a sym.value is stolen. 1626 void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym); 1627 /// Pop \a n symbols from the stack. 1628 void yypop_ (int n = 1); 1629 /// Constants. 1630 enum { 1631 yylast_ = 187, ///< Last index in yytable_. 1632 yynnts_ = 23, ///< Number of nonterminal symbols. 1633 yyfinal_ = 47 ///< Termination state number. 1634 }; 1635 // User arguments. 1636 uscript::Scanner* scanner; 1637 uscript::ScriptInterpreter* interpreter; 1638 }; 1639 yytranslate_(int t)1640 inline Parser::symbol_kind_type Parser::yytranslate_(int t) 1641 { 1642 // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to 1643 // TOKEN-NUM as returned by yylex. 1644 static const signed char translate_table[] = 1645 { 1646 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1647 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1648 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1649 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1650 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1651 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1652 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1653 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1654 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1655 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1656 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1657 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1658 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1659 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1660 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1661 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1662 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1663 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1664 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1665 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1666 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1667 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1668 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1669 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1670 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1671 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 1672 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1673 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 1674 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 1675 }; 1676 // Last valid token kind. 1677 const int code_max = 291; 1678 if (t <= 0) { 1679 return symbol_kind::S_YYEOF; 1680 } else if (t <= code_max) { 1681 return YY_CAST (symbol_kind_type, translate_table[t]); 1682 } else { 1683 return symbol_kind::S_YYUNDEF; 1684 } 1685 } 1686 1687 // basic_symbol. 1688 template <typename Base> basic_symbol(const basic_symbol & that)1689 Parser::basic_symbol<Base>::basic_symbol(const basic_symbol& that) 1690 : Base (that), value (), location (that.location) 1691 { 1692 switch (this->kind ()) { 1693 case symbol_kind::S_function_definition: // function_definition 1694 value.copy< ScriptFunction* > (YY_MOVE (that.value)); 1695 break; 1696 case symbol_kind::S_arglist: // arglist 1697 value.copy< ScriptParams* > (YY_MOVE (that.value)); 1698 break; 1699 case symbol_kind::S_definition_or_statement: // definition_or_statement 1700 case symbol_kind::S_expression: // expression 1701 case symbol_kind::S_value_expression: // value_expression 1702 case symbol_kind::S_compare_expression: // compare_expression 1703 case symbol_kind::S_add_sub_expression: // add_sub_expression 1704 case symbol_kind::S_mul_div_expression: // mul_div_expression 1705 case symbol_kind::S_primary_expression: // primary_expression 1706 case symbol_kind::S_arg: // arg 1707 case symbol_kind::S_expression_option: // expression_option 1708 value.copy< UScriptExpression* > (YY_MOVE (that.value)); 1709 break; 1710 case symbol_kind::S_statement: // statement 1711 case symbol_kind::S_expression_statement: // expression_statement 1712 case symbol_kind::S_for_statement: // for_statement 1713 case symbol_kind::S_while_statement: // while_statement 1714 case symbol_kind::S_if_statement: // if_statement 1715 case symbol_kind::S_break_statement: // break_statement 1716 case symbol_kind::S_continue_statement: // continue_statement 1717 case symbol_kind::S_return_statement: // return_statement 1718 value.copy< UScriptStatement* > (YY_MOVE (that.value)); 1719 break; 1720 case symbol_kind::S_statement_list: // statement_list 1721 case symbol_kind::S_block: // block 1722 value.copy< UScriptStatementList* > (YY_MOVE (that.value)); 1723 break; 1724 case symbol_kind::S_FLOAT: // FLOAT 1725 value.copy< float > (YY_MOVE (that.value)); 1726 break; 1727 case symbol_kind::S_NUMBER: // NUMBER 1728 value.copy< int > (YY_MOVE (that.value)); 1729 break; 1730 case symbol_kind::S_VAR: // VAR 1731 case symbol_kind::S_FUNCTION: // FUNCTION 1732 case symbol_kind::S_GLOBAL: // GLOBAL 1733 case symbol_kind::S_FOR: // FOR 1734 case symbol_kind::S_WHILE: // WHILE 1735 case symbol_kind::S_IF: // IF 1736 case symbol_kind::S_ELSE: // ELSE 1737 case symbol_kind::S_ADD: // ADD 1738 case symbol_kind::S_SUB: // SUB 1739 case symbol_kind::S_MUL: // MUL 1740 case symbol_kind::S_DIV: // DIV 1741 case symbol_kind::S_ASSIGN: // ASSIGN 1742 case symbol_kind::S_AND: // AND 1743 case symbol_kind::S_OR: // OR 1744 case symbol_kind::S_EQ: // EQ 1745 case symbol_kind::S_NE: // NE 1746 case symbol_kind::S_GT: // GT 1747 case symbol_kind::S_GE: // GE 1748 case symbol_kind::S_LT: // LT 1749 case symbol_kind::S_LE: // LE 1750 case symbol_kind::S_LP: // LP 1751 case symbol_kind::S_RP: // RP 1752 case symbol_kind::S_LC: // LC 1753 case symbol_kind::S_RC: // RC 1754 case symbol_kind::S_SEMICOLON: // SEMICOLON 1755 case symbol_kind::S_IDENTIFIER: // IDENTIFIER 1756 case symbol_kind::S_BREAK: // BREAK 1757 case symbol_kind::S_CONTINUE: // CONTINUE 1758 case symbol_kind::S_RETURN: // RETURN 1759 case symbol_kind::S_COMMA: // COMMA 1760 case symbol_kind::S_STRING: // STRING 1761 value.copy< string > (YY_MOVE (that.value)); 1762 break; 1763 default: 1764 break; 1765 } 1766 } 1767 1768 template <typename Base> Parser::symbol_kind_type type_get() const1769 Parser::basic_symbol<Base>::type_get () const YY_NOEXCEPT 1770 { 1771 return this->kind (); 1772 } 1773 1774 template <typename Base> empty() const1775 bool Parser::basic_symbol<Base>::empty () const YY_NOEXCEPT 1776 { 1777 return this->kind () == symbol_kind::S_YYEMPTY; 1778 } 1779 1780 template <typename Base> move(basic_symbol & s)1781 void Parser::basic_symbol<Base>::move (basic_symbol& s) 1782 { 1783 super_type::move (s); 1784 switch (this->kind()) { 1785 case symbol_kind::S_function_definition: // function_definition 1786 value.move< ScriptFunction* > (YY_MOVE (s.value)); 1787 break; 1788 case symbol_kind::S_arglist: // arglist 1789 value.move< ScriptParams* > (YY_MOVE (s.value)); 1790 break; 1791 case symbol_kind::S_definition_or_statement: // definition_or_statement 1792 case symbol_kind::S_expression: // expression 1793 case symbol_kind::S_value_expression: // value_expression 1794 case symbol_kind::S_compare_expression: // compare_expression 1795 case symbol_kind::S_add_sub_expression: // add_sub_expression 1796 case symbol_kind::S_mul_div_expression: // mul_div_expression 1797 case symbol_kind::S_primary_expression: // primary_expression 1798 case symbol_kind::S_arg: // arg 1799 case symbol_kind::S_expression_option: // expression_option 1800 value.move< UScriptExpression* > (YY_MOVE (s.value)); 1801 break; 1802 case symbol_kind::S_statement: // statement 1803 case symbol_kind::S_expression_statement: // expression_statement 1804 case symbol_kind::S_for_statement: // for_statement 1805 case symbol_kind::S_while_statement: // while_statement 1806 case symbol_kind::S_if_statement: // if_statement 1807 case symbol_kind::S_break_statement: // break_statement 1808 case symbol_kind::S_continue_statement: // continue_statement 1809 case symbol_kind::S_return_statement: // return_statement 1810 value.move< UScriptStatement* > (YY_MOVE (s.value)); 1811 break; 1812 case symbol_kind::S_statement_list: // statement_list 1813 case symbol_kind::S_block: // block 1814 value.move< UScriptStatementList* > (YY_MOVE (s.value)); 1815 break; 1816 case symbol_kind::S_FLOAT: // FLOAT 1817 value.move< float > (YY_MOVE (s.value)); 1818 break; 1819 case symbol_kind::S_NUMBER: // NUMBER 1820 value.move< int > (YY_MOVE (s.value)); 1821 break; 1822 case symbol_kind::S_VAR: // VAR 1823 case symbol_kind::S_FUNCTION: // FUNCTION 1824 case symbol_kind::S_GLOBAL: // GLOBAL 1825 case symbol_kind::S_FOR: // FOR 1826 case symbol_kind::S_WHILE: // WHILE 1827 case symbol_kind::S_IF: // IF 1828 case symbol_kind::S_ELSE: // ELSE 1829 case symbol_kind::S_ADD: // ADD 1830 case symbol_kind::S_SUB: // SUB 1831 case symbol_kind::S_MUL: // MUL 1832 case symbol_kind::S_DIV: // DIV 1833 case symbol_kind::S_ASSIGN: // ASSIGN 1834 case symbol_kind::S_AND: // AND 1835 case symbol_kind::S_OR: // OR 1836 case symbol_kind::S_EQ: // EQ 1837 case symbol_kind::S_NE: // NE 1838 case symbol_kind::S_GT: // GT 1839 case symbol_kind::S_GE: // GE 1840 case symbol_kind::S_LT: // LT 1841 case symbol_kind::S_LE: // LE 1842 case symbol_kind::S_LP: // LP 1843 case symbol_kind::S_RP: // RP 1844 case symbol_kind::S_LC: // LC 1845 case symbol_kind::S_RC: // RC 1846 case symbol_kind::S_SEMICOLON: // SEMICOLON 1847 case symbol_kind::S_IDENTIFIER: // IDENTIFIER 1848 case symbol_kind::S_BREAK: // BREAK 1849 case symbol_kind::S_CONTINUE: // CONTINUE 1850 case symbol_kind::S_RETURN: // RETURN 1851 case symbol_kind::S_COMMA: // COMMA 1852 case symbol_kind::S_STRING: // STRING 1853 value.move< string > (YY_MOVE (s.value)); 1854 break; 1855 default: 1856 break; 1857 } 1858 location = YY_MOVE (s.location); 1859 } 1860 1861 // by_kind. by_kind()1862 inline Parser::by_kind::by_kind () 1863 : kind_ (symbol_kind::S_YYEMPTY) {} 1864 1865 #if 201103L <= YY_CPLUSPLUS by_kind(by_kind && that)1866 inline Parser::by_kind::by_kind(by_kind&& that) 1867 : kind_ (that.kind_) 1868 { 1869 that.clear (); 1870 } 1871 #endif 1872 by_kind(const by_kind & that)1873 inline Parser::by_kind::by_kind(const by_kind& that) 1874 : kind_ (that.kind_) {} 1875 by_kind(token_kind_type t)1876 inline Parser::by_kind::by_kind(token_kind_type t) 1877 : kind_ (yytranslate_ (t)) {} 1878 clear()1879 inline void Parser::by_kind::clear() 1880 { 1881 kind_ = symbol_kind::S_YYEMPTY; 1882 } 1883 move(by_kind & that)1884 inline void Parser::by_kind::move(by_kind& that) 1885 { 1886 kind_ = that.kind_; 1887 that.clear (); 1888 } 1889 kind() const1890 inline Parser::symbol_kind_type Parser::by_kind::kind() const YY_NOEXCEPT 1891 { 1892 return kind_; 1893 } 1894 type_get() const1895 inline Parser::symbol_kind_type Parser::by_kind::type_get() const YY_NOEXCEPT 1896 { 1897 return this->kind (); 1898 } 1899 } // uscript 1900 1901 #endif // !YY_YY_YACC_PARSER_HPP_INCLUDED 1902