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