Line data Source code
1 : // A Bison parser, made by GNU Bison 3.0.4.
2 :
3 : // Skeleton interface for Bison LALR(1) parsers in C++
4 :
5 : // Copyright (C) 2002-2015 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 : ** \file y.tab.h
35 : ** Define the lha::parser class.
36 : */
37 :
38 : // C++ LALR(1) parser skeleton written by Akim Demaille.
39 :
40 : #ifndef YY_LHA_LHA_PARSER_HH_INCLUDED
41 : # define YY_LHA_LHA_PARSER_HH_INCLUDED
42 : // // "%code requires" blocks.
43 : #line 6 "../../../../src/ModelGenerator/LhaParser/Lha-parser.yy" // lalr1.cc:377
44 :
45 : #include <math.h>
46 : #include <limits.h>
47 : # include <string>
48 :
49 : #include <fstream>
50 : #include <sstream>
51 : #include <set>
52 : #include "../Eval/Eval.hpp"
53 : #include "../HaslFormula.hpp"
54 :
55 : class Lha_Reader;
56 :
57 :
58 : #define BUFF_SIZE 5000
59 :
60 : #line 61 "Lha-parser.hh" // lalr1.cc:377
61 :
62 :
63 : # include <cstdlib> // std::abort
64 : # include <iostream>
65 : # include <stdexcept>
66 : # include <string>
67 : # include <vector>
68 : # include "stack.hh"
69 : # include "location.hh"
70 :
71 :
72 : #ifndef YY_ATTRIBUTE
73 : # if (defined __GNUC__ \
74 : && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
75 : || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
76 : # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
77 : # else
78 : # define YY_ATTRIBUTE(Spec) /* empty */
79 : # endif
80 : #endif
81 :
82 : #ifndef YY_ATTRIBUTE_PURE
83 : # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
84 : #endif
85 :
86 : #ifndef YY_ATTRIBUTE_UNUSED
87 : # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
88 : #endif
89 :
90 : #if !defined _Noreturn \
91 : && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
92 : # if defined _MSC_VER && 1200 <= _MSC_VER
93 : # define _Noreturn __declspec (noreturn)
94 : # else
95 : # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
96 : # endif
97 : #endif
98 :
99 : /* Suppress unused-variable warnings by "using" E. */
100 : #if ! defined lint || defined __GNUC__
101 : # define YYUSE(E) ((void) (E))
102 : #else
103 : # define YYUSE(E) /* empty */
104 : #endif
105 :
106 : #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
107 : /* Suppress an incorrect diagnostic about yylval being uninitialized. */
108 : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
109 : _Pragma ("GCC diagnostic push") \
110 : _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
111 : _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
112 : # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
113 : _Pragma ("GCC diagnostic pop")
114 : #else
115 : # define YY_INITIAL_VALUE(Value) Value
116 : #endif
117 : #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
118 : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
119 : # define YY_IGNORE_MAYBE_UNINITIALIZED_END
120 : #endif
121 : #ifndef YY_INITIAL_VALUE
122 : # define YY_INITIAL_VALUE(Value) /* Nothing. */
123 : #endif
124 :
125 : /* Debug traces. */
126 : #ifndef YYDEBUG
127 : # define YYDEBUG 1
128 : #endif
129 :
130 :
131 : namespace lha {
132 : #line 133 "Lha-parser.hh" // lalr1.cc:377
133 :
134 :
135 :
136 :
137 :
138 : /// A Bison parser.
139 : class Lha_parser
140 : {
141 : public:
142 : #ifndef YYSTYPE
143 : /// Symbol semantic values.
144 : union semantic_type
145 : {
146 : #line 34 "/builds/barbot/Cosmos/build/src/ModelGenerator/LhaParser/../../../../src/ModelGenerator/LhaParser/Lha-parser.yy" // lalr1.cc:377
147 :
148 : double RealVal;
149 : int IntVal;
150 : std::string *name;
151 : char expression[BUFF_SIZE];
152 : HaslFormulasTop *TOPHASL;
153 :
154 : #line 155 "Lha-parser.hh" // lalr1.cc:377
155 : };
156 : #else
157 : typedef YYSTYPE semantic_type;
158 : #endif
159 : /// Symbol locations.
160 : typedef location location_type;
161 :
162 : /// Syntax errors thrown from user actions.
163 : struct syntax_error : std::runtime_error
164 : {
165 : syntax_error (const location_type& l, const std::string& m);
166 : location_type location;
167 : };
168 :
169 : /// Tokens.
170 : struct token
171 : {
172 : enum yytokentype
173 : {
174 : END = 0,
175 : str = 258,
176 : rval = 259,
177 : ival = 260,
178 : SEMICOLON = 261,
179 : COLON = 262,
180 : COMMA = 263,
181 : LB = 264,
182 : RB = 265,
183 : LSB = 266,
184 : RSB = 267,
185 : SHARP = 268,
186 : ALL = 269,
187 : BackSlash = 270,
188 : EQ = 271,
189 : GEQ = 272,
190 : LEQ = 273,
191 : LL = 274,
192 : GG = 275,
193 : AND = 276,
194 : OR = 277,
195 : NOT = 278,
196 : TRUE = 279,
197 : FALSE = 280,
198 : DOUBLE = 281,
199 : INT = 282,
200 : DIV = 283,
201 : MUL = 284,
202 : PLUS = 285,
203 : MINUS = 286,
204 : POWER = 287,
205 : FLOOR = 288,
206 : MIN = 289,
207 : MAX = 290,
208 : MOD = 291,
209 : LhaMIN = 292,
210 : LhaMAX = 293,
211 : AVG = 294,
212 : VAR = 295,
213 : PROB = 296,
214 : SPRT = 297,
215 : LAST = 298,
216 : INTEGRAL = 299,
217 : MEAN = 300,
218 : DISC = 301,
219 : NOTDET = 302,
220 : LhaName = 303,
221 : Const = 304,
222 : Hybrid = 305,
223 : NbLoc = 306,
224 : NbVar = 307,
225 : VList = 308,
226 : LList = 309,
227 : Iloc = 310,
228 : Floc = 311,
229 : locations = 312,
230 : edges = 313,
231 : PDF = 314,
232 : CDF = 315,
233 : EXIST_TOK = 316,
234 : NOTALL_TOK = 317,
235 : NEG = 318
236 : };
237 : };
238 :
239 : /// (External) token type, as returned by yylex.
240 : typedef token::yytokentype token_type;
241 :
242 : /// Symbol type: an internal symbol number.
243 : typedef int symbol_number_type;
244 :
245 : /// The symbol type number to denote an empty symbol.
246 : enum { empty_symbol = -2 };
247 :
248 : /// Internal symbol number for tokens (subsumed by symbol_number_type).
249 : typedef unsigned char token_number_type;
250 :
251 : /// A complete symbol.
252 : ///
253 : /// Expects its Base type to provide access to the symbol type
254 : /// via type_get().
255 : ///
256 : /// Provide access to semantic value and location.
257 : template <typename Base>
258 : struct basic_symbol : Base
259 : {
260 : /// Alias to Base.
261 : typedef Base super_type;
262 :
263 : /// Default constructor.
264 : basic_symbol ();
265 :
266 : /// Copy constructor.
267 : basic_symbol (const basic_symbol& other);
268 :
269 : /// Constructor for valueless symbols.
270 : basic_symbol (typename Base::kind_type t,
271 : const location_type& l);
272 :
273 : /// Constructor for symbols with semantic value.
274 : basic_symbol (typename Base::kind_type t,
275 : const semantic_type& v,
276 : const location_type& l);
277 :
278 : /// Destroy the symbol.
279 : ~basic_symbol ();
280 :
281 : /// Destroy contents, and record that is empty.
282 : void clear ();
283 :
284 : /// Whether empty.
285 : bool empty () const;
286 :
287 : /// Destructive move, \a s is emptied into this.
288 : void move (basic_symbol& s);
289 :
290 : /// The semantic value.
291 : semantic_type value;
292 :
293 : /// The location.
294 : location_type location;
295 :
296 : private:
297 : /// Assignment operator.
298 : basic_symbol& operator= (const basic_symbol& other);
299 : };
300 :
301 : /// Type access provider for token (enum) based symbols.
302 : struct by_type
303 : {
304 : /// Default constructor.
305 : by_type ();
306 :
307 : /// Copy constructor.
308 : by_type (const by_type& other);
309 :
310 : /// The symbol type as needed by the constructor.
311 : typedef token_type kind_type;
312 :
313 : /// Constructor from (external) token numbers.
314 : by_type (kind_type t);
315 :
316 : /// Record that this symbol is empty.
317 : void clear ();
318 :
319 : /// Steal the symbol type from \a that.
320 : void move (by_type& that);
321 :
322 : /// The (internal) type number (corresponding to \a type).
323 : /// \a empty when empty.
324 : symbol_number_type type_get () const;
325 :
326 : /// The token.
327 : token_type token () const;
328 :
329 : /// The symbol type.
330 : /// \a empty_symbol when empty.
331 : /// An int, not token_number_type, to be able to store empty_symbol.
332 : int type;
333 : };
334 :
335 : /// "External" symbols: returned by the scanner.
336 : typedef basic_symbol<by_type> symbol_type;
337 :
338 :
339 : /// Build a parser object.
340 : Lha_parser (Lha_Reader& Reader_yyarg);
341 : virtual ~Lha_parser ();
342 :
343 : /// Parse.
344 : /// \returns 0 iff parsing succeeded.
345 : virtual int parse ();
346 :
347 : #if YYDEBUG
348 : /// The current debugging stream.
349 : std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
350 : /// Set the current debugging stream.
351 : void set_debug_stream (std::ostream &);
352 :
353 : /// Type for debugging levels.
354 : typedef int debug_level_type;
355 : /// The current debugging level.
356 : debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
357 : /// Set the current debugging level.
358 : void set_debug_level (debug_level_type l);
359 : #endif
360 :
361 : /// Report a syntax error.
362 : /// \param loc where the syntax error is found.
363 : /// \param msg a description of the syntax error.
364 : virtual void error (const location_type& loc, const std::string& msg);
365 :
366 : /// Report a syntax error.
367 : void error (const syntax_error& err);
368 :
369 : private:
370 : /// This class is not copyable.
371 : Lha_parser (const Lha_parser&);
372 : Lha_parser& operator= (const Lha_parser&);
373 :
374 : /// State numbers.
375 : typedef int state_type;
376 :
377 : /// Generate an error message.
378 : /// \param yystate the state where the error occurred.
379 : /// \param yyla the lookahead token.
380 : virtual std::string yysyntax_error_ (state_type yystate,
381 : const symbol_type& yyla) const;
382 :
383 : /// Compute post-reduction state.
384 : /// \param yystate the current state
385 : /// \param yysym the nonterminal to push on the stack
386 : state_type yy_lr_goto_state_ (state_type yystate, int yysym);
387 :
388 : /// Whether the given \c yypact_ value indicates a defaulted state.
389 : /// \param yyvalue the value to check
390 : static bool yy_pact_value_is_default_ (int yyvalue);
391 :
392 : /// Whether the given \c yytable_ value indicates a syntax error.
393 : /// \param yyvalue the value to check
394 : static bool yy_table_value_is_error_ (int yyvalue);
395 :
396 : static const short int yypact_ninf_;
397 : static const signed char yytable_ninf_;
398 :
399 : /// Convert a scanner token number \a t to a symbol number.
400 : static token_number_type yytranslate_ (int t);
401 :
402 : // Tables.
403 : // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
404 : // STATE-NUM.
405 : static const short int yypact_[];
406 :
407 : // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
408 : // Performed when YYTABLE does not specify something else to do. Zero
409 : // means the default is an error.
410 : static const unsigned char yydefact_[];
411 :
412 : // YYPGOTO[NTERM-NUM].
413 : static const short int yypgoto_[];
414 :
415 : // YYDEFGOTO[NTERM-NUM].
416 : static const short int yydefgoto_[];
417 :
418 : // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
419 : // positive, shift that token. If negative, reduce the rule whose
420 : // number is the opposite. If YYTABLE_NINF, syntax error.
421 : static const short int yytable_[];
422 :
423 : static const short int yycheck_[];
424 :
425 : // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
426 : // symbol of state STATE-NUM.
427 : static const unsigned char yystos_[];
428 :
429 : // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
430 : static const unsigned char yyr1_[];
431 :
432 : // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
433 : static const unsigned char yyr2_[];
434 :
435 :
436 : /// Convert the symbol name \a n to a form suitable for a diagnostic.
437 : static std::string yytnamerr_ (const char *n);
438 :
439 :
440 : /// For a symbol, its name in clear.
441 : static const char* const yytname_[];
442 : #if YYDEBUG
443 : // YYRLINE[YYN] -- Source line where rule number YYN was defined.
444 : static const unsigned short int yyrline_[];
445 : /// Report on the debug stream that the rule \a r is going to be reduced.
446 : virtual void yy_reduce_print_ (int r);
447 : /// Print the state stack on the debug stream.
448 : virtual void yystack_print_ ();
449 :
450 : // Debugging.
451 : int yydebug_;
452 : std::ostream* yycdebug_;
453 :
454 : /// \brief Display a symbol type, value and location.
455 : /// \param yyo The output stream.
456 : /// \param yysym The symbol.
457 : template <typename Base>
458 : void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
459 : #endif
460 :
461 : /// \brief Reclaim the memory associated to a symbol.
462 : /// \param yymsg Why this token is reclaimed.
463 : /// If null, print nothing.
464 : /// \param yysym The symbol.
465 : template <typename Base>
466 : void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
467 :
468 : private:
469 : /// Type access provider for state based symbols.
470 : struct by_state
471 : {
472 : /// Default constructor.
473 : by_state ();
474 :
475 : /// The symbol type as needed by the constructor.
476 : typedef state_type kind_type;
477 :
478 : /// Constructor.
479 : by_state (kind_type s);
480 :
481 : /// Copy constructor.
482 : by_state (const by_state& other);
483 :
484 : /// Record that this symbol is empty.
485 : void clear ();
486 :
487 : /// Steal the symbol type from \a that.
488 : void move (by_state& that);
489 :
490 : /// The (internal) type number (corresponding to \a state).
491 : /// \a empty_symbol when empty.
492 : symbol_number_type type_get () const;
493 :
494 : /// The state number used to denote an empty symbol.
495 : enum { empty_state = -1 };
496 :
497 : /// The state.
498 : /// \a empty when empty.
499 : state_type state;
500 : };
501 :
502 : /// "Internal" symbol: element of the stack.
503 64503 : struct stack_symbol_type : basic_symbol<by_state>
504 : {
505 : /// Superclass.
506 : typedef basic_symbol<by_state> super_type;
507 : /// Construct an empty symbol.
508 : stack_symbol_type ();
509 : /// Steal the contents from \a sym to build this.
510 : stack_symbol_type (state_type s, symbol_type& sym);
511 : /// Assignment, needed by push_back.
512 : stack_symbol_type& operator= (const stack_symbol_type& that);
513 : };
514 :
515 : /// Stack type.
516 : typedef stack<stack_symbol_type> stack_type;
517 :
518 : /// The stack.
519 : stack_type yystack_;
520 :
521 : /// Push a new state on the stack.
522 : /// \param m a debug message to display
523 : /// if null, no trace is output.
524 : /// \param s the symbol
525 : /// \warning the contents of \a s.value is stolen.
526 : void yypush_ (const char* m, stack_symbol_type& s);
527 :
528 : /// Push a new look ahead token on the state on the stack.
529 : /// \param m a debug message to display
530 : /// if null, no trace is output.
531 : /// \param s the state
532 : /// \param sym the symbol (for its value and location).
533 : /// \warning the contents of \a s.value is stolen.
534 : void yypush_ (const char* m, state_type s, symbol_type& sym);
535 :
536 : /// Pop \a n symbols the three stacks.
537 : void yypop_ (unsigned int n = 1);
538 :
539 : /// Constants.
540 : enum
541 : {
542 : yyeof_ = 0,
543 : yylast_ = 859, ///< Last index in yytable_.
544 : yynnts_ = 53, ///< Number of nonterminal symbols.
545 : yyfinal_ = 35, ///< Termination state number.
546 : yyterror_ = 1,
547 : yyerrcode_ = 256,
548 : yyntokens_ = 66 ///< Number of tokens.
549 : };
550 :
551 :
552 : // User arguments.
553 : Lha_Reader& Reader;
554 : };
555 :
556 :
557 :
558 : } // lha
559 : #line 560 "Lha-parser.hh" // lalr1.cc:377
560 :
561 :
562 :
563 :
564 : #endif // !YY_LHA_LHA_PARSER_HH_INCLUDED
|