Line data Source code
1 : // A Bison parser, made by GNU Bison 3.0.4.
2 :
3 : // Skeleton implementation 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 : // Take the name prefix into account.
34 : #define yylex evallex
35 :
36 : // First part of user declarations.
37 :
38 : #line 39 "Eval-parser.cc" // lalr1.cc:404
39 :
40 : # ifndef YY_NULLPTR
41 : # if defined __cplusplus && 201103L <= __cplusplus
42 : # define YY_NULLPTR nullptr
43 : # else
44 : # define YY_NULLPTR 0
45 : # endif
46 : # endif
47 :
48 : #include "Eval-parser.hh"
49 :
50 : // User implementation prologue.
51 :
52 : #line 53 "Eval-parser.cc" // lalr1.cc:412
53 : // Unqualified %code blocks.
54 : #line 38 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:413
55 :
56 : #include "Eval.hpp"
57 : #include <set>
58 : #include <vector>
59 :
60 :
61 : #line 62 "Eval-parser.cc" // lalr1.cc:413
62 :
63 :
64 : #ifndef YY_
65 : # if defined YYENABLE_NLS && YYENABLE_NLS
66 : # if ENABLE_NLS
67 : # include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE.
68 : # define YY_(msgid) dgettext ("bison-runtime", msgid)
69 : # endif
70 : # endif
71 : # ifndef YY_
72 : # define YY_(msgid) msgid
73 : # endif
74 : #endif
75 :
76 : #define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
77 : /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
78 : If N is 0, then set CURRENT to the empty location which ends
79 : the previous symbol: RHS[0] (always defined). */
80 :
81 : # ifndef YYLLOC_DEFAULT
82 : # define YYLLOC_DEFAULT(Current, Rhs, N) \
83 : do \
84 : if (N) \
85 : { \
86 : (Current).begin = YYRHSLOC (Rhs, 1).begin; \
87 : (Current).end = YYRHSLOC (Rhs, N).end; \
88 : } \
89 : else \
90 : { \
91 : (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
92 : } \
93 : while (/*CONSTCOND*/ false)
94 : # endif
95 :
96 :
97 : // Suppress unused-variable warnings by "using" E.
98 : #define YYUSE(E) ((void) (E))
99 :
100 : // Enable debugging if requested.
101 : #if YYDEBUG
102 :
103 : // A pseudo ostream that takes yydebug_ into account.
104 : # define YYCDEBUG if (yydebug_) (*yycdebug_)
105 :
106 : # define YY_SYMBOL_PRINT(Title, Symbol) \
107 : do { \
108 : if (yydebug_) \
109 : { \
110 : *yycdebug_ << Title << ' '; \
111 : yy_print_ (*yycdebug_, Symbol); \
112 : *yycdebug_ << std::endl; \
113 : } \
114 : } while (false)
115 :
116 : # define YY_REDUCE_PRINT(Rule) \
117 : do { \
118 : if (yydebug_) \
119 : yy_reduce_print_ (Rule); \
120 : } while (false)
121 :
122 : # define YY_STACK_PRINT() \
123 : do { \
124 : if (yydebug_) \
125 : yystack_print_ (); \
126 : } while (false)
127 :
128 : #else // !YYDEBUG
129 :
130 : # define YYCDEBUG if (false) std::cerr
131 : # define YY_SYMBOL_PRINT(Title, Symbol) YYUSE(Symbol)
132 : # define YY_REDUCE_PRINT(Rule) static_cast<void>(0)
133 : # define YY_STACK_PRINT() static_cast<void>(0)
134 :
135 : #endif // !YYDEBUG
136 :
137 : #define yyerrok (yyerrstatus_ = 0)
138 : #define yyclearin (yyla.clear ())
139 :
140 : #define YYACCEPT goto yyacceptlab
141 : #define YYABORT goto yyabortlab
142 : #define YYERROR goto yyerrorlab
143 : #define YYRECOVERING() (!!yyerrstatus_)
144 :
145 :
146 : namespace eval {
147 : #line 148 "Eval-parser.cc" // lalr1.cc:479
148 :
149 : /* Return YYSTR after stripping away unnecessary quotes and
150 : backslashes, so that it's suitable for yyerror. The heuristic is
151 : that double-quoting is unnecessary unless the string contains an
152 : apostrophe, a comma, or backslash (other than backslash-backslash).
153 : YYSTR is taken from yytname. */
154 : std::string
155 10 : Eval_parser::yytnamerr_ (const char *yystr)
156 : {
157 10 : if (*yystr == '"')
158 : {
159 0 : std::string yyr = "";
160 0 : char const *yyp = yystr;
161 :
162 : for (;;)
163 0 : switch (*++yyp)
164 : {
165 : case '\'':
166 : case ',':
167 0 : goto do_not_strip_quotes;
168 :
169 : case '\\':
170 0 : if (*++yyp != '\\')
171 0 : goto do_not_strip_quotes;
172 : // Fall through.
173 : default:
174 0 : yyr += *yyp;
175 0 : break;
176 :
177 : case '"':
178 0 : return yyr;
179 : }
180 : do_not_strip_quotes: ;
181 : }
182 :
183 10 : return yystr;
184 : }
185 :
186 :
187 : /// Build a parser object.
188 528 : Eval_parser::Eval_parser (Eval& Evaluate_yyarg)
189 : :
190 : #if YYDEBUG
191 : yydebug_ (false),
192 : yycdebug_ (&std::cerr),
193 : #endif
194 528 : Evaluate (Evaluate_yyarg)
195 528 : {}
196 :
197 528 : Eval_parser::~Eval_parser ()
198 528 : {}
199 :
200 :
201 : /*---------------.
202 : | Symbol types. |
203 : `---------------*/
204 :
205 : inline
206 : Eval_parser::syntax_error::syntax_error (const location_type& l, const std::string& m)
207 : : std::runtime_error (m)
208 : , location (l)
209 : {}
210 :
211 : // basic_symbol.
212 : template <typename Base>
213 : inline
214 5810 : Eval_parser::basic_symbol<Base>::basic_symbol ()
215 5810 : : value ()
216 5810 : {}
217 :
218 : template <typename Base>
219 : inline
220 2638 : Eval_parser::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
221 : : Base (other)
222 : , value ()
223 2638 : , location (other.location)
224 : {
225 2638 : value = other.value;
226 2638 : }
227 :
228 :
229 : template <typename Base>
230 : inline
231 : Eval_parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const semantic_type& v, const location_type& l)
232 : : Base (t)
233 : , value (v)
234 : , location (l)
235 : {}
236 :
237 :
238 : /// Constructor for valueless symbols.
239 : template <typename Base>
240 : inline
241 1588 : Eval_parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const location_type& l)
242 : : Base (t)
243 : , value ()
244 1588 : , location (l)
245 1588 : {}
246 :
247 : template <typename Base>
248 : inline
249 10036 : Eval_parser::basic_symbol<Base>::~basic_symbol ()
250 : {
251 10036 : clear ();
252 10036 : }
253 :
254 : template <typename Base>
255 : inline
256 : void
257 10036 : Eval_parser::basic_symbol<Base>::clear ()
258 : {
259 10036 : Base::clear ();
260 10036 : }
261 :
262 : template <typename Base>
263 : inline
264 : bool
265 2128 : Eval_parser::basic_symbol<Base>::empty () const
266 : {
267 2128 : return Base::type_get () == empty_symbol;
268 : }
269 :
270 : template <typename Base>
271 : inline
272 : void
273 2638 : Eval_parser::basic_symbol<Base>::move (basic_symbol& s)
274 : {
275 2638 : super_type::move(s);
276 2638 : value = s.value;
277 2638 : location = s.location;
278 2638 : }
279 :
280 : // by_type.
281 : inline
282 528 : Eval_parser::by_type::by_type ()
283 528 : : type (empty_symbol)
284 528 : {}
285 :
286 : inline
287 : Eval_parser::by_type::by_type (const by_type& other)
288 : : type (other.type)
289 : {}
290 :
291 : inline
292 : Eval_parser::by_type::by_type (token_type t)
293 : : type (yytranslate_ (t))
294 : {}
295 :
296 : inline
297 : void
298 528 : Eval_parser::by_type::clear ()
299 : {
300 528 : type = empty_symbol;
301 528 : }
302 :
303 : inline
304 : void
305 : Eval_parser::by_type::move (by_type& that)
306 : {
307 : type = that.type;
308 : that.clear ();
309 : }
310 :
311 : inline
312 : int
313 5328 : Eval_parser::by_type::type_get () const
314 : {
315 5328 : return type;
316 : }
317 :
318 :
319 : // by_state.
320 : inline
321 5282 : Eval_parser::by_state::by_state ()
322 5282 : : state (empty_state)
323 5282 : {}
324 :
325 : inline
326 2638 : Eval_parser::by_state::by_state (const by_state& other)
327 2638 : : state (other.state)
328 2638 : {}
329 :
330 : inline
331 : void
332 12146 : Eval_parser::by_state::clear ()
333 : {
334 12146 : state = empty_state;
335 12146 : }
336 :
337 : inline
338 : void
339 2638 : Eval_parser::by_state::move (by_state& that)
340 : {
341 2638 : state = that.state;
342 2638 : that.clear ();
343 2638 : }
344 :
345 : inline
346 1588 : Eval_parser::by_state::by_state (state_type s)
347 1588 : : state (s)
348 1588 : {}
349 :
350 : inline
351 : Eval_parser::symbol_number_type
352 1056 : Eval_parser::by_state::type_get () const
353 : {
354 1056 : if (state == empty_state)
355 0 : return empty_symbol;
356 : else
357 1056 : return yystos_[state];
358 : }
359 :
360 : inline
361 5282 : Eval_parser::stack_symbol_type::stack_symbol_type ()
362 5282 : {}
363 :
364 :
365 : inline
366 1588 : Eval_parser::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that)
367 1588 : : super_type (s, that.location)
368 : {
369 1588 : value = that.value;
370 : // that is emptied.
371 1588 : that.type = empty_symbol;
372 1588 : }
373 :
374 : inline
375 : Eval_parser::stack_symbol_type&
376 : Eval_parser::stack_symbol_type::operator= (const stack_symbol_type& that)
377 : {
378 : state = that.state;
379 : value = that.value;
380 : location = that.location;
381 : return *this;
382 : }
383 :
384 :
385 : template <typename Base>
386 : inline
387 : void
388 1066 : Eval_parser::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
389 : {
390 1066 : if (yymsg)
391 1066 : YY_SYMBOL_PRINT (yymsg, yysym);
392 :
393 : // User destructor.
394 1066 : switch (yysym.type_get ())
395 : {
396 : case 3: // str
397 :
398 : #line 69 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:614
399 : { delete (yysym.value.name); }
400 : #line 401 "Eval-parser.cc" // lalr1.cc:614
401 10 : break;
402 :
403 :
404 : default:
405 1056 : break;
406 : }
407 1066 : }
408 :
409 : #if YYDEBUG
410 : template <typename Base>
411 : void
412 0 : Eval_parser::yy_print_ (std::ostream& yyo,
413 : const basic_symbol<Base>& yysym) const
414 : {
415 0 : std::ostream& yyoutput = yyo;
416 : YYUSE (yyoutput);
417 0 : symbol_number_type yytype = yysym.type_get ();
418 : // Avoid a (spurious) G++ 4.8 warning about "array subscript is
419 : // below array bounds".
420 0 : if (yysym.empty ())
421 0 : std::abort ();
422 0 : yyo << (yytype < yyntokens_ ? "token" : "nterm")
423 0 : << ' ' << yytname_[yytype] << " ("
424 0 : << yysym.location << ": ";
425 0 : switch (yytype)
426 : {
427 : case 3: // str
428 :
429 : #line 68 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:636
430 : { debug_stream () << *(yysym.value.name); }
431 : #line 432 "Eval-parser.cc" // lalr1.cc:636
432 0 : break;
433 :
434 : case 4: // rval
435 :
436 : #line 72 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:636
437 : { debug_stream () << (yysym.value.RealVal); }
438 : #line 439 "Eval-parser.cc" // lalr1.cc:636
439 0 : break;
440 :
441 : case 5: // ival
442 :
443 : #line 71 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:636
444 : { debug_stream () << (yysym.value.IntVal); }
445 : #line 446 "Eval-parser.cc" // lalr1.cc:636
446 0 : break;
447 :
448 : case 21: // exp
449 :
450 : #line 72 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:636
451 : { debug_stream () << (yysym.value.RealVal); }
452 : #line 453 "Eval-parser.cc" // lalr1.cc:636
453 0 : break;
454 :
455 :
456 : default:
457 0 : break;
458 : }
459 0 : yyo << ')';
460 0 : }
461 : #endif
462 :
463 : inline
464 : void
465 1588 : Eval_parser::yypush_ (const char* m, state_type s, symbol_type& sym)
466 : {
467 3176 : stack_symbol_type t (s, sym);
468 1588 : yypush_ (m, t);
469 1588 : }
470 :
471 : inline
472 : void
473 2638 : Eval_parser::yypush_ (const char* m, stack_symbol_type& s)
474 : {
475 2638 : if (m)
476 1060 : YY_SYMBOL_PRINT (m, s);
477 2638 : yystack_.push (s);
478 2638 : }
479 :
480 : inline
481 : void
482 2634 : Eval_parser::yypop_ (unsigned int n)
483 : {
484 2634 : yystack_.pop (n);
485 2634 : }
486 :
487 : #if YYDEBUG
488 : std::ostream&
489 0 : Eval_parser::debug_stream () const
490 : {
491 0 : return *yycdebug_;
492 : }
493 :
494 : void
495 0 : Eval_parser::set_debug_stream (std::ostream& o)
496 : {
497 0 : yycdebug_ = &o;
498 0 : }
499 :
500 :
501 : Eval_parser::debug_level_type
502 0 : Eval_parser::debug_level () const
503 : {
504 0 : return yydebug_;
505 : }
506 :
507 : void
508 528 : Eval_parser::set_debug_level (debug_level_type l)
509 : {
510 528 : yydebug_ = l;
511 528 : }
512 : #endif // YYDEBUG
513 :
514 : inline Eval_parser::state_type
515 1050 : Eval_parser::yy_lr_goto_state_ (state_type yystate, int yysym)
516 : {
517 1050 : int yyr = yypgoto_[yysym - yyntokens_] + yystate;
518 1050 : if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
519 2 : return yytable_[yyr];
520 : else
521 1048 : return yydefgoto_[yysym - yyntokens_];
522 : }
523 :
524 : inline bool
525 2160 : Eval_parser::yy_pact_value_is_default_ (int yyvalue)
526 : {
527 2160 : return yyvalue == yypact_ninf_;
528 : }
529 :
530 : inline bool
531 50 : Eval_parser::yy_table_value_is_error_ (int yyvalue)
532 : {
533 50 : return yyvalue == yytable_ninf_;
534 : }
535 :
536 : int
537 528 : Eval_parser::parse ()
538 : {
539 : // State.
540 : int yyn;
541 : /// Length of the RHS of the rule being reduced.
542 528 : int yylen = 0;
543 :
544 : // Error handling.
545 528 : int yynerrs_ = 0;
546 528 : int yyerrstatus_ = 0;
547 :
548 : /// The lookahead symbol.
549 1056 : symbol_type yyla;
550 :
551 : /// The locations where the error started and ended.
552 1056 : stack_symbol_type yyerror_range[3];
553 :
554 : /// The return value of parse ().
555 : int yyresult;
556 :
557 : // FIXME: This shoud be completely indented. It is not yet to
558 : // avoid gratuitous conflicts when merging into the master branch.
559 : try
560 : {
561 528 : YYCDEBUG << "Starting parse" << std::endl;
562 :
563 :
564 : /* Initialize the stack. The initial state will be set in
565 : yynewstate, since the latter expects the semantical and the
566 : location values to have been already stored, initialize these
567 : stacks with a primary value. */
568 528 : yystack_.clear ();
569 528 : yypush_ (YY_NULLPTR, 0, yyla);
570 :
571 : // A new symbol was pushed on the stack.
572 : yynewstate:
573 2638 : YYCDEBUG << "Entering state " << yystack_[0].state << std::endl;
574 :
575 : // Accept?
576 2638 : if (yystack_[0].state == yyfinal_)
577 518 : goto yyacceptlab;
578 :
579 2120 : goto yybackup;
580 :
581 : // Backup.
582 : yybackup:
583 :
584 : // Try to take a decision without lookahead.
585 2120 : yyn = yypact_[yystack_[0].state];
586 2120 : if (yy_pact_value_is_default_ (yyn))
587 530 : goto yydefault;
588 :
589 : // Read a lookahead token.
590 1590 : if (yyla.empty ())
591 : {
592 1070 : YYCDEBUG << "Reading a token: ";
593 : try
594 : {
595 1070 : yyla.type = yytranslate_ (yylex (&yyla.value, &yyla.location, Evaluate));
596 : }
597 0 : catch (const syntax_error& yyexc)
598 : {
599 0 : error (yyexc);
600 0 : goto yyerrlab1;
601 : }
602 : }
603 1590 : YY_SYMBOL_PRINT ("Next token is", yyla);
604 :
605 : /* If the proper action on seeing token YYLA.TYPE is to reduce or
606 : to detect an error, take that action. */
607 1590 : yyn += yyla.type_get ();
608 1590 : if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type_get ())
609 530 : goto yydefault;
610 :
611 : // Reduce or error.
612 1060 : yyn = yytable_[yyn];
613 1060 : if (yyn <= 0)
614 : {
615 0 : if (yy_table_value_is_error_ (yyn))
616 0 : goto yyerrlab;
617 0 : yyn = -yyn;
618 0 : goto yyreduce;
619 : }
620 :
621 : // Count tokens shifted since error; after three, turn off error status.
622 1060 : if (yyerrstatus_)
623 0 : --yyerrstatus_;
624 :
625 : // Shift the lookahead token.
626 1060 : yypush_ ("Shifting", yyn, yyla);
627 1060 : goto yynewstate;
628 :
629 : /*-----------------------------------------------------------.
630 : | yydefault -- do the default action for the current state. |
631 : `-----------------------------------------------------------*/
632 : yydefault:
633 1060 : yyn = yydefact_[yystack_[0].state];
634 1060 : if (yyn == 0)
635 10 : goto yyerrlab;
636 1050 : goto yyreduce;
637 :
638 : /*-----------------------------.
639 : | yyreduce -- Do a reduction. |
640 : `-----------------------------*/
641 : yyreduce:
642 1050 : yylen = yyr2_[yyn];
643 : {
644 2100 : stack_symbol_type yylhs;
645 1050 : yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]);
646 : /* If YYLEN is nonzero, implement the default value of the
647 : action: '$$ = $1'. Otherwise, use the top of the stack.
648 :
649 : Otherwise, the following line sets YYLHS.VALUE to garbage.
650 : This behavior is undocumented and Bison users should not rely
651 : upon it. */
652 1050 : if (yylen)
653 1050 : yylhs.value = yystack_[yylen - 1].value;
654 : else
655 0 : yylhs.value = yystack_[0].value;
656 :
657 : // Compute the default @$.
658 : {
659 1050 : slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
660 1050 : YYLLOC_DEFAULT (yylhs.location, slice, yylen);
661 : }
662 :
663 : // Perform the reduction.
664 1050 : YY_REDUCE_PRINT (yyn);
665 : try
666 : {
667 1050 : switch (yyn)
668 : {
669 : case 2:
670 : #line 82 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:859
671 : {Evaluate.IntResult=(int) (yystack_[0].value.RealVal);Evaluate.RealResult=(yystack_[0].value.RealVal);}
672 : #line 673 "Eval-parser.cc" // lalr1.cc:859
673 518 : break;
674 :
675 : case 3:
676 : #line 84 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:859
677 : {(yylhs.value.RealVal)=(yystack_[0].value.IntVal);}
678 : #line 679 "Eval-parser.cc" // lalr1.cc:859
679 458 : break;
680 :
681 : case 4:
682 : #line 85 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:859
683 : {(yylhs.value.RealVal)=(yystack_[0].value.RealVal);}
684 : #line 685 "Eval-parser.cc" // lalr1.cc:859
685 72 : break;
686 :
687 : case 5:
688 : #line 86 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:859
689 : {(yylhs.value.RealVal)=(yystack_[1].value.RealVal);}
690 : #line 691 "Eval-parser.cc" // lalr1.cc:859
691 0 : break;
692 :
693 : case 6:
694 : #line 87 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:859
695 : {(yylhs.value.RealVal)=-(yystack_[0].value.RealVal);}
696 : #line 697 "Eval-parser.cc" // lalr1.cc:859
697 0 : break;
698 :
699 : case 7:
700 : #line 88 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:859
701 : {(yylhs.value.RealVal)=(yystack_[2].value.RealVal)+(yystack_[0].value.RealVal);}
702 : #line 703 "Eval-parser.cc" // lalr1.cc:859
703 0 : break;
704 :
705 : case 8:
706 : #line 89 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:859
707 : {(yylhs.value.RealVal)=(yystack_[2].value.RealVal)*(yystack_[0].value.RealVal);}
708 : #line 709 "Eval-parser.cc" // lalr1.cc:859
709 2 : break;
710 :
711 : case 9:
712 : #line 90 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:859
713 : {(yylhs.value.RealVal)=(yystack_[2].value.RealVal)-(yystack_[0].value.RealVal);}
714 : #line 715 "Eval-parser.cc" // lalr1.cc:859
715 0 : break;
716 :
717 : case 10:
718 : #line 91 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:859
719 : {(yylhs.value.RealVal)=double((yystack_[0].value.RealVal));}
720 : #line 721 "Eval-parser.cc" // lalr1.cc:859
721 0 : break;
722 :
723 : case 11:
724 : #line 92 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:859
725 : {if((yystack_[0].value.RealVal)==0) {cout<<"Division by zero !";YYABORT;}
726 : else (yylhs.value.RealVal)=(yystack_[2].value.RealVal)/double (yystack_[0].value.RealVal);
727 : }
728 : #line 729 "Eval-parser.cc" // lalr1.cc:859
729 0 : break;
730 :
731 : case 12:
732 : #line 95 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:859
733 : {(yylhs.value.RealVal)=pow((yystack_[2].value.RealVal),(yystack_[0].value.RealVal));}
734 : #line 735 "Eval-parser.cc" // lalr1.cc:859
735 0 : break;
736 :
737 : case 13:
738 : #line 96 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:859
739 : {if((yystack_[3].value.RealVal)<=(yystack_[1].value.RealVal)) (yylhs.value.RealVal)=(yystack_[3].value.RealVal); else (yylhs.value.RealVal)=(yystack_[1].value.RealVal);}
740 : #line 741 "Eval-parser.cc" // lalr1.cc:859
741 0 : break;
742 :
743 : case 14:
744 : #line 97 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:859
745 : {if((yystack_[3].value.RealVal)>=(yystack_[1].value.RealVal)) (yylhs.value.RealVal)=(yystack_[3].value.RealVal); else (yylhs.value.RealVal)=(yystack_[1].value.RealVal);}
746 : #line 747 "Eval-parser.cc" // lalr1.cc:859
747 0 : break;
748 :
749 : case 15:
750 : #line 98 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:859
751 : {(yylhs.value.RealVal)=floor((yystack_[1].value.RealVal));}
752 : #line 753 "Eval-parser.cc" // lalr1.cc:859
753 0 : break;
754 :
755 :
756 : #line 757 "Eval-parser.cc" // lalr1.cc:859
757 : default:
758 0 : break;
759 : }
760 : }
761 0 : catch (const syntax_error& yyexc)
762 : {
763 0 : error (yyexc);
764 0 : YYERROR;
765 : }
766 1050 : YY_SYMBOL_PRINT ("-> $$ =", yylhs);
767 1050 : yypop_ (yylen);
768 1050 : yylen = 0;
769 1050 : YY_STACK_PRINT ();
770 :
771 : // Shift the result of the reduction.
772 1050 : yypush_ (YY_NULLPTR, yylhs);
773 : }
774 1050 : goto yynewstate;
775 :
776 : /*--------------------------------------.
777 : | yyerrlab -- here on detecting error. |
778 : `--------------------------------------*/
779 : yyerrlab:
780 : // If not already recovering from an error, report this error.
781 10 : if (!yyerrstatus_)
782 : {
783 10 : ++yynerrs_;
784 10 : error (yyla.location, yysyntax_error_ (yystack_[0].state, yyla));
785 : }
786 :
787 :
788 10 : yyerror_range[1].location = yyla.location;
789 10 : if (yyerrstatus_ == 3)
790 : {
791 : /* If just tried and failed to reuse lookahead token after an
792 : error, discard it. */
793 :
794 : // Return failure if at end of input.
795 0 : if (yyla.type_get () == yyeof_)
796 0 : YYABORT;
797 0 : else if (!yyla.empty ())
798 : {
799 0 : yy_destroy_ ("Error: discarding", yyla);
800 0 : yyla.clear ();
801 : }
802 : }
803 :
804 : // Else will try to reuse lookahead token after shifting the error token.
805 10 : goto yyerrlab1;
806 :
807 :
808 : /*---------------------------------------------------.
809 : | yyerrorlab -- error raised explicitly by YYERROR. |
810 : `---------------------------------------------------*/
811 : yyerrorlab:
812 :
813 : /* Pacify compilers like GCC when the user code never invokes
814 : YYERROR and the label yyerrorlab therefore never appears in user
815 : code. */
816 : if (false)
817 : goto yyerrorlab;
818 0 : yyerror_range[1].location = yystack_[yylen - 1].location;
819 : /* Do not reclaim the symbols of the rule whose action triggered
820 : this YYERROR. */
821 0 : yypop_ (yylen);
822 0 : yylen = 0;
823 0 : goto yyerrlab1;
824 :
825 : /*-------------------------------------------------------------.
826 : | yyerrlab1 -- common code for both syntax error and YYERROR. |
827 : `-------------------------------------------------------------*/
828 : yyerrlab1:
829 10 : yyerrstatus_ = 3; // Each real token shifted decrements this.
830 : {
831 10 : stack_symbol_type error_token;
832 : for (;;)
833 : {
834 50 : yyn = yypact_[yystack_[0].state];
835 30 : if (!yy_pact_value_is_default_ (yyn))
836 : {
837 30 : yyn += yyterror_;
838 30 : if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
839 : {
840 0 : yyn = yytable_[yyn];
841 0 : if (0 < yyn)
842 0 : break;
843 : }
844 : }
845 :
846 : // Pop the current state because it cannot handle the error token.
847 30 : if (yystack_.size () == 1)
848 10 : YYABORT;
849 :
850 20 : yyerror_range[1].location = yystack_[0].location;
851 20 : yy_destroy_ ("Error: popping", yystack_[0]);
852 20 : yypop_ ();
853 20 : YY_STACK_PRINT ();
854 : }
855 :
856 0 : yyerror_range[2].location = yyla.location;
857 0 : YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
858 :
859 : // Shift the error token.
860 0 : error_token.state = yyn;
861 0 : yypush_ ("Shifting", error_token);
862 : }
863 0 : goto yynewstate;
864 :
865 : // Accept.
866 : yyacceptlab:
867 518 : yyresult = 0;
868 518 : goto yyreturn;
869 :
870 : // Abort.
871 : yyabortlab:
872 10 : yyresult = 1;
873 10 : goto yyreturn;
874 :
875 : yyreturn:
876 528 : if (!yyla.empty ())
877 10 : yy_destroy_ ("Cleanup: discarding lookahead", yyla);
878 :
879 : /* Do not reclaim the symbols of the rule whose action triggered
880 : this YYABORT or YYACCEPT. */
881 528 : yypop_ (yylen);
882 2600 : while (1 < yystack_.size ())
883 : {
884 1036 : yy_destroy_ ("Cleanup: popping", yystack_[0]);
885 1036 : yypop_ ();
886 : }
887 :
888 1056 : return yyresult;
889 : }
890 0 : catch (...)
891 : {
892 0 : YYCDEBUG << "Exception caught: cleaning lookahead and stack"
893 0 : << std::endl;
894 : // Do not try to display the values of the reclaimed symbols,
895 : // as their printer might throw an exception.
896 0 : if (!yyla.empty ())
897 0 : yy_destroy_ (YY_NULLPTR, yyla);
898 :
899 0 : while (1 < yystack_.size ())
900 : {
901 0 : yy_destroy_ (YY_NULLPTR, yystack_[0]);
902 0 : yypop_ ();
903 : }
904 0 : throw;
905 : }
906 : }
907 :
908 : void
909 0 : Eval_parser::error (const syntax_error& yyexc)
910 : {
911 0 : error (yyexc.location, yyexc.what());
912 0 : }
913 :
914 : // Generate an error message.
915 : std::string
916 10 : Eval_parser::yysyntax_error_ (state_type yystate, const symbol_type& yyla) const
917 : {
918 : // Number of reported tokens (one for the "unexpected", one per
919 : // "expected").
920 10 : size_t yycount = 0;
921 : // Its maximum.
922 : enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
923 : // Arguments of yyformat.
924 : char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
925 :
926 : /* There are many possibilities here to consider:
927 : - If this state is a consistent state with a default action, then
928 : the only way this function was invoked is if the default action
929 : is an error action. In that case, don't check for expected
930 : tokens because there are none.
931 : - The only way there can be no lookahead present (in yyla) is
932 : if this state is a consistent state with a default action.
933 : Thus, detecting the absence of a lookahead is sufficient to
934 : determine that there is no unexpected or expected token to
935 : report. In that case, just report a simple "syntax error".
936 : - Don't assume there isn't a lookahead just because this state is
937 : a consistent state with a default action. There might have
938 : been a previous inconsistent state, consistent state with a
939 : non-default action, or user semantic action that manipulated
940 : yyla. (However, yyla is currently not documented for users.)
941 : - Of course, the expected token list depends on states to have
942 : correct lookahead information, and it depends on the parser not
943 : to perform extra reductions after fetching a lookahead from the
944 : scanner and before detecting a syntax error. Thus, state
945 : merging (from LALR or IELR) and default reductions corrupt the
946 : expected token list. However, the list is correct for
947 : canonical LR with one exception: it will still contain any
948 : token that will not be accepted due to an error action in a
949 : later state.
950 : */
951 10 : if (!yyla.empty ())
952 : {
953 10 : int yytoken = yyla.type_get ();
954 10 : yyarg[yycount++] = yytname_[yytoken];
955 10 : int yyn = yypact_[yystate];
956 10 : if (!yy_pact_value_is_default_ (yyn))
957 : {
958 : /* Start YYX at -YYN if negative to avoid negative indexes in
959 : YYCHECK. In other words, skip the first -YYN actions for
960 : this state because they are default actions. */
961 10 : int yyxbegin = yyn < 0 ? -yyn : 0;
962 : // Stay within bounds of both yycheck and yytname.
963 10 : int yychecklim = yylast_ - yyn + 1;
964 10 : int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
965 90 : for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
966 230 : if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
967 140 : && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
968 : {
969 50 : if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
970 : {
971 10 : yycount = 1;
972 10 : break;
973 : }
974 : else
975 40 : yyarg[yycount++] = yytname_[yyx];
976 : }
977 : }
978 : }
979 :
980 10 : char const* yyformat = YY_NULLPTR;
981 10 : switch (yycount)
982 : {
983 : #define YYCASE_(N, S) \
984 : case N: \
985 : yyformat = S; \
986 : break
987 0 : YYCASE_(0, YY_("syntax error"));
988 10 : YYCASE_(1, YY_("syntax error, unexpected %s"));
989 0 : YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
990 0 : YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
991 0 : YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
992 0 : YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
993 : #undef YYCASE_
994 : }
995 :
996 10 : std::string yyres;
997 : // Argument number.
998 10 : size_t yyi = 0;
999 270 : for (char const* yyp = yyformat; *yyp; ++yyp)
1000 260 : if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
1001 : {
1002 10 : yyres += yytnamerr_ (yyarg[yyi++]);
1003 10 : ++yyp;
1004 : }
1005 : else
1006 250 : yyres += *yyp;
1007 10 : return yyres;
1008 : }
1009 :
1010 :
1011 : const signed char Eval_parser::yypact_ninf_ = -12;
1012 :
1013 : const signed char Eval_parser::yytable_ninf_ = -1;
1014 :
1015 : const signed char
1016 : Eval_parser::yypact_[] =
1017 : {
1018 : 14, -12, -12, -11, -10, 3, 14, 14, 14, 11,
1019 : 67, 14, 14, 14, -3, 39, -12, -12, 14, 14,
1020 : 14, 14, 14, 23, 31, 46, -12, -3, -3, 10,
1021 : 10, -12, 14, 14, -12, 53, 60, -12, -12
1022 : };
1023 :
1024 : const unsigned char
1025 : Eval_parser::yydefact_[] =
1026 : {
1027 : 0, 4, 3, 0, 0, 0, 0, 0, 0, 0,
1028 : 2, 0, 0, 0, 6, 0, 10, 1, 0, 0,
1029 : 0, 0, 0, 0, 0, 0, 5, 7, 9, 8,
1030 : 11, 12, 0, 0, 15, 0, 0, 13, 14
1031 : };
1032 :
1033 : const signed char
1034 : Eval_parser::yypgoto_[] =
1035 : {
1036 : -12, -12, -6
1037 : };
1038 :
1039 : const signed char
1040 : Eval_parser::yydefgoto_[] =
1041 : {
1042 : -1, 9, 10
1043 : };
1044 :
1045 : const unsigned char
1046 : Eval_parser::yytable_[] =
1047 : {
1048 : 14, 15, 16, 11, 12, 23, 24, 25, 20, 21,
1049 : 22, 17, 27, 28, 29, 30, 31, 13, 1, 2,
1050 : 3, 4, 5, 22, 6, 0, 35, 36, 7, 0,
1051 : 0, 8, 18, 19, 20, 21, 22, 0, 0, 32,
1052 : 18, 19, 20, 21, 22, 0, 0, 33, 18, 19,
1053 : 20, 21, 22, 0, 26, 18, 19, 20, 21, 22,
1054 : 0, 34, 18, 19, 20, 21, 22, 0, 37, 18,
1055 : 19, 20, 21, 22, 0, 38, 18, 19, 20, 21,
1056 : 22
1057 : };
1058 :
1059 : const signed char
1060 : Eval_parser::yycheck_[] =
1061 : {
1062 : 6, 7, 8, 14, 14, 11, 12, 13, 11, 12,
1063 : 13, 0, 18, 19, 20, 21, 22, 14, 4, 5,
1064 : 6, 7, 8, 13, 10, -1, 32, 33, 14, -1,
1065 : -1, 17, 9, 10, 11, 12, 13, -1, -1, 16,
1066 : 9, 10, 11, 12, 13, -1, -1, 16, 9, 10,
1067 : 11, 12, 13, -1, 15, 9, 10, 11, 12, 13,
1068 : -1, 15, 9, 10, 11, 12, 13, -1, 15, 9,
1069 : 10, 11, 12, 13, -1, 15, 9, 10, 11, 12,
1070 : 13
1071 : };
1072 :
1073 : const unsigned char
1074 : Eval_parser::yystos_[] =
1075 : {
1076 : 0, 4, 5, 6, 7, 8, 10, 14, 17, 20,
1077 : 21, 14, 14, 14, 21, 21, 21, 0, 9, 10,
1078 : 11, 12, 13, 21, 21, 21, 15, 21, 21, 21,
1079 : 21, 21, 16, 16, 15, 21, 21, 15, 15
1080 : };
1081 :
1082 : const unsigned char
1083 : Eval_parser::yyr1_[] =
1084 : {
1085 : 0, 19, 20, 21, 21, 21, 21, 21, 21, 21,
1086 : 21, 21, 21, 21, 21, 21
1087 : };
1088 :
1089 : const unsigned char
1090 : Eval_parser::yyr2_[] =
1091 : {
1092 : 0, 2, 1, 1, 1, 3, 2, 3, 3, 3,
1093 : 2, 3, 3, 6, 6, 4
1094 : };
1095 :
1096 :
1097 :
1098 : // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1099 : // First, the terminals, then, starting at \a yyntokens_, nonterminals.
1100 : const char*
1101 : const Eval_parser::yytname_[] =
1102 : {
1103 : "\"end of file\"", "error", "$undefined", "str", "rval", "ival", "MIN",
1104 : "MAX", "FLOOR", "PLUS", "MINUS", "MUL", "DIV", "POWER", "LB", "RB",
1105 : "COMMA", "DOUBLE", "NEG", "$accept", "ArithmethicExp", "exp", YY_NULLPTR
1106 : };
1107 :
1108 : #if YYDEBUG
1109 : const unsigned char
1110 : Eval_parser::yyrline_[] =
1111 : {
1112 : 0, 82, 82, 84, 85, 86, 87, 88, 89, 90,
1113 : 91, 92, 95, 96, 97, 98
1114 : };
1115 :
1116 : // Print the state stack on the debug stream.
1117 : void
1118 0 : Eval_parser::yystack_print_ ()
1119 : {
1120 0 : *yycdebug_ << "Stack now";
1121 0 : for (stack_type::const_iterator
1122 0 : i = yystack_.begin (),
1123 0 : i_end = yystack_.end ();
1124 : i != i_end; ++i)
1125 0 : *yycdebug_ << ' ' << i->state;
1126 0 : *yycdebug_ << std::endl;
1127 0 : }
1128 :
1129 : // Report on the debug stream that the rule \a yyrule is going to be reduced.
1130 : void
1131 0 : Eval_parser::yy_reduce_print_ (int yyrule)
1132 : {
1133 0 : unsigned int yylno = yyrline_[yyrule];
1134 0 : int yynrhs = yyr2_[yyrule];
1135 : // Print the symbols being reduced, and their result.
1136 0 : *yycdebug_ << "Reducing stack by rule " << yyrule - 1
1137 0 : << " (line " << yylno << "):" << std::endl;
1138 : // The symbols being reduced.
1139 0 : for (int yyi = 0; yyi < yynrhs; yyi++)
1140 0 : YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
1141 : yystack_[(yynrhs) - (yyi + 1)]);
1142 0 : }
1143 : #endif // YYDEBUG
1144 :
1145 : // Symbol number corresponding to token number t.
1146 : inline
1147 : Eval_parser::token_number_type
1148 1070 : Eval_parser::yytranslate_ (int t)
1149 : {
1150 : static
1151 : const token_number_type
1152 : translate_table[] =
1153 : {
1154 : 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1155 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1156 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1157 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1158 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1159 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1160 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1161 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1162 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1163 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1164 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1165 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1166 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1167 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1168 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1169 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1170 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1171 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1172 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1173 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1174 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1175 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1176 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1177 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1178 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1179 : 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1180 : 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1181 : 15, 16, 17, 18
1182 : };
1183 1070 : const unsigned int user_token_number_max_ = 273;
1184 1070 : const token_number_type undef_token_ = 2;
1185 :
1186 1070 : if (static_cast<int>(t) <= yyeof_)
1187 518 : return yyeof_;
1188 552 : else if (static_cast<unsigned int> (t) <= user_token_number_max_)
1189 552 : return translate_table[t];
1190 : else
1191 0 : return undef_token_;
1192 : }
1193 :
1194 :
1195 : } // eval
1196 : #line 1197 "Eval-parser.cc" // lalr1.cc:1167
1197 : #line 100 "../../../../src/ModelGenerator/Eval/Eval-parser.yy" // lalr1.cc:1168
1198 :
1199 :
1200 : void
1201 : eval::Eval_parser::error (const eval::Eval_parser::location_type& l,
1202 : const std::string& m)
1203 : {
1204 : Evaluate.error (l, m);
1205 : }
|