]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gprofng/src/QLParser.tab.cc
gprofng: a new GNU profiler
[thirdparty/binutils-gdb.git] / gprofng / src / QLParser.tab.cc
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 // "%code top" blocks.
38 #line 28 "QLParser.yy"
39
40 #include <stdio.h>
41 #include <string.h>
42 #include <string>
43
44 #line 45 "QLParser.tab.cc"
45
46
47
48
49 #include "QLParser.tab.hh"
50
51
52 // Unqualified %code blocks.
53 #line 42 "QLParser.yy"
54
55 namespace QL
56 {
57 static QL::Parser::symbol_type yylex (QL::Result &result);
58 }
59
60 #line 61 "QLParser.tab.cc"
61
62
63 #ifndef YY_
64 # if defined YYENABLE_NLS && YYENABLE_NLS
65 # if ENABLE_NLS
66 # include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE.
67 # define YY_(msgid) dgettext ("bison-runtime", msgid)
68 # endif
69 # endif
70 # ifndef YY_
71 # define YY_(msgid) msgid
72 # endif
73 #endif
74
75
76 // Whether we are compiled with exception support.
77 #ifndef YY_EXCEPTIONS
78 # if defined __GNUC__ && !defined __EXCEPTIONS
79 # define YY_EXCEPTIONS 0
80 # else
81 # define YY_EXCEPTIONS 1
82 # endif
83 #endif
84
85
86
87 // Enable debugging if requested.
88 #if YYDEBUG
89
90 // A pseudo ostream that takes yydebug_ into account.
91 # define YYCDEBUG if (yydebug_) (*yycdebug_)
92
93 # define YY_SYMBOL_PRINT(Title, Symbol) \
94 do { \
95 if (yydebug_) \
96 { \
97 *yycdebug_ << Title << ' '; \
98 yy_print_ (*yycdebug_, Symbol); \
99 *yycdebug_ << '\n'; \
100 } \
101 } while (false)
102
103 # define YY_REDUCE_PRINT(Rule) \
104 do { \
105 if (yydebug_) \
106 yy_reduce_print_ (Rule); \
107 } while (false)
108
109 # define YY_STACK_PRINT() \
110 do { \
111 if (yydebug_) \
112 yy_stack_print_ (); \
113 } while (false)
114
115 #else // !YYDEBUG
116
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)
121
122 #endif // !YYDEBUG
123
124 #define yyerrok (yyerrstatus_ = 0)
125 #define yyclearin (yyla.clear ())
126
127 #define YYACCEPT goto yyacceptlab
128 #define YYABORT goto yyabortlab
129 #define YYERROR goto yyerrorlab
130 #define YYRECOVERING() (!!yyerrstatus_)
131
132 #line 50 "QLParser.yy"
133 namespace QL {
134 #line 135 "QLParser.tab.cc"
135
136 /// Build a parser object.
137 Parser::Parser (QL::Result &result_yyarg)
138 #if YYDEBUG
139 : yydebug_ (false),
140 yycdebug_ (&std::cerr),
141 #else
142 :
143 #endif
144 result (result_yyarg)
145 {}
146
147 Parser::~Parser ()
148 {}
149
150 Parser::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
151 {}
152
153 /*---------------.
154 | symbol kinds. |
155 `---------------*/
156
157
158
159 // by_state.
160 Parser::by_state::by_state () YY_NOEXCEPT
161 : state (empty_state)
162 {}
163
164 Parser::by_state::by_state (const by_state& that) YY_NOEXCEPT
165 : state (that.state)
166 {}
167
168 void
169 Parser::by_state::clear () YY_NOEXCEPT
170 {
171 state = empty_state;
172 }
173
174 void
175 Parser::by_state::move (by_state& that)
176 {
177 state = that.state;
178 that.clear ();
179 }
180
181 Parser::by_state::by_state (state_type s) YY_NOEXCEPT
182 : state (s)
183 {}
184
185 Parser::symbol_kind_type
186 Parser::by_state::kind () const YY_NOEXCEPT
187 {
188 if (state == empty_state)
189 return symbol_kind::S_YYEMPTY;
190 else
191 return YY_CAST (symbol_kind_type, yystos_[+state]);
192 }
193
194 Parser::stack_symbol_type::stack_symbol_type ()
195 {}
196
197 Parser::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that)
198 : super_type (YY_MOVE (that.state))
199 {
200 switch (that.kind ())
201 {
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));
212 break;
213
214 default:
215 break;
216 }
217
218 #if 201103L <= YY_CPLUSPLUS
219 // that is emptied.
220 that.state = empty_state;
221 #endif
222 }
223
224 Parser::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that)
225 : super_type (s)
226 {
227 switch (that.kind ())
228 {
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));
239 break;
240
241 default:
242 break;
243 }
244
245 // that is emptied.
246 that.kind_ = symbol_kind::S_YYEMPTY;
247 }
248
249 #if YY_CPLUSPLUS < 201103L
250 Parser::stack_symbol_type&
251 Parser::stack_symbol_type::operator= (const stack_symbol_type& that)
252 {
253 state = that.state;
254 switch (that.kind ())
255 {
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);
266 break;
267
268 default:
269 break;
270 }
271
272 return *this;
273 }
274
275 Parser::stack_symbol_type&
276 Parser::stack_symbol_type::operator= (stack_symbol_type& that)
277 {
278 state = that.state;
279 switch (that.kind ())
280 {
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);
291 break;
292
293 default:
294 break;
295 }
296
297 // that is emptied.
298 that.state = empty_state;
299 return *this;
300 }
301 #endif
302
303 template <typename Base>
304 void
305 Parser::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
306 {
307 if (yymsg)
308 YY_SYMBOL_PRINT (yymsg, yysym);
309 }
310
311 #if YYDEBUG
312 template <typename Base>
313 void
314 Parser::yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const
315 {
316 std::ostream& yyoutput = yyo;
317 YY_USE (yyoutput);
318 if (yysym.empty ())
319 yyo << "empty symbol";
320 else
321 {
322 symbol_kind_type yykind = yysym.kind ();
323 yyo << (yykind < YYNTOKENS ? "token" : "nterm")
324 << ' ' << yysym.name () << " (";
325 YY_USE (yykind);
326 yyo << ')';
327 }
328 }
329 #endif
330
331 void
332 Parser::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym)
333 {
334 if (m)
335 YY_SYMBOL_PRINT (m, sym);
336 yystack_.push (YY_MOVE (sym));
337 }
338
339 void
340 Parser::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym)
341 {
342 #if 201103L <= YY_CPLUSPLUS
343 yypush_ (m, stack_symbol_type (s, std::move (sym)));
344 #else
345 stack_symbol_type ss (s, sym);
346 yypush_ (m, ss);
347 #endif
348 }
349
350 void
351 Parser::yypop_ (int n)
352 {
353 yystack_.pop (n);
354 }
355
356 #if YYDEBUG
357 std::ostream&
358 Parser::debug_stream () const
359 {
360 return *yycdebug_;
361 }
362
363 void
364 Parser::set_debug_stream (std::ostream& o)
365 {
366 yycdebug_ = &o;
367 }
368
369
370 Parser::debug_level_type
371 Parser::debug_level () const
372 {
373 return yydebug_;
374 }
375
376 void
377 Parser::set_debug_level (debug_level_type l)
378 {
379 yydebug_ = l;
380 }
381 #endif // YYDEBUG
382
383 Parser::state_type
384 Parser::yy_lr_goto_state_ (state_type yystate, int yysym)
385 {
386 int yyr = yypgoto_[yysym - YYNTOKENS] + yystate;
387 if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
388 return yytable_[yyr];
389 else
390 return yydefgoto_[yysym - YYNTOKENS];
391 }
392
393 bool
394 Parser::yy_pact_value_is_default_ (int yyvalue)
395 {
396 return yyvalue == yypact_ninf_;
397 }
398
399 bool
400 Parser::yy_table_value_is_error_ (int yyvalue)
401 {
402 return yyvalue == yytable_ninf_;
403 }
404
405 int
406 Parser::operator() ()
407 {
408 return parse ();
409 }
410
411 int
412 Parser::parse ()
413 {
414 int yyn;
415 /// Length of the RHS of the rule being reduced.
416 int yylen = 0;
417
418 // Error handling.
419 int yynerrs_ = 0;
420 int yyerrstatus_ = 0;
421
422 /// The lookahead symbol.
423 symbol_type yyla;
424
425 /// The return value of parse ().
426 int yyresult;
427
428 #if YY_EXCEPTIONS
429 try
430 #endif // YY_EXCEPTIONS
431 {
432 YYCDEBUG << "Starting parse\n";
433
434
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. */
439 yystack_.clear ();
440 yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));
441
442 /*-----------------------------------------------.
443 | yynewstate -- push a new symbol on the stack. |
444 `-----------------------------------------------*/
445 yynewstate:
446 YYCDEBUG << "Entering state " << int (yystack_[0].state) << '\n';
447 YY_STACK_PRINT ();
448
449 // Accept?
450 if (yystack_[0].state == yyfinal_)
451 YYACCEPT;
452
453 goto yybackup;
454
455
456 /*-----------.
457 | yybackup. |
458 `-----------*/
459 yybackup:
460 // Try to take a decision without lookahead.
461 yyn = yypact_[+yystack_[0].state];
462 if (yy_pact_value_is_default_ (yyn))
463 goto yydefault;
464
465 // Read a lookahead token.
466 if (yyla.empty ())
467 {
468 YYCDEBUG << "Reading a token\n";
469 #if YY_EXCEPTIONS
470 try
471 #endif // YY_EXCEPTIONS
472 {
473 symbol_type yylookahead (yylex (result));
474 yyla.move (yylookahead);
475 }
476 #if YY_EXCEPTIONS
477 catch (const syntax_error& yyexc)
478 {
479 YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
480 error (yyexc);
481 goto yyerrlab1;
482 }
483 #endif // YY_EXCEPTIONS
484 }
485 YY_SYMBOL_PRINT ("Next token is", yyla);
486
487 if (yyla.kind () == symbol_kind::S_YYerror)
488 {
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;
494 goto yyerrlab1;
495 }
496
497 /* If the proper action on seeing token YYLA.TYPE is to reduce or
498 to detect an error, take that action. */
499 yyn += yyla.kind ();
500 if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind ())
501 {
502 goto yydefault;
503 }
504
505 // Reduce or error.
506 yyn = yytable_[yyn];
507 if (yyn <= 0)
508 {
509 if (yy_table_value_is_error_ (yyn))
510 goto yyerrlab;
511 yyn = -yyn;
512 goto yyreduce;
513 }
514
515 // Count tokens shifted since error; after three, turn off error status.
516 if (yyerrstatus_)
517 --yyerrstatus_;
518
519 // Shift the lookahead token.
520 yypush_ ("Shifting", state_type (yyn), YY_MOVE (yyla));
521 goto yynewstate;
522
523
524 /*-----------------------------------------------------------.
525 | yydefault -- do the default action for the current state. |
526 `-----------------------------------------------------------*/
527 yydefault:
528 yyn = yydefact_[+yystack_[0].state];
529 if (yyn == 0)
530 goto yyerrlab;
531 goto yyreduce;
532
533
534 /*-----------------------------.
535 | yyreduce -- do a reduction. |
536 `-----------------------------*/
537 yyreduce:
538 yylen = yyr2_[yyn];
539 {
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. */
545 switch (yyr1_[yyn])
546 {
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 * > ();
557 break;
558
559 default:
560 break;
561 }
562
563
564
565 // Perform the reduction.
566 YY_REDUCE_PRINT (yyn);
567 #if YY_EXCEPTIONS
568 try
569 #endif // YY_EXCEPTIONS
570 {
571 switch (yyn)
572 {
573 case 2: // S: %empty
574 #line 104 "QLParser.yy"
575 { result.out = new Expression (Expression::OP_NUM, (uint64_t) 1); }
576 #line 577 "QLParser.tab.cc"
577 break;
578
579 case 3: // S: exp
580 #line 105 "QLParser.yy"
581 { result.out = new Expression (yystack_[0].value.as < Expression * > ()); }
582 #line 583 "QLParser.tab.cc"
583 break;
584
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"
589 break;
590
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"
595 break;
596
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"
601 break;
602
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"
607 break;
608
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"
613 break;
614
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"
619 break;
620
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"
625 break;
626
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"
631 break;
632
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"
637 break;
638
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"
643 break;
644
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"
649 break;
650
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"
655 break;
656
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"
661 break;
662
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"
667 break;
668
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"
673 break;
674
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"
679 break;
680
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"
685 break;
686
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"
691 break;
692
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"
697 break;
698
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"
703 break;
704
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"
709 break;
710
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"
716 break;
717
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"
722 break;
723
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"
728 break;
729
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"
734 break;
735
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"
740 break;
741
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"
746 break;
747
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"
753 break;
754
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"
759 break;
760
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"
765 break;
766
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"
771 break;
772
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"
777 break;
778
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"
783 break;
784
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"
789 break;
790
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"
795 break;
796
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"
801 break;
802
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"
807 break;
808
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"
813 break;
814
815
816 #line 817 "QLParser.tab.cc"
817
818 default:
819 break;
820 }
821 }
822 #if YY_EXCEPTIONS
823 catch (const syntax_error& yyexc)
824 {
825 YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
826 error (yyexc);
827 YYERROR;
828 }
829 #endif // YY_EXCEPTIONS
830 YY_SYMBOL_PRINT ("-> $$ =", yylhs);
831 yypop_ (yylen);
832 yylen = 0;
833
834 // Shift the result of the reduction.
835 yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
836 }
837 goto yynewstate;
838
839
840 /*--------------------------------------.
841 | yyerrlab -- here on detecting error. |
842 `--------------------------------------*/
843 yyerrlab:
844 // If not already recovering from an error, report this error.
845 if (!yyerrstatus_)
846 {
847 ++yynerrs_;
848 std::string msg = YY_("syntax error");
849 error (YY_MOVE (msg));
850 }
851
852
853 if (yyerrstatus_ == 3)
854 {
855 /* If just tried and failed to reuse lookahead token after an
856 error, discard it. */
857
858 // Return failure if at end of input.
859 if (yyla.kind () == symbol_kind::S_YYEOF)
860 YYABORT;
861 else if (!yyla.empty ())
862 {
863 yy_destroy_ ("Error: discarding", yyla);
864 yyla.clear ();
865 }
866 }
867
868 // Else will try to reuse lookahead token after shifting the error token.
869 goto yyerrlab1;
870
871
872 /*---------------------------------------------------.
873 | yyerrorlab -- error raised explicitly by YYERROR. |
874 `---------------------------------------------------*/
875 yyerrorlab:
876 /* Pacify compilers when the user code never invokes YYERROR and
877 the label yyerrorlab therefore never appears in user code. */
878 if (false)
879 YYERROR;
880
881 /* Do not reclaim the symbols of the rule whose action triggered
882 this YYERROR. */
883 yypop_ (yylen);
884 yylen = 0;
885 YY_STACK_PRINT ();
886 goto yyerrlab1;
887
888
889 /*-------------------------------------------------------------.
890 | yyerrlab1 -- common code for both syntax error and YYERROR. |
891 `-------------------------------------------------------------*/
892 yyerrlab1:
893 yyerrstatus_ = 3; // Each real token shifted decrements this.
894 // Pop stack until we find a state that shifts the error token.
895 for (;;)
896 {
897 yyn = yypact_[+yystack_[0].state];
898 if (!yy_pact_value_is_default_ (yyn))
899 {
900 yyn += symbol_kind::S_YYerror;
901 if (0 <= yyn && yyn <= yylast_
902 && yycheck_[yyn] == symbol_kind::S_YYerror)
903 {
904 yyn = yytable_[yyn];
905 if (0 < yyn)
906 break;
907 }
908 }
909
910 // Pop the current state because it cannot handle the error token.
911 if (yystack_.size () == 1)
912 YYABORT;
913
914 yy_destroy_ ("Error: popping", yystack_[0]);
915 yypop_ ();
916 YY_STACK_PRINT ();
917 }
918 {
919 stack_symbol_type error_token;
920
921
922 // Shift the error token.
923 error_token.state = state_type (yyn);
924 yypush_ ("Shifting", YY_MOVE (error_token));
925 }
926 goto yynewstate;
927
928
929 /*-------------------------------------.
930 | yyacceptlab -- YYACCEPT comes here. |
931 `-------------------------------------*/
932 yyacceptlab:
933 yyresult = 0;
934 goto yyreturn;
935
936
937 /*-----------------------------------.
938 | yyabortlab -- YYABORT comes here. |
939 `-----------------------------------*/
940 yyabortlab:
941 yyresult = 1;
942 goto yyreturn;
943
944
945 /*-----------------------------------------------------.
946 | yyreturn -- parsing is finished, return the result. |
947 `-----------------------------------------------------*/
948 yyreturn:
949 if (!yyla.empty ())
950 yy_destroy_ ("Cleanup: discarding lookahead", yyla);
951
952 /* Do not reclaim the symbols of the rule whose action triggered
953 this YYABORT or YYACCEPT. */
954 yypop_ (yylen);
955 YY_STACK_PRINT ();
956 while (1 < yystack_.size ())
957 {
958 yy_destroy_ ("Cleanup: popping", yystack_[0]);
959 yypop_ ();
960 }
961
962 return yyresult;
963 }
964 #if YY_EXCEPTIONS
965 catch (...)
966 {
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.
970 if (!yyla.empty ())
971 yy_destroy_ (YY_NULLPTR, yyla);
972
973 while (1 < yystack_.size ())
974 {
975 yy_destroy_ (YY_NULLPTR, yystack_[0]);
976 yypop_ ();
977 }
978 throw;
979 }
980 #endif // YY_EXCEPTIONS
981 }
982
983 void
984 Parser::error (const syntax_error& yyexc)
985 {
986 error (yyexc.what ());
987 }
988
989 #if YYDEBUG || 0
990 const char *
991 Parser::symbol_name (symbol_kind_type yysymbol)
992 {
993 return yytname_[yysymbol];
994 }
995 #endif // #if YYDEBUG || 0
996
997
998
999
1000
1001 const signed char Parser::yypact_ninf_ = -3;
1002
1003 const signed char Parser::yytable_ninf_ = -1;
1004
1005 const short
1006 Parser::yypact_[] =
1007 {
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,
1017 0, 221
1018 };
1019
1020 const signed char
1021 Parser::yydefact_[] =
1022 {
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,
1032 0, 25
1033 };
1034
1035 const signed char
1036 Parser::yypgoto_[] =
1037 {
1038 -3, -3, -1, 4
1039 };
1040
1041 const signed char
1042 Parser::yydefgoto_[] =
1043 {
1044 0, 12, 13, 14
1045 };
1046
1047 const signed char
1048 Parser::yytable_[] =
1049 {
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
1078 };
1079
1080 const signed char
1081 Parser::yycheck_[] =
1082 {
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
1111 };
1112
1113 const signed char
1114 Parser::yystos_[] =
1115 {
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,
1125 20, 65
1126 };
1127
1128 const signed char
1129 Parser::yyr1_[] =
1130 {
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,
1135 66, 66
1136 };
1137
1138 const signed char
1139 Parser::yyr2_[] =
1140 {
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,
1145 1, 1
1146 };
1147
1148
1149 #if YYDEBUG
1150 // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1151 // First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
1152 const char*
1153 const Parser::yytname_[] =
1154 {
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
1164 };
1165 #endif
1166
1167
1168 #if YYDEBUG
1169 const unsigned char
1170 Parser::yyrline_[] =
1171 {
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,
1176 146, 147
1177 };
1178
1179 void
1180 Parser::yy_stack_print_ () const
1181 {
1182 *yycdebug_ << "Stack now";
1183 for (stack_type::const_iterator
1184 i = yystack_.begin (),
1185 i_end = yystack_.end ();
1186 i != i_end; ++i)
1187 *yycdebug_ << ' ' << int (i->state);
1188 *yycdebug_ << '\n';
1189 }
1190
1191 void
1192 Parser::yy_reduce_print_ (int yyrule) const
1193 {
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)]);
1203 }
1204 #endif // YYDEBUG
1205
1206
1207 #line 50 "QLParser.yy"
1208 } // QL
1209 #line 1210 "QLParser.tab.cc"
1210
1211 #line 149 "QLParser.yy"
1212
1213
1214 namespace QL
1215 {
1216 static Parser::symbol_type
1217 unget_ret (std::istream &in, char c, Parser::symbol_type tok)
1218 {
1219 in.putback (c);
1220 return tok;
1221 }
1222
1223 static Expression *
1224 processName (char *name)
1225 {
1226 int propID = dbeSession->getPropIdByName (name);
1227 if (propID != PROP_NONE)
1228 {
1229 Expression *expr = new Expression (Expression::OP_NUM, (uint64_t) propID);
1230 Expression *ret = new Expression (Expression::OP_NAME, expr);
1231 delete expr;
1232 return ret;
1233 }
1234
1235 // If a name is not statically known try user defined objects
1236 Expression *expr = dbeSession->findObjDefByName (name);
1237 if (expr != NULL)
1238 return expr->copy();
1239
1240 throw Parser::syntax_error ("Name not found");
1241 }
1242
1243 static Parser::symbol_type
1244 yylex (QL::Result &result)
1245 {
1246 int base = 0;
1247 int c;
1248
1249 do
1250 c = result.in.get ();
1251 while (result.in && (c == ' ' || c == '\t'));
1252 if (!result.in)
1253 return Parser::make_YYEOF ();
1254
1255 switch (c)
1256 {
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 ();
1270 case '|':
1271 c = result.in.get ();
1272 if (c == '|')
1273 return Parser::make_OR ();
1274 else
1275 return unget_ret (result.in, c, Parser::make_BITOR ());
1276 case '&':
1277 c = result.in.get ();
1278 if (c == '&')
1279 return Parser::make_AND ();
1280 else
1281 return unget_ret (result.in, c, Parser::make_BITAND ());
1282 case '!':
1283 c = result.in.get ();
1284 if (c == '=')
1285 return Parser::make_NE ();
1286 else
1287 return unget_ret (result.in, c, Parser::make_NOT ());
1288 case '=':
1289 c = result.in.get ();
1290 if (c == '=')
1291 return Parser::make_EQ ();
1292 else
1293 throw Parser::syntax_error ("Syntax error after =");
1294 case '<':
1295 c = result.in.get ();
1296 if (c == '=')
1297 return Parser::make_LE ();
1298 else if (c == '<')
1299 return Parser::make_LS ();
1300 else
1301 return unget_ret (result.in, c, Parser::make_LT ());
1302 case '>':
1303 c = result.in.get ();
1304 if (c == '=')
1305 return Parser::make_GE ();
1306 else if (c == '>')
1307 return Parser::make_RS ();
1308 else
1309 return unget_ret (result.in, c, Parser::make_GT ());
1310 case '"':
1311 {
1312 int maxsz = 16;
1313 char *str = (char *) malloc (maxsz);
1314 char *ptr = str;
1315
1316 for (;;)
1317 {
1318 c = result.in.get ();
1319 if (!result.in)
1320 {
1321 free (str);
1322 throw Parser::syntax_error ("Unclosed \"");
1323 }
1324
1325 switch (c)
1326 {
1327 case '"':
1328 *ptr = (char)0;
1329 // XXX omazur: need new string type
1330 return Parser::make_QSTR (new Expression (Expression::OP_NUM, (uint64_t) str));
1331 case 0:
1332 case '\n':
1333 free (str);
1334 throw Parser::syntax_error ("Multiline strings are not supported");
1335 default:
1336 if (ptr - str >= maxsz)
1337 {
1338 size_t len = ptr - str;
1339 maxsz = maxsz > 8192 ? maxsz + 8192 : maxsz * 2;
1340 char *new_s = (char *) realloc (str, maxsz);
1341 str = new_s;
1342 ptr = str + len;
1343 }
1344 *ptr++ = c;
1345 }
1346 }
1347 }
1348 default:
1349 if (c == '0')
1350 {
1351 base = 8;
1352 c = result.in.get ();
1353 if ( c == 'x' )
1354 {
1355 base = 16;
1356 c = result.in.get ();
1357 }
1358 }
1359 else if (c >= '1' && c <='9')
1360 base = 10;
1361
1362 if (base)
1363 {
1364 uint64_t lval = 0;
1365 for (;;)
1366 {
1367 int digit = -1;
1368 switch (c)
1369 {
1370 case '0': case '1': case '2': case '3':
1371 case '4': case '5': case '6': case '7':
1372 digit = c - '0';
1373 break;
1374 case '8': case '9':
1375 if (base > 8)
1376 digit = c - '0';
1377 break;
1378 case 'a': case 'b': case 'c':
1379 case 'd': case 'e': case 'f':
1380 if (base == 16)
1381 digit = c - 'a' + 10;
1382 break;
1383 case 'A': case 'B': case 'C':
1384 case 'D': case 'E': case 'F':
1385 if (base == 16)
1386 digit = c - 'A' + 10;
1387 break;
1388 }
1389 if (digit == -1)
1390 {
1391 result.in.putback (c);
1392 break;
1393 }
1394 lval = lval * base + digit;
1395 c = result.in.get ();
1396 }
1397 return Parser::make_NUM (new Expression (Expression::OP_NUM, lval));
1398 }
1399
1400 if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
1401 {
1402 char name[32]; // omazur XXX: accept any length
1403 name[0] = (char)c;
1404 for (size_t i = 1; i < sizeof (name); i++)
1405 {
1406 c = result.in.get ();
1407 if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
1408 (c >= '0' && c <= '9') || (c == '_'))
1409 name[i] = c;
1410 else
1411 {
1412 name[i] = (char)0;
1413 result.in.putback (c);
1414 break;
1415 }
1416 }
1417
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));
1440
1441 return Parser::make_NAME (processName (name));
1442 }
1443
1444 throw Parser::syntax_error ("Syntax error");
1445 }
1446 }
1447 void
1448 Parser::error (const std::string &)
1449 {
1450 // do nothing for now
1451 }
1452 }
1453