1 // A Bison parser, made by GNU Bison 3.5.1. 2 3 // Skeleton interface for Bison LALR(1) parsers in C++ 4 5 // Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc. 6 7 // This program is free software: you can redistribute it and/or modify 8 // it under the terms of the GNU General Public License as published by 9 // the Free Software Foundation, either version 3 of the License, or 10 // (at your option) any later version. 11 12 // This program is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 // GNU General Public License for more details. 16 17 // You should have received a copy of the GNU General Public License 18 // along with this program. If not, see <http://www.gnu.org/licenses/>. 19 20 // As a special exception, you may create a larger work that contains 21 // part or all of the Bison parser skeleton and distribute that work 22 // under terms of your choice, so long as that work isn't itself a 23 // parser generator using the skeleton or a modified version thereof 24 // as a parser skeleton. Alternatively, if you modify or redistribute 25 // the parser skeleton itself, you may (at your option) remove this 26 // special exception, which will cause the skeleton and the resulting 27 // Bison output files to be licensed under the GNU General Public 28 // License without this special exception. 29 30 // This special exception was added by the Free Software Foundation in 31 // version 2.2 of Bison. 32 33 34 /** 35 ** \file /home/kaminski/Documents/git/potassco/clingo/release/build/debug/libgringo/src/input/nongroundgrammar/grammar.hh 36 ** Define the Gringo::Input::NonGroundGrammar::parser class. 37 */ 38 39 // C++ LALR(1) parser skeleton written by Akim Demaille. 40 41 // Undocumented macros, especially those whose name start with YY_, 42 // are private implementation details. Do not rely on them. 43 44 #ifndef YY_GRINGONONGROUNDGRAMMAR_HOME_KAMINSKI_DOCUMENTS_GIT_POTASSCO_CLINGO_RELEASE_BUILD_DEBUG_LIBGRINGO_SRC_INPUT_NONGROUNDGRAMMAR_GRAMMAR_HH_INCLUDED 45 # define YY_GRINGONONGROUNDGRAMMAR_HOME_KAMINSKI_DOCUMENTS_GIT_POTASSCO_CLINGO_RELEASE_BUILD_DEBUG_LIBGRINGO_SRC_INPUT_NONGROUNDGRAMMAR_GRAMMAR_HH_INCLUDED 46 // "%code requires" blocks. 47 #line 46 "/home/kaminski/Documents/git/potassco/clingo/release/libgringo/src/input/nongroundgrammar.yy" 48 49 #include "gringo/input/programbuilder.hh" 50 #include "potassco/basic_types.h" 51 52 namespace Gringo { namespace Input { class NonGroundParser; } } 53 54 struct DefaultLocation : Gringo::Location { DefaultLocationDefaultLocation55 DefaultLocation() : Location("<undef>", 0, 0, "<undef>", 0, 0) { } 56 }; 57 58 59 #line 60 "/home/kaminski/Documents/git/potassco/clingo/release/build/debug/libgringo/src/input/nongroundgrammar/grammar.hh" 60 61 62 # include <cstdlib> // std::abort 63 # include <iostream> 64 # include <stdexcept> 65 # include <string> 66 # include <vector> 67 68 #if defined __cplusplus 69 # define YY_CPLUSPLUS __cplusplus 70 #else 71 # define YY_CPLUSPLUS 199711L 72 #endif 73 74 // Support move semantics when possible. 75 #if 201103L <= YY_CPLUSPLUS 76 # define YY_MOVE std::move 77 # define YY_MOVE_OR_COPY move 78 # define YY_MOVE_REF(Type) Type&& 79 # define YY_RVREF(Type) Type&& 80 # define YY_COPY(Type) Type 81 #else 82 # define YY_MOVE 83 # define YY_MOVE_OR_COPY copy 84 # define YY_MOVE_REF(Type) Type& 85 # define YY_RVREF(Type) const Type& 86 # define YY_COPY(Type) const Type& 87 #endif 88 89 // Support noexcept when possible. 90 #if 201103L <= YY_CPLUSPLUS 91 # define YY_NOEXCEPT noexcept 92 # define YY_NOTHROW 93 #else 94 # define YY_NOEXCEPT 95 # define YY_NOTHROW throw () 96 #endif 97 98 // Support constexpr when possible. 99 #if 201703 <= YY_CPLUSPLUS 100 # define YY_CONSTEXPR constexpr 101 #else 102 # define YY_CONSTEXPR 103 #endif 104 105 106 107 #ifndef YY_ATTRIBUTE_PURE 108 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) 109 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) 110 # else 111 # define YY_ATTRIBUTE_PURE 112 # endif 113 #endif 114 115 #ifndef YY_ATTRIBUTE_UNUSED 116 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) 117 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) 118 # else 119 # define YY_ATTRIBUTE_UNUSED 120 # endif 121 #endif 122 123 /* Suppress unused-variable warnings by "using" E. */ 124 #if ! defined lint || defined __GNUC__ 125 # define YYUSE(E) ((void) (E)) 126 #else 127 # define YYUSE(E) /* empty */ 128 #endif 129 130 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ 131 /* Suppress an incorrect diagnostic about yylval being uninitialized. */ 132 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ 133 _Pragma ("GCC diagnostic push") \ 134 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ 135 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") 136 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ 137 _Pragma ("GCC diagnostic pop") 138 #else 139 # define YY_INITIAL_VALUE(Value) Value 140 #endif 141 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 142 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 143 # define YY_IGNORE_MAYBE_UNINITIALIZED_END 144 #endif 145 #ifndef YY_INITIAL_VALUE 146 # define YY_INITIAL_VALUE(Value) /* Nothing. */ 147 #endif 148 149 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ 150 # define YY_IGNORE_USELESS_CAST_BEGIN \ 151 _Pragma ("GCC diagnostic push") \ 152 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") 153 # define YY_IGNORE_USELESS_CAST_END \ 154 _Pragma ("GCC diagnostic pop") 155 #endif 156 #ifndef YY_IGNORE_USELESS_CAST_BEGIN 157 # define YY_IGNORE_USELESS_CAST_BEGIN 158 # define YY_IGNORE_USELESS_CAST_END 159 #endif 160 161 # ifndef YY_CAST 162 # ifdef __cplusplus 163 # define YY_CAST(Type, Val) static_cast<Type> (Val) 164 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val) 165 # else 166 # define YY_CAST(Type, Val) ((Type) (Val)) 167 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) 168 # endif 169 # endif 170 # ifndef YY_NULLPTR 171 # if defined __cplusplus 172 # if 201103L <= __cplusplus 173 # define YY_NULLPTR nullptr 174 # else 175 # define YY_NULLPTR 0 176 # endif 177 # else 178 # define YY_NULLPTR ((void*)0) 179 # endif 180 # endif 181 182 /* Debug traces. */ 183 #ifndef YYDEBUG 184 # define YYDEBUG 0 185 #endif 186 187 #line 28 "/home/kaminski/Documents/git/potassco/clingo/release/libgringo/src/input/nongroundgrammar.yy" 188 namespace Gringo { namespace Input { namespace NonGroundGrammar { 189 #line 190 "/home/kaminski/Documents/git/potassco/clingo/release/build/debug/libgringo/src/input/nongroundgrammar/grammar.hh" 190 191 192 193 194 /// A Bison parser. 195 class parser 196 { 197 public: 198 #ifndef YYSTYPE 199 /// Symbol semantic values. 200 union semantic_type 201 { 202 #line 108 "/home/kaminski/Documents/git/potassco/clingo/release/libgringo/src/input/nongroundgrammar.yy" 203 204 IdVecUid idlist; 205 CSPLitUid csplit; 206 CSPAddTermUid cspaddterm; 207 CSPMulTermUid cspmulterm; 208 CSPElemVecUid cspelemvec; 209 TermUid term; 210 TermVecUid termvec; 211 TermVecVecUid termvecvec; 212 LitVecUid litvec; 213 LitUid lit; 214 BdAggrElemVecUid bodyaggrelemvec; 215 CondLitVecUid condlitlist; 216 HdAggrElemVecUid headaggrelemvec; 217 BoundVecUid bounds; 218 BdLitVecUid body; 219 HdLitUid head; 220 Relation rel; 221 AggregateFunction fun; 222 struct { 223 NAF first; 224 CSPElemVecUid second; 225 } disjoint; 226 struct { 227 uintptr_t first; 228 unsigned second; 229 } pair; 230 struct { 231 TermVecUid first; 232 LitVecUid second; 233 } bodyaggrelem; 234 struct { 235 LitUid first; 236 LitVecUid second; 237 } lbodyaggrelem; 238 struct { 239 AggregateFunction fun; 240 unsigned choice : 1; 241 unsigned elems : 31; 242 } aggr; 243 struct { 244 Relation rel; 245 TermUid term; 246 } bound; 247 struct { 248 TermUid first; 249 TermUid second; 250 } termpair; 251 unsigned uid; 252 uintptr_t str; 253 int num; 254 Potassco::Heuristic_t::E heu; 255 TheoryOpVecUid theoryOps; 256 TheoryTermUid theoryTerm; 257 TheoryOptermUid theoryOpterm; 258 TheoryOptermVecUid theoryOpterms; 259 TheoryElemVecUid theoryElems; 260 struct { 261 TheoryOptermVecUid first; 262 LitVecUid second; 263 } theoryElem; 264 TheoryAtomUid theoryAtom; 265 TheoryOpDefUid theoryOpDef; 266 TheoryOpDefVecUid theoryOpDefs; 267 TheoryTermDefUid theoryTermDef; 268 TheoryAtomDefUid theoryAtomDef; 269 TheoryDefVecUid theoryDefs; 270 TheoryAtomType theoryAtomType; 271 272 #line 273 "/home/kaminski/Documents/git/potassco/clingo/release/build/debug/libgringo/src/input/nongroundgrammar/grammar.hh" 273 274 }; 275 #else 276 typedef YYSTYPE semantic_type; 277 #endif 278 /// Symbol locations. 279 typedef DefaultLocation location_type; 280 281 /// Syntax errors thrown from user actions. 282 struct syntax_error : std::runtime_error 283 { syntax_errorGringo::Input::NonGroundGrammar::parser::syntax_error284 syntax_error (const location_type& l, const std::string& m) 285 : std::runtime_error (m) 286 , location (l) 287 {} 288 syntax_errorGringo::Input::NonGroundGrammar::parser::syntax_error289 syntax_error (const syntax_error& s) 290 : std::runtime_error (s.what ()) 291 , location (s.location) 292 {} 293 294 ~syntax_error () YY_NOEXCEPT YY_NOTHROW; 295 296 location_type location; 297 }; 298 299 /// Tokens. 300 struct token 301 { 302 enum yytokentype 303 { 304 END = 0, 305 ADD = 258, 306 AND = 259, 307 EQ = 260, 308 AT = 261, 309 BASE = 262, 310 BNOT = 263, 311 COLON = 264, 312 COMMA = 265, 313 CONST = 266, 314 COUNT = 267, 315 CSP = 268, 316 CSP_ADD = 269, 317 CSP_SUB = 270, 318 CSP_MUL = 271, 319 CSP_LEQ = 272, 320 CSP_LT = 273, 321 CSP_GT = 274, 322 CSP_GEQ = 275, 323 CSP_EQ = 276, 324 CSP_NEQ = 277, 325 CUMULATIVE = 278, 326 DISJOINT = 279, 327 DOT = 280, 328 DOTS = 281, 329 EXTERNAL = 282, 330 DEFINED = 283, 331 FALSE = 284, 332 FORGET = 285, 333 GEQ = 286, 334 GT = 287, 335 IF = 288, 336 INCLUDE = 289, 337 INFIMUM = 290, 338 LBRACE = 291, 339 LBRACK = 292, 340 LEQ = 293, 341 LPAREN = 294, 342 LT = 295, 343 MAX = 296, 344 MAXIMIZE = 297, 345 MIN = 298, 346 MINIMIZE = 299, 347 MOD = 300, 348 MUL = 301, 349 NEQ = 302, 350 POW = 303, 351 QUESTION = 304, 352 RBRACE = 305, 353 RBRACK = 306, 354 RPAREN = 307, 355 SEM = 308, 356 SHOW = 309, 357 EDGE = 310, 358 PROJECT = 311, 359 HEURISTIC = 312, 360 SHOWSIG = 313, 361 SLASH = 314, 362 SUB = 315, 363 SUM = 316, 364 SUMP = 317, 365 SUPREMUM = 318, 366 TRUE = 319, 367 BLOCK = 320, 368 UBNOT = 321, 369 UMINUS = 322, 370 VBAR = 323, 371 VOLATILE = 324, 372 WIF = 325, 373 XOR = 326, 374 PARSE_LP = 327, 375 PARSE_DEF = 328, 376 ANY = 329, 377 UNARY = 330, 378 BINARY = 331, 379 LEFT = 332, 380 RIGHT = 333, 381 HEAD = 334, 382 BODY = 335, 383 DIRECTIVE = 336, 384 THEORY = 337, 385 SYNC = 338, 386 NUMBER = 339, 387 ANONYMOUS = 340, 388 IDENTIFIER = 341, 389 SCRIPT = 342, 390 CODE = 343, 391 STRING = 344, 392 VARIABLE = 345, 393 THEORY_OP = 346, 394 NOT = 347, 395 DEFAULT = 348, 396 OVERRIDE = 349 397 }; 398 }; 399 400 /// (External) token type, as returned by yylex. 401 typedef token::yytokentype token_type; 402 403 /// Symbol type: an internal symbol number. 404 typedef int symbol_number_type; 405 406 /// The symbol type number to denote an empty symbol. 407 enum { empty_symbol = -2 }; 408 409 /// Internal symbol number for tokens (subsumed by symbol_number_type). 410 typedef signed char token_number_type; 411 412 /// A complete symbol. 413 /// 414 /// Expects its Base type to provide access to the symbol type 415 /// via type_get (). 416 /// 417 /// Provide access to semantic value and location. 418 template <typename Base> 419 struct basic_symbol : Base 420 { 421 /// Alias to Base. 422 typedef Base super_type; 423 424 /// Default constructor. basic_symbolGringo::Input::NonGroundGrammar::parser::basic_symbol425 basic_symbol () 426 : value () 427 , location () 428 {} 429 430 #if 201103L <= YY_CPLUSPLUS 431 /// Move constructor. 432 basic_symbol (basic_symbol&& that); 433 #endif 434 435 /// Copy constructor. 436 basic_symbol (const basic_symbol& that); 437 /// Constructor for valueless symbols. 438 basic_symbol (typename Base::kind_type t, 439 YY_MOVE_REF (location_type) l); 440 441 /// Constructor for symbols with semantic value. 442 basic_symbol (typename Base::kind_type t, 443 YY_RVREF (semantic_type) v, 444 YY_RVREF (location_type) l); 445 446 /// Destroy the symbol. ~basic_symbolGringo::Input::NonGroundGrammar::parser::basic_symbol447 ~basic_symbol () 448 { 449 clear (); 450 } 451 452 /// Destroy contents, and record that is empty. clearGringo::Input::NonGroundGrammar::parser::basic_symbol453 void clear () 454 { 455 Base::clear (); 456 } 457 458 /// Whether empty. 459 bool empty () const YY_NOEXCEPT; 460 461 /// Destructive move, \a s is emptied into this. 462 void move (basic_symbol& s); 463 464 /// The semantic value. 465 semantic_type value; 466 467 /// The location. 468 location_type location; 469 470 private: 471 #if YY_CPLUSPLUS < 201103L 472 /// Assignment operator. 473 basic_symbol& operator= (const basic_symbol& that); 474 #endif 475 }; 476 477 /// Type access provider for token (enum) based symbols. 478 struct by_type 479 { 480 /// Default constructor. 481 by_type (); 482 483 #if 201103L <= YY_CPLUSPLUS 484 /// Move constructor. 485 by_type (by_type&& that); 486 #endif 487 488 /// Copy constructor. 489 by_type (const by_type& that); 490 491 /// The symbol type as needed by the constructor. 492 typedef token_type kind_type; 493 494 /// Constructor from (external) token numbers. 495 by_type (kind_type t); 496 497 /// Record that this symbol is empty. 498 void clear (); 499 500 /// Steal the symbol type from \a that. 501 void move (by_type& that); 502 503 /// The (internal) type number (corresponding to \a type). 504 /// \a empty when empty. 505 symbol_number_type type_get () const YY_NOEXCEPT; 506 507 /// The symbol type. 508 /// \a empty_symbol when empty. 509 /// An int, not token_number_type, to be able to store empty_symbol. 510 int type; 511 }; 512 513 /// "External" symbols: returned by the scanner. 514 struct symbol_type : basic_symbol<by_type> 515 {}; 516 517 /// Build a parser object. 518 parser (Gringo::Input::NonGroundParser *lexer_yyarg); 519 virtual ~parser (); 520 521 /// Parse. An alias for parse (). 522 /// \returns 0 iff parsing succeeded. 523 int operator() (); 524 525 /// Parse. 526 /// \returns 0 iff parsing succeeded. 527 virtual int parse (); 528 529 #if YYDEBUG 530 /// The current debugging stream. 531 std::ostream& debug_stream () const YY_ATTRIBUTE_PURE; 532 /// Set the current debugging stream. 533 void set_debug_stream (std::ostream &); 534 535 /// Type for debugging levels. 536 typedef int debug_level_type; 537 /// The current debugging level. 538 debug_level_type debug_level () const YY_ATTRIBUTE_PURE; 539 /// Set the current debugging level. 540 void set_debug_level (debug_level_type l); 541 #endif 542 543 /// Report a syntax error. 544 /// \param loc where the syntax error is found. 545 /// \param msg a description of the syntax error. 546 virtual void error (const location_type& loc, const std::string& msg); 547 548 /// Report a syntax error. 549 void error (const syntax_error& err); 550 551 552 553 private: 554 /// This class is not copyable. 555 parser (const parser&); 556 parser& operator= (const parser&); 557 558 /// Stored state numbers (used for stacks). 559 typedef short state_type; 560 561 /// Generate an error message. 562 /// \param yystate the state where the error occurred. 563 /// \param yyla the lookahead token. 564 virtual std::string yysyntax_error_ (state_type yystate, 565 const symbol_type& yyla) const; 566 567 /// Compute post-reduction state. 568 /// \param yystate the current state 569 /// \param yysym the nonterminal to push on the stack 570 static state_type yy_lr_goto_state_ (state_type yystate, int yysym); 571 572 /// Whether the given \c yypact_ value indicates a defaulted state. 573 /// \param yyvalue the value to check 574 static bool yy_pact_value_is_default_ (int yyvalue); 575 576 /// Whether the given \c yytable_ value indicates a syntax error. 577 /// \param yyvalue the value to check 578 static bool yy_table_value_is_error_ (int yyvalue); 579 580 static const short yypact_ninf_; 581 static const short yytable_ninf_; 582 583 /// Convert a scanner token number \a t to a symbol number. 584 /// In theory \a t should be a token_type, but character literals 585 /// are valid, yet not members of the token_type enum. 586 static token_number_type yytranslate_ (int t); 587 588 // Tables. 589 // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 590 // STATE-NUM. 591 static const short yypact_[]; 592 593 // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. 594 // Performed when YYTABLE does not specify something else to do. Zero 595 // means the default is an error. 596 static const short yydefact_[]; 597 598 // YYPGOTO[NTERM-NUM]. 599 static const short yypgoto_[]; 600 601 // YYDEFGOTO[NTERM-NUM]. 602 static const short yydefgoto_[]; 603 604 // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If 605 // positive, shift that token. If negative, reduce the rule whose 606 // number is the opposite. If YYTABLE_NINF, syntax error. 607 static const short yytable_[]; 608 609 static const short yycheck_[]; 610 611 // YYSTOS[STATE-NUM] -- The (internal number of the) accessing 612 // symbol of state STATE-NUM. 613 static const unsigned char yystos_[]; 614 615 // YYR1[YYN] -- Symbol number of symbol that rule YYN derives. 616 static const unsigned char yyr1_[]; 617 618 // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. 619 static const signed char yyr2_[]; 620 621 622 /// Convert the symbol name \a n to a form suitable for a diagnostic. 623 static std::string yytnamerr_ (const char *n); 624 625 626 /// For a symbol, its name in clear. 627 static const char* const yytname_[]; 628 #if YYDEBUG 629 // YYRLINE[YYN] -- Source line where rule number YYN was defined. 630 static const short yyrline_[]; 631 /// Report on the debug stream that the rule \a r is going to be reduced. 632 virtual void yy_reduce_print_ (int r); 633 /// Print the state stack on the debug stream. 634 virtual void yystack_print_ (); 635 636 /// Debugging level. 637 int yydebug_; 638 /// Debug stream. 639 std::ostream* yycdebug_; 640 641 /// \brief Display a symbol type, value and location. 642 /// \param yyo The output stream. 643 /// \param yysym The symbol. 644 template <typename Base> 645 void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const; 646 #endif 647 648 /// \brief Reclaim the memory associated to a symbol. 649 /// \param yymsg Why this token is reclaimed. 650 /// If null, print nothing. 651 /// \param yysym The symbol. 652 template <typename Base> 653 void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const; 654 655 private: 656 /// Type access provider for state based symbols. 657 struct by_state 658 { 659 /// Default constructor. 660 by_state () YY_NOEXCEPT; 661 662 /// The symbol type as needed by the constructor. 663 typedef state_type kind_type; 664 665 /// Constructor. 666 by_state (kind_type s) YY_NOEXCEPT; 667 668 /// Copy constructor. 669 by_state (const by_state& that) YY_NOEXCEPT; 670 671 /// Record that this symbol is empty. 672 void clear () YY_NOEXCEPT; 673 674 /// Steal the symbol type from \a that. 675 void move (by_state& that); 676 677 /// The (internal) type number (corresponding to \a state). 678 /// \a empty_symbol when empty. 679 symbol_number_type type_get () const YY_NOEXCEPT; 680 681 /// The state number used to denote an empty symbol. 682 /// We use the initial state, as it does not have a value. 683 enum { empty_state = 0 }; 684 685 /// The state. 686 /// \a empty when empty. 687 state_type state; 688 }; 689 690 /// "Internal" symbol: element of the stack. 691 struct stack_symbol_type : basic_symbol<by_state> 692 { 693 /// Superclass. 694 typedef basic_symbol<by_state> super_type; 695 /// Construct an empty symbol. 696 stack_symbol_type (); 697 /// Move or copy construction. 698 stack_symbol_type (YY_RVREF (stack_symbol_type) that); 699 /// Steal the contents from \a sym to build this. 700 stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym); 701 #if YY_CPLUSPLUS < 201103L 702 /// Assignment, needed by push_back by some old implementations. 703 /// Moves the contents of that. 704 stack_symbol_type& operator= (stack_symbol_type& that); 705 706 /// Assignment, needed by push_back by other implementations. 707 /// Needed by some other old implementations. 708 stack_symbol_type& operator= (const stack_symbol_type& that); 709 #endif 710 }; 711 712 /// A stack with random access from its top. 713 template <typename T, typename S = std::vector<T> > 714 class stack 715 { 716 public: 717 // Hide our reversed order. 718 typedef typename S::reverse_iterator iterator; 719 typedef typename S::const_reverse_iterator const_iterator; 720 typedef typename S::size_type size_type; 721 typedef typename std::ptrdiff_t index_type; 722 stack(size_type n=200)723 stack (size_type n = 200) 724 : seq_ (n) 725 {} 726 727 /// Random access. 728 /// 729 /// Index 0 returns the topmost element. 730 const T& operator [](index_type i) const731 operator[] (index_type i) const 732 { 733 return seq_[size_type (size () - 1 - i)]; 734 } 735 736 /// Random access. 737 /// 738 /// Index 0 returns the topmost element. 739 T& operator [](index_type i)740 operator[] (index_type i) 741 { 742 return seq_[size_type (size () - 1 - i)]; 743 } 744 745 /// Steal the contents of \a t. 746 /// 747 /// Close to move-semantics. 748 void push(YY_MOVE_REF (T)t)749 push (YY_MOVE_REF (T) t) 750 { 751 seq_.push_back (T ()); 752 operator[] (0).move (t); 753 } 754 755 /// Pop elements from the stack. 756 void pop(std::ptrdiff_t n=1)757 pop (std::ptrdiff_t n = 1) YY_NOEXCEPT 758 { 759 for (; 0 < n; --n) 760 seq_.pop_back (); 761 } 762 763 /// Pop all elements from the stack. 764 void clear()765 clear () YY_NOEXCEPT 766 { 767 seq_.clear (); 768 } 769 770 /// Number of elements on the stack. 771 index_type size() const772 size () const YY_NOEXCEPT 773 { 774 return index_type (seq_.size ()); 775 } 776 777 std::ptrdiff_t ssize() const778 ssize () const YY_NOEXCEPT 779 { 780 return std::ptrdiff_t (size ()); 781 } 782 783 /// Iterator on top of the stack (going downwards). 784 const_iterator begin() const785 begin () const YY_NOEXCEPT 786 { 787 return seq_.rbegin (); 788 } 789 790 /// Bottom of the stack. 791 const_iterator end() const792 end () const YY_NOEXCEPT 793 { 794 return seq_.rend (); 795 } 796 797 /// Present a slice of the top of a stack. 798 class slice 799 { 800 public: slice(const stack & stack,index_type range)801 slice (const stack& stack, index_type range) 802 : stack_ (stack) 803 , range_ (range) 804 {} 805 806 const T& operator [](index_type i) const807 operator[] (index_type i) const 808 { 809 return stack_[range_ - i]; 810 } 811 812 private: 813 const stack& stack_; 814 index_type range_; 815 }; 816 817 private: 818 stack (const stack&); 819 stack& operator= (const stack&); 820 /// The wrapped container. 821 S seq_; 822 }; 823 824 825 /// Stack type. 826 typedef stack<stack_symbol_type> stack_type; 827 828 /// The stack. 829 stack_type yystack_; 830 831 /// Push a new state on the stack. 832 /// \param m a debug message to display 833 /// if null, no trace is output. 834 /// \param sym the symbol 835 /// \warning the contents of \a s.value is stolen. 836 void yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym); 837 838 /// Push a new look ahead token on the state on the stack. 839 /// \param m a debug message to display 840 /// if null, no trace is output. 841 /// \param s the state 842 /// \param sym the symbol (for its value and location). 843 /// \warning the contents of \a sym.value is stolen. 844 void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym); 845 846 /// Pop \a n symbols from the stack. 847 void yypop_ (int n = 1); 848 849 /// Some specific tokens. 850 static const token_number_type yy_error_token_ = 1; 851 static const token_number_type yy_undef_token_ = 2; 852 853 /// Constants. 854 enum 855 { 856 yyeof_ = 0, 857 yylast_ = 2326, ///< Last index in yytable_. 858 yynnts_ = 84, ///< Number of nonterminal symbols. 859 yyfinal_ = 10, ///< Termination state number. 860 yyntokens_ = 95 ///< Number of tokens. 861 }; 862 863 864 // User arguments. 865 Gringo::Input::NonGroundParser *lexer; 866 }; 867 868 869 #line 28 "/home/kaminski/Documents/git/potassco/clingo/release/libgringo/src/input/nongroundgrammar.yy" 870 } } } // Gringo::Input::NonGroundGrammar 871 #line 872 "/home/kaminski/Documents/git/potassco/clingo/release/build/debug/libgringo/src/input/nongroundgrammar/grammar.hh" 872 873 874 875 876 877 #endif // !YY_GRINGONONGROUNDGRAMMAR_HOME_KAMINSKI_DOCUMENTS_GIT_POTASSCO_CLINGO_RELEASE_BUILD_DEBUG_LIBGRINGO_SRC_INPUT_NONGROUNDGRAMMAR_GRAMMAR_HH_INCLUDED 878