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