Kea 2.0.2
parser.cc
Go to the documentation of this file.
1// A Bison parser, made by GNU Bison 3.8.2.
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 <https://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// Take the name prefix into account.
39#define yylex evallex
40
41
42
43#include "parser.h"
44
45
46// Unqualified %code blocks.
47#line 33 "parser.yy"
48
49# include "eval_context.h"
50
51#line 52 "parser.cc"
52
53
54#ifndef YY_
55# if defined YYENABLE_NLS && YYENABLE_NLS
56# if ENABLE_NLS
57# include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE.
58# define YY_(msgid) dgettext ("bison-runtime", msgid)
59# endif
60# endif
61# ifndef YY_
62# define YY_(msgid) msgid
63# endif
64#endif
65
66
67// Whether we are compiled with exception support.
68#ifndef YY_EXCEPTIONS
69# if defined __GNUC__ && !defined __EXCEPTIONS
70# define YY_EXCEPTIONS 0
71# else
72# define YY_EXCEPTIONS 1
73# endif
74#endif
75
76#define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
77/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
78 If N is 0, then set CURRENT to the empty location which ends
79 the previous symbol: RHS[0] (always defined). */
80
81# ifndef YYLLOC_DEFAULT
82# define YYLLOC_DEFAULT(Current, Rhs, N) \
83 do \
84 if (N) \
85 { \
86 (Current).begin = YYRHSLOC (Rhs, 1).begin; \
87 (Current).end = YYRHSLOC (Rhs, N).end; \
88 } \
89 else \
90 { \
91 (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
92 } \
93 while (false)
94# endif
95
96
97// Enable debugging if requested.
98#if EVALDEBUG
99
100// A pseudo ostream that takes yydebug_ into account.
101# define YYCDEBUG if (yydebug_) (*yycdebug_)
102
103# define YY_SYMBOL_PRINT(Title, Symbol) \
104 do { \
105 if (yydebug_) \
106 { \
107 *yycdebug_ << Title << ' '; \
108 yy_print_ (*yycdebug_, Symbol); \
109 *yycdebug_ << '\n'; \
110 } \
111 } while (false)
112
113# define YY_REDUCE_PRINT(Rule) \
114 do { \
115 if (yydebug_) \
116 yy_reduce_print_ (Rule); \
117 } while (false)
118
119# define YY_STACK_PRINT() \
120 do { \
121 if (yydebug_) \
122 yy_stack_print_ (); \
123 } while (false)
124
125#else // !EVALDEBUG
126
127# define YYCDEBUG if (false) std::cerr
128# define YY_SYMBOL_PRINT(Title, Symbol) YY_USE (Symbol)
129# define YY_REDUCE_PRINT(Rule) static_cast<void> (0)
130# define YY_STACK_PRINT() static_cast<void> (0)
131
132#endif // !EVALDEBUG
133
134#define yyerrok (yyerrstatus_ = 0)
135#define yyclearin (yyla.clear ())
136
137#define YYACCEPT goto yyacceptlab
138#define YYABORT goto yyabortlab
139#define YYERROR goto yyerrorlab
140#define YYRECOVERING() (!!yyerrstatus_)
141
142#line 14 "parser.yy"
143namespace isc { namespace eval {
144#line 145 "parser.cc"
145
148#if EVALDEBUG
149 : yydebug_ (false),
150 yycdebug_ (&std::cerr),
151#else
152 :
153#endif
154 ctx (ctx_yyarg)
155 {}
156
158 {}
159
161 {}
162
163 /*---------.
164 | symbol. |
165 `---------*/
166
167
168
169 // by_state.
170 EvalParser::by_state::by_state () YY_NOEXCEPT
171 : state (empty_state)
172 {}
173
174 EvalParser::by_state::by_state (const by_state& that) YY_NOEXCEPT
175 : state (that.state)
176 {}
177
178 void
179 EvalParser::by_state::clear () YY_NOEXCEPT
180 {
181 state = empty_state;
182 }
183
184 void
185 EvalParser::by_state::move (by_state& that)
186 {
187 state = that.state;
188 that.clear ();
189 }
190
191 EvalParser::by_state::by_state (state_type s) YY_NOEXCEPT
192 : state (s)
193 {}
194
196 EvalParser::by_state::kind () const YY_NOEXCEPT
197 {
198 if (state == empty_state)
200 else
201 return YY_CAST (symbol_kind_type, yystos_[+state]);
202 }
203
204 EvalParser::stack_symbol_type::stack_symbol_type ()
205 {}
206
207 EvalParser::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that)
208 : super_type (YY_MOVE (that.state), YY_MOVE (that.location))
209 {
210 switch (that.kind ())
211 {
212 case symbol_kind::S_option_repr_type: // option_repr_type
213 value.YY_MOVE_OR_COPY< TokenOption::RepresentationType > (YY_MOVE (that.value));
214 break;
215
216 case symbol_kind::S_pkt4_field: // pkt4_field
217 value.YY_MOVE_OR_COPY< TokenPkt4::FieldType > (YY_MOVE (that.value));
218 break;
219
220 case symbol_kind::S_pkt6_field: // pkt6_field
221 value.YY_MOVE_OR_COPY< TokenPkt6::FieldType > (YY_MOVE (that.value));
222 break;
223
224 case symbol_kind::S_pkt_metadata: // pkt_metadata
225 value.YY_MOVE_OR_COPY< TokenPkt::MetadataType > (YY_MOVE (that.value));
226 break;
227
228 case symbol_kind::S_relay6_field: // relay6_field
229 value.YY_MOVE_OR_COPY< TokenRelay6Field::FieldType > (YY_MOVE (that.value));
230 break;
231
232 case symbol_kind::S_nest_level: // nest_level
233 value.YY_MOVE_OR_COPY< int8_t > (YY_MOVE (that.value));
234 break;
235
236 case symbol_kind::S_STRING: // "constant string"
237 case symbol_kind::S_INTEGER: // "integer"
238 case symbol_kind::S_HEXSTRING: // "constant hexstring"
239 case symbol_kind::S_OPTION_NAME: // "option name"
240 case symbol_kind::S_IP_ADDRESS: // "ip address"
241 value.YY_MOVE_OR_COPY< std::string > (YY_MOVE (that.value));
242 break;
243
244 case symbol_kind::S_option_code: // option_code
245 case symbol_kind::S_sub_option_code: // sub_option_code
246 value.YY_MOVE_OR_COPY< uint16_t > (YY_MOVE (that.value));
247 break;
248
249 case symbol_kind::S_integer_expr: // integer_expr
250 case symbol_kind::S_enterprise_id: // enterprise_id
251 value.YY_MOVE_OR_COPY< uint32_t > (YY_MOVE (that.value));
252 break;
253
254 default:
255 break;
256 }
257
258#if 201103L <= YY_CPLUSPLUS
259 // that is emptied.
260 that.state = empty_state;
261#endif
262 }
263
264 EvalParser::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that)
265 : super_type (s, YY_MOVE (that.location))
266 {
267 switch (that.kind ())
268 {
269 case symbol_kind::S_option_repr_type: // option_repr_type
270 value.move< TokenOption::RepresentationType > (YY_MOVE (that.value));
271 break;
272
273 case symbol_kind::S_pkt4_field: // pkt4_field
274 value.move< TokenPkt4::FieldType > (YY_MOVE (that.value));
275 break;
276
277 case symbol_kind::S_pkt6_field: // pkt6_field
278 value.move< TokenPkt6::FieldType > (YY_MOVE (that.value));
279 break;
280
281 case symbol_kind::S_pkt_metadata: // pkt_metadata
282 value.move< TokenPkt::MetadataType > (YY_MOVE (that.value));
283 break;
284
285 case symbol_kind::S_relay6_field: // relay6_field
286 value.move< TokenRelay6Field::FieldType > (YY_MOVE (that.value));
287 break;
288
289 case symbol_kind::S_nest_level: // nest_level
290 value.move< int8_t > (YY_MOVE (that.value));
291 break;
292
293 case symbol_kind::S_STRING: // "constant string"
294 case symbol_kind::S_INTEGER: // "integer"
295 case symbol_kind::S_HEXSTRING: // "constant hexstring"
296 case symbol_kind::S_OPTION_NAME: // "option name"
297 case symbol_kind::S_IP_ADDRESS: // "ip address"
298 value.move< std::string > (YY_MOVE (that.value));
299 break;
300
301 case symbol_kind::S_option_code: // option_code
302 case symbol_kind::S_sub_option_code: // sub_option_code
303 value.move< uint16_t > (YY_MOVE (that.value));
304 break;
305
306 case symbol_kind::S_integer_expr: // integer_expr
307 case symbol_kind::S_enterprise_id: // enterprise_id
308 value.move< uint32_t > (YY_MOVE (that.value));
309 break;
310
311 default:
312 break;
313 }
314
315 // that is emptied.
316 that.kind_ = symbol_kind::S_YYEMPTY;
317 }
318
319#if YY_CPLUSPLUS < 201103L
320 EvalParser::stack_symbol_type&
321 EvalParser::stack_symbol_type::operator= (const stack_symbol_type& that)
322 {
323 state = that.state;
324 switch (that.kind ())
325 {
326 case symbol_kind::S_option_repr_type: // option_repr_type
327 value.copy< TokenOption::RepresentationType > (that.value);
328 break;
329
330 case symbol_kind::S_pkt4_field: // pkt4_field
331 value.copy< TokenPkt4::FieldType > (that.value);
332 break;
333
334 case symbol_kind::S_pkt6_field: // pkt6_field
335 value.copy< TokenPkt6::FieldType > (that.value);
336 break;
337
338 case symbol_kind::S_pkt_metadata: // pkt_metadata
339 value.copy< TokenPkt::MetadataType > (that.value);
340 break;
341
342 case symbol_kind::S_relay6_field: // relay6_field
343 value.copy< TokenRelay6Field::FieldType > (that.value);
344 break;
345
346 case symbol_kind::S_nest_level: // nest_level
347 value.copy< int8_t > (that.value);
348 break;
349
350 case symbol_kind::S_STRING: // "constant string"
351 case symbol_kind::S_INTEGER: // "integer"
352 case symbol_kind::S_HEXSTRING: // "constant hexstring"
353 case symbol_kind::S_OPTION_NAME: // "option name"
354 case symbol_kind::S_IP_ADDRESS: // "ip address"
355 value.copy< std::string > (that.value);
356 break;
357
358 case symbol_kind::S_option_code: // option_code
359 case symbol_kind::S_sub_option_code: // sub_option_code
360 value.copy< uint16_t > (that.value);
361 break;
362
363 case symbol_kind::S_integer_expr: // integer_expr
364 case symbol_kind::S_enterprise_id: // enterprise_id
365 value.copy< uint32_t > (that.value);
366 break;
367
368 default:
369 break;
370 }
371
372 location = that.location;
373 return *this;
374 }
375
376 EvalParser::stack_symbol_type&
377 EvalParser::stack_symbol_type::operator= (stack_symbol_type& that)
378 {
379 state = that.state;
380 switch (that.kind ())
381 {
382 case symbol_kind::S_option_repr_type: // option_repr_type
383 value.move< TokenOption::RepresentationType > (that.value);
384 break;
385
386 case symbol_kind::S_pkt4_field: // pkt4_field
387 value.move< TokenPkt4::FieldType > (that.value);
388 break;
389
390 case symbol_kind::S_pkt6_field: // pkt6_field
391 value.move< TokenPkt6::FieldType > (that.value);
392 break;
393
394 case symbol_kind::S_pkt_metadata: // pkt_metadata
395 value.move< TokenPkt::MetadataType > (that.value);
396 break;
397
398 case symbol_kind::S_relay6_field: // relay6_field
399 value.move< TokenRelay6Field::FieldType > (that.value);
400 break;
401
402 case symbol_kind::S_nest_level: // nest_level
403 value.move< int8_t > (that.value);
404 break;
405
406 case symbol_kind::S_STRING: // "constant string"
407 case symbol_kind::S_INTEGER: // "integer"
408 case symbol_kind::S_HEXSTRING: // "constant hexstring"
409 case symbol_kind::S_OPTION_NAME: // "option name"
410 case symbol_kind::S_IP_ADDRESS: // "ip address"
411 value.move< std::string > (that.value);
412 break;
413
414 case symbol_kind::S_option_code: // option_code
415 case symbol_kind::S_sub_option_code: // sub_option_code
416 value.move< uint16_t > (that.value);
417 break;
418
419 case symbol_kind::S_integer_expr: // integer_expr
420 case symbol_kind::S_enterprise_id: // enterprise_id
421 value.move< uint32_t > (that.value);
422 break;
423
424 default:
425 break;
426 }
427
428 location = that.location;
429 // that is emptied.
430 that.state = empty_state;
431 return *this;
432 }
433#endif
434
435 template <typename Base>
436 void
437 EvalParser::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
438 {
439 if (yymsg)
440 YY_SYMBOL_PRINT (yymsg, yysym);
441 }
442
443#if EVALDEBUG
444 template <typename Base>
445 void
446 EvalParser::yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const
447 {
448 std::ostream& yyoutput = yyo;
449 YY_USE (yyoutput);
450 if (yysym.empty ())
451 yyo << "empty symbol";
452 else
453 {
454 symbol_kind_type yykind = yysym.kind ();
455 yyo << (yykind < YYNTOKENS ? "token" : "nterm")
456 << ' ' << yysym.name () << " ("
457 << yysym.location << ": ";
458 switch (yykind)
459 {
460 case symbol_kind::S_STRING: // "constant string"
461#line 121 "parser.yy"
462 { yyoutput << yysym.value.template as < std::string > (); }
463#line 464 "parser.cc"
464 break;
465
466 case symbol_kind::S_INTEGER: // "integer"
467#line 121 "parser.yy"
468 { yyoutput << yysym.value.template as < std::string > (); }
469#line 470 "parser.cc"
470 break;
471
472 case symbol_kind::S_HEXSTRING: // "constant hexstring"
473#line 121 "parser.yy"
474 { yyoutput << yysym.value.template as < std::string > (); }
475#line 476 "parser.cc"
476 break;
477
478 case symbol_kind::S_OPTION_NAME: // "option name"
479#line 121 "parser.yy"
480 { yyoutput << yysym.value.template as < std::string > (); }
481#line 482 "parser.cc"
482 break;
483
484 case symbol_kind::S_IP_ADDRESS: // "ip address"
485#line 121 "parser.yy"
486 { yyoutput << yysym.value.template as < std::string > (); }
487#line 488 "parser.cc"
488 break;
489
490 case symbol_kind::S_integer_expr: // integer_expr
491#line 121 "parser.yy"
492 { yyoutput << yysym.value.template as < uint32_t > (); }
493#line 494 "parser.cc"
494 break;
495
496 case symbol_kind::S_option_code: // option_code
497#line 121 "parser.yy"
498 { yyoutput << yysym.value.template as < uint16_t > (); }
499#line 500 "parser.cc"
500 break;
501
502 case symbol_kind::S_sub_option_code: // sub_option_code
503#line 121 "parser.yy"
504 { yyoutput << yysym.value.template as < uint16_t > (); }
505#line 506 "parser.cc"
506 break;
507
508 case symbol_kind::S_option_repr_type: // option_repr_type
509#line 121 "parser.yy"
510 { yyoutput << yysym.value.template as < TokenOption::RepresentationType > (); }
511#line 512 "parser.cc"
512 break;
513
514 case symbol_kind::S_nest_level: // nest_level
515#line 121 "parser.yy"
516 { yyoutput << yysym.value.template as < int8_t > (); }
517#line 518 "parser.cc"
518 break;
519
520 case symbol_kind::S_pkt_metadata: // pkt_metadata
521#line 121 "parser.yy"
522 { yyoutput << yysym.value.template as < TokenPkt::MetadataType > (); }
523#line 524 "parser.cc"
524 break;
525
526 case symbol_kind::S_enterprise_id: // enterprise_id
527#line 121 "parser.yy"
528 { yyoutput << yysym.value.template as < uint32_t > (); }
529#line 530 "parser.cc"
530 break;
531
532 case symbol_kind::S_pkt4_field: // pkt4_field
533#line 121 "parser.yy"
534 { yyoutput << yysym.value.template as < TokenPkt4::FieldType > (); }
535#line 536 "parser.cc"
536 break;
537
538 case symbol_kind::S_pkt6_field: // pkt6_field
539#line 121 "parser.yy"
540 { yyoutput << yysym.value.template as < TokenPkt6::FieldType > (); }
541#line 542 "parser.cc"
542 break;
543
544 case symbol_kind::S_relay6_field: // relay6_field
545#line 121 "parser.yy"
546 { yyoutput << yysym.value.template as < TokenRelay6Field::FieldType > (); }
547#line 548 "parser.cc"
548 break;
549
550 default:
551 break;
552 }
553 yyo << ')';
554 }
555 }
556#endif
557
558 void
559 EvalParser::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym)
560 {
561 if (m)
562 YY_SYMBOL_PRINT (m, sym);
563 yystack_.push (YY_MOVE (sym));
564 }
565
566 void
567 EvalParser::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym)
568 {
569#if 201103L <= YY_CPLUSPLUS
570 yypush_ (m, stack_symbol_type (s, std::move (sym)));
571#else
572 stack_symbol_type ss (s, sym);
573 yypush_ (m, ss);
574#endif
575 }
576
577 void
578 EvalParser::yypop_ (int n) YY_NOEXCEPT
579 {
580 yystack_.pop (n);
581 }
582
583#if EVALDEBUG
584 std::ostream&
586 {
587 return *yycdebug_;
588 }
589
590 void
592 {
593 yycdebug_ = &o;
594 }
595
596
599 {
600 return yydebug_;
601 }
602
603 void
605 {
606 yydebug_ = l;
607 }
608#endif // EVALDEBUG
609
610 EvalParser::state_type
611 EvalParser::yy_lr_goto_state_ (state_type yystate, int yysym)
612 {
613 int yyr = yypgoto_[yysym - YYNTOKENS] + yystate;
614 if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
615 return yytable_[yyr];
616 else
617 return yydefgoto_[yysym - YYNTOKENS];
618 }
619
620 bool
621 EvalParser::yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT
622 {
623 return yyvalue == yypact_ninf_;
624 }
625
626 bool
627 EvalParser::yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT
628 {
629 return yyvalue == yytable_ninf_;
630 }
631
632 int
634 {
635 return parse ();
636 }
637
638 int
640 {
641 int yyn;
643 int yylen = 0;
644
645 // Error handling.
646 int yynerrs_ = 0;
647 int yyerrstatus_ = 0;
648
650 symbol_type yyla;
651
653 stack_symbol_type yyerror_range[3];
654
656 int yyresult;
657
658#if YY_EXCEPTIONS
659 try
660#endif // YY_EXCEPTIONS
661 {
662 YYCDEBUG << "Starting parse\n";
663
664
665 /* Initialize the stack. The initial state will be set in
666 yynewstate, since the latter expects the semantical and the
667 location values to have been already stored, initialize these
668 stacks with a primary value. */
669 yystack_.clear ();
670 yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));
671
672 /*-----------------------------------------------.
673 | yynewstate -- push a new symbol on the stack. |
674 `-----------------------------------------------*/
675 yynewstate:
676 YYCDEBUG << "Entering state " << int (yystack_[0].state) << '\n';
678
679 // Accept?
680 if (yystack_[0].state == yyfinal_)
681 YYACCEPT;
682
683 goto yybackup;
684
685
686 /*-----------.
687 | yybackup. |
688 `-----------*/
689 yybackup:
690 // Try to take a decision without lookahead.
691 yyn = yypact_[+yystack_[0].state];
692 if (yy_pact_value_is_default_ (yyn))
693 goto yydefault;
694
695 // Read a lookahead token.
696 if (yyla.empty ())
697 {
698 YYCDEBUG << "Reading a token\n";
699#if YY_EXCEPTIONS
700 try
701#endif // YY_EXCEPTIONS
702 {
703 symbol_type yylookahead (yylex (ctx));
704 yyla.move (yylookahead);
705 }
706#if YY_EXCEPTIONS
707 catch (const syntax_error& yyexc)
708 {
709 YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
710 error (yyexc);
711 goto yyerrlab1;
712 }
713#endif // YY_EXCEPTIONS
714 }
715 YY_SYMBOL_PRINT ("Next token is", yyla);
716
717 if (yyla.kind () == symbol_kind::S_YYerror)
718 {
719 // The scanner already issued an error message, process directly
720 // to error recovery. But do not keep the error token as
721 // lookahead, it is too special and may lead us to an endless
722 // loop in error recovery. */
723 yyla.kind_ = symbol_kind::S_YYUNDEF;
724 goto yyerrlab1;
725 }
726
727 /* If the proper action on seeing token YYLA.TYPE is to reduce or
728 to detect an error, take that action. */
729 yyn += yyla.kind ();
730 if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind ())
731 {
732 goto yydefault;
733 }
734
735 // Reduce or error.
736 yyn = yytable_[yyn];
737 if (yyn <= 0)
738 {
739 if (yy_table_value_is_error_ (yyn))
740 goto yyerrlab;
741 yyn = -yyn;
742 goto yyreduce;
743 }
744
745 // Count tokens shifted since error; after three, turn off error status.
746 if (yyerrstatus_)
747 --yyerrstatus_;
748
749 // Shift the lookahead token.
750 yypush_ ("Shifting", state_type (yyn), YY_MOVE (yyla));
751 goto yynewstate;
752
753
754 /*-----------------------------------------------------------.
755 | yydefault -- do the default action for the current state. |
756 `-----------------------------------------------------------*/
757 yydefault:
758 yyn = yydefact_[+yystack_[0].state];
759 if (yyn == 0)
760 goto yyerrlab;
761 goto yyreduce;
762
763
764 /*-----------------------------.
765 | yyreduce -- do a reduction. |
766 `-----------------------------*/
767 yyreduce:
768 yylen = yyr2_[yyn];
769 {
770 stack_symbol_type yylhs;
771 yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]);
772 /* Variants are always initialized to an empty instance of the
773 correct type. The default '$$ = $1' action is NOT applied
774 when using variants. */
775 switch (yyr1_[yyn])
776 {
777 case symbol_kind::S_option_repr_type: // option_repr_type
778 yylhs.value.emplace< TokenOption::RepresentationType > ();
779 break;
780
781 case symbol_kind::S_pkt4_field: // pkt4_field
782 yylhs.value.emplace< TokenPkt4::FieldType > ();
783 break;
784
785 case symbol_kind::S_pkt6_field: // pkt6_field
786 yylhs.value.emplace< TokenPkt6::FieldType > ();
787 break;
788
789 case symbol_kind::S_pkt_metadata: // pkt_metadata
790 yylhs.value.emplace< TokenPkt::MetadataType > ();
791 break;
792
793 case symbol_kind::S_relay6_field: // relay6_field
794 yylhs.value.emplace< TokenRelay6Field::FieldType > ();
795 break;
796
797 case symbol_kind::S_nest_level: // nest_level
798 yylhs.value.emplace< int8_t > ();
799 break;
800
801 case symbol_kind::S_STRING: // "constant string"
802 case symbol_kind::S_INTEGER: // "integer"
803 case symbol_kind::S_HEXSTRING: // "constant hexstring"
804 case symbol_kind::S_OPTION_NAME: // "option name"
805 case symbol_kind::S_IP_ADDRESS: // "ip address"
806 yylhs.value.emplace< std::string > ();
807 break;
808
809 case symbol_kind::S_option_code: // option_code
810 case symbol_kind::S_sub_option_code: // sub_option_code
811 yylhs.value.emplace< uint16_t > ();
812 break;
813
814 case symbol_kind::S_integer_expr: // integer_expr
815 case symbol_kind::S_enterprise_id: // enterprise_id
816 yylhs.value.emplace< uint32_t > ();
817 break;
818
819 default:
820 break;
821 }
822
823
824 // Default location.
825 {
826 stack_type::slice range (yystack_, yylen);
827 YYLLOC_DEFAULT (yylhs.location, range, yylen);
828 yyerror_range[1].location = yylhs.location;
829 }
830
831 // Perform the reduction.
832 YY_REDUCE_PRINT (yyn);
833#if YY_EXCEPTIONS
834 try
835#endif // YY_EXCEPTIONS
836 {
837 switch (yyn)
838 {
839 case 6: // bool_expr: "not" bool_expr
840#line 141 "parser.yy"
841 {
842 TokenPtr neg(new TokenNot());
843 ctx.expression.push_back(neg);
844 }
845#line 846 "parser.cc"
846 break;
847
848 case 7: // bool_expr: bool_expr "and" bool_expr
849#line 146 "parser.yy"
850 {
851 TokenPtr neg(new TokenAnd());
852 ctx.expression.push_back(neg);
853 }
854#line 855 "parser.cc"
855 break;
856
857 case 8: // bool_expr: bool_expr "or" bool_expr
858#line 151 "parser.yy"
859 {
860 TokenPtr neg(new TokenOr());
861 ctx.expression.push_back(neg);
862 }
863#line 864 "parser.cc"
864 break;
865
866 case 9: // bool_expr: string_expr "==" string_expr
867#line 156 "parser.yy"
868 {
869 TokenPtr eq(new TokenEqual());
870 ctx.expression.push_back(eq);
871 }
872#line 873 "parser.cc"
873 break;
874
875 case 10: // bool_expr: "option" "[" option_code "]" "." "exists"
876#line 161 "parser.yy"
877 {
878 TokenPtr opt(new TokenOption(yystack_[3].value.as < uint16_t > (), TokenOption::EXISTS));
879 ctx.expression.push_back(opt);
880 }
881#line 882 "parser.cc"
882 break;
883
884 case 11: // bool_expr: "option" "[" option_code "]" "." "option" "[" sub_option_code "]" "." "exists"
885#line 166 "parser.yy"
886 {
887 TokenPtr opt(new TokenSubOption(yystack_[8].value.as < uint16_t > (), yystack_[3].value.as < uint16_t > (), TokenOption::EXISTS));
888 ctx.expression.push_back(opt);
889 }
890#line 891 "parser.cc"
891 break;
892
893 case 12: // bool_expr: "relay4" "[" sub_option_code "]" "." "exists"
894#line 171 "parser.yy"
895 {
896 switch (ctx.getUniverse()) {
897 case Option::V4:
898 {
899 TokenPtr opt(new TokenRelay4Option(yystack_[3].value.as < uint16_t > (), TokenOption::EXISTS));
900 ctx.expression.push_back(opt);
901 break;
902 }
903 case Option::V6:
904 // We will have relay6[123] for the DHCPv6.
905 // In a very distant future we'll possibly be able
906 // to mix both if we have DHCPv4-over-DHCPv6, so it
907 // has some sense to make it explicit whether we
908 // talk about DHCPv4 relay or DHCPv6 relay. However,
909 // for the time being relay4 can be used in DHCPv4
910 // only.
911 error(yystack_[5].location, "relay4 can only be used in DHCPv4.");
912 }
913 }
914#line 915 "parser.cc"
915 break;
916
917 case 13: // bool_expr: "relay6" "[" nest_level "]" "." "option" "[" sub_option_code "]" "." "exists"
918#line 191 "parser.yy"
919 {
920 switch (ctx.getUniverse()) {
921 case Option::V6:
922 {
923 TokenPtr opt(new TokenRelay6Option(yystack_[8].value.as < int8_t > (), yystack_[3].value.as < uint16_t > (), TokenOption::EXISTS));
924 ctx.expression.push_back(opt);
925 break;
926 }
927 case Option::V4:
928 // For now we only use relay6 in DHCPv6.
929 error(yystack_[10].location, "relay6 can only be used in DHCPv6.");
930 }
931 }
932#line 933 "parser.cc"
933 break;
934
935 case 14: // bool_expr: "vendor-class" "[" enterprise_id "]" "." "exists"
936#line 205 "parser.yy"
937 {
938 // Expression: vendor-class[1234].exists
939 //
940 // This token will find option 124 (DHCPv4) or 16 (DHCPv6),
941 // and will check if enterprise-id equals specified value.
942 TokenPtr exist(new TokenVendorClass(ctx.getUniverse(), yystack_[3].value.as < uint32_t > (), TokenOption::EXISTS));
943 ctx.expression.push_back(exist);
944 }
945#line 946 "parser.cc"
946 break;
947
948 case 15: // bool_expr: "vendor" "[" enterprise_id "]" "." "exists"
949#line 214 "parser.yy"
950 {
951 // Expression: vendor[1234].exists
952 //
953 // This token will find option 125 (DHCPv4) or 17 (DHCPv6),
954 // and will check if enterprise-id equals specified value.
955 TokenPtr exist(new TokenVendor(ctx.getUniverse(), yystack_[3].value.as < uint32_t > (), TokenOption::EXISTS));
956 ctx.expression.push_back(exist);
957 }
958#line 959 "parser.cc"
959 break;
960
961 case 16: // bool_expr: "vendor" "[" enterprise_id "]" "." "option" "[" sub_option_code "]" "." "exists"
962#line 223 "parser.yy"
963 {
964 // Expression vendor[1234].option[123].exists
965 //
966 // This token will check if specified vendor option
967 // exists, has specified enterprise-id and if has
968 // specified suboption.
969 TokenPtr exist(new TokenVendor(ctx.getUniverse(), yystack_[8].value.as < uint32_t > (), TokenOption::EXISTS, yystack_[3].value.as < uint16_t > ()));
970 ctx.expression.push_back(exist);
971 }
972#line 973 "parser.cc"
973 break;
974
975 case 17: // bool_expr: "member" "(" "constant string" ")"
976#line 233 "parser.yy"
977 {
978 // Expression member('foo')
979 //
980 // This token will check if the packet is a member of
981 // the specified client class.
982 // To avoid loops at evaluation only already defined and
983 // built-in classes are allowed.
984 std::string cc = yystack_[1].value.as < std::string > ();
985 if (!ctx.isClientClassDefined(cc)) {
986 error(yystack_[1].location, "Not defined client class '" + cc + "'");
987 }
988 TokenPtr member(new TokenMember(cc));
989 ctx.expression.push_back(member);
990 }
991#line 992 "parser.cc"
992 break;
993
994 case 18: // string_expr: "constant string"
995#line 250 "parser.yy"
996 {
997 TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ()));
998 ctx.expression.push_back(str);
999 }
1000#line 1001 "parser.cc"
1001 break;
1002
1003 case 19: // string_expr: "constant hexstring"
1004#line 255 "parser.yy"
1005 {
1006 TokenPtr hex(new TokenHexString(yystack_[0].value.as < std::string > ()));
1007 ctx.expression.push_back(hex);
1008 }
1009#line 1010 "parser.cc"
1010 break;
1011
1012 case 20: // string_expr: "ip address"
1013#line 260 "parser.yy"
1014 {
1015 TokenPtr ip(new TokenIpAddress(yystack_[0].value.as < std::string > ()));
1016 ctx.expression.push_back(ip);
1017 }
1018#line 1019 "parser.cc"
1019 break;
1020
1021 case 21: // string_expr: "option" "[" option_code "]" "." option_repr_type
1022#line 265 "parser.yy"
1023 {
1024 TokenPtr opt(new TokenOption(yystack_[3].value.as < uint16_t > (), yystack_[0].value.as < TokenOption::RepresentationType > ()));
1025 ctx.expression.push_back(opt);
1026 }
1027#line 1028 "parser.cc"
1028 break;
1029
1030 case 22: // string_expr: "option" "[" option_code "]" "." "option" "[" sub_option_code "]" "." option_repr_type
1031#line 270 "parser.yy"
1032 {
1033 TokenPtr opt(new TokenSubOption(yystack_[8].value.as < uint16_t > (), yystack_[3].value.as < uint16_t > (), yystack_[0].value.as < TokenOption::RepresentationType > ()));
1034 ctx.expression.push_back(opt);
1035 }
1036#line 1037 "parser.cc"
1037 break;
1038
1039 case 23: // string_expr: "relay4" "[" sub_option_code "]" "." option_repr_type
1040#line 275 "parser.yy"
1041 {
1042 switch (ctx.getUniverse()) {
1043 case Option::V4:
1044 {
1045 TokenPtr opt(new TokenRelay4Option(yystack_[3].value.as < uint16_t > (), yystack_[0].value.as < TokenOption::RepresentationType > ()));
1046 ctx.expression.push_back(opt);
1047 break;
1048 }
1049 case Option::V6:
1050 // We will have relay6[123] for the DHCPv6.
1051 // In a very distant future we'll possibly be able
1052 // to mix both if we have DHCPv4-over-DHCPv6, so it
1053 // has some sense to make it explicit whether we
1054 // talk about DHCPv4 relay or DHCPv6 relay. However,
1055 // for the time being relay4 can be used in DHCPv4
1056 // only.
1057 error(yystack_[5].location, "relay4 can only be used in DHCPv4.");
1058 }
1059 }
1060#line 1061 "parser.cc"
1061 break;
1062
1063 case 24: // string_expr: "relay6" "[" nest_level "]" "." "option" "[" sub_option_code "]" "." option_repr_type
1064#line 296 "parser.yy"
1065 {
1066 switch (ctx.getUniverse()) {
1067 case Option::V6:
1068 {
1069 TokenPtr opt(new TokenRelay6Option(yystack_[8].value.as < int8_t > (), yystack_[3].value.as < uint16_t > (), yystack_[0].value.as < TokenOption::RepresentationType > ()));
1070 ctx.expression.push_back(opt);
1071 break;
1072 }
1073 case Option::V4:
1074 // For now we only use relay6 in DHCPv6.
1075 error(yystack_[10].location, "relay6 can only be used in DHCPv6.");
1076 }
1077 }
1078#line 1079 "parser.cc"
1079 break;
1080
1081 case 25: // string_expr: "pkt" "." pkt_metadata
1082#line 311 "parser.yy"
1083 {
1084 TokenPtr pkt_metadata(new TokenPkt(yystack_[0].value.as < TokenPkt::MetadataType > ()));
1085 ctx.expression.push_back(pkt_metadata);
1086 }
1087#line 1088 "parser.cc"
1088 break;
1089
1090 case 26: // string_expr: "pkt4" "." pkt4_field
1091#line 316 "parser.yy"
1092 {
1093 switch (ctx.getUniverse()) {
1094 case Option::V4:
1095 {
1096 TokenPtr pkt4_field(new TokenPkt4(yystack_[0].value.as < TokenPkt4::FieldType > ()));
1097 ctx.expression.push_back(pkt4_field);
1098 break;
1099 }
1100 case Option::V6:
1101 // For now we only use pkt4 in DHCPv4.
1102 error(yystack_[2].location, "pkt4 can only be used in DHCPv4.");
1103 }
1104 }
1105#line 1106 "parser.cc"
1106 break;
1107
1108 case 27: // string_expr: "pkt6" "." pkt6_field
1109#line 330 "parser.yy"
1110 {
1111 switch (ctx.getUniverse()) {
1112 case Option::V6:
1113 {
1114 TokenPtr pkt6_field(new TokenPkt6(yystack_[0].value.as < TokenPkt6::FieldType > ()));
1115 ctx.expression.push_back(pkt6_field);
1116 break;
1117 }
1118 case Option::V4:
1119 // For now we only use pkt6 in DHCPv6.
1120 error(yystack_[2].location, "pkt6 can only be used in DHCPv6.");
1121 }
1122 }
1123#line 1124 "parser.cc"
1124 break;
1125
1126 case 28: // string_expr: "relay6" "[" nest_level "]" "." relay6_field
1127#line 344 "parser.yy"
1128 {
1129 switch (ctx.getUniverse()) {
1130 case Option::V6:
1131 {
1132 TokenPtr relay6field(new TokenRelay6Field(yystack_[3].value.as < int8_t > (), yystack_[0].value.as < TokenRelay6Field::FieldType > ()));
1133 ctx.expression.push_back(relay6field);
1134 break;
1135 }
1136 case Option::V4:
1137 // For now we only use relay6 in DHCPv6.
1138 error(yystack_[5].location, "relay6 can only be used in DHCPv6.");
1139 }
1140 }
1141#line 1142 "parser.cc"
1142 break;
1143
1144 case 29: // string_expr: "substring" "(" string_expr "," start_expr "," length_expr ")"
1145#line 359 "parser.yy"
1146 {
1147 TokenPtr sub(new TokenSubstring());
1148 ctx.expression.push_back(sub);
1149 }
1150#line 1151 "parser.cc"
1151 break;
1152
1153 case 30: // string_expr: "concat" "(" string_expr "," string_expr ")"
1154#line 364 "parser.yy"
1155 {
1156 TokenPtr conc(new TokenConcat());
1157 ctx.expression.push_back(conc);
1158 }
1159#line 1160 "parser.cc"
1160 break;
1161
1162 case 31: // string_expr: string_expr "+" string_expr
1163#line 369 "parser.yy"
1164 {
1165 TokenPtr conc(new TokenConcat());
1166 ctx.expression.push_back(conc);
1167 }
1168#line 1169 "parser.cc"
1169 break;
1170
1171 case 32: // string_expr: "ifelse" "(" bool_expr "," string_expr "," string_expr ")"
1172#line 374 "parser.yy"
1173 {
1174 TokenPtr cond(new TokenIfElse());
1175 ctx.expression.push_back(cond);
1176 }
1177#line 1178 "parser.cc"
1178 break;
1179
1180 case 33: // string_expr: "hexstring" "(" string_expr "," string_expr ")"
1181#line 379 "parser.yy"
1182 {
1183 TokenPtr tohex(new TokenToHexString());
1184 ctx.expression.push_back(tohex);
1185 }
1186#line 1187 "parser.cc"
1187 break;
1188
1189 case 34: // string_expr: "addrtotext" "(" string_expr ")"
1190#line 384 "parser.yy"
1191 {
1192 TokenPtr addrtotext(new TokenIpAddressToText());
1193 ctx.expression.push_back(addrtotext);
1194 }
1195#line 1196 "parser.cc"
1196 break;
1197
1198 case 35: // string_expr: "int8totext" "(" string_expr ")"
1199#line 389 "parser.yy"
1200 {
1201 TokenPtr int8totext(new TokenInt8ToText());
1202 ctx.expression.push_back(int8totext);
1203 }
1204#line 1205 "parser.cc"
1205 break;
1206
1207 case 36: // string_expr: "int16totext" "(" string_expr ")"
1208#line 394 "parser.yy"
1209 {
1210 TokenPtr int16totext(new TokenInt16ToText());
1211 ctx.expression.push_back(int16totext);
1212 }
1213#line 1214 "parser.cc"
1214 break;
1215
1216 case 37: // string_expr: "int32totext" "(" string_expr ")"
1217#line 399 "parser.yy"
1218 {
1219 TokenPtr int32totext(new TokenInt32ToText());
1220 ctx.expression.push_back(int32totext);
1221 }
1222#line 1223 "parser.cc"
1223 break;
1224
1225 case 38: // string_expr: "uint8totext" "(" string_expr ")"
1226#line 404 "parser.yy"
1227 {
1228 TokenPtr uint8totext(new TokenUInt8ToText());
1229 ctx.expression.push_back(uint8totext);
1230 }
1231#line 1232 "parser.cc"
1232 break;
1233
1234 case 39: // string_expr: "uint16totext" "(" string_expr ")"
1235#line 409 "parser.yy"
1236 {
1237 TokenPtr uint16totext(new TokenUInt16ToText());
1238 ctx.expression.push_back(uint16totext);
1239 }
1240#line 1241 "parser.cc"
1241 break;
1242
1243 case 40: // string_expr: "uint32totext" "(" string_expr ")"
1244#line 414 "parser.yy"
1245 {
1246 TokenPtr uint32totext(new TokenUInt32ToText());
1247 ctx.expression.push_back(uint32totext);
1248 }
1249#line 1250 "parser.cc"
1250 break;
1251
1252 case 41: // string_expr: "vendor" "." "enterprise"
1253#line 419 "parser.yy"
1254 {
1255 // expression: vendor.enterprise
1256 //
1257 // This token will return enterprise-id number of
1258 // received vendor option.
1259 TokenPtr vendor(new TokenVendor(ctx.getUniverse(), 0, TokenVendor::ENTERPRISE_ID));
1260 ctx.expression.push_back(vendor);
1261 }
1262#line 1263 "parser.cc"
1263 break;
1264
1265 case 42: // string_expr: "vendor-class" "." "enterprise"
1266#line 428 "parser.yy"
1267 {
1268 // expression: vendor-class.enterprise
1269 //
1270 // This token will return enterprise-id number of
1271 // received vendor class option.
1272 TokenPtr vendor(new TokenVendorClass(ctx.getUniverse(), 0,
1273 TokenVendor::ENTERPRISE_ID));
1274 ctx.expression.push_back(vendor);
1275 }
1276#line 1277 "parser.cc"
1277 break;
1278
1279 case 43: // string_expr: "vendor" "[" enterprise_id "]" "." "option" "[" sub_option_code "]" "." option_repr_type
1280#line 438 "parser.yy"
1281 {
1282 // This token will search for vendor option with
1283 // specified enterprise-id. If found, will search
1284 // for specified suboption and finally will return
1285 // its content.
1286 TokenPtr opt(new TokenVendor(ctx.getUniverse(), yystack_[8].value.as < uint32_t > (), yystack_[0].value.as < TokenOption::RepresentationType > (), yystack_[3].value.as < uint16_t > ()));
1287 ctx.expression.push_back(opt);
1288 }
1289#line 1290 "parser.cc"
1290 break;
1291
1292 case 44: // string_expr: "vendor-class" "[" enterprise_id "]" "." "data"
1293#line 447 "parser.yy"
1294 {
1295 // expression: vendor-class[1234].data
1296 //
1297 // Vendor class option does not have suboptions,
1298 // but chunks of data (typically 1, but the option
1299 // structure allows multiple of them). If chunk
1300 // offset is not specified, we assume the first (0th)
1301 // is requested.
1302 TokenPtr vendor_class(new TokenVendorClass(ctx.getUniverse(), yystack_[3].value.as < uint32_t > (),
1303 TokenVendor::DATA, 0));
1304 ctx.expression.push_back(vendor_class);
1305 }
1306#line 1307 "parser.cc"
1307 break;
1308
1309 case 45: // string_expr: "vendor-class" "[" enterprise_id "]" "." "data" "[" "integer" "]"
1310#line 460 "parser.yy"
1311 {
1312 // expression: vendor-class[1234].data[5]
1313 //
1314 // Vendor class option does not have suboptions,
1315 // but chunks of data (typically 1, but the option
1316 // structure allows multiple of them). This syntax
1317 // specifies which data chunk (tuple) we want.
1318 uint8_t index = ctx.convertUint8(yystack_[1].value.as < std::string > (), yystack_[1].location);
1319 TokenPtr vendor_class(new TokenVendorClass(ctx.getUniverse(), yystack_[6].value.as < uint32_t > (),
1320 TokenVendor::DATA, index));
1321 ctx.expression.push_back(vendor_class);
1322 }
1323#line 1324 "parser.cc"
1324 break;
1325
1326 case 46: // string_expr: integer_expr
1327#line 473 "parser.yy"
1328 {
1329 TokenPtr integer(new TokenInteger(yystack_[0].value.as < uint32_t > ()));
1330 ctx.expression.push_back(integer);
1331 }
1332#line 1333 "parser.cc"
1333 break;
1334
1335 case 48: // integer_expr: "integer"
1336#line 481 "parser.yy"
1337 {
1338 yylhs.value.as < uint32_t > () = ctx.convertUint32(yystack_[0].value.as < std::string > (), yystack_[0].location);
1339 }
1340#line 1341 "parser.cc"
1341 break;
1342
1343 case 49: // option_code: "integer"
1344#line 487 "parser.yy"
1345 {
1346 yylhs.value.as < uint16_t > () = ctx.convertOptionCode(yystack_[0].value.as < std::string > (), yystack_[0].location);
1347 }
1348#line 1349 "parser.cc"
1349 break;
1350
1351 case 50: // option_code: "option name"
1352#line 491 "parser.yy"
1353 {
1354 yylhs.value.as < uint16_t > () = ctx.convertOptionName(yystack_[0].value.as < std::string > (), yystack_[0].location);
1355 }
1356#line 1357 "parser.cc"
1357 break;
1358
1359 case 51: // sub_option_code: "integer"
1360#line 497 "parser.yy"
1361 {
1362 yylhs.value.as < uint16_t > () = ctx.convertOptionCode(yystack_[0].value.as < std::string > (), yystack_[0].location);
1363 }
1364#line 1365 "parser.cc"
1365 break;
1366
1367 case 52: // option_repr_type: "text"
1368#line 503 "parser.yy"
1369 {
1370 yylhs.value.as < TokenOption::RepresentationType > () = TokenOption::TEXTUAL;
1371 }
1372#line 1373 "parser.cc"
1373 break;
1374
1375 case 53: // option_repr_type: "hex"
1376#line 507 "parser.yy"
1377 {
1378 yylhs.value.as < TokenOption::RepresentationType > () = TokenOption::HEXADECIMAL;
1379 }
1380#line 1381 "parser.cc"
1381 break;
1382
1383 case 54: // nest_level: "integer"
1384#line 513 "parser.yy"
1385 {
1386 yylhs.value.as < int8_t > () = ctx.convertNestLevelNumber(yystack_[0].value.as < std::string > (), yystack_[0].location);
1387 }
1388#line 1389 "parser.cc"
1389 break;
1390
1391 case 55: // pkt_metadata: "iface"
1392#line 522 "parser.yy"
1393 {
1394 yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::IFACE;
1395 }
1396#line 1397 "parser.cc"
1397 break;
1398
1399 case 56: // pkt_metadata: "src"
1400#line 526 "parser.yy"
1401 {
1402 yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::SRC;
1403 }
1404#line 1405 "parser.cc"
1405 break;
1406
1407 case 57: // pkt_metadata: "dst"
1408#line 530 "parser.yy"
1409 {
1410 yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::DST;
1411 }
1412#line 1413 "parser.cc"
1413 break;
1414
1415 case 58: // pkt_metadata: "len"
1416#line 534 "parser.yy"
1417 {
1418 yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::LEN;
1419 }
1420#line 1421 "parser.cc"
1421 break;
1422
1423 case 59: // enterprise_id: "integer"
1424#line 540 "parser.yy"
1425 {
1426 yylhs.value.as < uint32_t > () = ctx.convertUint32(yystack_[0].value.as < std::string > (), yystack_[0].location);
1427 }
1428#line 1429 "parser.cc"
1429 break;
1430
1431 case 60: // enterprise_id: "*"
1432#line 544 "parser.yy"
1433 {
1434 yylhs.value.as < uint32_t > () = 0;
1435 }
1436#line 1437 "parser.cc"
1437 break;
1438
1439 case 61: // pkt4_field: "mac"
1440#line 550 "parser.yy"
1441 {
1442 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::CHADDR;
1443 }
1444#line 1445 "parser.cc"
1445 break;
1446
1447 case 62: // pkt4_field: "hlen"
1448#line 554 "parser.yy"
1449 {
1450 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::HLEN;
1451 }
1452#line 1453 "parser.cc"
1453 break;
1454
1455 case 63: // pkt4_field: "htype"
1456#line 558 "parser.yy"
1457 {
1458 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::HTYPE;
1459 }
1460#line 1461 "parser.cc"
1461 break;
1462
1463 case 64: // pkt4_field: "ciaddr"
1464#line 562 "parser.yy"
1465 {
1466 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::CIADDR;
1467 }
1468#line 1469 "parser.cc"
1469 break;
1470
1471 case 65: // pkt4_field: "giaddr"
1472#line 566 "parser.yy"
1473 {
1474 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::GIADDR;
1475 }
1476#line 1477 "parser.cc"
1477 break;
1478
1479 case 66: // pkt4_field: "yiaddr"
1480#line 570 "parser.yy"
1481 {
1482 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::YIADDR;
1483 }
1484#line 1485 "parser.cc"
1485 break;
1486
1487 case 67: // pkt4_field: "siaddr"
1488#line 574 "parser.yy"
1489 {
1490 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::SIADDR;
1491 }
1492#line 1493 "parser.cc"
1493 break;
1494
1495 case 68: // pkt4_field: "msgtype"
1496#line 578 "parser.yy"
1497 {
1498 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::MSGTYPE;
1499 }
1500#line 1501 "parser.cc"
1501 break;
1502
1503 case 69: // pkt4_field: "transid"
1504#line 582 "parser.yy"
1505 {
1506 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::TRANSID;
1507 }
1508#line 1509 "parser.cc"
1509 break;
1510
1511 case 70: // pkt6_field: "msgtype"
1512#line 588 "parser.yy"
1513 {
1514 yylhs.value.as < TokenPkt6::FieldType > () = TokenPkt6::MSGTYPE;
1515 }
1516#line 1517 "parser.cc"
1517 break;
1518
1519 case 71: // pkt6_field: "transid"
1520#line 592 "parser.yy"
1521 {
1522 yylhs.value.as < TokenPkt6::FieldType > () = TokenPkt6::TRANSID;
1523 }
1524#line 1525 "parser.cc"
1525 break;
1526
1527 case 72: // relay6_field: "peeraddr"
1528#line 598 "parser.yy"
1529 {
1530 yylhs.value.as < TokenRelay6Field::FieldType > () = TokenRelay6Field::PEERADDR;
1531 }
1532#line 1533 "parser.cc"
1533 break;
1534
1535 case 73: // relay6_field: "linkaddr"
1536#line 602 "parser.yy"
1537 {
1538 yylhs.value.as < TokenRelay6Field::FieldType > () = TokenRelay6Field::LINKADDR;
1539 }
1540#line 1541 "parser.cc"
1541 break;
1542
1543 case 74: // start_expr: "integer"
1544#line 608 "parser.yy"
1545 {
1546 TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ()));
1547 ctx.expression.push_back(str);
1548 }
1549#line 1550 "parser.cc"
1550 break;
1551
1552 case 75: // length_expr: "integer"
1553#line 615 "parser.yy"
1554 {
1555 TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ()));
1556 ctx.expression.push_back(str);
1557 }
1558#line 1559 "parser.cc"
1559 break;
1560
1561 case 76: // length_expr: "all"
1562#line 620 "parser.yy"
1563 {
1564 TokenPtr str(new TokenString("all"));
1565 ctx.expression.push_back(str);
1566 }
1567#line 1568 "parser.cc"
1568 break;
1569
1570
1571#line 1572 "parser.cc"
1572
1573 default:
1574 break;
1575 }
1576 }
1577#if YY_EXCEPTIONS
1578 catch (const syntax_error& yyexc)
1579 {
1580 YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
1581 error (yyexc);
1582 YYERROR;
1583 }
1584#endif // YY_EXCEPTIONS
1585 YY_SYMBOL_PRINT ("-> $$ =", yylhs);
1586 yypop_ (yylen);
1587 yylen = 0;
1588
1589 // Shift the result of the reduction.
1590 yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
1591 }
1592 goto yynewstate;
1593
1594
1595 /*--------------------------------------.
1596 | yyerrlab -- here on detecting error. |
1597 `--------------------------------------*/
1598 yyerrlab:
1599 // If not already recovering from an error, report this error.
1600 if (!yyerrstatus_)
1601 {
1602 ++yynerrs_;
1603 context yyctx (*this, yyla);
1604 std::string msg = yysyntax_error_ (yyctx);
1605 error (yyla.location, YY_MOVE (msg));
1606 }
1607
1608
1609 yyerror_range[1].location = yyla.location;
1610 if (yyerrstatus_ == 3)
1611 {
1612 /* If just tried and failed to reuse lookahead token after an
1613 error, discard it. */
1614
1615 // Return failure if at end of input.
1616 if (yyla.kind () == symbol_kind::S_YYEOF)
1617 YYABORT;
1618 else if (!yyla.empty ())
1619 {
1620 yy_destroy_ ("Error: discarding", yyla);
1621 yyla.clear ();
1622 }
1623 }
1624
1625 // Else will try to reuse lookahead token after shifting the error token.
1626 goto yyerrlab1;
1627
1628
1629 /*---------------------------------------------------.
1630 | yyerrorlab -- error raised explicitly by YYERROR. |
1631 `---------------------------------------------------*/
1632 yyerrorlab:
1633 /* Pacify compilers when the user code never invokes YYERROR and
1634 the label yyerrorlab therefore never appears in user code. */
1635 if (false)
1636 YYERROR;
1637
1638 /* Do not reclaim the symbols of the rule whose action triggered
1639 this YYERROR. */
1640 yypop_ (yylen);
1641 yylen = 0;
1642 YY_STACK_PRINT ();
1643 goto yyerrlab1;
1644
1645
1646 /*-------------------------------------------------------------.
1647 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1648 `-------------------------------------------------------------*/
1649 yyerrlab1:
1650 yyerrstatus_ = 3; // Each real token shifted decrements this.
1651 // Pop stack until we find a state that shifts the error token.
1652 for (;;)
1653 {
1654 yyn = yypact_[+yystack_[0].state];
1655 if (!yy_pact_value_is_default_ (yyn))
1656 {
1658 if (0 <= yyn && yyn <= yylast_
1659 && yycheck_[yyn] == symbol_kind::S_YYerror)
1660 {
1661 yyn = yytable_[yyn];
1662 if (0 < yyn)
1663 break;
1664 }
1665 }
1666
1667 // Pop the current state because it cannot handle the error token.
1668 if (yystack_.size () == 1)
1669 YYABORT;
1670
1671 yyerror_range[1].location = yystack_[0].location;
1672 yy_destroy_ ("Error: popping", yystack_[0]);
1673 yypop_ ();
1674 YY_STACK_PRINT ();
1675 }
1676 {
1677 stack_symbol_type error_token;
1678
1679 yyerror_range[2].location = yyla.location;
1680 YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
1681
1682 // Shift the error token.
1683 error_token.state = state_type (yyn);
1684 yypush_ ("Shifting", YY_MOVE (error_token));
1685 }
1686 goto yynewstate;
1687
1688
1689 /*-------------------------------------.
1690 | yyacceptlab -- YYACCEPT comes here. |
1691 `-------------------------------------*/
1692 yyacceptlab:
1693 yyresult = 0;
1694 goto yyreturn;
1695
1696
1697 /*-----------------------------------.
1698 | yyabortlab -- YYABORT comes here. |
1699 `-----------------------------------*/
1700 yyabortlab:
1701 yyresult = 1;
1702 goto yyreturn;
1703
1704
1705 /*-----------------------------------------------------.
1706 | yyreturn -- parsing is finished, return the result. |
1707 `-----------------------------------------------------*/
1708 yyreturn:
1709 if (!yyla.empty ())
1710 yy_destroy_ ("Cleanup: discarding lookahead", yyla);
1711
1712 /* Do not reclaim the symbols of the rule whose action triggered
1713 this YYABORT or YYACCEPT. */
1714 yypop_ (yylen);
1715 YY_STACK_PRINT ();
1716 while (1 < yystack_.size ())
1717 {
1718 yy_destroy_ ("Cleanup: popping", yystack_[0]);
1719 yypop_ ();
1720 }
1721
1722 return yyresult;
1723 }
1724#if YY_EXCEPTIONS
1725 catch (...)
1726 {
1727 YYCDEBUG << "Exception caught: cleaning lookahead and stack\n";
1728 // Do not try to display the values of the reclaimed symbols,
1729 // as their printers might throw an exception.
1730 if (!yyla.empty ())
1731 yy_destroy_ (YY_NULLPTR, yyla);
1732
1733 while (1 < yystack_.size ())
1734 {
1735 yy_destroy_ (YY_NULLPTR, yystack_[0]);
1736 yypop_ ();
1737 }
1738 throw;
1739 }
1740#endif // YY_EXCEPTIONS
1741 }
1742
1743 void
1745 {
1746 error (yyexc.location, yyexc.what ());
1747 }
1748
1749 /* Return YYSTR after stripping away unnecessary quotes and
1750 backslashes, so that it's suitable for yyerror. The heuristic is
1751 that double-quoting is unnecessary unless the string contains an
1752 apostrophe, a comma, or backslash (other than backslash-backslash).
1753 YYSTR is taken from yytname. */
1754 std::string
1755 EvalParser::yytnamerr_ (const char *yystr)
1756 {
1757 if (*yystr == '"')
1758 {
1759 std::string yyr;
1760 char const *yyp = yystr;
1761
1762 for (;;)
1763 switch (*++yyp)
1764 {
1765 case '\'':
1766 case ',':
1767 goto do_not_strip_quotes;
1768
1769 case '\\':
1770 if (*++yyp != '\\')
1771 goto do_not_strip_quotes;
1772 else
1773 goto append;
1774
1775 append:
1776 default:
1777 yyr += *yyp;
1778 break;
1779
1780 case '"':
1781 return yyr;
1782 }
1783 do_not_strip_quotes: ;
1784 }
1785
1786 return yystr;
1787 }
1788
1789 std::string
1791 {
1792 return yytnamerr_ (yytname_[yysymbol]);
1793 }
1794
1795
1796
1797 // EvalParser::context.
1799 : yyparser_ (yyparser)
1800 , yyla_ (yyla)
1801 {}
1802
1803 int
1805 {
1806 // Actual number of expected tokens
1807 int yycount = 0;
1808
1809 const int yyn = yypact_[+yyparser_.yystack_[0].state];
1810 if (!yy_pact_value_is_default_ (yyn))
1811 {
1812 /* Start YYX at -YYN if negative to avoid negative indexes in
1813 YYCHECK. In other words, skip the first -YYN actions for
1814 this state because they are default actions. */
1815 const int yyxbegin = yyn < 0 ? -yyn : 0;
1816 // Stay within bounds of both yycheck and yytname.
1817 const int yychecklim = yylast_ - yyn + 1;
1818 const int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1819 for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
1820 if (yycheck_[yyx + yyn] == yyx && yyx != symbol_kind::S_YYerror
1821 && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
1822 {
1823 if (!yyarg)
1824 ++yycount;
1825 else if (yycount == yyargn)
1826 return 0;
1827 else
1828 yyarg[yycount++] = YY_CAST (symbol_kind_type, yyx);
1829 }
1830 }
1831
1832 if (yyarg && yycount == 0 && 0 < yyargn)
1833 yyarg[0] = symbol_kind::S_YYEMPTY;
1834 return yycount;
1835 }
1836
1837
1838
1839
1840
1841
1842 int
1843 EvalParser::yy_syntax_error_arguments_ (const context& yyctx,
1844 symbol_kind_type yyarg[], int yyargn) const
1845 {
1846 /* There are many possibilities here to consider:
1847 - If this state is a consistent state with a default action, then
1848 the only way this function was invoked is if the default action
1849 is an error action. In that case, don't check for expected
1850 tokens because there are none.
1851 - The only way there can be no lookahead present (in yyla) is
1852 if this state is a consistent state with a default action.
1853 Thus, detecting the absence of a lookahead is sufficient to
1854 determine that there is no unexpected or expected token to
1855 report. In that case, just report a simple "syntax error".
1856 - Don't assume there isn't a lookahead just because this state is
1857 a consistent state with a default action. There might have
1858 been a previous inconsistent state, consistent state with a
1859 non-default action, or user semantic action that manipulated
1860 yyla. (However, yyla is currently not documented for users.)
1861 - Of course, the expected token list depends on states to have
1862 correct lookahead information, and it depends on the parser not
1863 to perform extra reductions after fetching a lookahead from the
1864 scanner and before detecting a syntax error. Thus, state merging
1865 (from LALR or IELR) and default reductions corrupt the expected
1866 token list. However, the list is correct for canonical LR with
1867 one exception: it will still contain any token that will not be
1868 accepted due to an error action in a later state.
1869 */
1870
1871 if (!yyctx.lookahead ().empty ())
1872 {
1873 if (yyarg)
1874 yyarg[0] = yyctx.token ();
1875 int yyn = yyctx.expected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn - 1);
1876 return yyn + 1;
1877 }
1878 return 0;
1879 }
1880
1881 // Generate an error message.
1882 std::string
1883 EvalParser::yysyntax_error_ (const context& yyctx) const
1884 {
1885 // Its maximum.
1886 enum { YYARGS_MAX = 5 };
1887 // Arguments of yyformat.
1888 symbol_kind_type yyarg[YYARGS_MAX];
1889 int yycount = yy_syntax_error_arguments_ (yyctx, yyarg, YYARGS_MAX);
1890
1891 char const* yyformat = YY_NULLPTR;
1892 switch (yycount)
1893 {
1894#define YYCASE_(N, S) \
1895 case N: \
1896 yyformat = S; \
1897 break
1898 default: // Avoid compiler warnings.
1899 YYCASE_ (0, YY_("syntax error"));
1900 YYCASE_ (1, YY_("syntax error, unexpected %s"));
1901 YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s"));
1902 YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1903 YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1904 YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1905#undef YYCASE_
1906 }
1907
1908 std::string yyres;
1909 // Argument number.
1910 std::ptrdiff_t yyi = 0;
1911 for (char const* yyp = yyformat; *yyp; ++yyp)
1912 if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
1913 {
1914 yyres += symbol_name (yyarg[yyi++]);
1915 ++yyp;
1916 }
1917 else
1918 yyres += *yyp;
1919 return yyres;
1920 }
1921
1922
1923 const short EvalParser::yypact_ninf_ = -149;
1924
1925 const signed char EvalParser::yytable_ninf_ = -1;
1926
1927 const short
1928 EvalParser::yypact_[] =
1929 {
1930 -16, 103, 149, 66, 103, 103, 87, 101, 102, 21,
1931 114, 121, 150, 161, 171, 178, 181, 195, 196, 203,
1932 210, 211, 212, 152, 72, 124, -149, -149, -149, -149,
1933 -149, 12, 39, -149, 149, 201, 202, 204, 165, 170,
1934 180, -149, 126, -1, -149, -34, 162, 163, 168, 98,
1935 51, 149, 149, 103, 149, 149, 149, 149, 149, 149,
1936 149, 149, 43, -38, 169, -38, 172, 103, 103, 149,
1937 149, 0, -34, 162, 163, -38, -38, -149, -149, -149,
1938 -149, 207, -149, 209, -149, 213, 216, -149, -149, -149,
1939 -149, -149, -149, -149, -149, -149, -149, -149, -149, -149,
1940 -149, -149, 69, 166, 29, 167, 1, 4, 5, 6,
1941 7, 10, 13, -149, -149, -149, -149, -149, 214, -149,
1942 215, -149, -149, 222, 180, -149, 217, 218, 219, 220,
1943 221, 223, 224, 225, -149, 173, 149, 149, 149, -149,
1944 -149, -149, -149, -149, -149, -149, 226, 227, 228, 229,
1945 230, 231, 232, 76, 91, 77, -149, 233, 22, 174,
1946 24, 9, 11, 79, 138, 90, 184, 241, 236, -149,
1947 -149, -149, -149, -149, -149, 237, -149, -149, -149, -13,
1948 -149, 149, -149, -149, 238, 239, -149, 240, 242, 243,
1949 162, 162, -149, -149, 235, 26, 197, 162, 162, 162,
1950 162, 244, 245, -149, -149, 246, 247, 248, 249, 250,
1951 251, 253, -149, 254, 255, 256, 257, 148, 153, 158,
1952 138, 138, 138, -149, -149, -149, -149, -149, -149
1953 };
1954
1955 const signed char
1956 EvalParser::yydefact_[] =
1957 {
1958 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1959 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1960 0, 0, 0, 0, 0, 0, 18, 48, 19, 20,
1961 2, 4, 0, 46, 0, 0, 0, 0, 0, 0,
1962 3, 1, 0, 0, 6, 0, 0, 0, 0, 0,
1963 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1964 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1965 0, 0, 0, 0, 0, 0, 0, 5, 47, 49,
1966 50, 0, 51, 0, 54, 0, 0, 55, 56, 57,
1967 58, 25, 61, 62, 63, 64, 65, 66, 67, 68,
1968 69, 26, 0, 0, 0, 0, 0, 0, 0, 0,
1969 0, 0, 0, 70, 71, 27, 60, 59, 0, 42,
1970 0, 41, 7, 8, 9, 31, 0, 0, 0, 0,
1971 0, 0, 0, 0, 17, 0, 0, 0, 0, 34,
1972 35, 36, 37, 38, 39, 40, 0, 0, 0, 0,
1973 0, 0, 0, 0, 0, 0, 74, 0, 0, 0,
1974 0, 0, 0, 0, 0, 0, 0, 0, 0, 52,
1975 53, 10, 21, 12, 23, 0, 72, 73, 28, 0,
1976 30, 0, 33, 14, 44, 0, 15, 0, 0, 0,
1977 0, 0, 76, 75, 0, 0, 0, 0, 0, 0,
1978 0, 0, 0, 29, 32, 0, 0, 0, 0, 0,
1979 0, 0, 45, 0, 0, 0, 0, 0, 0, 0,
1980 0, 0, 0, 11, 22, 13, 24, 16, 43
1981 };
1982
1983 const short
1984 EvalParser::yypgoto_[] =
1985 {
1986 -149, -149, -149, 8, -2, -149, 187, -72, -148, 193,
1987 -149, -42, -149, -149, -149, -149, -149
1988 };
1989
1990 const unsigned char
1991 EvalParser::yydefgoto_[] =
1992 {
1993 0, 3, 30, 31, 32, 33, 81, 83, 172, 85,
1994 91, 118, 101, 115, 178, 157, 194
1995 };
1996
1997 const unsigned char
1998 EvalParser::yytable_[] =
1999 {
2000 40, 127, 43, 78, 78, 139, 174, 69, 140, 141,
2001 142, 143, 42, 44, 144, 116, 174, 145, 67, 68,
2002 185, 117, 192, 120, 48, 79, 180, 80, 182, 183,
2003 204, 186, 71, 129, 130, 67, 68, 70, 70, 70,
2004 1, 2, 70, 70, 70, 70, 193, 69, 70, 102,
2005 103, 70, 105, 106, 107, 108, 109, 110, 111, 112,
2006 70, 104, 70, 184, 70, 137, 41, 124, 125, 224,
2007 226, 228, 224, 226, 228, 122, 123, 70, 92, 93,
2008 94, 95, 96, 97, 98, 168, 175, 63, 187, 64,
2009 176, 177, 113, 114, 169, 170, 171, 169, 170, 188,
2010 99, 100, 45, 176, 177, 135, 4, 70, 5, 169,
2011 170, 173, 6, 7, 8, 9, 46, 47, 201, 202,
2012 87, 88, 89, 90, 10, 206, 207, 208, 209, 11,
2013 77, 49, 67, 68, 158, 159, 160, 12, 50, 65,
2014 13, 66, 14, 15, 16, 17, 18, 19, 20, 21,
2015 22, 23, 34, 51, 24, 25, 169, 170, 35, 36,
2016 37, 26, 27, 28, 52, 29, 169, 170, 223, 62,
2017 10, 169, 170, 225, 53, 11, 169, 170, 227, 195,
2018 75, 54, 64, 12, 55, 76, 13, 66, 14, 15,
2019 16, 17, 18, 19, 20, 21, 22, 23, 56, 57,
2020 38, 39, 136, 138, 70, 70, 58, 26, 27, 28,
2021 181, 29, 70, 59, 60, 61, 72, 73, 70, 74,
2022 134, 82, 84, 131, 119, 132, 86, 121, 67, 133,
2023 146, 147, 156, 148, 149, 150, 151, 152, 184, 203,
2024 153, 154, 155, 161, 162, 163, 164, 165, 166, 167,
2025 189, 190, 191, 196, 197, 198, 205, 199, 200, 126,
2026 210, 211, 212, 213, 214, 215, 216, 128, 217, 179,
2027 218, 219, 220, 221, 222
2028 };
2029
2030 const unsigned char
2031 EvalParser::yycheck_[] =
2032 {
2033 2, 73, 4, 4, 4, 4, 154, 8, 4, 4,
2034 4, 4, 4, 5, 4, 53, 164, 4, 6, 7,
2035 9, 59, 35, 65, 3, 59, 4, 61, 4, 20,
2036 4, 20, 34, 75, 76, 6, 7, 38, 38, 38,
2037 56, 57, 38, 38, 38, 38, 59, 8, 38, 51,
2038 52, 38, 54, 55, 56, 57, 58, 59, 60, 61,
2039 38, 53, 38, 54, 38, 36, 0, 69, 70, 217,
2040 218, 219, 220, 221, 222, 67, 68, 38, 27, 28,
2041 29, 30, 31, 32, 33, 9, 9, 15, 9, 17,
2042 13, 14, 49, 50, 18, 19, 20, 18, 19, 9,
2043 49, 50, 15, 13, 14, 36, 3, 38, 5, 18,
2044 19, 20, 9, 10, 11, 12, 15, 15, 190, 191,
2045 22, 23, 24, 25, 21, 197, 198, 199, 200, 26,
2046 4, 17, 6, 7, 136, 137, 138, 34, 17, 15,
2047 37, 17, 39, 40, 41, 42, 43, 44, 45, 46,
2048 47, 48, 3, 3, 51, 52, 18, 19, 9, 10,
2049 11, 58, 59, 60, 3, 62, 18, 19, 20, 17,
2050 21, 18, 19, 20, 3, 26, 18, 19, 20, 181,
2051 15, 3, 17, 34, 3, 15, 37, 17, 39, 40,
2052 41, 42, 43, 44, 45, 46, 47, 48, 3, 3,
2053 51, 52, 36, 36, 38, 38, 3, 58, 59, 60,
2054 36, 62, 38, 3, 3, 3, 15, 15, 38, 15,
2055 4, 59, 59, 16, 55, 16, 58, 55, 6, 16,
2056 16, 16, 59, 16, 16, 16, 16, 16, 54, 4,
2057 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
2058 9, 15, 15, 15, 15, 15, 59, 15, 15, 72,
2059 16, 16, 16, 16, 16, 16, 16, 74, 17, 36,
2060 17, 17, 17, 17, 17
2061 };
2062
2063 const signed char
2064 EvalParser::yystos_[] =
2065 {
2066 0, 56, 57, 64, 3, 5, 9, 10, 11, 12,
2067 21, 26, 34, 37, 39, 40, 41, 42, 43, 44,
2068 45, 46, 47, 48, 51, 52, 58, 59, 60, 62,
2069 65, 66, 67, 68, 3, 9, 10, 11, 51, 52,
2070 67, 0, 66, 67, 66, 15, 15, 15, 3, 17,
2071 17, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2072 3, 3, 17, 15, 17, 15, 17, 6, 7, 8,
2073 38, 67, 15, 15, 15, 15, 15, 4, 4, 59,
2074 61, 69, 59, 70, 59, 72, 58, 22, 23, 24,
2075 25, 73, 27, 28, 29, 30, 31, 32, 33, 49,
2076 50, 75, 67, 67, 66, 67, 67, 67, 67, 67,
2077 67, 67, 67, 49, 50, 76, 53, 59, 74, 55,
2078 74, 55, 66, 66, 67, 67, 69, 70, 72, 74,
2079 74, 16, 16, 16, 4, 36, 36, 36, 36, 4,
2080 4, 4, 4, 4, 4, 4, 16, 16, 16, 16,
2081 16, 16, 16, 17, 17, 17, 59, 78, 67, 67,
2082 67, 17, 17, 17, 17, 17, 17, 17, 9, 18,
2083 19, 20, 71, 20, 71, 9, 13, 14, 77, 36,
2084 4, 36, 4, 20, 54, 9, 20, 9, 9, 9,
2085 15, 15, 35, 59, 79, 67, 15, 15, 15, 15,
2086 15, 70, 70, 4, 4, 59, 70, 70, 70, 70,
2087 16, 16, 16, 16, 16, 16, 16, 17, 17, 17,
2088 17, 17, 17, 20, 71, 20, 71, 20, 71
2089 };
2090
2091 const signed char
2092 EvalParser::yyr1_[] =
2093 {
2094 0, 63, 64, 64, 65, 66, 66, 66, 66, 66,
2095 66, 66, 66, 66, 66, 66, 66, 66, 67, 67,
2096 67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
2097 67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
2098 67, 67, 67, 67, 67, 67, 67, 67, 68, 69,
2099 69, 70, 71, 71, 72, 73, 73, 73, 73, 74,
2100 74, 75, 75, 75, 75, 75, 75, 75, 75, 75,
2101 76, 76, 77, 77, 78, 79, 79
2102 };
2103
2104 const signed char
2105 EvalParser::yyr2_[] =
2106 {
2107 0, 2, 2, 2, 1, 3, 2, 3, 3, 3,
2108 6, 11, 6, 11, 6, 6, 11, 4, 1, 1,
2109 1, 6, 11, 6, 11, 3, 3, 3, 6, 8,
2110 6, 3, 8, 6, 4, 4, 4, 4, 4, 4,
2111 4, 3, 3, 11, 6, 9, 1, 3, 1, 1,
2112 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2113 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2114 1, 1, 1, 1, 1, 1, 1
2115 };
2116
2117
2118#if EVALDEBUG || 1
2119 // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2120 // First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
2121 const char*
2122 const EvalParser::yytname_[] =
2123 {
2124 "\"end of file\"", "error", "\"invalid token\"", "\"(\"", "\")\"",
2125 "\"not\"", "\"and\"", "\"or\"", "\"==\"", "\"option\"", "\"relay4\"",
2126 "\"relay6\"", "\"member\"", "\"peeraddr\"", "\"linkaddr\"", "\"[\"",
2127 "\"]\"", "\".\"", "\"text\"", "\"hex\"", "\"exists\"", "\"pkt\"",
2128 "\"iface\"", "\"src\"", "\"dst\"", "\"len\"", "\"pkt4\"", "\"mac\"",
2129 "\"hlen\"", "\"htype\"", "\"ciaddr\"", "\"giaddr\"", "\"yiaddr\"",
2130 "\"siaddr\"", "\"substring\"", "\"all\"", "\",\"", "\"concat\"", "\"+\"",
2131 "\"ifelse\"", "\"hexstring\"", "\"addrtotext\"", "\"int8totext\"",
2132 "\"int16totext\"", "\"int32totext\"", "\"uint8totext\"",
2133 "\"uint16totext\"", "\"uint32totext\"", "\"pkt6\"", "\"msgtype\"",
2134 "\"transid\"", "\"vendor-class\"", "\"vendor\"", "\"*\"", "\"data\"",
2135 "\"enterprise\"", "\"top-level bool\"", "\"top-level string\"",
2136 "\"constant string\"", "\"integer\"", "\"constant hexstring\"",
2137 "\"option name\"", "\"ip address\"", "$accept", "start", "expression",
2138 "bool_expr", "string_expr", "integer_expr", "option_code",
2139 "sub_option_code", "option_repr_type", "nest_level", "pkt_metadata",
2140 "enterprise_id", "pkt4_field", "pkt6_field", "relay6_field",
2141 "start_expr", "length_expr", YY_NULLPTR
2142 };
2143#endif
2144
2145
2146#if EVALDEBUG
2147 const short
2148 EvalParser::yyrline_[] =
2149 {
2150 0, 130, 130, 131, 136, 139, 140, 145, 150, 155,
2151 160, 165, 170, 190, 204, 213, 222, 232, 249, 254,
2152 259, 264, 269, 274, 295, 310, 315, 329, 343, 358,
2153 363, 368, 373, 378, 383, 388, 393, 398, 403, 408,
2154 413, 418, 427, 437, 446, 459, 472, 477, 480, 486,
2155 490, 496, 502, 506, 512, 521, 525, 529, 533, 539,
2156 543, 549, 553, 557, 561, 565, 569, 573, 577, 581,
2157 587, 591, 597, 601, 607, 614, 619
2158 };
2159
2160 void
2161 EvalParser::yy_stack_print_ () const
2162 {
2163 *yycdebug_ << "Stack now";
2164 for (stack_type::const_iterator
2165 i = yystack_.begin (),
2166 i_end = yystack_.end ();
2167 i != i_end; ++i)
2168 *yycdebug_ << ' ' << int (i->state);
2169 *yycdebug_ << '\n';
2170 }
2171
2172 void
2173 EvalParser::yy_reduce_print_ (int yyrule) const
2174 {
2175 int yylno = yyrline_[yyrule];
2176 int yynrhs = yyr2_[yyrule];
2177 // Print the symbols being reduced, and their result.
2178 *yycdebug_ << "Reducing stack by rule " << yyrule - 1
2179 << " (line " << yylno << "):\n";
2180 // The symbols being reduced.
2181 for (int yyi = 0; yyi < yynrhs; yyi++)
2182 YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
2183 yystack_[(yynrhs) - (yyi + 1)]);
2184 }
2185#endif // EVALDEBUG
2186
2187
2188#line 14 "parser.yy"
2189} } // isc::eval
2190#line 2191 "parser.cc"
2191
2192#line 626 "parser.yy"
2193
2194void
2196 const std::string& what)
2197{
2198 ctx.error(loc, what);
2199}
#define YY_RVREF(Type)
Definition: agent_parser.h:85
#define YY_CAST(Type, Val)
Definition: agent_parser.h:177
#define YY_MOVE_REF(Type)
Definition: agent_parser.h:84
#define YY_NOEXCEPT
Definition: agent_parser.h:94
#define YY_MOVE
Definition: agent_parser.h:82
#define YY_NOTHROW
Definition: agent_parser.h:95
#define YY_USE(E)
Definition: agent_parser.h:130
Token that represents logical and operator.
Definition: token.h:920
Token that represents concat operator (concatenates two other tokens)
Definition: token.h:803
Token that represents equality operator (compares two other tokens)
Definition: token.h:721
Token representing a constant string in hexadecimal format.
Definition: token.h:137
Token that represents an alternative.
Definition: token.h:831
Token representing a 16 bit integer as a string.
Definition: token.h:249
Token representing a 32 bit integer as a string.
Definition: token.h:267
Token representing an 8 bit integer as a string.
Definition: token.h:231
Token representing an unsigned 32 bit integer.
Definition: token.h:164
Token representing an IP address as a string.
Definition: token.h:214
Token representing an IP address as a constant string.
Definition: token.h:191
Token that represents client class membership.
Definition: token.h:970
Token that represents logical negation operator.
Definition: token.h:896
Token that represents a value of an option.
Definition: token.h:344
RepresentationType
Token representation type.
Definition: token.h:354
Token that represents logical or operator.
Definition: token.h:945
Token that represents fields of a DHCPv4 packet.
Definition: token.h:559
FieldType
enum value that determines the field.
Definition: token.h:563
Token that represents fields of DHCPv6 packet.
Definition: token.h:613
FieldType
enum value that determines the field.
Definition: token.h:616
Token that represents meta data of a DHCP packet.
Definition: token.h:509
MetadataType
enum value that determines the field.
Definition: token.h:513
Represents a sub-option inserted by the DHCPv4 relay.
Definition: token.h:435
Token that represents a value of a field within a DHCPv6 relay encapsulation.
Definition: token.h:664
FieldType
enum value that determines the field.
Definition: token.h:668
Token that represents a value of an option within a DHCPv6 relay encapsulation.
Definition: token.h:467
The order where Token subtypes are declared should be:
Definition: token.h:114
Token that represents sub-options in DHCPv4 and DHCPv6.
Definition: token.h:1197
Token that represents the substring operator (returns a portion of the supplied string)
Definition: token.h:746
Token that converts to hexadecimal string.
Definition: token.h:861
Token representing a 16 bit unsigned integer as a string.
Definition: token.h:303
Token representing a 32 bit unsigned integer as a string.
Definition: token.h:321
Token representing an 8 bit unsigned integer as a string.
Definition: token.h:285
Token that represents vendor class options in DHCPv4 and DHCPv6.
Definition: token.h:1130
Token that represents vendor options in DHCPv4 and DHCPv6.
Definition: token.h:1015
Evaluation context, an interface to the expression evaluation.
Definition: eval_context.h:34
int8_t convertNestLevelNumber(const std::string &nest_level, const isc::eval::location &loc)
Nest level conversion.
uint16_t convertOptionCode(const std::string &option_code, const isc::eval::location &loc)
Option code conversion.
Definition: eval_context.cc:65
uint16_t convertOptionName(const std::string &option_name, const isc::eval::location &loc)
Option name conversion.
Definition: eval_context.cc:89
isc::dhcp::Expression expression
Parsed expression (output tokens are stored here)
Definition: eval_context.h:67
Option::Universe getUniverse()
Returns the universe (v4 or v6)
Definition: eval_context.h:218
static uint32_t convertUint32(const std::string &number, const isc::eval::location &loc)
Attempts to convert string to unsigned 32bit integer.
bool isClientClassDefined(const ClientClass &client_class)
Check if a client class is already defined.
static uint8_t convertUint8(const std::string &number, const isc::eval::location &loc)
Attempts to convert string to unsigned 8bit integer.
const symbol_type & lookahead() const YY_NOEXCEPT
Definition: parser.h:2074
int expected_tokens(symbol_kind_type yyarg[], int yyargn) const
Put in YYARG at most YYARGN of the expected tokens, and return the number of tokens stored in YYARG.
Definition: parser.cc:1804
context(const EvalParser &yyparser, const symbol_type &yyla)
Definition: parser.cc:1798
symbol_kind_type token() const YY_NOEXCEPT
Definition: parser.h:2075
Present a slice of the top of a stack.
Definition: parser.h:2341
A Bison parser.
Definition: parser.h:215
symbol_kind::symbol_kind_type symbol_kind_type
(Internal) symbol kind.
Definition: parser.h:673
debug_level_type debug_level() const YY_ATTRIBUTE_PURE
The current debugging level.
Definition: parser.cc:598
int operator()()
Parse.
Definition: parser.cc:633
virtual int parse()
Parse.
Definition: parser.cc:639
int debug_level_type
Type for debugging levels.
Definition: parser.h:1103
location location_type
Symbol locations.
Definition: parser.h:482
void set_debug_stream(std::ostream &)
Set the current debugging stream.
Definition: parser.cc:591
void set_debug_level(debug_level_type l)
Set the current debugging level.
Definition: parser.cc:604
std::ostream & debug_stream() const YY_ATTRIBUTE_PURE
The current debugging stream.
Definition: parser.cc:585
virtual ~EvalParser()
Definition: parser.cc:157
EvalParser(EvalContext &ctx_yyarg)
Build a parser object.
Definition: parser.cc:147
static const symbol_kind_type YYNTOKENS
The number of tokens.
Definition: parser.h:676
virtual void error(const location_type &loc, const std::string &msg)
Report a syntax error.
Definition: parser.cc:2195
static std::string symbol_name(symbol_kind_type yysymbol)
The user-facing name of the symbol whose (internal) number is YYSYMBOL.
Definition: parser.cc:1790
boost::shared_ptr< Token > TokenPtr
Pointer to a single Token.
Definition: token.h:17
Defines the logger used by the top-level component of kea-lfc.
#define YYCDEBUG
Definition: parser.cc:101
#define YYABORT
Definition: parser.cc:138
#define YYLLOC_DEFAULT(Current, Rhs, N)
Definition: parser.cc:82
#define YY_REDUCE_PRINT(Rule)
Definition: parser.cc:113
#define YY_SYMBOL_PRINT(Title, Symbol)
Definition: parser.cc:103
#define yylex
Definition: parser.cc:39
#define YYCASE_(N, S)
#define YY_STACK_PRINT()
Definition: parser.cc:119
#define YY_(msgid)
Definition: parser.cc:62
#define YYACCEPT
Definition: parser.cc:137
#define YYERROR
Definition: parser.cc:139
Define the isc::eval::parser class.
void move(basic_symbol &s)
Destructive move, s is emptied into this.
Definition: parser.h:2540
location_type location
The location.
Definition: parser.h:988
bool empty() const YY_NOEXCEPT
Whether empty.
Definition: parser.h:2533
void clear() YY_NOEXCEPT
Destroy contents, and record that is empty.
Definition: parser.h:905
"External" symbols: returned by the scanner.
Definition: parser.h:1042
Syntax errors thrown from user actions.
Definition: parser.h:486
~syntax_error() YY_NOEXCEPT YY_NOTHROW
Definition: parser.cc:160