1 // A Bison parser, made by GNU Bison 3.7.5.
2
3 // Skeleton implementation for Bison LALR(1) parsers in C++
4
5 // Copyright (C) 2002-2015, 2018-2021 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 // DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
34 // especially those whose name start with YY_ or yy_. They are
35 // private implementation details that can be changed or removed.
36
37
38
39
40
41 #include "sbml_parser.tab.hh"
42
43
44 // Unqualified %code blocks.
45 #line 15 "sbml_parser.yy"
46
47 #include "symengine/pow.h"
48 #include "symengine/logic.h"
49 #include "symengine/parser/sbml/sbml_parser.h"
50
51 using SymEngine::add;
52 using SymEngine::Basic;
53 using SymEngine::Boolean;
54 using SymEngine::Eq;
55 using SymEngine::Ge;
56 using SymEngine::Gt;
57 using SymEngine::Le;
58 using SymEngine::Lt;
59 using SymEngine::mul;
60 using SymEngine::Ne;
61 using SymEngine::one;
62 using SymEngine::pow;
63 using SymEngine::RCP;
64 using SymEngine::rcp_static_cast;
65 using SymEngine::set_boolean;
66 using SymEngine::sub;
67 using SymEngine::vec_basic;
68 using SymEngine::vec_boolean;
69
70 #include "symengine/parser/sbml/sbml_tokenizer.h"
71
72 namespace sbml
73 {
74
yylex(sbml::parser::semantic_type * yylval,SymEngine::SbmlParser & p)75 int yylex(sbml::parser::semantic_type* yylval, SymEngine::SbmlParser & p)
76 {
77 return p.m_tokenizer->lex(yylval);
78 }
79
error(const std::string & msg)80 void parser::error(const std::string &msg)
81 {
82 throw SymEngine::ParseError(msg);
83 }
84
85 }
86
87
88 #line 89 "sbml_parser.tab.cc"
89
90
91 #ifndef YY_
92 # if defined YYENABLE_NLS && YYENABLE_NLS
93 # if ENABLE_NLS
94 # include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE.
95 # define YY_(msgid) dgettext ("bison-runtime", msgid)
96 # endif
97 # endif
98 # ifndef YY_
99 # define YY_(msgid) msgid
100 # endif
101 #endif
102
103
104 // Whether we are compiled with exception support.
105 #ifndef YY_EXCEPTIONS
106 # if defined __GNUC__ && !defined __EXCEPTIONS
107 # define YY_EXCEPTIONS 0
108 # else
109 # define YY_EXCEPTIONS 1
110 # endif
111 #endif
112
113
114
115 // Enable debugging if requested.
116 #if YYDEBUG
117
118 // A pseudo ostream that takes yydebug_ into account.
119 # define YYCDEBUG if (yydebug_) (*yycdebug_)
120
121 # define YY_SYMBOL_PRINT(Title, Symbol) \
122 do { \
123 if (yydebug_) \
124 { \
125 *yycdebug_ << Title << ' '; \
126 yy_print_ (*yycdebug_, Symbol); \
127 *yycdebug_ << '\n'; \
128 } \
129 } while (false)
130
131 # define YY_REDUCE_PRINT(Rule) \
132 do { \
133 if (yydebug_) \
134 yy_reduce_print_ (Rule); \
135 } while (false)
136
137 # define YY_STACK_PRINT() \
138 do { \
139 if (yydebug_) \
140 yy_stack_print_ (); \
141 } while (false)
142
143 #else // !YYDEBUG
144
145 # define YYCDEBUG if (false) std::cerr
146 # define YY_SYMBOL_PRINT(Title, Symbol) YY_USE (Symbol)
147 # define YY_REDUCE_PRINT(Rule) static_cast<void> (0)
148 # define YY_STACK_PRINT() static_cast<void> (0)
149
150 #endif // !YYDEBUG
151
152 #define yyerrok (yyerrstatus_ = 0)
153 #define yyclearin (yyla.clear ())
154
155 #define YYACCEPT goto yyacceptlab
156 #define YYABORT goto yyabortlab
157 #define YYERROR goto yyerrorlab
158 #define YYRECOVERING() (!!yyerrstatus_)
159
160 #line 4 "sbml_parser.yy"
161 namespace sbml {
162 #line 163 "sbml_parser.tab.cc"
163
164 /// Build a parser object.
parser(SymEngine::SbmlParser & p_yyarg)165 parser::parser (SymEngine::SbmlParser &p_yyarg)
166 #if YYDEBUG
167 : yydebug_ (false),
168 yycdebug_ (&std::cerr),
169 #else
170 :
171 #endif
172 p (p_yyarg)
173 {}
174
~parser()175 parser::~parser ()
176 {}
177
~syntax_error()178 parser::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
179 {}
180
181 /*---------------.
182 | symbol kinds. |
183 `---------------*/
184
185 // basic_symbol.
186 template <typename Base>
basic_symbol(const basic_symbol & that)187 parser::basic_symbol<Base>::basic_symbol (const basic_symbol& that)
188 : Base (that)
189 , value ()
190 {
191 switch (this->kind ())
192 {
193 case symbol_kind::S_st_expr: // st_expr
194 case symbol_kind::S_expr: // expr
195 value.copy< SymEngine::RCP<const SymEngine::Basic> > (YY_MOVE (that.value));
196 break;
197
198 case symbol_kind::S_expr_list: // expr_list
199 value.copy< SymEngine::vec_basic > (YY_MOVE (that.value));
200 break;
201
202 case symbol_kind::S_IDENTIFIER: // IDENTIFIER
203 case symbol_kind::S_NUMERIC: // NUMERIC
204 value.copy< std::string > (YY_MOVE (that.value));
205 break;
206
207 default:
208 break;
209 }
210
211 }
212
213
214
215 template <typename Base>
216 parser::symbol_kind_type
type_get() const217 parser::basic_symbol<Base>::type_get () const YY_NOEXCEPT
218 {
219 return this->kind ();
220 }
221
222 template <typename Base>
223 bool
empty() const224 parser::basic_symbol<Base>::empty () const YY_NOEXCEPT
225 {
226 return this->kind () == symbol_kind::S_YYEMPTY;
227 }
228
229 template <typename Base>
230 void
move(basic_symbol & s)231 parser::basic_symbol<Base>::move (basic_symbol& s)
232 {
233 super_type::move (s);
234 switch (this->kind ())
235 {
236 case symbol_kind::S_st_expr: // st_expr
237 case symbol_kind::S_expr: // expr
238 value.move< SymEngine::RCP<const SymEngine::Basic> > (YY_MOVE (s.value));
239 break;
240
241 case symbol_kind::S_expr_list: // expr_list
242 value.move< SymEngine::vec_basic > (YY_MOVE (s.value));
243 break;
244
245 case symbol_kind::S_IDENTIFIER: // IDENTIFIER
246 case symbol_kind::S_NUMERIC: // NUMERIC
247 value.move< std::string > (YY_MOVE (s.value));
248 break;
249
250 default:
251 break;
252 }
253
254 }
255
256 // by_kind.
by_kind()257 parser::by_kind::by_kind ()
258 : kind_ (symbol_kind::S_YYEMPTY)
259 {}
260
261 #if 201103L <= YY_CPLUSPLUS
by_kind(by_kind && that)262 parser::by_kind::by_kind (by_kind&& that)
263 : kind_ (that.kind_)
264 {
265 that.clear ();
266 }
267 #endif
268
by_kind(const by_kind & that)269 parser::by_kind::by_kind (const by_kind& that)
270 : kind_ (that.kind_)
271 {}
272
by_kind(token_kind_type t)273 parser::by_kind::by_kind (token_kind_type t)
274 : kind_ (yytranslate_ (t))
275 {}
276
277 void
clear()278 parser::by_kind::clear () YY_NOEXCEPT
279 {
280 kind_ = symbol_kind::S_YYEMPTY;
281 }
282
283 void
move(by_kind & that)284 parser::by_kind::move (by_kind& that)
285 {
286 kind_ = that.kind_;
287 that.clear ();
288 }
289
290 parser::symbol_kind_type
kind() const291 parser::by_kind::kind () const YY_NOEXCEPT
292 {
293 return kind_;
294 }
295
296 parser::symbol_kind_type
type_get() const297 parser::by_kind::type_get () const YY_NOEXCEPT
298 {
299 return this->kind ();
300 }
301
302
303 // by_state.
by_state()304 parser::by_state::by_state () YY_NOEXCEPT
305 : state (empty_state)
306 {}
307
by_state(const by_state & that)308 parser::by_state::by_state (const by_state& that) YY_NOEXCEPT
309 : state (that.state)
310 {}
311
312 void
clear()313 parser::by_state::clear () YY_NOEXCEPT
314 {
315 state = empty_state;
316 }
317
318 void
move(by_state & that)319 parser::by_state::move (by_state& that)
320 {
321 state = that.state;
322 that.clear ();
323 }
324
by_state(state_type s)325 parser::by_state::by_state (state_type s) YY_NOEXCEPT
326 : state (s)
327 {}
328
329 parser::symbol_kind_type
kind() const330 parser::by_state::kind () const YY_NOEXCEPT
331 {
332 if (state == empty_state)
333 return symbol_kind::S_YYEMPTY;
334 else
335 return YY_CAST (symbol_kind_type, yystos_[+state]);
336 }
337
stack_symbol_type()338 parser::stack_symbol_type::stack_symbol_type ()
339 {}
340
stack_symbol_type(YY_RVREF (stack_symbol_type)that)341 parser::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that)
342 : super_type (YY_MOVE (that.state))
343 {
344 switch (that.kind ())
345 {
346 case symbol_kind::S_st_expr: // st_expr
347 case symbol_kind::S_expr: // expr
348 value.YY_MOVE_OR_COPY< SymEngine::RCP<const SymEngine::Basic> > (YY_MOVE (that.value));
349 break;
350
351 case symbol_kind::S_expr_list: // expr_list
352 value.YY_MOVE_OR_COPY< SymEngine::vec_basic > (YY_MOVE (that.value));
353 break;
354
355 case symbol_kind::S_IDENTIFIER: // IDENTIFIER
356 case symbol_kind::S_NUMERIC: // NUMERIC
357 value.YY_MOVE_OR_COPY< std::string > (YY_MOVE (that.value));
358 break;
359
360 default:
361 break;
362 }
363
364 #if 201103L <= YY_CPLUSPLUS
365 // that is emptied.
366 that.state = empty_state;
367 #endif
368 }
369
stack_symbol_type(state_type s,YY_MOVE_REF (symbol_type)that)370 parser::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that)
371 : super_type (s)
372 {
373 switch (that.kind ())
374 {
375 case symbol_kind::S_st_expr: // st_expr
376 case symbol_kind::S_expr: // expr
377 value.move< SymEngine::RCP<const SymEngine::Basic> > (YY_MOVE (that.value));
378 break;
379
380 case symbol_kind::S_expr_list: // expr_list
381 value.move< SymEngine::vec_basic > (YY_MOVE (that.value));
382 break;
383
384 case symbol_kind::S_IDENTIFIER: // IDENTIFIER
385 case symbol_kind::S_NUMERIC: // NUMERIC
386 value.move< std::string > (YY_MOVE (that.value));
387 break;
388
389 default:
390 break;
391 }
392
393 // that is emptied.
394 that.kind_ = symbol_kind::S_YYEMPTY;
395 }
396
397 #if YY_CPLUSPLUS < 201103L
398 parser::stack_symbol_type&
operator =(const stack_symbol_type & that)399 parser::stack_symbol_type::operator= (const stack_symbol_type& that)
400 {
401 state = that.state;
402 switch (that.kind ())
403 {
404 case symbol_kind::S_st_expr: // st_expr
405 case symbol_kind::S_expr: // expr
406 value.copy< SymEngine::RCP<const SymEngine::Basic> > (that.value);
407 break;
408
409 case symbol_kind::S_expr_list: // expr_list
410 value.copy< SymEngine::vec_basic > (that.value);
411 break;
412
413 case symbol_kind::S_IDENTIFIER: // IDENTIFIER
414 case symbol_kind::S_NUMERIC: // NUMERIC
415 value.copy< std::string > (that.value);
416 break;
417
418 default:
419 break;
420 }
421
422 return *this;
423 }
424
425 parser::stack_symbol_type&
operator =(stack_symbol_type & that)426 parser::stack_symbol_type::operator= (stack_symbol_type& that)
427 {
428 state = that.state;
429 switch (that.kind ())
430 {
431 case symbol_kind::S_st_expr: // st_expr
432 case symbol_kind::S_expr: // expr
433 value.move< SymEngine::RCP<const SymEngine::Basic> > (that.value);
434 break;
435
436 case symbol_kind::S_expr_list: // expr_list
437 value.move< SymEngine::vec_basic > (that.value);
438 break;
439
440 case symbol_kind::S_IDENTIFIER: // IDENTIFIER
441 case symbol_kind::S_NUMERIC: // NUMERIC
442 value.move< std::string > (that.value);
443 break;
444
445 default:
446 break;
447 }
448
449 // that is emptied.
450 that.state = empty_state;
451 return *this;
452 }
453 #endif
454
455 template <typename Base>
456 void
yy_destroy_(const char * yymsg,basic_symbol<Base> & yysym) const457 parser::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
458 {
459 if (yymsg)
460 YY_SYMBOL_PRINT (yymsg, yysym);
461 }
462
463 #if YYDEBUG
464 template <typename Base>
465 void
yy_print_(std::ostream & yyo,const basic_symbol<Base> & yysym) const466 parser::yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const
467 {
468 std::ostream& yyoutput = yyo;
469 YY_USE (yyoutput);
470 if (yysym.empty ())
471 yyo << "empty symbol";
472 else
473 {
474 symbol_kind_type yykind = yysym.kind ();
475 yyo << (yykind < YYNTOKENS ? "token" : "nterm")
476 << ' ' << yysym.name () << " (";
477 YY_USE (yykind);
478 yyo << ')';
479 }
480 }
481 #endif
482
483 void
yypush_(const char * m,YY_MOVE_REF (stack_symbol_type)sym)484 parser::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym)
485 {
486 if (m)
487 YY_SYMBOL_PRINT (m, sym);
488 yystack_.push (YY_MOVE (sym));
489 }
490
491 void
yypush_(const char * m,state_type s,YY_MOVE_REF (symbol_type)sym)492 parser::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym)
493 {
494 #if 201103L <= YY_CPLUSPLUS
495 yypush_ (m, stack_symbol_type (s, std::move (sym)));
496 #else
497 stack_symbol_type ss (s, sym);
498 yypush_ (m, ss);
499 #endif
500 }
501
502 void
yypop_(int n)503 parser::yypop_ (int n)
504 {
505 yystack_.pop (n);
506 }
507
508 #if YYDEBUG
509 std::ostream&
debug_stream() const510 parser::debug_stream () const
511 {
512 return *yycdebug_;
513 }
514
515 void
set_debug_stream(std::ostream & o)516 parser::set_debug_stream (std::ostream& o)
517 {
518 yycdebug_ = &o;
519 }
520
521
522 parser::debug_level_type
debug_level() const523 parser::debug_level () const
524 {
525 return yydebug_;
526 }
527
528 void
set_debug_level(debug_level_type l)529 parser::set_debug_level (debug_level_type l)
530 {
531 yydebug_ = l;
532 }
533 #endif // YYDEBUG
534
535 parser::state_type
yy_lr_goto_state_(state_type yystate,int yysym)536 parser::yy_lr_goto_state_ (state_type yystate, int yysym)
537 {
538 int yyr = yypgoto_[yysym - YYNTOKENS] + yystate;
539 if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
540 return yytable_[yyr];
541 else
542 return yydefgoto_[yysym - YYNTOKENS];
543 }
544
545 bool
yy_pact_value_is_default_(int yyvalue)546 parser::yy_pact_value_is_default_ (int yyvalue)
547 {
548 return yyvalue == yypact_ninf_;
549 }
550
551 bool
yy_table_value_is_error_(int yyvalue)552 parser::yy_table_value_is_error_ (int yyvalue)
553 {
554 return yyvalue == yytable_ninf_;
555 }
556
557 int
operator ()()558 parser::operator() ()
559 {
560 return parse ();
561 }
562
563 int
parse()564 parser::parse ()
565 {
566 int yyn;
567 /// Length of the RHS of the rule being reduced.
568 int yylen = 0;
569
570 // Error handling.
571 int yynerrs_ = 0;
572 int yyerrstatus_ = 0;
573
574 /// The lookahead symbol.
575 symbol_type yyla;
576
577 /// The return value of parse ().
578 int yyresult;
579
580 #if YY_EXCEPTIONS
581 try
582 #endif // YY_EXCEPTIONS
583 {
584 YYCDEBUG << "Starting parse\n";
585
586
587 /* Initialize the stack. The initial state will be set in
588 yynewstate, since the latter expects the semantical and the
589 location values to have been already stored, initialize these
590 stacks with a primary value. */
591 yystack_.clear ();
592 yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));
593
594 /*-----------------------------------------------.
595 | yynewstate -- push a new symbol on the stack. |
596 `-----------------------------------------------*/
597 yynewstate:
598 YYCDEBUG << "Entering state " << int (yystack_[0].state) << '\n';
599 YY_STACK_PRINT ();
600
601 // Accept?
602 if (yystack_[0].state == yyfinal_)
603 YYACCEPT;
604
605 goto yybackup;
606
607
608 /*-----------.
609 | yybackup. |
610 `-----------*/
611 yybackup:
612 // Try to take a decision without lookahead.
613 yyn = yypact_[+yystack_[0].state];
614 if (yy_pact_value_is_default_ (yyn))
615 goto yydefault;
616
617 // Read a lookahead token.
618 if (yyla.empty ())
619 {
620 YYCDEBUG << "Reading a token\n";
621 #if YY_EXCEPTIONS
622 try
623 #endif // YY_EXCEPTIONS
624 {
625 yyla.kind_ = yytranslate_ (yylex (&yyla.value, p));
626 }
627 #if YY_EXCEPTIONS
628 catch (const syntax_error& yyexc)
629 {
630 YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
631 error (yyexc);
632 goto yyerrlab1;
633 }
634 #endif // YY_EXCEPTIONS
635 }
636 YY_SYMBOL_PRINT ("Next token is", yyla);
637
638 if (yyla.kind () == symbol_kind::S_YYerror)
639 {
640 // The scanner already issued an error message, process directly
641 // to error recovery. But do not keep the error token as
642 // lookahead, it is too special and may lead us to an endless
643 // loop in error recovery. */
644 yyla.kind_ = symbol_kind::S_YYUNDEF;
645 goto yyerrlab1;
646 }
647
648 /* If the proper action on seeing token YYLA.TYPE is to reduce or
649 to detect an error, take that action. */
650 yyn += yyla.kind ();
651 if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind ())
652 {
653 goto yydefault;
654 }
655
656 // Reduce or error.
657 yyn = yytable_[yyn];
658 if (yyn <= 0)
659 {
660 if (yy_table_value_is_error_ (yyn))
661 goto yyerrlab;
662 yyn = -yyn;
663 goto yyreduce;
664 }
665
666 // Count tokens shifted since error; after three, turn off error status.
667 if (yyerrstatus_)
668 --yyerrstatus_;
669
670 // Shift the lookahead token.
671 yypush_ ("Shifting", state_type (yyn), YY_MOVE (yyla));
672 goto yynewstate;
673
674
675 /*-----------------------------------------------------------.
676 | yydefault -- do the default action for the current state. |
677 `-----------------------------------------------------------*/
678 yydefault:
679 yyn = yydefact_[+yystack_[0].state];
680 if (yyn == 0)
681 goto yyerrlab;
682 goto yyreduce;
683
684
685 /*-----------------------------.
686 | yyreduce -- do a reduction. |
687 `-----------------------------*/
688 yyreduce:
689 yylen = yyr2_[yyn];
690 {
691 stack_symbol_type yylhs;
692 yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]);
693 /* Variants are always initialized to an empty instance of the
694 correct type. The default '$$ = $1' action is NOT applied
695 when using variants. */
696 switch (yyr1_[yyn])
697 {
698 case symbol_kind::S_st_expr: // st_expr
699 case symbol_kind::S_expr: // expr
700 yylhs.value.emplace< SymEngine::RCP<const SymEngine::Basic> > ();
701 break;
702
703 case symbol_kind::S_expr_list: // expr_list
704 yylhs.value.emplace< SymEngine::vec_basic > ();
705 break;
706
707 case symbol_kind::S_IDENTIFIER: // IDENTIFIER
708 case symbol_kind::S_NUMERIC: // NUMERIC
709 yylhs.value.emplace< std::string > ();
710 break;
711
712 default:
713 break;
714 }
715
716
717
718 // Perform the reduction.
719 YY_REDUCE_PRINT (yyn);
720 #if YY_EXCEPTIONS
721 try
722 #endif // YY_EXCEPTIONS
723 {
724 switch (yyn)
725 {
726 case 2: // st_expr: expr
727 #line 78 "sbml_parser.yy"
728 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > (); p.res = yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > (); }
729 #line 730 "sbml_parser.tab.cc"
730 break;
731
732 case 3: // expr: expr '+' expr
733 #line 82 "sbml_parser.yy"
734 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = add(yystack_[2].value.as < SymEngine::RCP<const SymEngine::Basic> > (), yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
735 #line 736 "sbml_parser.tab.cc"
736 break;
737
738 case 4: // expr: expr '-' expr
739 #line 83 "sbml_parser.yy"
740 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = sub(yystack_[2].value.as < SymEngine::RCP<const SymEngine::Basic> > (), yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
741 #line 742 "sbml_parser.tab.cc"
742 break;
743
744 case 5: // expr: expr '*' expr
745 #line 84 "sbml_parser.yy"
746 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = mul(yystack_[2].value.as < SymEngine::RCP<const SymEngine::Basic> > (), yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
747 #line 748 "sbml_parser.tab.cc"
748 break;
749
750 case 6: // expr: expr '/' expr
751 #line 85 "sbml_parser.yy"
752 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = div(yystack_[2].value.as < SymEngine::RCP<const SymEngine::Basic> > (), yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
753 #line 754 "sbml_parser.tab.cc"
754 break;
755
756 case 7: // expr: expr '%' expr
757 #line 86 "sbml_parser.yy"
758 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = p.modulo(yystack_[2].value.as < SymEngine::RCP<const SymEngine::Basic> > (), yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
759 #line 760 "sbml_parser.tab.cc"
760 break;
761
762 case 8: // expr: expr '^' expr
763 #line 87 "sbml_parser.yy"
764 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = pow(yystack_[2].value.as < SymEngine::RCP<const SymEngine::Basic> > (), yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
765 #line 766 "sbml_parser.tab.cc"
766 break;
767
768 case 9: // expr: expr '<' expr
769 #line 88 "sbml_parser.yy"
770 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = Lt(yystack_[2].value.as < SymEngine::RCP<const SymEngine::Basic> > (), yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
771 #line 772 "sbml_parser.tab.cc"
772 break;
773
774 case 10: // expr: expr '>' expr
775 #line 89 "sbml_parser.yy"
776 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = Gt(yystack_[2].value.as < SymEngine::RCP<const SymEngine::Basic> > (), yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
777 #line 778 "sbml_parser.tab.cc"
778 break;
779
780 case 11: // expr: expr NE expr
781 #line 90 "sbml_parser.yy"
782 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = Ne(yystack_[2].value.as < SymEngine::RCP<const SymEngine::Basic> > (), yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
783 #line 784 "sbml_parser.tab.cc"
784 break;
785
786 case 12: // expr: expr LE expr
787 #line 91 "sbml_parser.yy"
788 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = Le(yystack_[2].value.as < SymEngine::RCP<const SymEngine::Basic> > (), yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
789 #line 790 "sbml_parser.tab.cc"
790 break;
791
792 case 13: // expr: expr GE expr
793 #line 92 "sbml_parser.yy"
794 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = Ge(yystack_[2].value.as < SymEngine::RCP<const SymEngine::Basic> > (), yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
795 #line 796 "sbml_parser.tab.cc"
796 break;
797
798 case 14: // expr: expr EQ expr
799 #line 93 "sbml_parser.yy"
800 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = Eq(yystack_[2].value.as < SymEngine::RCP<const SymEngine::Basic> > (), yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
801 #line 802 "sbml_parser.tab.cc"
802 break;
803
804 case 15: // expr: expr OR expr
805 #line 94 "sbml_parser.yy"
806 {
807 set_boolean s;
808 s.insert(rcp_static_cast<const Boolean>(yystack_[2].value.as < SymEngine::RCP<const SymEngine::Basic> > ()));
809 s.insert(rcp_static_cast<const Boolean>(yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()));
810 yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = logical_or(s); }
811 #line 812 "sbml_parser.tab.cc"
812 break;
813
814 case 16: // expr: expr AND expr
815 #line 99 "sbml_parser.yy"
816 {
817 set_boolean s;
818 s.insert(rcp_static_cast<const Boolean>(yystack_[2].value.as < SymEngine::RCP<const SymEngine::Basic> > ()));
819 s.insert(rcp_static_cast<const Boolean>(yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()));
820 yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = logical_and(s); }
821 #line 822 "sbml_parser.tab.cc"
822 break;
823
824 case 17: // expr: '(' expr ')'
825 #line 104 "sbml_parser.yy"
826 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = yystack_[1].value.as < SymEngine::RCP<const SymEngine::Basic> > (); }
827 #line 828 "sbml_parser.tab.cc"
828 break;
829
830 case 18: // expr: '-' expr
831 #line 105 "sbml_parser.yy"
832 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = neg(yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
833 #line 834 "sbml_parser.tab.cc"
834 break;
835
836 case 19: // expr: '+' expr
837 #line 106 "sbml_parser.yy"
838 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > (); }
839 #line 840 "sbml_parser.tab.cc"
840 break;
841
842 case 20: // expr: '!' expr
843 #line 107 "sbml_parser.yy"
844 {
845 yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = logical_not(rcp_static_cast<const Boolean>(yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ())); }
846 #line 847 "sbml_parser.tab.cc"
847 break;
848
849 case 21: // expr: IDENTIFIER
850 #line 109 "sbml_parser.yy"
851 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = p.parse_identifier(yystack_[0].value.as < std::string > ()); }
852 #line 853 "sbml_parser.tab.cc"
853 break;
854
855 case 22: // expr: NUMERIC
856 #line 110 "sbml_parser.yy"
857 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = p.parse_numeric(yystack_[0].value.as < std::string > ()); }
858 #line 859 "sbml_parser.tab.cc"
859 break;
860
861 case 23: // expr: IDENTIFIER '(' expr_list ')'
862 #line 111 "sbml_parser.yy"
863 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = p.functionify(yystack_[3].value.as < std::string > (), yystack_[1].value.as < SymEngine::vec_basic > ()); }
864 #line 865 "sbml_parser.tab.cc"
865 break;
866
867 case 24: // expr: IDENTIFIER '(' ')'
868 #line 112 "sbml_parser.yy"
869 { yylhs.value.as < SymEngine::RCP<const SymEngine::Basic> > () = p.functionify(yystack_[2].value.as < std::string > ()); }
870 #line 871 "sbml_parser.tab.cc"
871 break;
872
873 case 25: // expr_list: expr_list ',' expr
874 #line 116 "sbml_parser.yy"
875 { yylhs.value.as < SymEngine::vec_basic > () = yystack_[2].value.as < SymEngine::vec_basic > (); yylhs.value.as < SymEngine::vec_basic > ().push_back(yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
876 #line 877 "sbml_parser.tab.cc"
877 break;
878
879 case 26: // expr_list: expr
880 #line 117 "sbml_parser.yy"
881 { yylhs.value.as < SymEngine::vec_basic > () = vec_basic(1, yystack_[0].value.as < SymEngine::RCP<const SymEngine::Basic> > ()); }
882 #line 883 "sbml_parser.tab.cc"
883 break;
884
885
886 #line 887 "sbml_parser.tab.cc"
887
888 default:
889 break;
890 }
891 }
892 #if YY_EXCEPTIONS
893 catch (const syntax_error& yyexc)
894 {
895 YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
896 error (yyexc);
897 YYERROR;
898 }
899 #endif // YY_EXCEPTIONS
900 YY_SYMBOL_PRINT ("-> $$ =", yylhs);
901 yypop_ (yylen);
902 yylen = 0;
903
904 // Shift the result of the reduction.
905 yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
906 }
907 goto yynewstate;
908
909
910 /*--------------------------------------.
911 | yyerrlab -- here on detecting error. |
912 `--------------------------------------*/
913 yyerrlab:
914 // If not already recovering from an error, report this error.
915 if (!yyerrstatus_)
916 {
917 ++yynerrs_;
918 std::string msg = YY_("syntax error");
919 error (YY_MOVE (msg));
920 }
921
922
923 if (yyerrstatus_ == 3)
924 {
925 /* If just tried and failed to reuse lookahead token after an
926 error, discard it. */
927
928 // Return failure if at end of input.
929 if (yyla.kind () == symbol_kind::S_YYEOF)
930 YYABORT;
931 else if (!yyla.empty ())
932 {
933 yy_destroy_ ("Error: discarding", yyla);
934 yyla.clear ();
935 }
936 }
937
938 // Else will try to reuse lookahead token after shifting the error token.
939 goto yyerrlab1;
940
941
942 /*---------------------------------------------------.
943 | yyerrorlab -- error raised explicitly by YYERROR. |
944 `---------------------------------------------------*/
945 yyerrorlab:
946 /* Pacify compilers when the user code never invokes YYERROR and
947 the label yyerrorlab therefore never appears in user code. */
948 if (false)
949 YYERROR;
950
951 /* Do not reclaim the symbols of the rule whose action triggered
952 this YYERROR. */
953 yypop_ (yylen);
954 yylen = 0;
955 YY_STACK_PRINT ();
956 goto yyerrlab1;
957
958
959 /*-------------------------------------------------------------.
960 | yyerrlab1 -- common code for both syntax error and YYERROR. |
961 `-------------------------------------------------------------*/
962 yyerrlab1:
963 yyerrstatus_ = 3; // Each real token shifted decrements this.
964 // Pop stack until we find a state that shifts the error token.
965 for (;;)
966 {
967 yyn = yypact_[+yystack_[0].state];
968 if (!yy_pact_value_is_default_ (yyn))
969 {
970 yyn += symbol_kind::S_YYerror;
971 if (0 <= yyn && yyn <= yylast_
972 && yycheck_[yyn] == symbol_kind::S_YYerror)
973 {
974 yyn = yytable_[yyn];
975 if (0 < yyn)
976 break;
977 }
978 }
979
980 // Pop the current state because it cannot handle the error token.
981 if (yystack_.size () == 1)
982 YYABORT;
983
984 yy_destroy_ ("Error: popping", yystack_[0]);
985 yypop_ ();
986 YY_STACK_PRINT ();
987 }
988 {
989 stack_symbol_type error_token;
990
991
992 // Shift the error token.
993 error_token.state = state_type (yyn);
994 yypush_ ("Shifting", YY_MOVE (error_token));
995 }
996 goto yynewstate;
997
998
999 /*-------------------------------------.
1000 | yyacceptlab -- YYACCEPT comes here. |
1001 `-------------------------------------*/
1002 yyacceptlab:
1003 yyresult = 0;
1004 goto yyreturn;
1005
1006
1007 /*-----------------------------------.
1008 | yyabortlab -- YYABORT comes here. |
1009 `-----------------------------------*/
1010 yyabortlab:
1011 yyresult = 1;
1012 goto yyreturn;
1013
1014
1015 /*-----------------------------------------------------.
1016 | yyreturn -- parsing is finished, return the result. |
1017 `-----------------------------------------------------*/
1018 yyreturn:
1019 if (!yyla.empty ())
1020 yy_destroy_ ("Cleanup: discarding lookahead", yyla);
1021
1022 /* Do not reclaim the symbols of the rule whose action triggered
1023 this YYABORT or YYACCEPT. */
1024 yypop_ (yylen);
1025 YY_STACK_PRINT ();
1026 while (1 < yystack_.size ())
1027 {
1028 yy_destroy_ ("Cleanup: popping", yystack_[0]);
1029 yypop_ ();
1030 }
1031
1032 return yyresult;
1033 }
1034 #if YY_EXCEPTIONS
1035 catch (...)
1036 {
1037 YYCDEBUG << "Exception caught: cleaning lookahead and stack\n";
1038 // Do not try to display the values of the reclaimed symbols,
1039 // as their printers might throw an exception.
1040 if (!yyla.empty ())
1041 yy_destroy_ (YY_NULLPTR, yyla);
1042
1043 while (1 < yystack_.size ())
1044 {
1045 yy_destroy_ (YY_NULLPTR, yystack_[0]);
1046 yypop_ ();
1047 }
1048 throw;
1049 }
1050 #endif // YY_EXCEPTIONS
1051 }
1052
1053 void
error(const syntax_error & yyexc)1054 parser::error (const syntax_error& yyexc)
1055 {
1056 error (yyexc.what ());
1057 }
1058
1059 #if YYDEBUG || 0
1060 const char *
symbol_name(symbol_kind_type yysymbol)1061 parser::symbol_name (symbol_kind_type yysymbol)
1062 {
1063 return yytname_[yysymbol];
1064 }
1065 #endif // #if YYDEBUG || 0
1066
1067
1068
1069
1070
1071 const signed char parser::yypact_ninf_ = -20;
1072
1073 const signed char parser::yytable_ninf_ = -1;
1074
1075 const signed char
1076 parser::yypact_[] =
1077 {
1078 28, -15, -20, 28, 28, 28, 28, 8, 65, 24,
1079 -12, -12, -12, 46, -20, 28, 28, 28, 28, 28,
1080 28, 28, 28, 28, 28, 28, 28, 28, 28, -20,
1081 65, -19, -20, 80, 80, 89, 89, 89, 89, 89,
1082 89, 18, 18, -12, -12, -12, -20, -20, 28, 65
1083 };
1084
1085 const signed char
1086 parser::yydefact_[] =
1087 {
1088 0, 21, 22, 0, 0, 0, 0, 0, 2, 0,
1089 19, 18, 20, 0, 1, 0, 0, 0, 0, 0,
1090 0, 0, 0, 0, 0, 0, 0, 0, 0, 24,
1091 26, 0, 17, 16, 15, 14, 9, 10, 12, 13,
1092 11, 3, 4, 5, 6, 7, 8, 23, 0, 25
1093 };
1094
1095 const signed char
1096 parser::yypgoto_[] =
1097 {
1098 -20, -20, -3, -20
1099 };
1100
1101 const signed char
1102 parser::yydefgoto_[] =
1103 {
1104 0, 7, 8, 31
1105 };
1106
1107 const signed char
1108 parser::yytable_[] =
1109 {
1110 10, 11, 12, 13, 47, 48, 30, 9, 14, 28,
1111 0, 0, 33, 34, 35, 36, 37, 38, 39, 40,
1112 41, 42, 43, 44, 45, 46, 0, 1, 2, 0,
1113 0, 1, 2, 25, 26, 27, 0, 3, 4, 28,
1114 0, 3, 4, 0, 5, 49, 6, 29, 5, 0,
1115 6, 15, 16, 17, 18, 19, 20, 21, 22, 23,
1116 24, 25, 26, 27, 0, 0, 0, 28, 0, 32,
1117 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1118 25, 26, 27, 0, 0, 0, 28, 17, 18, 19,
1119 20, 21, 22, 23, 24, 25, 26, 27, 0, 0,
1120 0, 28, 23, 24, 25, 26, 27, 0, 0, 0,
1121 28
1122 };
1123
1124 const signed char
1125 parser::yycheck_[] =
1126 {
1127 3, 4, 5, 6, 23, 24, 9, 22, 0, 21,
1128 -1, -1, 15, 16, 17, 18, 19, 20, 21, 22,
1129 23, 24, 25, 26, 27, 28, -1, 3, 4, -1,
1130 -1, 3, 4, 15, 16, 17, -1, 13, 14, 21,
1131 -1, 13, 14, -1, 20, 48, 22, 23, 20, -1,
1132 22, 5, 6, 7, 8, 9, 10, 11, 12, 13,
1133 14, 15, 16, 17, -1, -1, -1, 21, -1, 23,
1134 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1135 15, 16, 17, -1, -1, -1, 21, 7, 8, 9,
1136 10, 11, 12, 13, 14, 15, 16, 17, -1, -1,
1137 -1, 21, 13, 14, 15, 16, 17, -1, -1, -1,
1138 21
1139 };
1140
1141 const signed char
1142 parser::yystos_[] =
1143 {
1144 0, 3, 4, 13, 14, 20, 22, 26, 27, 22,
1145 27, 27, 27, 27, 0, 5, 6, 7, 8, 9,
1146 10, 11, 12, 13, 14, 15, 16, 17, 21, 23,
1147 27, 28, 23, 27, 27, 27, 27, 27, 27, 27,
1148 27, 27, 27, 27, 27, 27, 27, 23, 24, 27
1149 };
1150
1151 const signed char
1152 parser::yyr1_[] =
1153 {
1154 0, 25, 26, 27, 27, 27, 27, 27, 27, 27,
1155 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
1156 27, 27, 27, 27, 27, 28, 28
1157 };
1158
1159 const signed char
1160 parser::yyr2_[] =
1161 {
1162 0, 2, 1, 3, 3, 3, 3, 3, 3, 3,
1163 3, 3, 3, 3, 3, 3, 3, 3, 2, 2,
1164 2, 1, 1, 4, 3, 3, 1
1165 };
1166
1167
1168 #if YYDEBUG
1169 // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1170 // First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
1171 const char*
1172 const parser::yytname_[] =
1173 {
1174 "END_OF_FILE", "error", "\"invalid token\"", "IDENTIFIER", "NUMERIC",
1175 "AND", "OR", "EQ", "'<'", "'>'", "LE", "GE", "NE", "'+'", "'-'", "'*'",
1176 "'/'", "'%'", "UMINUS", "UPLUS", "'!'", "'^'", "'('", "')'", "','",
1177 "$accept", "st_expr", "expr", "expr_list", YY_NULLPTR
1178 };
1179 #endif
1180
1181
1182 #if YYDEBUG
1183 const signed char
1184 parser::yyrline_[] =
1185 {
1186 0, 78, 78, 82, 83, 84, 85, 86, 87, 88,
1187 89, 90, 91, 92, 93, 94, 99, 104, 105, 106,
1188 107, 109, 110, 111, 112, 116, 117
1189 };
1190
1191 void
yy_stack_print_() const1192 parser::yy_stack_print_ () const
1193 {
1194 *yycdebug_ << "Stack now";
1195 for (stack_type::const_iterator
1196 i = yystack_.begin (),
1197 i_end = yystack_.end ();
1198 i != i_end; ++i)
1199 *yycdebug_ << ' ' << int (i->state);
1200 *yycdebug_ << '\n';
1201 }
1202
1203 void
yy_reduce_print_(int yyrule) const1204 parser::yy_reduce_print_ (int yyrule) const
1205 {
1206 int yylno = yyrline_[yyrule];
1207 int yynrhs = yyr2_[yyrule];
1208 // Print the symbols being reduced, and their result.
1209 *yycdebug_ << "Reducing stack by rule " << yyrule - 1
1210 << " (line " << yylno << "):\n";
1211 // The symbols being reduced.
1212 for (int yyi = 0; yyi < yynrhs; yyi++)
1213 YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
1214 yystack_[(yynrhs) - (yyi + 1)]);
1215 }
1216 #endif // YYDEBUG
1217
1218 parser::symbol_kind_type
yytranslate_(int t)1219 parser::yytranslate_ (int t)
1220 {
1221 // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to
1222 // TOKEN-NUM as returned by yylex.
1223 static
1224 const signed char
1225 translate_table[] =
1226 {
1227 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1228 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1229 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1230 2, 2, 2, 20, 2, 2, 2, 17, 2, 2,
1231 22, 23, 15, 13, 24, 14, 2, 16, 2, 2,
1232 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1233 8, 2, 9, 2, 2, 2, 2, 2, 2, 2,
1234 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1235 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1236 2, 2, 2, 2, 21, 2, 2, 2, 2, 2,
1237 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1238 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1239 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1240 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1241 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1242 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1243 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1244 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1245 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1246 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1247 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1248 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1249 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1250 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1251 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1252 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1253 5, 6, 7, 10, 11, 12, 18, 19
1254 };
1255 // Last valid token kind.
1256 const int code_max = 267;
1257
1258 if (t <= 0)
1259 return symbol_kind::S_YYEOF;
1260 else if (t <= code_max)
1261 return YY_CAST (symbol_kind_type, translate_table[t]);
1262 else
1263 return symbol_kind::S_YYUNDEF;
1264 }
1265
1266 #line 4 "sbml_parser.yy"
1267 } // sbml
1268 #line 1269 "sbml_parser.tab.cc"
1269
1270