1 // A Bison parser, made by GNU Bison 3.7.5.
3 // Skeleton implementation for Bison LALR(1) parsers in C++
5 // Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc.
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.
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.
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/>.
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.
30 // This special exception was added by the Free Software Foundation in
31 // version 2.2 of Bison.
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.
37 // "%code top" blocks.
38 #line 28 "QLParser.yy"
44 #line 45 "QLParser.tab.cc"
49 #include "QLParser.tab.hh"
52 // Unqualified %code blocks.
53 #line 42 "QLParser.yy"
57 static QL::Parser::symbol_type
yylex (QL::Result
&result
);
60 #line 61 "QLParser.tab.cc"
64 # if defined YYENABLE_NLS && YYENABLE_NLS
66 # include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE.
67 # define YY_(msgid) dgettext ("bison-runtime", msgid)
71 # define YY_(msgid) msgid
76 // Whether we are compiled with exception support.
78 # if defined __GNUC__ && !defined __EXCEPTIONS
79 # define YY_EXCEPTIONS 0
81 # define YY_EXCEPTIONS 1
87 // Enable debugging if requested.
90 // A pseudo ostream that takes yydebug_ into account.
91 # define YYCDEBUG if (yydebug_) (*yycdebug_)
93 # define YY_SYMBOL_PRINT(Title, Symbol) \
97 *yycdebug_ << Title << ' '; \
98 yy_print_ (*yycdebug_, Symbol); \
103 # define YY_REDUCE_PRINT(Rule) \
106 yy_reduce_print_ (Rule); \
109 # define YY_STACK_PRINT() \
112 yy_stack_print_ (); \
117 # define YYCDEBUG if (false) std::cerr
118 # define YY_SYMBOL_PRINT(Title, Symbol) YY_USE (Symbol)
119 # define YY_REDUCE_PRINT(Rule) static_cast<void> (0)
120 # define YY_STACK_PRINT() static_cast<void> (0)
124 #define yyerrok (yyerrstatus_ = 0)
125 #define yyclearin (yyla.clear ())
127 #define YYACCEPT goto yyacceptlab
128 #define YYABORT goto yyabortlab
129 #define YYERROR goto yyerrorlab
130 #define YYRECOVERING() (!!yyerrstatus_)
132 #line 50 "QLParser.yy"
134 #line 135 "QLParser.tab.cc"
136 /// Build a parser object.
137 Parser::Parser (QL::Result
&result_yyarg
)
140 yycdebug_ (&std::cerr
),
144 result (result_yyarg
)
150 Parser::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
160 Parser::by_state::by_state () YY_NOEXCEPT
161 : state (empty_state
)
164 Parser::by_state::by_state (const by_state
& that
) YY_NOEXCEPT
169 Parser::by_state::clear () YY_NOEXCEPT
175 Parser::by_state::move (by_state
& that
)
181 Parser::by_state::by_state (state_type s
) YY_NOEXCEPT
185 Parser::symbol_kind_type
186 Parser::by_state::kind () const YY_NOEXCEPT
188 if (state
== empty_state
)
189 return symbol_kind::S_YYEMPTY
;
191 return YY_CAST (symbol_kind_type
, yystos_
[+state
]);
194 Parser::stack_symbol_type::stack_symbol_type ()
197 Parser::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type
) that
)
198 : super_type (YY_MOVE (that
.state
))
200 switch (that
.kind ())
202 case symbol_kind::S_NUM
: // "number"
203 case symbol_kind::S_NAME
: // "name"
204 case symbol_kind::S_FNAME
: // FNAME
205 case symbol_kind::S_JGROUP
: // JGROUP
206 case symbol_kind::S_JPARENT
: // JPARENT
207 case symbol_kind::S_QSTR
: // QSTR
208 case symbol_kind::S_FILEIOVFD
: // FILEIOVFD
209 case symbol_kind::S_exp
: // exp
210 case symbol_kind::S_term
: // term
211 value
.YY_MOVE_OR_COPY
< Expression
* > (YY_MOVE (that
.value
));
218 #if 201103L <= YY_CPLUSPLUS
220 that
.state
= empty_state
;
224 Parser::stack_symbol_type::stack_symbol_type (state_type s
, YY_MOVE_REF (symbol_type
) that
)
227 switch (that
.kind ())
229 case symbol_kind::S_NUM
: // "number"
230 case symbol_kind::S_NAME
: // "name"
231 case symbol_kind::S_FNAME
: // FNAME
232 case symbol_kind::S_JGROUP
: // JGROUP
233 case symbol_kind::S_JPARENT
: // JPARENT
234 case symbol_kind::S_QSTR
: // QSTR
235 case symbol_kind::S_FILEIOVFD
: // FILEIOVFD
236 case symbol_kind::S_exp
: // exp
237 case symbol_kind::S_term
: // term
238 value
.move
< Expression
* > (YY_MOVE (that
.value
));
246 that
.kind_
= symbol_kind::S_YYEMPTY
;
249 #if YY_CPLUSPLUS < 201103L
250 Parser::stack_symbol_type
&
251 Parser::stack_symbol_type::operator= (const stack_symbol_type
& that
)
254 switch (that
.kind ())
256 case symbol_kind::S_NUM
: // "number"
257 case symbol_kind::S_NAME
: // "name"
258 case symbol_kind::S_FNAME
: // FNAME
259 case symbol_kind::S_JGROUP
: // JGROUP
260 case symbol_kind::S_JPARENT
: // JPARENT
261 case symbol_kind::S_QSTR
: // QSTR
262 case symbol_kind::S_FILEIOVFD
: // FILEIOVFD
263 case symbol_kind::S_exp
: // exp
264 case symbol_kind::S_term
: // term
265 value
.copy
< Expression
* > (that
.value
);
275 Parser::stack_symbol_type
&
276 Parser::stack_symbol_type::operator= (stack_symbol_type
& that
)
279 switch (that
.kind ())
281 case symbol_kind::S_NUM
: // "number"
282 case symbol_kind::S_NAME
: // "name"
283 case symbol_kind::S_FNAME
: // FNAME
284 case symbol_kind::S_JGROUP
: // JGROUP
285 case symbol_kind::S_JPARENT
: // JPARENT
286 case symbol_kind::S_QSTR
: // QSTR
287 case symbol_kind::S_FILEIOVFD
: // FILEIOVFD
288 case symbol_kind::S_exp
: // exp
289 case symbol_kind::S_term
: // term
290 value
.move
< Expression
* > (that
.value
);
298 that
.state
= empty_state
;
303 template <typename Base
>
305 Parser::yy_destroy_ (const char* yymsg
, basic_symbol
<Base
>& yysym
) const
308 YY_SYMBOL_PRINT (yymsg
, yysym
);
312 template <typename Base
>
314 Parser::yy_print_ (std::ostream
& yyo
, const basic_symbol
<Base
>& yysym
) const
316 std::ostream
& yyoutput
= yyo
;
319 yyo
<< "empty symbol";
322 symbol_kind_type yykind
= yysym
.kind ();
323 yyo
<< (yykind
< YYNTOKENS
? "token" : "nterm")
324 << ' ' << yysym
.name () << " (";
332 Parser::yypush_ (const char* m
, YY_MOVE_REF (stack_symbol_type
) sym
)
335 YY_SYMBOL_PRINT (m
, sym
);
336 yystack_
.push (YY_MOVE (sym
));
340 Parser::yypush_ (const char* m
, state_type s
, YY_MOVE_REF (symbol_type
) sym
)
342 #if 201103L <= YY_CPLUSPLUS
343 yypush_ (m
, stack_symbol_type (s
, std::move (sym
)));
345 stack_symbol_type
ss (s
, sym
);
351 Parser::yypop_ (int n
)
358 Parser::debug_stream () const
364 Parser::set_debug_stream (std::ostream
& o
)
370 Parser::debug_level_type
371 Parser::debug_level () const
377 Parser::set_debug_level (debug_level_type l
)
384 Parser::yy_lr_goto_state_ (state_type yystate
, int yysym
)
386 int yyr
= yypgoto_
[yysym
- YYNTOKENS
] + yystate
;
387 if (0 <= yyr
&& yyr
<= yylast_
&& yycheck_
[yyr
] == yystate
)
388 return yytable_
[yyr
];
390 return yydefgoto_
[yysym
- YYNTOKENS
];
394 Parser::yy_pact_value_is_default_ (int yyvalue
)
396 return yyvalue
== yypact_ninf_
;
400 Parser::yy_table_value_is_error_ (int yyvalue
)
402 return yyvalue
== yytable_ninf_
;
406 Parser::operator() ()
415 /// Length of the RHS of the rule being reduced.
420 int yyerrstatus_
= 0;
422 /// The lookahead symbol.
425 /// The return value of parse ().
430 #endif // YY_EXCEPTIONS
432 YYCDEBUG
<< "Starting parse\n";
435 /* Initialize the stack. The initial state will be set in
436 yynewstate, since the latter expects the semantical and the
437 location values to have been already stored, initialize these
438 stacks with a primary value. */
440 yypush_ (YY_NULLPTR
, 0, YY_MOVE (yyla
));
442 /*-----------------------------------------------.
443 | yynewstate -- push a new symbol on the stack. |
444 `-----------------------------------------------*/
446 YYCDEBUG
<< "Entering state " << int (yystack_
[0].state
) << '\n';
450 if (yystack_
[0].state
== yyfinal_
)
460 // Try to take a decision without lookahead.
461 yyn
= yypact_
[+yystack_
[0].state
];
462 if (yy_pact_value_is_default_ (yyn
))
465 // Read a lookahead token.
468 YYCDEBUG
<< "Reading a token\n";
471 #endif // YY_EXCEPTIONS
473 symbol_type
yylookahead (yylex (result
));
474 yyla
.move (yylookahead
);
477 catch (const syntax_error
& yyexc
)
479 YYCDEBUG
<< "Caught exception: " << yyexc
.what() << '\n';
483 #endif // YY_EXCEPTIONS
485 YY_SYMBOL_PRINT ("Next token is", yyla
);
487 if (yyla
.kind () == symbol_kind::S_YYerror
)
489 // The scanner already issued an error message, process directly
490 // to error recovery. But do not keep the error token as
491 // lookahead, it is too special and may lead us to an endless
492 // loop in error recovery. */
493 yyla
.kind_
= symbol_kind::S_YYUNDEF
;
497 /* If the proper action on seeing token YYLA.TYPE is to reduce or
498 to detect an error, take that action. */
500 if (yyn
< 0 || yylast_
< yyn
|| yycheck_
[yyn
] != yyla
.kind ())
509 if (yy_table_value_is_error_ (yyn
))
515 // Count tokens shifted since error; after three, turn off error status.
519 // Shift the lookahead token.
520 yypush_ ("Shifting", state_type (yyn
), YY_MOVE (yyla
));
524 /*-----------------------------------------------------------.
525 | yydefault -- do the default action for the current state. |
526 `-----------------------------------------------------------*/
528 yyn
= yydefact_
[+yystack_
[0].state
];
534 /*-----------------------------.
535 | yyreduce -- do a reduction. |
536 `-----------------------------*/
540 stack_symbol_type yylhs
;
541 yylhs
.state
= yy_lr_goto_state_ (yystack_
[yylen
].state
, yyr1_
[yyn
]);
542 /* Variants are always initialized to an empty instance of the
543 correct type. The default '$$ = $1' action is NOT applied
544 when using variants. */
547 case symbol_kind::S_NUM
: // "number"
548 case symbol_kind::S_NAME
: // "name"
549 case symbol_kind::S_FNAME
: // FNAME
550 case symbol_kind::S_JGROUP
: // JGROUP
551 case symbol_kind::S_JPARENT
: // JPARENT
552 case symbol_kind::S_QSTR
: // QSTR
553 case symbol_kind::S_FILEIOVFD
: // FILEIOVFD
554 case symbol_kind::S_exp
: // exp
555 case symbol_kind::S_term
: // term
556 yylhs
.value
.emplace
< Expression
* > ();
565 // Perform the reduction.
566 YY_REDUCE_PRINT (yyn
);
569 #endif // YY_EXCEPTIONS
574 #line 104 "QLParser.yy"
575 { result
.out
= new Expression (Expression::OP_NUM
, (uint64_t) 1); }
576 #line 577 "QLParser.tab.cc"
580 #line 105 "QLParser.yy"
581 { result
.out
= new Expression (yystack_
[0].value
.as
< Expression
* > ()); }
582 #line 583 "QLParser.tab.cc"
585 case 4: // exp: exp DEG exp
586 #line 107 "QLParser.yy"
587 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_DEG
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
588 #line 589 "QLParser.tab.cc"
591 case 5: // exp: exp MUL exp
592 #line 108 "QLParser.yy"
593 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_MUL
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
594 #line 595 "QLParser.tab.cc"
597 case 6: // exp: exp DIV exp
598 #line 109 "QLParser.yy"
599 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_DIV
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
600 #line 601 "QLParser.tab.cc"
603 case 7: // exp: exp REM exp
604 #line 110 "QLParser.yy"
605 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_REM
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
606 #line 607 "QLParser.tab.cc"
609 case 8: // exp: exp ADD exp
610 #line 111 "QLParser.yy"
611 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_ADD
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
612 #line 613 "QLParser.tab.cc"
615 case 9: // exp: exp MINUS exp
616 #line 112 "QLParser.yy"
617 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_MINUS
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
618 #line 619 "QLParser.tab.cc"
621 case 10: // exp: exp LS exp
622 #line 113 "QLParser.yy"
623 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_LS
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
624 #line 625 "QLParser.tab.cc"
627 case 11: // exp: exp RS exp
628 #line 114 "QLParser.yy"
629 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_RS
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
630 #line 631 "QLParser.tab.cc"
633 case 12: // exp: exp LT exp
634 #line 115 "QLParser.yy"
635 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_LT
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
636 #line 637 "QLParser.tab.cc"
639 case 13: // exp: exp LE exp
640 #line 116 "QLParser.yy"
641 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_LE
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
642 #line 643 "QLParser.tab.cc"
645 case 14: // exp: exp GT exp
646 #line 117 "QLParser.yy"
647 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_GT
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
648 #line 649 "QLParser.tab.cc"
651 case 15: // exp: exp GE exp
652 #line 118 "QLParser.yy"
653 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_GE
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
654 #line 655 "QLParser.tab.cc"
657 case 16: // exp: exp EQ exp
658 #line 119 "QLParser.yy"
659 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_EQ
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
660 #line 661 "QLParser.tab.cc"
663 case 17: // exp: exp NE exp
664 #line 120 "QLParser.yy"
665 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_NE
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
666 #line 667 "QLParser.tab.cc"
669 case 18: // exp: exp BITAND exp
670 #line 121 "QLParser.yy"
671 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_BITAND
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
672 #line 673 "QLParser.tab.cc"
675 case 19: // exp: exp BITXOR exp
676 #line 122 "QLParser.yy"
677 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_BITXOR
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
678 #line 679 "QLParser.tab.cc"
681 case 20: // exp: exp BITOR exp
682 #line 123 "QLParser.yy"
683 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_BITOR
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
684 #line 685 "QLParser.tab.cc"
687 case 21: // exp: exp AND exp
688 #line 124 "QLParser.yy"
689 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_AND
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
690 #line 691 "QLParser.tab.cc"
693 case 22: // exp: exp OR exp
694 #line 125 "QLParser.yy"
695 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_OR
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
696 #line 697 "QLParser.tab.cc"
699 case 23: // exp: exp NEQV exp
700 #line 126 "QLParser.yy"
701 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_NEQV
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
702 #line 703 "QLParser.tab.cc"
705 case 24: // exp: exp EQV exp
706 #line 127 "QLParser.yy"
707 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_EQV
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
708 #line 709 "QLParser.tab.cc"
711 case 25: // exp: exp QWE exp COLON exp
712 #line 128 "QLParser.yy"
713 { Expression colon
= Expression (Expression::OP_COLON
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ());
714 yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_QWE
, yystack_
[4].value
.as
< Expression
* > (), &colon
); }
715 #line 716 "QLParser.tab.cc"
718 case 26: // exp: exp COMMA exp
719 #line 130 "QLParser.yy"
720 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_COMMA
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
721 #line 722 "QLParser.tab.cc"
724 case 27: // exp: exp IN exp
725 #line 131 "QLParser.yy"
726 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_IN
, yystack_
[2].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
727 #line 728 "QLParser.tab.cc"
730 case 28: // exp: exp SOME IN exp
731 #line 132 "QLParser.yy"
732 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_SOMEIN
, yystack_
[3].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
733 #line 734 "QLParser.tab.cc"
736 case 29: // exp: exp ORDR IN exp
737 #line 133 "QLParser.yy"
738 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_ORDRIN
, yystack_
[3].value
.as
< Expression
* > (), yystack_
[0].value
.as
< Expression
* > ()); }
739 #line 740 "QLParser.tab.cc"
742 case 30: // exp: term
743 #line 134 "QLParser.yy"
744 { yylhs
.value
.as
< Expression
* > () = new Expression (yystack_
[0].value
.as
< Expression
* > ()); }
745 #line 746 "QLParser.tab.cc"
748 case 31: // term: MINUS term
749 #line 136 "QLParser.yy"
750 { Expression num
= Expression (Expression::OP_NUM
, (uint64_t) 0);
751 yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_MINUS
, &num
, yystack_
[0].value
.as
< Expression
* > ()); }
752 #line 753 "QLParser.tab.cc"
755 case 32: // term: NOT term
756 #line 138 "QLParser.yy"
757 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_NOT
, yystack_
[0].value
.as
< Expression
* > (), NULL
); }
758 #line 759 "QLParser.tab.cc"
761 case 33: // term: BITNOT term
762 #line 139 "QLParser.yy"
763 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_BITNOT
, yystack_
[0].value
.as
< Expression
* > (), NULL
); }
764 #line 765 "QLParser.tab.cc"
767 case 34: // term: "(" exp ")"
768 #line 140 "QLParser.yy"
769 { yylhs
.value
.as
< Expression
* > () = new Expression (yystack_
[1].value
.as
< Expression
* > ()); }
770 #line 771 "QLParser.tab.cc"
773 case 35: // term: FNAME "(" QSTR ")"
774 #line 141 "QLParser.yy"
775 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_FUNC
, yystack_
[3].value
.as
< Expression
* > (), yystack_
[1].value
.as
< Expression
* > ()); }
776 #line 777 "QLParser.tab.cc"
779 case 36: // term: HASPROP "(" "name" ")"
780 #line 142 "QLParser.yy"
781 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_HASPROP
, yystack_
[1].value
.as
< Expression
* > (), NULL
); }
782 #line 783 "QLParser.tab.cc"
785 case 37: // term: JGROUP "(" QSTR ")"
786 #line 143 "QLParser.yy"
787 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_JAVA
, yystack_
[3].value
.as
< Expression
* > (), yystack_
[1].value
.as
< Expression
* > ()); }
788 #line 789 "QLParser.tab.cc"
791 case 38: // term: JPARENT "(" QSTR ")"
792 #line 144 "QLParser.yy"
793 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_JAVA
, yystack_
[3].value
.as
< Expression
* > (), yystack_
[1].value
.as
< Expression
* > ()); }
794 #line 795 "QLParser.tab.cc"
797 case 39: // term: FILEIOVFD "(" QSTR ")"
798 #line 145 "QLParser.yy"
799 { yylhs
.value
.as
< Expression
* > () = new Expression (Expression::OP_FILE
, yystack_
[3].value
.as
< Expression
* > (), yystack_
[1].value
.as
< Expression
* > ()); }
800 #line 801 "QLParser.tab.cc"
803 case 40: // term: "number"
804 #line 146 "QLParser.yy"
805 { yylhs
.value
.as
< Expression
* > () = new Expression (yystack_
[0].value
.as
< Expression
* > ()); }
806 #line 807 "QLParser.tab.cc"
809 case 41: // term: "name"
810 #line 147 "QLParser.yy"
811 { yylhs
.value
.as
< Expression
* > () = new Expression (yystack_
[0].value
.as
< Expression
* > ()); }
812 #line 813 "QLParser.tab.cc"
816 #line 817 "QLParser.tab.cc"
823 catch (const syntax_error
& yyexc
)
825 YYCDEBUG
<< "Caught exception: " << yyexc
.what() << '\n';
829 #endif // YY_EXCEPTIONS
830 YY_SYMBOL_PRINT ("-> $$ =", yylhs
);
834 // Shift the result of the reduction.
835 yypush_ (YY_NULLPTR
, YY_MOVE (yylhs
));
840 /*--------------------------------------.
841 | yyerrlab -- here on detecting error. |
842 `--------------------------------------*/
844 // If not already recovering from an error, report this error.
848 std::string msg
= YY_("syntax error");
849 error (YY_MOVE (msg
));
853 if (yyerrstatus_
== 3)
855 /* If just tried and failed to reuse lookahead token after an
856 error, discard it. */
858 // Return failure if at end of input.
859 if (yyla
.kind () == symbol_kind::S_YYEOF
)
861 else if (!yyla
.empty ())
863 yy_destroy_ ("Error: discarding", yyla
);
868 // Else will try to reuse lookahead token after shifting the error token.
872 /*---------------------------------------------------.
873 | yyerrorlab -- error raised explicitly by YYERROR. |
874 `---------------------------------------------------*/
876 /* Pacify compilers when the user code never invokes YYERROR and
877 the label yyerrorlab therefore never appears in user code. */
881 /* Do not reclaim the symbols of the rule whose action triggered
889 /*-------------------------------------------------------------.
890 | yyerrlab1 -- common code for both syntax error and YYERROR. |
891 `-------------------------------------------------------------*/
893 yyerrstatus_
= 3; // Each real token shifted decrements this.
894 // Pop stack until we find a state that shifts the error token.
897 yyn
= yypact_
[+yystack_
[0].state
];
898 if (!yy_pact_value_is_default_ (yyn
))
900 yyn
+= symbol_kind::S_YYerror
;
901 if (0 <= yyn
&& yyn
<= yylast_
902 && yycheck_
[yyn
] == symbol_kind::S_YYerror
)
910 // Pop the current state because it cannot handle the error token.
911 if (yystack_
.size () == 1)
914 yy_destroy_ ("Error: popping", yystack_
[0]);
919 stack_symbol_type error_token
;
922 // Shift the error token.
923 error_token
.state
= state_type (yyn
);
924 yypush_ ("Shifting", YY_MOVE (error_token
));
929 /*-------------------------------------.
930 | yyacceptlab -- YYACCEPT comes here. |
931 `-------------------------------------*/
937 /*-----------------------------------.
938 | yyabortlab -- YYABORT comes here. |
939 `-----------------------------------*/
945 /*-----------------------------------------------------.
946 | yyreturn -- parsing is finished, return the result. |
947 `-----------------------------------------------------*/
950 yy_destroy_ ("Cleanup: discarding lookahead", yyla
);
952 /* Do not reclaim the symbols of the rule whose action triggered
953 this YYABORT or YYACCEPT. */
956 while (1 < yystack_
.size ())
958 yy_destroy_ ("Cleanup: popping", yystack_
[0]);
967 YYCDEBUG
<< "Exception caught: cleaning lookahead and stack\n";
968 // Do not try to display the values of the reclaimed symbols,
969 // as their printers might throw an exception.
971 yy_destroy_ (YY_NULLPTR
, yyla
);
973 while (1 < yystack_
.size ())
975 yy_destroy_ (YY_NULLPTR
, yystack_
[0]);
980 #endif // YY_EXCEPTIONS
984 Parser::error (const syntax_error
& yyexc
)
986 error (yyexc
.what ());
991 Parser::symbol_name (symbol_kind_type yysymbol
)
993 return yytname_
[yysymbol
];
995 #endif // #if YYDEBUG || 0
1001 const signed char Parser::yypact_ninf_
= -3;
1003 const signed char Parser::yytable_ninf_
= -1;
1008 0, 0, -3, -3, -2, 1, 8, 13, 14, 0,
1009 0, 0, 2, 142, -3, 50, 7, 15, 9, 11,
1010 12, -3, -3, -3, -3, 0, 6, 38, 0, 0,
1011 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1012 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1013 0, -3, 21, 22, 48, 49, 51, 188, 0, 0,
1014 221, 96, 95, 95, 95, 95, 95, 95, 95, 141,
1015 141, 141, 141, 141, 141, 17, 17, 17, 17, 17,
1016 17, 17, 17, -3, -3, -3, -3, -3, 188, 188,
1021 Parser::yydefact_
[] =
1023 2, 0, 40, 41, 0, 0, 0, 0, 0, 0,
1024 0, 0, 0, 3, 30, 0, 0, 0, 0, 0,
1025 0, 31, 32, 33, 1, 0, 0, 0, 0, 0,
1026 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1027 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1028 0, 34, 0, 0, 0, 0, 0, 27, 0, 0,
1029 26, 0, 21, 22, 24, 23, 18, 20, 19, 16,
1030 17, 12, 14, 13, 15, 10, 11, 8, 9, 5,
1031 6, 7, 4, 35, 36, 37, 38, 39, 28, 29,
1036 Parser::yypgoto_
[] =
1042 Parser::yydefgoto_
[] =
1048 Parser::yytable_
[] =
1050 15, 16, 24, 1, 17, 2, 3, 4, 5, 6,
1051 7, 18, 8, 21, 22, 23, 19, 20, 52, 58,
1052 54, 53, 55, 56, 57, 83, 84, 60, 61, 62,
1053 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
1054 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
1055 9, 59, 85, 86, 51, 87, 0, 88, 89, 10,
1056 0, 11, 0, 25, 26, 27, 28, 0, 29, 0,
1057 0, 0, 30, 0, 31, 50, 32, 33, 34, 35,
1058 36, 0, 37, 0, 38, 0, 39, 0, 40, 91,
1059 41, 0, 42, 0, 43, 0, 44, 0, 45, 0,
1060 46, 0, 47, 0, 48, 0, 49, 0, 50, 25,
1061 26, 27, 28, 0, 29, 0, 90, 0, 30, 0,
1062 31, 0, 32, 33, 34, 35, 36, 37, 37, 38,
1063 38, 39, 39, 40, 40, 41, 41, 42, 42, 43,
1064 43, 44, 44, 45, 45, 46, 46, 47, 47, 48,
1065 48, 49, 49, 50, 50, 25, 26, 27, 28, 0,
1066 29, 0, 0, 0, 30, 0, 31, 0, 32, 33,
1067 34, 35, 36, -1, 37, -1, 38, -1, 39, -1,
1068 40, -1, 41, -1, 42, 43, 43, 44, 44, 45,
1069 45, 46, 46, 47, 47, 48, 48, 49, 49, 50,
1070 50, -1, -1, -1, 28, 0, 29, 0, 0, 0,
1071 30, 0, 31, 0, 32, 33, 34, 35, 36, 0,
1072 37, 0, 38, 0, 39, 0, 40, 0, 41, 0,
1073 42, 0, 43, 0, 44, 0, 45, 0, 46, 29,
1074 47, 0, 48, 30, 49, 31, 50, 32, 33, 34,
1075 35, 36, 0, 37, 0, 38, 0, 39, 0, 40,
1076 0, 41, 0, 42, 0, 43, 0, 44, 0, 45,
1077 0, 46, 0, 47, 0, 48, 0, 49, 0, 50
1081 Parser::yycheck_
[] =
1083 1, 3, 0, 3, 3, 5, 6, 7, 8, 9,
1084 10, 3, 12, 9, 10, 11, 3, 3, 11, 13,
1085 11, 6, 11, 11, 25, 4, 4, 28, 29, 30,
1086 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
1087 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
1088 50, 13, 4, 4, 4, 4, -1, 58, 59, 59,
1089 -1, 61, -1, 13, 14, 15, 16, -1, 18, -1,
1090 -1, -1, 22, -1, 24, 58, 26, 27, 28, 29,
1091 30, -1, 32, -1, 34, -1, 36, -1, 38, 90,
1092 40, -1, 42, -1, 44, -1, 46, -1, 48, -1,
1093 50, -1, 52, -1, 54, -1, 56, -1, 58, 13,
1094 14, 15, 16, -1, 18, -1, 20, -1, 22, -1,
1095 24, -1, 26, 27, 28, 29, 30, 32, 32, 34,
1096 34, 36, 36, 38, 38, 40, 40, 42, 42, 44,
1097 44, 46, 46, 48, 48, 50, 50, 52, 52, 54,
1098 54, 56, 56, 58, 58, 13, 14, 15, 16, -1,
1099 18, -1, -1, -1, 22, -1, 24, -1, 26, 27,
1100 28, 29, 30, 32, 32, 34, 34, 36, 36, 38,
1101 38, 40, 40, 42, 42, 44, 44, 46, 46, 48,
1102 48, 50, 50, 52, 52, 54, 54, 56, 56, 58,
1103 58, 13, 14, 15, 16, -1, 18, -1, -1, -1,
1104 22, -1, 24, -1, 26, 27, 28, 29, 30, -1,
1105 32, -1, 34, -1, 36, -1, 38, -1, 40, -1,
1106 42, -1, 44, -1, 46, -1, 48, -1, 50, 18,
1107 52, -1, 54, 22, 56, 24, 58, 26, 27, 28,
1108 29, 30, -1, 32, -1, 34, -1, 36, -1, 38,
1109 -1, 40, -1, 42, -1, 44, -1, 46, -1, 48,
1110 -1, 50, -1, 52, -1, 54, -1, 56, -1, 58
1116 0, 3, 5, 6, 7, 8, 9, 10, 12, 50,
1117 59, 61, 64, 65, 66, 65, 3, 3, 3, 3,
1118 3, 66, 66, 66, 0, 13, 14, 15, 16, 18,
1119 22, 24, 26, 27, 28, 29, 30, 32, 34, 36,
1120 38, 40, 42, 44, 46, 48, 50, 52, 54, 56,
1121 58, 4, 11, 6, 11, 11, 11, 65, 13, 13,
1122 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
1123 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
1124 65, 65, 65, 4, 4, 4, 4, 4, 65, 65,
1131 0, 63, 64, 64, 65, 65, 65, 65, 65, 65,
1132 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
1133 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
1134 65, 66, 66, 66, 66, 66, 66, 66, 66, 66,
1141 0, 2, 0, 1, 3, 3, 3, 3, 3, 3,
1142 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1143 3, 3, 3, 3, 3, 5, 3, 3, 4, 4,
1144 1, 2, 2, 2, 3, 4, 4, 4, 4, 4,
1150 // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1151 // First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
1153 const Parser::yytname_
[] =
1155 "\"end of file\"", "error", "\"invalid token\"", "\"(\"", "\")\"",
1156 "\"number\"", "\"name\"", "FNAME", "HASPROP", "JGROUP", "JPARENT",
1157 "QSTR", "FILEIOVFD", "IN", "SOME", "ORDR", "COMMA", "\",\"", "QWE",
1158 "\"?\"", "COLON", "\":\"", "AND", "\"&&\"", "OR", "\"|\"", "EQV", "NEQV",
1159 "BITAND", "BITOR", "BITXOR", "\"^\"", "EQ", "\"=\"", "NE", "\"!=\"",
1160 "LT", "\"<\"", "GT", "\">\"", "LE", "\"<=\"", "GE", "\">=\"", "LS",
1161 "\"<<\"", "RS", "\">>\"", "ADD", "\"+\"", "MINUS", "\"-\"", "MUL",
1162 "\"*\"", "DIV", "\"/\"", "REM", "\"%\"", "DEG", "NOT", "\"!\"", "BITNOT",
1163 "\"~\"", "$accept", "S", "exp", "term", YY_NULLPTR
1170 Parser::yyrline_
[] =
1172 0, 104, 104, 105, 107, 108, 109, 110, 111, 112,
1173 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
1174 123, 124, 125, 126, 127, 128, 130, 131, 132, 133,
1175 134, 136, 138, 139, 140, 141, 142, 143, 144, 145,
1180 Parser::yy_stack_print_ () const
1182 *yycdebug_
<< "Stack now";
1183 for (stack_type::const_iterator
1184 i
= yystack_
.begin (),
1185 i_end
= yystack_
.end ();
1187 *yycdebug_
<< ' ' << int (i
->state
);
1192 Parser::yy_reduce_print_ (int yyrule
) const
1194 int yylno
= yyrline_
[yyrule
];
1195 int yynrhs
= yyr2_
[yyrule
];
1196 // Print the symbols being reduced, and their result.
1197 *yycdebug_
<< "Reducing stack by rule " << yyrule
- 1
1198 << " (line " << yylno
<< "):\n";
1199 // The symbols being reduced.
1200 for (int yyi
= 0; yyi
< yynrhs
; yyi
++)
1201 YY_SYMBOL_PRINT (" $" << yyi
+ 1 << " =",
1202 yystack_
[(yynrhs
) - (yyi
+ 1)]);
1207 #line 50 "QLParser.yy"
1209 #line 1210 "QLParser.tab.cc"
1211 #line 149 "QLParser.yy"
1216 static Parser::symbol_type
1217 unget_ret (std::istream
&in
, char c
, Parser::symbol_type tok
)
1224 processName (char *name
)
1226 int propID
= dbeSession
->getPropIdByName (name
);
1227 if (propID
!= PROP_NONE
)
1229 Expression
*expr
= new Expression (Expression::OP_NUM
, (uint64_t) propID
);
1230 Expression
*ret
= new Expression (Expression::OP_NAME
, expr
);
1235 // If a name is not statically known try user defined objects
1236 Expression
*expr
= dbeSession
->findObjDefByName (name
);
1238 return expr
->copy();
1240 throw Parser::syntax_error ("Name not found");
1243 static Parser::symbol_type
1244 yylex (QL::Result
&result
)
1250 c
= result
.in
.get ();
1251 while (result
.in
&& (c
== ' ' || c
== '\t'));
1253 return Parser::make_YYEOF ();
1257 case '\n': return Parser::make_YYEOF ();
1258 case '(': return Parser::make_LPAR () ;
1259 case ')': return Parser::make_RPAR ();
1260 case ',': return Parser::make_COMMA ();
1261 case '%': return Parser::make_REM ();
1262 case '/': return Parser::make_DIV ();
1263 case '*': return Parser::make_MUL ();
1264 case '-': return Parser::make_MINUS ();
1265 case '+': return Parser::make_ADD ();
1266 case '~': return Parser::make_BITNOT ();
1267 case '^': return Parser::make_BITXOR ();
1268 case '?': return Parser::make_QWE ();
1269 case ':': return Parser::make_COLON ();
1271 c
= result
.in
.get ();
1273 return Parser::make_OR ();
1275 return unget_ret (result
.in
, c
, Parser::make_BITOR ());
1277 c
= result
.in
.get ();
1279 return Parser::make_AND ();
1281 return unget_ret (result
.in
, c
, Parser::make_BITAND ());
1283 c
= result
.in
.get ();
1285 return Parser::make_NE ();
1287 return unget_ret (result
.in
, c
, Parser::make_NOT ());
1289 c
= result
.in
.get ();
1291 return Parser::make_EQ ();
1293 throw Parser::syntax_error ("Syntax error after =");
1295 c
= result
.in
.get ();
1297 return Parser::make_LE ();
1299 return Parser::make_LS ();
1301 return unget_ret (result
.in
, c
, Parser::make_LT ());
1303 c
= result
.in
.get ();
1305 return Parser::make_GE ();
1307 return Parser::make_RS ();
1309 return unget_ret (result
.in
, c
, Parser::make_GT ());
1313 char *str
= (char *) malloc (maxsz
);
1318 c
= result
.in
.get ();
1322 throw Parser::syntax_error ("Unclosed \"");
1329 // XXX omazur: need new string type
1330 return Parser::make_QSTR (new Expression (Expression::OP_NUM
, (uint64_t) str
));
1334 throw Parser::syntax_error ("Multiline strings are not supported");
1336 if (ptr
- str
>= maxsz
)
1338 size_t len
= ptr
- str
;
1339 maxsz
= maxsz
> 8192 ? maxsz
+ 8192 : maxsz
* 2;
1340 char *new_s
= (char *) realloc (str
, maxsz
);
1352 c
= result
.in
.get ();
1356 c
= result
.in
.get ();
1359 else if (c
>= '1' && c
<='9')
1370 case '0': case '1': case '2': case '3':
1371 case '4': case '5': case '6': case '7':
1378 case 'a': case 'b': case 'c':
1379 case 'd': case 'e': case 'f':
1381 digit
= c
- 'a' + 10;
1383 case 'A': case 'B': case 'C':
1384 case 'D': case 'E': case 'F':
1386 digit
= c
- 'A' + 10;
1391 result
.in
.putback (c
);
1394 lval
= lval
* base
+ digit
;
1395 c
= result
.in
.get ();
1397 return Parser::make_NUM (new Expression (Expression::OP_NUM
, lval
));
1400 if ((c
>= 'A' && c
<= 'Z') || (c
>= 'a' && c
<= 'z'))
1402 char name
[32]; // omazur XXX: accept any length
1404 for (size_t i
= 1; i
< sizeof (name
); i
++)
1406 c
= result
.in
.get ();
1407 if ((c
>= 'A' && c
<= 'Z') || (c
>= 'a' && c
<= 'z') ||
1408 (c
>= '0' && c
<= '9') || (c
== '_'))
1413 result
.in
.putback (c
);
1418 if (strcasecmp (name
, NTXT ("IN")) == 0)
1419 return Parser::make_IN ();
1420 else if (strcasecmp (name
, NTXT ("SOME")) == 0)
1421 return Parser::make_SOME ();
1422 else if (strcasecmp (name
, NTXT ("ORDERED")) == 0)
1423 return Parser::make_ORDR ();
1424 else if (strcasecmp (name
, NTXT ("TRUE")) == 0)
1425 return Parser::make_NUM (new Expression (Expression::OP_NUM
, (uint64_t) 1));
1426 else if (strcasecmp (name
, NTXT ("FALSE")) == 0)
1427 return Parser::make_NUM (new Expression (Expression::OP_NUM
, (uint64_t) 0));
1428 else if (strcasecmp (name
, NTXT ("FNAME")) == 0)
1429 return Parser::make_FNAME (new Expression (Expression::OP_NUM
, Expression::FUNC_FNAME
));
1430 else if (strcasecmp (name
, NTXT ("HAS_PROP")) == 0)
1431 return Parser::make_HASPROP ();
1432 else if (strcasecmp (name
, NTXT ("JGROUP")) == 0)
1433 return Parser::make_JGROUP (new Expression (Expression::OP_NUM
, Expression::JAVA_JGROUP
));
1434 else if (strcasecmp (name
, NTXT ("JPARENT")) == 0 )
1435 return Parser::make_JPARENT (new Expression (Expression::OP_NUM
, Expression::JAVA_JPARENT
));
1436 else if (strcasecmp (name
, NTXT ("DNAME")) == 0)
1437 return Parser::make_FNAME (new Expression (Expression::OP_NUM
, Expression::FUNC_DNAME
));
1438 else if (strcasecmp (name
, NTXT ("FILEIOVFD")) == 0 )
1439 return Parser::make_FILEIOVFD (new Expression (Expression::OP_NUM
, (uint64_t) 0));
1441 return Parser::make_NAME (processName (name
));
1444 throw Parser::syntax_error ("Syntax error");
1448 Parser::error (const std::string
&)
1450 // do nothing for now