Kea 2.7.6
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 135 "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 135 "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 135 "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 135 "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 135 "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 135 "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 135 "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 135 "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 135 "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 135 "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 135 "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 135 "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 135 "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 135 "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 135 "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. */
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
784 break;
785
786 case symbol_kind::S_pkt4_field: // pkt4_field
788 break;
789
790 case symbol_kind::S_pkt6_field: // pkt6_field
792 break;
793
794 case symbol_kind::S_pkt_metadata: // pkt_metadata
796 break;
797
798 case symbol_kind::S_relay6_field: // relay6_field
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 155 "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: // $@1: %empty
854#line 160 "parser.yy"
855 {
856 unsigned target = ++ctx.label_;
857 ctx.labels_.push_back(target);
858 TokenPtr pobf(new TokenPopOrBranchFalse(target));
859 ctx.expression_.push_back(pobf);
860 }
861#line 862 "parser.cc"
862 break;
863
864 case 8: // bool_expr: bool_expr "and" $@1 bool_expr
865#line 165 "parser.yy"
866 {
867 unsigned target = ctx.labels_.back();
868 ctx.labels_.pop_back();
869 TokenPtr lab(new TokenLabel(target));
870 ctx.expression_.push_back(lab);
871 }
872#line 873 "parser.cc"
873 break;
874
875 case 9: // bool_expr: bool_expr "sand" bool_expr
876#line 172 "parser.yy"
877 {
878 TokenPtr neg(new TokenAnd());
879 ctx.expression_.push_back(neg);
880 }
881#line 882 "parser.cc"
882 break;
883
884 case 10: // $@2: %empty
885#line 177 "parser.yy"
886 {
887 unsigned target = ++ctx.label_;
888 ctx.labels_.push_back(target);
889 TokenPtr pobt(new TokenPopOrBranchTrue(target));
890 ctx.expression_.push_back(pobt);
891 }
892#line 893 "parser.cc"
893 break;
894
895 case 11: // bool_expr: bool_expr "or" $@2 bool_expr
896#line 182 "parser.yy"
897 {
898 unsigned target = ctx.labels_.back();
899 ctx.labels_.pop_back();
900 TokenPtr lab(new TokenLabel(target));
901 ctx.expression_.push_back(lab);
902 }
903#line 904 "parser.cc"
904 break;
905
906 case 12: // bool_expr: bool_expr "sor" bool_expr
907#line 189 "parser.yy"
908 {
909 TokenPtr neg(new TokenOr());
910 ctx.expression_.push_back(neg);
911 }
912#line 913 "parser.cc"
913 break;
914
915 case 13: // bool_expr: string_expr "==" string_expr
916#line 194 "parser.yy"
917 {
918 TokenPtr eq(new TokenEqual());
919 ctx.expression_.push_back(eq);
920 }
921#line 922 "parser.cc"
922 break;
923
924 case 14: // bool_expr: "option" "[" option_code "]" "." "exists"
925#line 199 "parser.yy"
926 {
927 TokenPtr opt(new TokenOption(yystack_[3].value.as < uint16_t > (), TokenOption::EXISTS));
928 ctx.expression_.push_back(opt);
929 }
930#line 931 "parser.cc"
931 break;
932
933 case 15: // bool_expr: "option" "[" option_code "]" "." "option" "[" sub_option_code "]" "." "exists"
934#line 204 "parser.yy"
935 {
936 TokenPtr opt(new TokenSubOption(yystack_[8].value.as < uint16_t > (), yystack_[3].value.as < uint16_t > (), TokenOption::EXISTS));
937 ctx.expression_.push_back(opt);
938 }
939#line 940 "parser.cc"
940 break;
941
942 case 16: // bool_expr: "relay4" "[" sub_option_code "]" "." "exists"
943#line 209 "parser.yy"
944 {
945 switch (ctx.getUniverse()) {
946 case Option::V4:
947 {
948 TokenPtr opt(new TokenRelay4Option(yystack_[3].value.as < uint16_t > (), TokenOption::EXISTS));
949 ctx.expression_.push_back(opt);
950 break;
951 }
952 case Option::V6:
953 // We will have relay6[123] for the DHCPv6.
954 // In a very distant future we'll possibly be able
955 // to mix both if we have DHCPv4-over-DHCPv6, so it
956 // has some sense to make it explicit whether we
957 // talk about DHCPv4 relay or DHCPv6 relay. However,
958 // for the time being relay4 can be used in DHCPv4
959 // only.
960 error(yystack_[5].location, "relay4 can only be used in DHCPv4.");
961 }
962 }
963#line 964 "parser.cc"
964 break;
965
966 case 17: // bool_expr: "relay6" "[" nest_level "]" "." "option" "[" sub_option_code "]" "." "exists"
967#line 229 "parser.yy"
968 {
969 switch (ctx.getUniverse()) {
970 case Option::V6:
971 {
972 TokenPtr opt(new TokenRelay6Option(yystack_[8].value.as < int8_t > (), yystack_[3].value.as < uint16_t > (), TokenOption::EXISTS));
973 ctx.expression_.push_back(opt);
974 break;
975 }
976 case Option::V4:
977 // For now we only use relay6 in DHCPv6.
978 error(yystack_[10].location, "relay6 can only be used in DHCPv6.");
979 }
980 }
981#line 982 "parser.cc"
982 break;
983
984 case 18: // bool_expr: "vendor-class" "[" enterprise_id "]" "." "exists"
985#line 243 "parser.yy"
986 {
987 // Expression: vendor-class[1234].exists
988 //
989 // This token will find option 124 (DHCPv4) or 16 (DHCPv6),
990 // and will check if enterprise-id equals specified value.
991 TokenPtr exist(new TokenVendorClass(ctx.getUniverse(), yystack_[3].value.as < uint32_t > (), TokenOption::EXISTS));
992 ctx.expression_.push_back(exist);
993 }
994#line 995 "parser.cc"
995 break;
996
997 case 19: // bool_expr: "vendor" "[" enterprise_id "]" "." "exists"
998#line 252 "parser.yy"
999 {
1000 // Expression: vendor[1234].exists
1001 //
1002 // This token will find option 125 (DHCPv4) or 17 (DHCPv6),
1003 // and will check if enterprise-id equals specified value.
1004 TokenPtr exist(new TokenVendor(ctx.getUniverse(), yystack_[3].value.as < uint32_t > (), TokenOption::EXISTS));
1005 ctx.expression_.push_back(exist);
1006 }
1007#line 1008 "parser.cc"
1008 break;
1009
1010 case 20: // bool_expr: "vendor" "[" enterprise_id "]" "." "option" "[" sub_option_code "]" "." "exists"
1011#line 261 "parser.yy"
1012 {
1013 // Expression vendor[1234].option[123].exists
1014 //
1015 // This token will check if specified vendor option
1016 // exists, has specified enterprise-id and if has
1017 // specified suboption.
1018 TokenPtr exist(new TokenVendor(ctx.getUniverse(), yystack_[8].value.as < uint32_t > (), TokenOption::EXISTS, yystack_[3].value.as < uint16_t > ()));
1019 ctx.expression_.push_back(exist);
1020 }
1021#line 1022 "parser.cc"
1022 break;
1023
1024 case 21: // bool_expr: "member" "(" "constant string" ")"
1025#line 271 "parser.yy"
1026 {
1027 // Expression member('foo')
1028 //
1029 // This token will check if the packet is a member of
1030 // the specified client class.
1031 // To avoid loops at evaluation only already defined and
1032 // built-in classes are allowed.
1033 std::string cc = yystack_[1].value.as < std::string > ();
1034 if (!ctx.isClientClassDefined(cc)) {
1035 error(yystack_[1].location, "Not defined client class '" + cc + "'");
1036 }
1037 TokenPtr member(new TokenMember(cc));
1038 ctx.expression_.push_back(member);
1039 }
1040#line 1041 "parser.cc"
1041 break;
1042
1043 case 22: // bool_expr: "match" "(" "constant string" "," string_expr ")"
1044#line 286 "parser.yy"
1045 {
1046 // Expression match('<regex>', <string_expr>)
1047 //
1048 // This token will check if the regular expression matches
1049 // the string expression.
1050 TokenPtr match(new TokenMatch(yystack_[3].value.as < std::string > ()));
1051 ctx.expression_.push_back(match);
1052 }
1053#line 1054 "parser.cc"
1054 break;
1055
1056 case 23: // string_expr: "constant string"
1057#line 297 "parser.yy"
1058 {
1059 TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ()));
1060 ctx.expression_.push_back(str);
1061 }
1062#line 1063 "parser.cc"
1063 break;
1064
1065 case 24: // string_expr: "constant hexstring"
1066#line 302 "parser.yy"
1067 {
1068 TokenPtr hex(new TokenHexString(yystack_[0].value.as < std::string > ()));
1069 ctx.expression_.push_back(hex);
1070 }
1071#line 1072 "parser.cc"
1072 break;
1073
1074 case 25: // string_expr: "ip address"
1075#line 307 "parser.yy"
1076 {
1077 TokenPtr ip(new TokenIpAddress(yystack_[0].value.as < std::string > ()));
1078 ctx.expression_.push_back(ip);
1079 }
1080#line 1081 "parser.cc"
1081 break;
1082
1083 case 26: // string_expr: "option" "[" option_code "]" "." option_repr_type
1084#line 312 "parser.yy"
1085 {
1086 TokenPtr opt(new TokenOption(yystack_[3].value.as < uint16_t > (), yystack_[0].value.as < TokenOption::RepresentationType > ()));
1087 ctx.expression_.push_back(opt);
1088 }
1089#line 1090 "parser.cc"
1090 break;
1091
1092 case 27: // string_expr: "option" "[" option_code "]" "." "option" "[" sub_option_code "]" "." option_repr_type
1093#line 317 "parser.yy"
1094 {
1095 TokenPtr opt(new TokenSubOption(yystack_[8].value.as < uint16_t > (), yystack_[3].value.as < uint16_t > (), yystack_[0].value.as < TokenOption::RepresentationType > ()));
1096 ctx.expression_.push_back(opt);
1097 }
1098#line 1099 "parser.cc"
1099 break;
1100
1101 case 28: // string_expr: "relay4" "[" sub_option_code "]" "." option_repr_type
1102#line 322 "parser.yy"
1103 {
1104 switch (ctx.getUniverse()) {
1105 case Option::V4:
1106 {
1107 TokenPtr opt(new TokenRelay4Option(yystack_[3].value.as < uint16_t > (), yystack_[0].value.as < TokenOption::RepresentationType > ()));
1108 ctx.expression_.push_back(opt);
1109 break;
1110 }
1111 case Option::V6:
1112 // We will have relay6[123] for the DHCPv6.
1113 // In a very distant future we'll possibly be able
1114 // to mix both if we have DHCPv4-over-DHCPv6, so it
1115 // has some sense to make it explicit whether we
1116 // talk about DHCPv4 relay or DHCPv6 relay. However,
1117 // for the time being relay4 can be used in DHCPv4
1118 // only.
1119 error(yystack_[5].location, "relay4 can only be used in DHCPv4.");
1120 }
1121 }
1122#line 1123 "parser.cc"
1123 break;
1124
1125 case 29: // string_expr: "relay6" "[" nest_level "]" "." "option" "[" sub_option_code "]" "." option_repr_type
1126#line 343 "parser.yy"
1127 {
1128 switch (ctx.getUniverse()) {
1129 case Option::V6:
1130 {
1131 TokenPtr opt(new TokenRelay6Option(yystack_[8].value.as < int8_t > (), yystack_[3].value.as < uint16_t > (), yystack_[0].value.as < TokenOption::RepresentationType > ()));
1132 ctx.expression_.push_back(opt);
1133 break;
1134 }
1135 case Option::V4:
1136 // For now we only use relay6 in DHCPv6.
1137 error(yystack_[10].location, "relay6 can only be used in DHCPv6.");
1138 }
1139 }
1140#line 1141 "parser.cc"
1141 break;
1142
1143 case 30: // string_expr: "pkt" "." pkt_metadata
1144#line 358 "parser.yy"
1145 {
1146 TokenPtr pkt_metadata(new TokenPkt(yystack_[0].value.as < TokenPkt::MetadataType > ()));
1147 ctx.expression_.push_back(pkt_metadata);
1148 }
1149#line 1150 "parser.cc"
1150 break;
1151
1152 case 31: // string_expr: "pkt4" "." pkt4_field
1153#line 363 "parser.yy"
1154 {
1155 switch (ctx.getUniverse()) {
1156 case Option::V4:
1157 {
1158 TokenPtr pkt4_field(new TokenPkt4(yystack_[0].value.as < TokenPkt4::FieldType > ()));
1159 ctx.expression_.push_back(pkt4_field);
1160 break;
1161 }
1162 case Option::V6:
1163 // For now we only use pkt4 in DHCPv4.
1164 error(yystack_[2].location, "pkt4 can only be used in DHCPv4.");
1165 }
1166 }
1167#line 1168 "parser.cc"
1168 break;
1169
1170 case 32: // string_expr: "pkt6" "." pkt6_field
1171#line 377 "parser.yy"
1172 {
1173 switch (ctx.getUniverse()) {
1174 case Option::V6:
1175 {
1176 TokenPtr pkt6_field(new TokenPkt6(yystack_[0].value.as < TokenPkt6::FieldType > ()));
1177 ctx.expression_.push_back(pkt6_field);
1178 break;
1179 }
1180 case Option::V4:
1181 // For now we only use pkt6 in DHCPv6.
1182 error(yystack_[2].location, "pkt6 can only be used in DHCPv6.");
1183 }
1184 }
1185#line 1186 "parser.cc"
1186 break;
1187
1188 case 33: // string_expr: "relay6" "[" nest_level "]" "." relay6_field
1189#line 391 "parser.yy"
1190 {
1191 switch (ctx.getUniverse()) {
1192 case Option::V6:
1193 {
1194 TokenPtr relay6field(new TokenRelay6Field(yystack_[3].value.as < int8_t > (), yystack_[0].value.as < TokenRelay6Field::FieldType > ()));
1195 ctx.expression_.push_back(relay6field);
1196 break;
1197 }
1198 case Option::V4:
1199 // For now we only use relay6 in DHCPv6.
1200 error(yystack_[5].location, "relay6 can only be used in DHCPv6.");
1201 }
1202 }
1203#line 1204 "parser.cc"
1204 break;
1205
1206 case 34: // string_expr: "substring" "(" string_expr "," start_expr "," length_expr ")"
1207#line 406 "parser.yy"
1208 {
1209 TokenPtr sub(new TokenSubstring());
1210 ctx.expression_.push_back(sub);
1211 }
1212#line 1213 "parser.cc"
1213 break;
1214
1215 case 35: // string_expr: "split" "(" string_expr "," string_expr "," int_expr ")"
1216#line 411 "parser.yy"
1217 {
1218 TokenPtr split(new TokenSplit());
1219 ctx.expression_.push_back(split);
1220 }
1221#line 1222 "parser.cc"
1222 break;
1223
1224 case 36: // string_expr: "concat" "(" string_expr "," string_expr ")"
1225#line 416 "parser.yy"
1226 {
1227 TokenPtr conc(new TokenConcat());
1228 ctx.expression_.push_back(conc);
1229 }
1230#line 1231 "parser.cc"
1231 break;
1232
1233 case 37: // string_expr: string_expr "+" string_expr
1234#line 421 "parser.yy"
1235 {
1236 TokenPtr conc(new TokenConcat());
1237 ctx.expression_.push_back(conc);
1238 }
1239#line 1240 "parser.cc"
1240 break;
1241
1242 case 38: // string_expr: "lcase" "(" string_expr ")"
1243#line 426 "parser.yy"
1244 {
1245 TokenPtr lcase(new TokenLowerCase());
1246 ctx.expression_.push_back(lcase);
1247 }
1248#line 1249 "parser.cc"
1249 break;
1250
1251 case 39: // string_expr: "ucase" "(" string_expr ")"
1252#line 431 "parser.yy"
1253 {
1254 TokenPtr ucase(new TokenUpperCase());
1255 ctx.expression_.push_back(ucase);
1256 }
1257#line 1258 "parser.cc"
1258 break;
1259
1260 case 40: // $@3: %empty
1261#line 436 "parser.yy"
1262 {
1263 unsigned target = ++ctx.label_;
1264 ctx.labels_.push_back(target);
1265 TokenPtr pabf(new TokenPopAndBranchFalse(target));
1266 ctx.expression_.push_back(pabf);
1267 }
1268#line 1269 "parser.cc"
1269 break;
1270
1271 case 41: // $@4: %empty
1272#line 441 "parser.yy"
1273 {
1274 unsigned target = ctx.labels_.back();
1275 ctx.labels_.pop_back();
1276 unsigned target2 = ++ctx.label_;
1277 ctx.labels_.push_back(target2);
1278 TokenPtr branch(new TokenBranch(target2));
1279 ctx.expression_.push_back(branch);
1280 TokenPtr lab(new TokenLabel(target));
1281 ctx.expression_.push_back(lab);
1282 }
1283#line 1284 "parser.cc"
1284 break;
1285
1286 case 42: // string_expr: "ifelse" "(" bool_expr "," $@3 string_expr "," $@4 string_expr ")"
1287#line 450 "parser.yy"
1288 {
1289 unsigned target = ctx.labels_.back();
1290 ctx.labels_.pop_back();
1291 TokenPtr lab(new TokenLabel(target));
1292 ctx.expression_.push_back(lab);
1293 }
1294#line 1295 "parser.cc"
1295 break;
1296
1297 case 43: // string_expr: "sifelse" "(" bool_expr "," string_expr "," string_expr ")"
1298#line 457 "parser.yy"
1299 {
1300 TokenPtr cond(new TokenIfElse());
1301 ctx.expression_.push_back(cond);
1302 }
1303#line 1304 "parser.cc"
1304 break;
1305
1306 case 44: // string_expr: "hexstring" "(" string_expr "," string_expr ")"
1307#line 462 "parser.yy"
1308 {
1309 TokenPtr tohex(new TokenToHexString());
1310 ctx.expression_.push_back(tohex);
1311 }
1312#line 1313 "parser.cc"
1313 break;
1314
1315 case 45: // string_expr: "addrtotext" "(" string_expr ")"
1316#line 467 "parser.yy"
1317 {
1318 TokenPtr addrtotext(new TokenIpAddressToText());
1319 ctx.expression_.push_back(addrtotext);
1320 }
1321#line 1322 "parser.cc"
1322 break;
1323
1324 case 46: // string_expr: "int8totext" "(" string_expr ")"
1325#line 472 "parser.yy"
1326 {
1327 TokenPtr int8totext(new TokenInt8ToText());
1328 ctx.expression_.push_back(int8totext);
1329 }
1330#line 1331 "parser.cc"
1331 break;
1332
1333 case 47: // string_expr: "int16totext" "(" string_expr ")"
1334#line 477 "parser.yy"
1335 {
1336 TokenPtr int16totext(new TokenInt16ToText());
1337 ctx.expression_.push_back(int16totext);
1338 }
1339#line 1340 "parser.cc"
1340 break;
1341
1342 case 48: // string_expr: "int32totext" "(" string_expr ")"
1343#line 482 "parser.yy"
1344 {
1345 TokenPtr int32totext(new TokenInt32ToText());
1346 ctx.expression_.push_back(int32totext);
1347 }
1348#line 1349 "parser.cc"
1349 break;
1350
1351 case 49: // string_expr: "uint8totext" "(" string_expr ")"
1352#line 487 "parser.yy"
1353 {
1354 TokenPtr uint8totext(new TokenUInt8ToText());
1355 ctx.expression_.push_back(uint8totext);
1356 }
1357#line 1358 "parser.cc"
1358 break;
1359
1360 case 50: // string_expr: "uint16totext" "(" string_expr ")"
1361#line 492 "parser.yy"
1362 {
1363 TokenPtr uint16totext(new TokenUInt16ToText());
1364 ctx.expression_.push_back(uint16totext);
1365 }
1366#line 1367 "parser.cc"
1367 break;
1368
1369 case 51: // string_expr: "uint32totext" "(" string_expr ")"
1370#line 497 "parser.yy"
1371 {
1372 TokenPtr uint32totext(new TokenUInt32ToText());
1373 ctx.expression_.push_back(uint32totext);
1374 }
1375#line 1376 "parser.cc"
1376 break;
1377
1378 case 52: // string_expr: "vendor" "." "enterprise"
1379#line 502 "parser.yy"
1380 {
1381 // expression: vendor.enterprise
1382 //
1383 // This token will return enterprise-id number of
1384 // received vendor option.
1386 ctx.expression_.push_back(vendor);
1387 }
1388#line 1389 "parser.cc"
1389 break;
1390
1391 case 53: // string_expr: "vendor-class" "." "enterprise"
1392#line 511 "parser.yy"
1393 {
1394 // expression: vendor-class.enterprise
1395 //
1396 // This token will return enterprise-id number of
1397 // received vendor class option.
1398 TokenPtr vendor(new TokenVendorClass(ctx.getUniverse(), 0,
1400 ctx.expression_.push_back(vendor);
1401 }
1402#line 1403 "parser.cc"
1403 break;
1404
1405 case 54: // string_expr: "vendor" "[" enterprise_id "]" "." "option" "[" sub_option_code "]" "." option_repr_type
1406#line 521 "parser.yy"
1407 {
1408 // This token will search for vendor option with
1409 // specified enterprise-id. If found, will search
1410 // for specified suboption and finally will return
1411 // its content.
1412 TokenPtr opt(new TokenVendor(ctx.getUniverse(), yystack_[8].value.as < uint32_t > (), yystack_[0].value.as < TokenOption::RepresentationType > (), yystack_[3].value.as < uint16_t > ()));
1413 ctx.expression_.push_back(opt);
1414 }
1415#line 1416 "parser.cc"
1416 break;
1417
1418 case 55: // string_expr: "vendor-class" "[" enterprise_id "]" "." "data"
1419#line 530 "parser.yy"
1420 {
1421 // expression: vendor-class[1234].data
1422 //
1423 // Vendor class option does not have suboptions,
1424 // but chunks of data (typically 1, but the option
1425 // structure allows multiple of them). If chunk
1426 // offset is not specified, we assume the first (0th)
1427 // is requested.
1428 TokenPtr vendor_class(new TokenVendorClass(ctx.getUniverse(), yystack_[3].value.as < uint32_t > (),
1429 TokenVendor::DATA, 0));
1430 ctx.expression_.push_back(vendor_class);
1431 }
1432#line 1433 "parser.cc"
1433 break;
1434
1435 case 56: // string_expr: "vendor-class" "[" enterprise_id "]" "." "data" "[" "integer" "]"
1436#line 543 "parser.yy"
1437 {
1438 // expression: vendor-class[1234].data[5]
1439 //
1440 // Vendor class option does not have suboptions,
1441 // but chunks of data (typically 1, but the option
1442 // structure allows multiple of them). This syntax
1443 // specifies which data chunk (tuple) we want.
1444 uint8_t index = ctx.convertUint8(yystack_[1].value.as < std::string > (), yystack_[1].location);
1445 TokenPtr vendor_class(new TokenVendorClass(ctx.getUniverse(), yystack_[6].value.as < uint32_t > (),
1446 TokenVendor::DATA, index));
1447 ctx.expression_.push_back(vendor_class);
1448 }
1449#line 1450 "parser.cc"
1450 break;
1451
1452 case 57: // string_expr: integer_expr
1453#line 556 "parser.yy"
1454 {
1455 TokenPtr integer(new TokenInteger(yystack_[0].value.as < uint32_t > ()));
1456 ctx.expression_.push_back(integer);
1457 }
1458#line 1459 "parser.cc"
1459 break;
1460
1461 case 59: // integer_expr: "integer"
1462#line 564 "parser.yy"
1463 {
1464 yylhs.value.as < uint32_t > () = ctx.convertUint32(yystack_[0].value.as < std::string > (), yystack_[0].location);
1465 }
1466#line 1467 "parser.cc"
1467 break;
1468
1469 case 60: // option_code: "integer"
1470#line 570 "parser.yy"
1471 {
1472 yylhs.value.as < uint16_t > () = ctx.convertOptionCode(yystack_[0].value.as < std::string > (), yystack_[0].location);
1473 }
1474#line 1475 "parser.cc"
1475 break;
1476
1477 case 61: // option_code: "option name"
1478#line 574 "parser.yy"
1479 {
1480 yylhs.value.as < uint16_t > () = ctx.convertOptionName(yystack_[0].value.as < std::string > (), yystack_[0].location);
1481 }
1482#line 1483 "parser.cc"
1483 break;
1484
1485 case 62: // sub_option_code: "integer"
1486#line 580 "parser.yy"
1487 {
1488 yylhs.value.as < uint16_t > () = ctx.convertOptionCode(yystack_[0].value.as < std::string > (), yystack_[0].location);
1489 }
1490#line 1491 "parser.cc"
1491 break;
1492
1493 case 63: // option_repr_type: "text"
1494#line 586 "parser.yy"
1495 {
1497 }
1498#line 1499 "parser.cc"
1499 break;
1500
1501 case 64: // option_repr_type: "hex"
1502#line 590 "parser.yy"
1503 {
1505 }
1506#line 1507 "parser.cc"
1507 break;
1508
1509 case 65: // nest_level: "integer"
1510#line 596 "parser.yy"
1511 {
1512 yylhs.value.as < int8_t > () = ctx.convertNestLevelNumber(yystack_[0].value.as < std::string > (), yystack_[0].location);
1513 }
1514#line 1515 "parser.cc"
1515 break;
1516
1517 case 66: // pkt_metadata: "iface"
1518#line 605 "parser.yy"
1519 {
1521 }
1522#line 1523 "parser.cc"
1523 break;
1524
1525 case 67: // pkt_metadata: "src"
1526#line 609 "parser.yy"
1527 {
1529 }
1530#line 1531 "parser.cc"
1531 break;
1532
1533 case 68: // pkt_metadata: "dst"
1534#line 613 "parser.yy"
1535 {
1537 }
1538#line 1539 "parser.cc"
1539 break;
1540
1541 case 69: // pkt_metadata: "len"
1542#line 617 "parser.yy"
1543 {
1545 }
1546#line 1547 "parser.cc"
1547 break;
1548
1549 case 70: // enterprise_id: "integer"
1550#line 623 "parser.yy"
1551 {
1552 yylhs.value.as < uint32_t > () = ctx.convertUint32(yystack_[0].value.as < std::string > (), yystack_[0].location);
1553 }
1554#line 1555 "parser.cc"
1555 break;
1556
1557 case 71: // enterprise_id: "*"
1558#line 627 "parser.yy"
1559 {
1560 yylhs.value.as < uint32_t > () = 0;
1561 }
1562#line 1563 "parser.cc"
1563 break;
1564
1565 case 72: // pkt4_field: "mac"
1566#line 633 "parser.yy"
1567 {
1569 }
1570#line 1571 "parser.cc"
1571 break;
1572
1573 case 73: // pkt4_field: "hlen"
1574#line 637 "parser.yy"
1575 {
1577 }
1578#line 1579 "parser.cc"
1579 break;
1580
1581 case 74: // pkt4_field: "htype"
1582#line 641 "parser.yy"
1583 {
1585 }
1586#line 1587 "parser.cc"
1587 break;
1588
1589 case 75: // pkt4_field: "ciaddr"
1590#line 645 "parser.yy"
1591 {
1593 }
1594#line 1595 "parser.cc"
1595 break;
1596
1597 case 76: // pkt4_field: "giaddr"
1598#line 649 "parser.yy"
1599 {
1601 }
1602#line 1603 "parser.cc"
1603 break;
1604
1605 case 77: // pkt4_field: "yiaddr"
1606#line 653 "parser.yy"
1607 {
1609 }
1610#line 1611 "parser.cc"
1611 break;
1612
1613 case 78: // pkt4_field: "siaddr"
1614#line 657 "parser.yy"
1615 {
1617 }
1618#line 1619 "parser.cc"
1619 break;
1620
1621 case 79: // pkt4_field: "msgtype"
1622#line 661 "parser.yy"
1623 {
1625 }
1626#line 1627 "parser.cc"
1627 break;
1628
1629 case 80: // pkt4_field: "transid"
1630#line 665 "parser.yy"
1631 {
1633 }
1634#line 1635 "parser.cc"
1635 break;
1636
1637 case 81: // pkt6_field: "msgtype"
1638#line 671 "parser.yy"
1639 {
1641 }
1642#line 1643 "parser.cc"
1643 break;
1644
1645 case 82: // pkt6_field: "transid"
1646#line 675 "parser.yy"
1647 {
1649 }
1650#line 1651 "parser.cc"
1651 break;
1652
1653 case 83: // relay6_field: "peeraddr"
1654#line 681 "parser.yy"
1655 {
1657 }
1658#line 1659 "parser.cc"
1659 break;
1660
1661 case 84: // relay6_field: "linkaddr"
1662#line 685 "parser.yy"
1663 {
1665 }
1666#line 1667 "parser.cc"
1667 break;
1668
1669 case 85: // start_expr: "integer"
1670#line 691 "parser.yy"
1671 {
1672 TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ()));
1673 ctx.expression_.push_back(str);
1674 }
1675#line 1676 "parser.cc"
1676 break;
1677
1678 case 86: // length_expr: "integer"
1679#line 698 "parser.yy"
1680 {
1681 TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ()));
1682 ctx.expression_.push_back(str);
1683 }
1684#line 1685 "parser.cc"
1685 break;
1686
1687 case 87: // length_expr: "all"
1688#line 703 "parser.yy"
1689 {
1690 TokenPtr str(new TokenString("all"));
1691 ctx.expression_.push_back(str);
1692 }
1693#line 1694 "parser.cc"
1694 break;
1695
1696 case 88: // int_expr: "integer"
1697#line 710 "parser.yy"
1698 {
1699 TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ()));
1700 ctx.expression_.push_back(str);
1701 }
1702#line 1703 "parser.cc"
1703 break;
1704
1705
1706#line 1707 "parser.cc"
1707
1708 default:
1709 break;
1710 }
1711 }
1712#if YY_EXCEPTIONS
1713 catch (const syntax_error& yyexc)
1714 {
1715 YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
1716 error (yyexc);
1717 YYERROR;
1718 }
1719#endif // YY_EXCEPTIONS
1720 YY_SYMBOL_PRINT ("-> $$ =", yylhs);
1721 yypop_ (yylen);
1722 yylen = 0;
1723
1724 // Shift the result of the reduction.
1725 yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
1726 }
1727 goto yynewstate;
1728
1729
1730 /*--------------------------------------.
1731 | yyerrlab -- here on detecting error. |
1732 `--------------------------------------*/
1733 yyerrlab:
1734 // If not already recovering from an error, report this error.
1735 if (!yyerrstatus_)
1736 {
1737 ++yynerrs_;
1738 context yyctx (*this, yyla);
1739 std::string msg = yysyntax_error_ (yyctx);
1740 error (yyla.location, YY_MOVE (msg));
1741 }
1742
1743
1744 yyerror_range[1].location = yyla.location;
1745 if (yyerrstatus_ == 3)
1746 {
1747 /* If just tried and failed to reuse lookahead token after an
1748 error, discard it. */
1749
1750 // Return failure if at end of input.
1751 if (yyla.kind () == symbol_kind::S_YYEOF)
1752 YYABORT;
1753 else if (!yyla.empty ())
1754 {
1755 yy_destroy_ ("Error: discarding", yyla);
1756 yyla.clear ();
1757 }
1758 }
1759
1760 // Else will try to reuse lookahead token after shifting the error token.
1761 goto yyerrlab1;
1762
1763
1764 /*---------------------------------------------------.
1765 | yyerrorlab -- error raised explicitly by YYERROR. |
1766 `---------------------------------------------------*/
1767 yyerrorlab:
1768 /* Pacify compilers when the user code never invokes YYERROR and
1769 the label yyerrorlab therefore never appears in user code. */
1770 if (false)
1771 YYERROR;
1772
1773 /* Do not reclaim the symbols of the rule whose action triggered
1774 this YYERROR. */
1775 yypop_ (yylen);
1776 yylen = 0;
1777 YY_STACK_PRINT ();
1778 goto yyerrlab1;
1779
1780
1781 /*-------------------------------------------------------------.
1782 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1783 `-------------------------------------------------------------*/
1784 yyerrlab1:
1785 yyerrstatus_ = 3; // Each real token shifted decrements this.
1786 // Pop stack until we find a state that shifts the error token.
1787 for (;;)
1788 {
1789 yyn = yypact_[+yystack_[0].state];
1790 if (!yy_pact_value_is_default_ (yyn))
1791 {
1793 if (0 <= yyn && yyn <= yylast_
1794 && yycheck_[yyn] == symbol_kind::S_YYerror)
1795 {
1796 yyn = yytable_[yyn];
1797 if (0 < yyn)
1798 break;
1799 }
1800 }
1801
1802 // Pop the current state because it cannot handle the error token.
1803 if (yystack_.size () == 1)
1804 YYABORT;
1805
1806 yyerror_range[1].location = yystack_[0].location;
1807 yy_destroy_ ("Error: popping", yystack_[0]);
1808 yypop_ ();
1809 YY_STACK_PRINT ();
1810 }
1811 {
1812 stack_symbol_type error_token;
1813
1814 yyerror_range[2].location = yyla.location;
1815 YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
1816
1817 // Shift the error token.
1818 error_token.state = state_type (yyn);
1819 yypush_ ("Shifting", YY_MOVE (error_token));
1820 }
1821 goto yynewstate;
1822
1823
1824 /*-------------------------------------.
1825 | yyacceptlab -- YYACCEPT comes here. |
1826 `-------------------------------------*/
1827 yyacceptlab:
1828 yyresult = 0;
1829 goto yyreturn;
1830
1831
1832 /*-----------------------------------.
1833 | yyabortlab -- YYABORT comes here. |
1834 `-----------------------------------*/
1835 yyabortlab:
1836 yyresult = 1;
1837 goto yyreturn;
1838
1839
1840 /*-----------------------------------------------------.
1841 | yyreturn -- parsing is finished, return the result. |
1842 `-----------------------------------------------------*/
1843 yyreturn:
1844 if (!yyla.empty ())
1845 yy_destroy_ ("Cleanup: discarding lookahead", yyla);
1846
1847 /* Do not reclaim the symbols of the rule whose action triggered
1848 this YYABORT or YYACCEPT. */
1849 yypop_ (yylen);
1850 YY_STACK_PRINT ();
1851 while (1 < yystack_.size ())
1852 {
1853 yy_destroy_ ("Cleanup: popping", yystack_[0]);
1854 yypop_ ();
1855 }
1856
1857 return yyresult;
1858 }
1859#if YY_EXCEPTIONS
1860 catch (...)
1861 {
1862 YYCDEBUG << "Exception caught: cleaning lookahead and stack\n";
1863 // Do not try to display the values of the reclaimed symbols,
1864 // as their printers might throw an exception.
1865 if (!yyla.empty ())
1866 yy_destroy_ (YY_NULLPTR, yyla);
1867
1868 while (1 < yystack_.size ())
1869 {
1870 yy_destroy_ (YY_NULLPTR, yystack_[0]);
1871 yypop_ ();
1872 }
1873 throw;
1874 }
1875#endif // YY_EXCEPTIONS
1876 }
1877
1878 void
1880 {
1881 error (yyexc.location, yyexc.what ());
1882 }
1883
1884 /* Return YYSTR after stripping away unnecessary quotes and
1885 backslashes, so that it's suitable for yyerror. The heuristic is
1886 that double-quoting is unnecessary unless the string contains an
1887 apostrophe, a comma, or backslash (other than backslash-backslash).
1888 YYSTR is taken from yytname. */
1889 std::string
1890 EvalParser::yytnamerr_ (const char *yystr)
1891 {
1892 if (*yystr == '"')
1893 {
1894 std::string yyr;
1895 char const *yyp = yystr;
1896
1897 for (;;)
1898 switch (*++yyp)
1899 {
1900 case '\'':
1901 case ',':
1902 goto do_not_strip_quotes;
1903
1904 case '\\':
1905 if (*++yyp != '\\')
1906 goto do_not_strip_quotes;
1907 else
1908 goto append;
1909
1910 append:
1911 default:
1912 yyr += *yyp;
1913 break;
1914
1915 case '"':
1916 return yyr;
1917 }
1918 do_not_strip_quotes: ;
1919 }
1920
1921 return yystr;
1922 }
1923
1924 std::string
1926 {
1927 return yytnamerr_ (yytname_[yysymbol]);
1928 }
1929
1930
1931
1932 // EvalParser::context.
1934 : yyparser_ (yyparser)
1935 , yyla_ (yyla)
1936 {}
1937
1938 int
1940 {
1941 // Actual number of expected tokens
1942 int yycount = 0;
1943
1944 const int yyn = yypact_[+yyparser_.yystack_[0].state];
1945 if (!yy_pact_value_is_default_ (yyn))
1946 {
1947 /* Start YYX at -YYN if negative to avoid negative indexes in
1948 YYCHECK. In other words, skip the first -YYN actions for
1949 this state because they are default actions. */
1950 const int yyxbegin = yyn < 0 ? -yyn : 0;
1951 // Stay within bounds of both yycheck and yytname.
1952 const int yychecklim = yylast_ - yyn + 1;
1953 const int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1954 for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
1955 if (yycheck_[yyx + yyn] == yyx && yyx != symbol_kind::S_YYerror
1956 && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
1957 {
1958 if (!yyarg)
1959 ++yycount;
1960 else if (yycount == yyargn)
1961 return 0;
1962 else
1963 yyarg[yycount++] = YY_CAST (symbol_kind_type, yyx);
1964 }
1965 }
1966
1967 if (yyarg && yycount == 0 && 0 < yyargn)
1968 yyarg[0] = symbol_kind::S_YYEMPTY;
1969 return yycount;
1970 }
1971
1972
1973
1974
1975
1976
1977 int
1978 EvalParser::yy_syntax_error_arguments_ (const context& yyctx,
1979 symbol_kind_type yyarg[], int yyargn) const
1980 {
1981 /* There are many possibilities here to consider:
1982 - If this state is a consistent state with a default action, then
1983 the only way this function was invoked is if the default action
1984 is an error action. In that case, don't check for expected
1985 tokens because there are none.
1986 - The only way there can be no lookahead present (in yyla) is
1987 if this state is a consistent state with a default action.
1988 Thus, detecting the absence of a lookahead is sufficient to
1989 determine that there is no unexpected or expected token to
1990 report. In that case, just report a simple "syntax error".
1991 - Don't assume there isn't a lookahead just because this state is
1992 a consistent state with a default action. There might have
1993 been a previous inconsistent state, consistent state with a
1994 non-default action, or user semantic action that manipulated
1995 yyla. (However, yyla is currently not documented for users.)
1996 - Of course, the expected token list depends on states to have
1997 correct lookahead information, and it depends on the parser not
1998 to perform extra reductions after fetching a lookahead from the
1999 scanner and before detecting a syntax error. Thus, state merging
2000 (from LALR or IELR) and default reductions corrupt the expected
2001 token list. However, the list is correct for canonical LR with
2002 one exception: it will still contain any token that will not be
2003 accepted due to an error action in a later state.
2004 */
2005
2006 if (!yyctx.lookahead ().empty ())
2007 {
2008 if (yyarg)
2009 yyarg[0] = yyctx.token ();
2010 int yyn = yyctx.expected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn - 1);
2011 return yyn + 1;
2012 }
2013 return 0;
2014 }
2015
2016 // Generate an error message.
2017 std::string
2018 EvalParser::yysyntax_error_ (const context& yyctx) const
2019 {
2020 // Its maximum.
2021 enum { YYARGS_MAX = 5 };
2022 // Arguments of yyformat.
2023 symbol_kind_type yyarg[YYARGS_MAX];
2024 int yycount = yy_syntax_error_arguments_ (yyctx, yyarg, YYARGS_MAX);
2025
2026 char const* yyformat = YY_NULLPTR;
2027 switch (yycount)
2028 {
2029#define YYCASE_(N, S) \
2030 case N: \
2031 yyformat = S; \
2032 break
2033 default: // Avoid compiler warnings.
2034 YYCASE_ (0, YY_("syntax error"));
2035 YYCASE_ (1, YY_("syntax error, unexpected %s"));
2036 YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s"));
2037 YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s"));
2038 YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
2039 YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
2040#undef YYCASE_
2041 }
2042
2043 std::string yyres;
2044 // Argument number.
2045 std::ptrdiff_t yyi = 0;
2046 for (char const* yyp = yyformat; *yyp; ++yyp)
2047 if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
2048 {
2049 yyres += symbol_name (yyarg[yyi++]);
2050 ++yyp;
2051 }
2052 else
2053 yyres += *yyp;
2054 return yyres;
2055 }
2056
2057
2058 const short EvalParser::yypact_ninf_ = -173;
2059
2060 const signed char EvalParser::yytable_ninf_ = -1;
2061
2062 const short
2063 EvalParser::yypact_[] =
2064 {
2065 -45, 175, 236, 4, 175, 175, 61, 101, 107, 25,
2066 26, 82, 102, 149, 159, 179, 182, 192, 198, 205,
2067 206, 210, 211, 213, 227, 228, 232, 136, 156, 157,
2068 240, -173, -173, -173, -173, -173, 134, 7, -173, 236,
2069 151, 229, 233, 160, 164, 126, -173, 113, 1, -173,
2070 124, 185, 186, 180, 120, 79, 236, 236, 236, 175,
2071 175, 236, 236, 236, 236, 236, 236, 236, 236, 236,
2072 236, -33, -35, 193, -35, 194, 188, -173, 175, -173,
2073 175, 236, 236, 2, 124, 185, 186, -35, -35, -173,
2074 -173, -173, -173, 238, -173, 239, -173, 242, 254, -173,
2075 -173, -173, -173, -173, -173, -173, -173, -173, -173, -173,
2076 -173, -173, -173, -173, 152, 155, 158, 68, 84, 161,
2077 3, 5, 6, 8, 9, 10, 11, 12, 16, -173,
2078 -173, -173, -173, -173, 243, -173, 244, -173, 224, 175,
2079 259, 175, 125, 126, -173, 248, 249, 250, 251, 252,
2080 255, 256, 258, -173, 225, 236, 236, -173, 236, 236,
2081 -173, -173, -173, -173, -173, -173, -173, -173, -173, 273,
2082 276, 236, -173, 91, 277, 278, 279, 280, 281, 74,
2083 106, 88, -173, 265, 165, 28, 236, 166, 29, -19,
2084 18, 30, 95, 116, 114, 246, 260, 290, -173, -173,
2085 -173, -173, -173, -173, 291, -173, -173, -173, -8, 245,
2086 -173, 195, 236, -173, -173, 292, 293, -173, -173, 295,
2087 296, 297, 185, 185, -173, -173, 311, -173, 312, -173,
2088 31, 253, 185, 185, 185, 185, 299, 300, -173, -173,
2089 236, -173, 302, 303, 304, 305, 306, 307, 308, 32,
2090 -173, 309, 310, 313, 314, 138, 144, -173, 150, 116,
2091 116, 116, -173, -173, -173, -173, -173, -173
2092 };
2093
2094 const signed char
2095 EvalParser::yydefact_[] =
2096 {
2097 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2098 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2099 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2100 0, 23, 59, 24, 25, 2, 4, 0, 57, 0,
2101 0, 0, 0, 0, 0, 3, 1, 0, 0, 6,
2102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2103 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2104 0, 0, 0, 0, 0, 0, 0, 7, 0, 10,
2105 0, 0, 0, 0, 0, 0, 0, 0, 0, 5,
2106 58, 60, 61, 0, 62, 0, 65, 0, 0, 66,
2107 67, 68, 69, 30, 72, 73, 74, 75, 76, 77,
2108 78, 79, 80, 31, 0, 0, 0, 0, 0, 0,
2109 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2110 82, 32, 71, 70, 0, 53, 0, 52, 0, 0,
2111 9, 0, 12, 13, 37, 0, 0, 0, 0, 0,
2112 0, 0, 0, 21, 0, 0, 0, 40, 0, 0,
2113 45, 46, 47, 48, 49, 50, 51, 38, 39, 0,
2114 0, 0, 8, 11, 0, 0, 0, 0, 0, 0,
2115 0, 0, 85, 0, 0, 0, 0, 0, 0, 0,
2116 0, 0, 0, 0, 0, 0, 0, 0, 63, 64,
2117 14, 26, 16, 28, 0, 83, 84, 33, 0, 0,
2118 36, 0, 0, 44, 18, 55, 0, 19, 22, 0,
2119 0, 0, 0, 0, 87, 86, 0, 88, 0, 41,
2120 0, 0, 0, 0, 0, 0, 0, 0, 34, 35,
2121 0, 43, 0, 0, 0, 0, 0, 0, 0, 0,
2122 56, 0, 0, 0, 0, 0, 0, 42, 0, 0,
2123 0, 0, 15, 27, 17, 29, 20, 54
2124 };
2125
2126 const short
2127 EvalParser::yypgoto_[] =
2128 {
2129 -173, -173, -173, 22, -173, -173, -2, -173, -173, -173,
2130 241, -84, -172, 257, -173, -49, -173, -173, -173, -173,
2131 -173, -173
2132 };
2133
2134 const unsigned char
2135 EvalParser::yydefgoto_[] =
2136 {
2137 0, 3, 35, 36, 139, 141, 37, 186, 240, 38,
2138 93, 95, 201, 97, 103, 134, 113, 131, 207, 183,
2139 226, 228
2140 };
2141
2142 const short
2143 EvalParser::yytable_[] =
2144 {
2145 45, 146, 48, 214, 46, 90, 90, 160, 203, 161,
2146 162, 81, 163, 164, 165, 166, 167, 81, 1, 2,
2147 168, 203, 129, 130, 132, 136, 47, 49, 53, 216,
2148 224, 133, 210, 213, 218, 241, 257, 83, 148, 149,
2149 217, 215, 82, 82, 82, 54, 82, 82, 82, 82,
2150 82, 82, 82, 82, 114, 115, 116, 82, 225, 119,
2151 120, 121, 122, 123, 124, 125, 126, 127, 128, 82,
2152 82, 82, 82, 82, 77, 78, 79, 80, 50, 143,
2153 144, 117, 118, 263, 265, 197, 267, 263, 265, 267,
2154 77, 78, 79, 80, 198, 199, 200, 77, 78, 204,
2155 140, 55, 142, 205, 206, 56, 219, 157, 104, 105,
2156 106, 107, 108, 109, 110, 198, 199, 89, 51, 77,
2157 78, 79, 80, 158, 52, 220, 198, 199, 202, 205,
2158 206, 77, 78, 79, 111, 112, 198, 199, 236, 237,
2159 77, 78, 79, 80, 99, 100, 101, 102, 243, 244,
2160 245, 246, 57, 184, 185, 71, 187, 188, 198, 199,
2161 262, 172, 58, 173, 198, 199, 264, 82, 84, 191,
2162 198, 199, 266, 72, 74, 73, 75, 87, 4, 73,
2163 5, 88, 59, 75, 211, 60, 6, 7, 8, 9,
2164 91, 154, 92, 82, 155, 61, 82, 156, 10, 82,
2165 159, 62, 82, 11, 209, 212, 82, 82, 63, 64,
2166 230, 12, 13, 65, 66, 14, 67, 15, 16, 17,
2167 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
2168 68, 69, 28, 29, 229, 70, 82, 30, 249, 39,
2169 31, 32, 33, 76, 34, 98, 85, 40, 41, 42,
2170 86, 94, 96, 138, 135, 137, 150, 151, 153, 10,
2171 152, 169, 170, 171, 11, 77, 174, 175, 176, 177,
2172 178, 221, 12, 13, 179, 180, 14, 181, 15, 16,
2173 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
2174 27, 182, 189, 43, 44, 190, 192, 193, 194, 195,
2175 196, 31, 32, 33, 208, 34, 215, 222, 223, 231,
2176 232, 227, 233, 234, 235, 238, 239, 247, 248, 242,
2177 250, 251, 252, 253, 254, 145, 255, 256, 258, 259,
2178 0, 0, 260, 261, 0, 0, 0, 0, 0, 0,
2179 0, 0, 0, 147
2180 };
2181
2182 const short
2183 EvalParser::yycheck_[] =
2184 {
2185 2, 85, 4, 22, 0, 4, 4, 4, 180, 4,
2186 4, 10, 4, 4, 4, 4, 4, 10, 63, 64,
2187 4, 193, 55, 56, 59, 74, 4, 5, 3, 11,
2188 38, 66, 4, 4, 4, 4, 4, 39, 87, 88,
2189 22, 60, 41, 41, 41, 19, 41, 41, 41, 41,
2190 41, 41, 41, 41, 56, 57, 58, 41, 66, 61,
2191 62, 63, 64, 65, 66, 67, 68, 69, 70, 41,
2192 41, 41, 41, 41, 6, 7, 8, 9, 17, 81,
2193 82, 59, 60, 255, 256, 11, 258, 259, 260, 261,
2194 6, 7, 8, 9, 20, 21, 22, 6, 7, 11,
2195 78, 19, 80, 15, 16, 3, 11, 39, 29, 30,
2196 31, 32, 33, 34, 35, 20, 21, 4, 17, 6,
2197 7, 8, 9, 39, 17, 11, 20, 21, 22, 15,
2198 16, 6, 7, 8, 55, 56, 20, 21, 222, 223,
2199 6, 7, 8, 9, 24, 25, 26, 27, 232, 233,
2200 234, 235, 3, 155, 156, 19, 158, 159, 20, 21,
2201 22, 139, 3, 141, 20, 21, 22, 41, 17, 171,
2202 20, 21, 22, 17, 17, 19, 19, 17, 3, 19,
2203 5, 17, 3, 19, 186, 3, 11, 12, 13, 14,
2204 66, 39, 68, 41, 39, 3, 41, 39, 23, 41,
2205 39, 3, 41, 28, 39, 39, 41, 41, 3, 3,
2206 212, 36, 37, 3, 3, 40, 3, 42, 43, 44,
2207 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2208 3, 3, 57, 58, 39, 3, 41, 62, 240, 3,
2209 65, 66, 67, 3, 69, 65, 17, 11, 12, 13,
2210 17, 66, 66, 65, 61, 61, 18, 18, 4, 23,
2211 18, 18, 18, 39, 28, 6, 18, 18, 18, 18,
2212 18, 11, 36, 37, 19, 19, 40, 19, 42, 43,
2213 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
2214 54, 66, 19, 57, 58, 19, 19, 19, 19, 19,
2215 19, 65, 66, 67, 39, 69, 60, 17, 17, 17,
2216 17, 66, 17, 17, 17, 4, 4, 18, 18, 66,
2217 18, 18, 18, 18, 18, 84, 19, 19, 19, 19,
2218 -1, -1, 19, 19, -1, -1, -1, -1, -1, -1,
2219 -1, -1, -1, 86
2220 };
2221
2222 const signed char
2223 EvalParser::yystos_[] =
2224 {
2225 0, 63, 64, 71, 3, 5, 11, 12, 13, 14,
2226 23, 28, 36, 37, 40, 42, 43, 44, 45, 46,
2227 47, 48, 49, 50, 51, 52, 53, 54, 57, 58,
2228 62, 65, 66, 67, 69, 72, 73, 76, 79, 3,
2229 11, 12, 13, 57, 58, 76, 0, 73, 76, 73,
2230 17, 17, 17, 3, 19, 19, 3, 3, 3, 3,
2231 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2232 3, 19, 17, 19, 17, 19, 3, 6, 7, 8,
2233 9, 10, 41, 76, 17, 17, 17, 17, 17, 4,
2234 4, 66, 68, 80, 66, 81, 66, 83, 65, 24,
2235 25, 26, 27, 84, 29, 30, 31, 32, 33, 34,
2236 35, 55, 56, 86, 76, 76, 76, 73, 73, 76,
2237 76, 76, 76, 76, 76, 76, 76, 76, 76, 55,
2238 56, 87, 59, 66, 85, 61, 85, 61, 65, 74,
2239 73, 75, 73, 76, 76, 80, 81, 83, 85, 85,
2240 18, 18, 18, 4, 39, 39, 39, 39, 39, 39,
2241 4, 4, 4, 4, 4, 4, 4, 4, 4, 18,
2242 18, 39, 73, 73, 18, 18, 18, 18, 18, 19,
2243 19, 19, 66, 89, 76, 76, 77, 76, 76, 19,
2244 19, 76, 19, 19, 19, 19, 19, 11, 20, 21,
2245 22, 82, 22, 82, 11, 15, 16, 88, 39, 39,
2246 4, 76, 39, 4, 22, 60, 11, 22, 4, 11,
2247 11, 11, 17, 17, 38, 66, 90, 66, 91, 39,
2248 76, 17, 17, 17, 17, 17, 81, 81, 4, 4,
2249 78, 4, 66, 81, 81, 81, 81, 18, 18, 76,
2250 18, 18, 18, 18, 18, 19, 19, 4, 19, 19,
2251 19, 19, 22, 82, 22, 82, 22, 82
2252 };
2253
2254 const signed char
2255 EvalParser::yyr1_[] =
2256 {
2257 0, 70, 71, 71, 72, 73, 73, 74, 73, 73,
2258 75, 73, 73, 73, 73, 73, 73, 73, 73, 73,
2259 73, 73, 73, 76, 76, 76, 76, 76, 76, 76,
2260 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
2261 77, 78, 76, 76, 76, 76, 76, 76, 76, 76,
2262 76, 76, 76, 76, 76, 76, 76, 76, 76, 79,
2263 80, 80, 81, 82, 82, 83, 84, 84, 84, 84,
2264 85, 85, 86, 86, 86, 86, 86, 86, 86, 86,
2265 86, 87, 87, 88, 88, 89, 90, 90, 91
2266 };
2267
2268 const signed char
2269 EvalParser::yyr2_[] =
2270 {
2271 0, 2, 2, 2, 1, 3, 2, 0, 4, 3,
2272 0, 4, 3, 3, 6, 11, 6, 11, 6, 6,
2273 11, 4, 6, 1, 1, 1, 6, 11, 6, 11,
2274 3, 3, 3, 6, 8, 8, 6, 3, 4, 4,
2275 0, 0, 10, 8, 6, 4, 4, 4, 4, 4,
2276 4, 4, 3, 3, 11, 6, 9, 1, 3, 1,
2277 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2278 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2279 1, 1, 1, 1, 1, 1, 1, 1, 1
2280 };
2281
2282
2283#if EVALDEBUG || 1
2284 // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2285 // First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
2286 const char*
2287 const EvalParser::yytname_[] =
2288 {
2289 "\"end of file\"", "error", "\"invalid token\"", "\"(\"", "\")\"",
2290 "\"not\"", "\"and\"", "\"sand\"", "\"or\"", "\"sor\"", "\"==\"",
2291 "\"option\"", "\"relay4\"", "\"relay6\"", "\"member\"", "\"peeraddr\"",
2292 "\"linkaddr\"", "\"[\"", "\"]\"", "\".\"", "\"text\"", "\"hex\"",
2293 "\"exists\"", "\"pkt\"", "\"iface\"", "\"src\"", "\"dst\"", "\"len\"",
2294 "\"pkt4\"", "\"mac\"", "\"hlen\"", "\"htype\"", "\"ciaddr\"",
2295 "\"giaddr\"", "\"yiaddr\"", "\"siaddr\"", "\"substring\"", "\"split\"",
2296 "\"all\"", "\",\"", "\"concat\"", "\"+\"", "\"ifelse\"", "\"sifelse\"",
2297 "\"hexstring\"", "\"addrtotext\"", "\"int8totext\"", "\"int16totext\"",
2298 "\"int32totext\"", "\"uint8totext\"", "\"uint16totext\"",
2299 "\"uint32totext\"", "\"lcase\"", "\"ucase\"", "\"pkt6\"", "\"msgtype\"",
2300 "\"transid\"", "\"vendor-class\"", "\"vendor\"", "\"*\"", "\"data\"",
2301 "\"enterprise\"", "\"match\"", "\"top-level bool\"",
2302 "\"top-level string\"", "\"constant string\"", "\"integer\"",
2303 "\"constant hexstring\"", "\"option name\"", "\"ip address\"", "$accept",
2304 "start", "expression", "bool_expr", "$@1", "$@2", "string_expr", "$@3",
2305 "$@4", "integer_expr", "option_code", "sub_option_code",
2306 "option_repr_type", "nest_level", "pkt_metadata", "enterprise_id",
2307 "pkt4_field", "pkt6_field", "relay6_field", "start_expr", "length_expr",
2308 "int_expr", YY_NULLPTR
2309 };
2310#endif
2311
2312
2313#if EVALDEBUG
2314 const short
2315 EvalParser::yyrline_[] =
2316 {
2317 0, 144, 144, 145, 150, 153, 154, 160, 159, 171,
2318 177, 176, 188, 193, 198, 203, 208, 228, 242, 251,
2319 260, 270, 285, 296, 301, 306, 311, 316, 321, 342,
2320 357, 362, 376, 390, 405, 410, 415, 420, 425, 430,
2321 436, 441, 435, 456, 461, 466, 471, 476, 481, 486,
2322 491, 496, 501, 510, 520, 529, 542, 555, 560, 563,
2323 569, 573, 579, 585, 589, 595, 604, 608, 612, 616,
2324 622, 626, 632, 636, 640, 644, 648, 652, 656, 660,
2325 664, 670, 674, 680, 684, 690, 697, 702, 709
2326 };
2327
2328 void
2329 EvalParser::yy_stack_print_ () const
2330 {
2331 *yycdebug_ << "Stack now";
2332 for (stack_type::const_iterator
2333 i = yystack_.begin (),
2334 i_end = yystack_.end ();
2335 i != i_end; ++i)
2336 *yycdebug_ << ' ' << int (i->state);
2337 *yycdebug_ << '\n';
2338 }
2339
2340 void
2341 EvalParser::yy_reduce_print_ (int yyrule) const
2342 {
2343 int yylno = yyrline_[yyrule];
2344 int yynrhs = yyr2_[yyrule];
2345 // Print the symbols being reduced, and their result.
2346 *yycdebug_ << "Reducing stack by rule " << yyrule - 1
2347 << " (line " << yylno << "):\n";
2348 // The symbols being reduced.
2349 for (int yyi = 0; yyi < yynrhs; yyi++)
2350 YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
2351 yystack_[(yynrhs) - (yyi + 1)]);
2352 }
2353#endif // EVALDEBUG
2354
2355
2356#line 14 "parser.yy"
2357} } // isc::eval
2358#line 2359 "parser.cc"
2359
2360#line 716 "parser.yy"
2361
2362void
2364 const std::string& what)
2365{
2366 ctx.error(loc, what);
2367}
#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_CPLUSPLUS
#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:1036
Token that represents unconditional branch.
Definition token.h:1451
Token that represents concat operator (concatenates two other tokens)
Definition token.h:913
Token that represents equality operator (compares two other tokens)
Definition token.h:784
Token representing a constant string in hexadecimal format.
Definition token.h:151
Token that represents an alternative.
Definition token.h:942
Token representing a 16 bit integer as a string.
Definition token.h:303
Token representing a 32 bit integer as a string.
Definition token.h:322
Token representing an 8 bit integer as a string.
Definition token.h:284
Token representing an unsigned 32 bit integer.
Definition token.h:215
Token representing an IP address as a string.
Definition token.h:266
Token representing an IP address as a constant string.
Definition token.h:242
Token label i.e.
Definition token.h:1421
Token representing a constant lower case string.
Definition token.h:177
Token that represents regular expression (regex) matching.
Definition token.h:1379
Token that represents client class membership.
Definition token.h:1090
Token that represents logical negation operator.
Definition token.h:1009
Token that represents a value of an option.
Definition token.h:403
RepresentationType
Token representation type.
Definition token.h:413
Token that represents logical or operator.
Definition token.h:1064
Token that represents fields of a DHCPv4 packet.
Definition token.h:619
FieldType
enum value that determines the field.
Definition token.h:623
@ CIADDR
ciaddr (IPv4 address)
Definition token.h:626
@ HLEN
hlen (hardware address length)
Definition token.h:629
@ HTYPE
htype (hardware address type)
Definition token.h:630
@ GIADDR
giaddr (IPv4 address)
Definition token.h:625
@ CHADDR
chaddr field (up to 16 bytes link-layer address)
Definition token.h:624
@ YIADDR
yiaddr (IPv4 address)
Definition token.h:627
@ SIADDR
siaddr (IPv4 address)
Definition token.h:628
@ TRANSID
transaction-id (xid)
Definition token.h:632
@ MSGTYPE
message type (not really a field, content of option 53)
Definition token.h:631
Token that represents fields of DHCPv6 packet.
Definition token.h:674
FieldType
enum value that determines the field.
Definition token.h:677
@ TRANSID
transaction id (integer but manipulated as a string)
Definition token.h:679
@ MSGTYPE
msg type
Definition token.h:678
Token that represents meta data of a DHCP packet.
Definition token.h:569
MetadataType
enum value that determines the field.
Definition token.h:573
@ LEN
length (4 octets)
Definition token.h:577
@ DST
destination (IP address)
Definition token.h:576
@ IFACE
interface name (string)
Definition token.h:574
@ SRC
source (IP address)
Definition token.h:575
Token that represents pop and branch if false.
Definition token.h:1531
Token that represents pop or branch if false.
Definition token.h:1505
Token that represents pop or branch if true.
Definition token.h:1481
Represents a sub-option inserted by the DHCPv4 relay.
Definition token.h:495
Token that represents a value of a field within a DHCPv6 relay encapsulation.
Definition token.h:726
FieldType
enum value that determines the field.
Definition token.h:730
@ LINKADDR
Link address field (IPv6 address)
Definition token.h:732
@ PEERADDR
Peer address field (IPv6 address)
Definition token.h:731
Token that represents a value of an option within a DHCPv6 relay encapsulation.
Definition token.h:527
The order where Token subtypes are declared should be:
Definition token.h:129
Token that represents sub-options in DHCPv4 and DHCPv6.
Definition token.h:1324
Token that represents the substring operator (returns a portion of the supplied string)
Definition token.h:810
Token that converts to hexadecimal string.
Definition token.h:973
Token representing a 16 bit unsigned integer as a string.
Definition token.h:360
Token representing a 32 bit unsigned integer as a string.
Definition token.h:379
Token representing an 8 bit unsigned integer as a string.
Definition token.h:341
Token representing a constant upper case string.
Definition token.h:195
Token that represents vendor class options in DHCPv4 and DHCPv6.
Definition token.h:1251
Token that represents vendor options in DHCPv4 and DHCPv6.
Definition token.h:1136
@ DATA
data chunk, used in derived vendor-class only
Definition token.h:1144
@ ENTERPRISE_ID
enterprise-id field (vendor-info, vendor-class)
Definition token.h:1142
Evaluation context, an interface to the expression evaluation.
unsigned label_
Label counter.
std::vector< unsigned > labels_
Label stack.
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.
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.
isc::dhcp::Expression expression_
Parsed expression (output tokens are stored here)
const symbol_type & lookahead() const YY_NOEXCEPT
Definition parser.h:2198
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:1939
context(const EvalParser &yyparser, const symbol_type &yyla)
Definition parser.cc:1933
symbol_kind_type token() const YY_NOEXCEPT
Definition parser.h:2199
T & as() YY_NOEXCEPT
Accessor to a built T.
Definition parser.h:318
T & emplace()
Instantiate an empty T in here.
Definition parser.h:277
A Bison parser.
Definition parser.h:215
int operator()()
Parse.
Definition parser.cc:638
virtual int parse()
Parse.
Definition parser.cc:644
symbol_kind::symbol_kind_type symbol_kind_type
(Internal) symbol kind.
Definition parser.h:692
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:695
virtual void error(const location_type &loc, const std::string &msg)
Report a syntax error.
Definition parser.cc:2363
location location_type
Symbol locations.
Definition parser.h:482
static std::string symbol_name(symbol_kind_type yysymbol)
The user-facing name of the symbol whose (internal) number is YYSYMBOL.
Definition parser.cc:1925
@ 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.
void move(basic_symbol &s)
Destructive move, s is emptied into this.
Definition parser.h:2665
location_type location
The location.
Definition parser.h:1007
value_type value
The semantic value.
Definition parser.h:1004
bool empty() const YY_NOEXCEPT
Whether empty.
Definition parser.h:2658
void clear() YY_NOEXCEPT
Destroy contents, and record that is empty.
Definition parser.h:924
symbol_kind_type kind_
The symbol kind.
Definition parser.h:1053
symbol_kind_type kind() const YY_NOEXCEPT
The (internal) type number (corresponding to type).
Definition parser.h:2763
"External" symbols: returned by the scanner.
Definition parser.h:1061
Syntax errors thrown from user actions.
Definition parser.h:486
~syntax_error() YY_NOEXCEPT YY_NOTHROW
Definition parser.cc:165