Kea 2.5.8
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
163 {}
164
166 {}
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 129 "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 129 "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 129 "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 129 "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 129 "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 129 "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 129 "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 129 "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 129 "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 129 "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 129 "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 129 "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 129 "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 129 "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 129 "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 149 "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 154 "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 159 "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 164 "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 169 "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 174 "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 179 "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 199 "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 213 "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 222 "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 231 "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 241 "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: // string_expr: "constant string"
1000#line 258 "parser.yy"
1001 {
1002 TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ()));
1003 ctx.expression.push_back(str);
1004 }
1005#line 1006 "parser.cc"
1006 break;
1007
1008 case 19: // string_expr: "constant hexstring"
1009#line 263 "parser.yy"
1010 {
1011 TokenPtr hex(new TokenHexString(yystack_[0].value.as < std::string > ()));
1012 ctx.expression.push_back(hex);
1013 }
1014#line 1015 "parser.cc"
1015 break;
1016
1017 case 20: // string_expr: "ip address"
1018#line 268 "parser.yy"
1019 {
1020 TokenPtr ip(new TokenIpAddress(yystack_[0].value.as < std::string > ()));
1021 ctx.expression.push_back(ip);
1022 }
1023#line 1024 "parser.cc"
1024 break;
1025
1026 case 21: // string_expr: "option" "[" option_code "]" "." option_repr_type
1027#line 273 "parser.yy"
1028 {
1029 TokenPtr opt(new TokenOption(yystack_[3].value.as < uint16_t > (), yystack_[0].value.as < TokenOption::RepresentationType > ()));
1030 ctx.expression.push_back(opt);
1031 }
1032#line 1033 "parser.cc"
1033 break;
1034
1035 case 22: // string_expr: "option" "[" option_code "]" "." "option" "[" sub_option_code "]" "." option_repr_type
1036#line 278 "parser.yy"
1037 {
1038 TokenPtr opt(new TokenSubOption(yystack_[8].value.as < uint16_t > (), yystack_[3].value.as < uint16_t > (), yystack_[0].value.as < TokenOption::RepresentationType > ()));
1039 ctx.expression.push_back(opt);
1040 }
1041#line 1042 "parser.cc"
1042 break;
1043
1044 case 23: // string_expr: "relay4" "[" sub_option_code "]" "." option_repr_type
1045#line 283 "parser.yy"
1046 {
1047 switch (ctx.getUniverse()) {
1048 case Option::V4:
1049 {
1050 TokenPtr opt(new TokenRelay4Option(yystack_[3].value.as < uint16_t > (), yystack_[0].value.as < TokenOption::RepresentationType > ()));
1051 ctx.expression.push_back(opt);
1052 break;
1053 }
1054 case Option::V6:
1055 // We will have relay6[123] for the DHCPv6.
1056 // In a very distant future we'll possibly be able
1057 // to mix both if we have DHCPv4-over-DHCPv6, so it
1058 // has some sense to make it explicit whether we
1059 // talk about DHCPv4 relay or DHCPv6 relay. However,
1060 // for the time being relay4 can be used in DHCPv4
1061 // only.
1062 error(yystack_[5].location, "relay4 can only be used in DHCPv4.");
1063 }
1064 }
1065#line 1066 "parser.cc"
1066 break;
1067
1068 case 24: // string_expr: "relay6" "[" nest_level "]" "." "option" "[" sub_option_code "]" "." option_repr_type
1069#line 304 "parser.yy"
1070 {
1071 switch (ctx.getUniverse()) {
1072 case Option::V6:
1073 {
1074 TokenPtr opt(new TokenRelay6Option(yystack_[8].value.as < int8_t > (), yystack_[3].value.as < uint16_t > (), yystack_[0].value.as < TokenOption::RepresentationType > ()));
1075 ctx.expression.push_back(opt);
1076 break;
1077 }
1078 case Option::V4:
1079 // For now we only use relay6 in DHCPv6.
1080 error(yystack_[10].location, "relay6 can only be used in DHCPv6.");
1081 }
1082 }
1083#line 1084 "parser.cc"
1084 break;
1085
1086 case 25: // string_expr: "pkt" "." pkt_metadata
1087#line 319 "parser.yy"
1088 {
1089 TokenPtr pkt_metadata(new TokenPkt(yystack_[0].value.as < TokenPkt::MetadataType > ()));
1090 ctx.expression.push_back(pkt_metadata);
1091 }
1092#line 1093 "parser.cc"
1093 break;
1094
1095 case 26: // string_expr: "pkt4" "." pkt4_field
1096#line 324 "parser.yy"
1097 {
1098 switch (ctx.getUniverse()) {
1099 case Option::V4:
1100 {
1101 TokenPtr pkt4_field(new TokenPkt4(yystack_[0].value.as < TokenPkt4::FieldType > ()));
1102 ctx.expression.push_back(pkt4_field);
1103 break;
1104 }
1105 case Option::V6:
1106 // For now we only use pkt4 in DHCPv4.
1107 error(yystack_[2].location, "pkt4 can only be used in DHCPv4.");
1108 }
1109 }
1110#line 1111 "parser.cc"
1111 break;
1112
1113 case 27: // string_expr: "pkt6" "." pkt6_field
1114#line 338 "parser.yy"
1115 {
1116 switch (ctx.getUniverse()) {
1117 case Option::V6:
1118 {
1119 TokenPtr pkt6_field(new TokenPkt6(yystack_[0].value.as < TokenPkt6::FieldType > ()));
1120 ctx.expression.push_back(pkt6_field);
1121 break;
1122 }
1123 case Option::V4:
1124 // For now we only use pkt6 in DHCPv6.
1125 error(yystack_[2].location, "pkt6 can only be used in DHCPv6.");
1126 }
1127 }
1128#line 1129 "parser.cc"
1129 break;
1130
1131 case 28: // string_expr: "relay6" "[" nest_level "]" "." relay6_field
1132#line 352 "parser.yy"
1133 {
1134 switch (ctx.getUniverse()) {
1135 case Option::V6:
1136 {
1137 TokenPtr relay6field(new TokenRelay6Field(yystack_[3].value.as < int8_t > (), yystack_[0].value.as < TokenRelay6Field::FieldType > ()));
1138 ctx.expression.push_back(relay6field);
1139 break;
1140 }
1141 case Option::V4:
1142 // For now we only use relay6 in DHCPv6.
1143 error(yystack_[5].location, "relay6 can only be used in DHCPv6.");
1144 }
1145 }
1146#line 1147 "parser.cc"
1147 break;
1148
1149 case 29: // string_expr: "substring" "(" string_expr "," start_expr "," length_expr ")"
1150#line 367 "parser.yy"
1151 {
1152 TokenPtr sub(new TokenSubstring());
1153 ctx.expression.push_back(sub);
1154 }
1155#line 1156 "parser.cc"
1156 break;
1157
1158 case 30: // string_expr: "split" "(" string_expr "," string_expr "," int_expr ")"
1159#line 372 "parser.yy"
1160 {
1161 TokenPtr split(new TokenSplit());
1162 ctx.expression.push_back(split);
1163 }
1164#line 1165 "parser.cc"
1165 break;
1166
1167 case 31: // string_expr: "concat" "(" string_expr "," string_expr ")"
1168#line 377 "parser.yy"
1169 {
1170 TokenPtr conc(new TokenConcat());
1171 ctx.expression.push_back(conc);
1172 }
1173#line 1174 "parser.cc"
1174 break;
1175
1176 case 32: // string_expr: string_expr "+" string_expr
1177#line 382 "parser.yy"
1178 {
1179 TokenPtr conc(new TokenConcat());
1180 ctx.expression.push_back(conc);
1181 }
1182#line 1183 "parser.cc"
1183 break;
1184
1185 case 33: // string_expr: "lcase" "(" string_expr ")"
1186#line 387 "parser.yy"
1187 {
1188 TokenPtr lcase(new TokenLowerCase());
1189 ctx.expression.push_back(lcase);
1190 }
1191#line 1192 "parser.cc"
1192 break;
1193
1194 case 34: // string_expr: "ucase" "(" string_expr ")"
1195#line 392 "parser.yy"
1196 {
1197 TokenPtr ucase(new TokenUpperCase());
1198 ctx.expression.push_back(ucase);
1199 }
1200#line 1201 "parser.cc"
1201 break;
1202
1203 case 35: // string_expr: "ifelse" "(" bool_expr "," string_expr "," string_expr ")"
1204#line 397 "parser.yy"
1205 {
1206 TokenPtr cond(new TokenIfElse());
1207 ctx.expression.push_back(cond);
1208 }
1209#line 1210 "parser.cc"
1210 break;
1211
1212 case 36: // string_expr: "hexstring" "(" string_expr "," string_expr ")"
1213#line 402 "parser.yy"
1214 {
1215 TokenPtr tohex(new TokenToHexString());
1216 ctx.expression.push_back(tohex);
1217 }
1218#line 1219 "parser.cc"
1219 break;
1220
1221 case 37: // string_expr: "addrtotext" "(" string_expr ")"
1222#line 407 "parser.yy"
1223 {
1224 TokenPtr addrtotext(new TokenIpAddressToText());
1225 ctx.expression.push_back(addrtotext);
1226 }
1227#line 1228 "parser.cc"
1228 break;
1229
1230 case 38: // string_expr: "int8totext" "(" string_expr ")"
1231#line 412 "parser.yy"
1232 {
1233 TokenPtr int8totext(new TokenInt8ToText());
1234 ctx.expression.push_back(int8totext);
1235 }
1236#line 1237 "parser.cc"
1237 break;
1238
1239 case 39: // string_expr: "int16totext" "(" string_expr ")"
1240#line 417 "parser.yy"
1241 {
1242 TokenPtr int16totext(new TokenInt16ToText());
1243 ctx.expression.push_back(int16totext);
1244 }
1245#line 1246 "parser.cc"
1246 break;
1247
1248 case 40: // string_expr: "int32totext" "(" string_expr ")"
1249#line 422 "parser.yy"
1250 {
1251 TokenPtr int32totext(new TokenInt32ToText());
1252 ctx.expression.push_back(int32totext);
1253 }
1254#line 1255 "parser.cc"
1255 break;
1256
1257 case 41: // string_expr: "uint8totext" "(" string_expr ")"
1258#line 427 "parser.yy"
1259 {
1260 TokenPtr uint8totext(new TokenUInt8ToText());
1261 ctx.expression.push_back(uint8totext);
1262 }
1263#line 1264 "parser.cc"
1264 break;
1265
1266 case 42: // string_expr: "uint16totext" "(" string_expr ")"
1267#line 432 "parser.yy"
1268 {
1269 TokenPtr uint16totext(new TokenUInt16ToText());
1270 ctx.expression.push_back(uint16totext);
1271 }
1272#line 1273 "parser.cc"
1273 break;
1274
1275 case 43: // string_expr: "uint32totext" "(" string_expr ")"
1276#line 437 "parser.yy"
1277 {
1278 TokenPtr uint32totext(new TokenUInt32ToText());
1279 ctx.expression.push_back(uint32totext);
1280 }
1281#line 1282 "parser.cc"
1282 break;
1283
1284 case 44: // string_expr: "vendor" "." "enterprise"
1285#line 442 "parser.yy"
1286 {
1287 // expression: vendor.enterprise
1288 //
1289 // This token will return enterprise-id number of
1290 // received vendor option.
1292 ctx.expression.push_back(vendor);
1293 }
1294#line 1295 "parser.cc"
1295 break;
1296
1297 case 45: // string_expr: "vendor-class" "." "enterprise"
1298#line 451 "parser.yy"
1299 {
1300 // expression: vendor-class.enterprise
1301 //
1302 // This token will return enterprise-id number of
1303 // received vendor class option.
1304 TokenPtr vendor(new TokenVendorClass(ctx.getUniverse(), 0,
1306 ctx.expression.push_back(vendor);
1307 }
1308#line 1309 "parser.cc"
1309 break;
1310
1311 case 46: // string_expr: "vendor" "[" enterprise_id "]" "." "option" "[" sub_option_code "]" "." option_repr_type
1312#line 461 "parser.yy"
1313 {
1314 // This token will search for vendor option with
1315 // specified enterprise-id. If found, will search
1316 // for specified suboption and finally will return
1317 // its content.
1318 TokenPtr opt(new TokenVendor(ctx.getUniverse(), yystack_[8].value.as < uint32_t > (), yystack_[0].value.as < TokenOption::RepresentationType > (), yystack_[3].value.as < uint16_t > ()));
1319 ctx.expression.push_back(opt);
1320 }
1321#line 1322 "parser.cc"
1322 break;
1323
1324 case 47: // string_expr: "vendor-class" "[" enterprise_id "]" "." "data"
1325#line 470 "parser.yy"
1326 {
1327 // expression: vendor-class[1234].data
1328 //
1329 // Vendor class option does not have suboptions,
1330 // but chunks of data (typically 1, but the option
1331 // structure allows multiple of them). If chunk
1332 // offset is not specified, we assume the first (0th)
1333 // is requested.
1334 TokenPtr vendor_class(new TokenVendorClass(ctx.getUniverse(), yystack_[3].value.as < uint32_t > (),
1335 TokenVendor::DATA, 0));
1336 ctx.expression.push_back(vendor_class);
1337 }
1338#line 1339 "parser.cc"
1339 break;
1340
1341 case 48: // string_expr: "vendor-class" "[" enterprise_id "]" "." "data" "[" "integer" "]"
1342#line 483 "parser.yy"
1343 {
1344 // expression: vendor-class[1234].data[5]
1345 //
1346 // Vendor class option does not have suboptions,
1347 // but chunks of data (typically 1, but the option
1348 // structure allows multiple of them). This syntax
1349 // specifies which data chunk (tuple) we want.
1350 uint8_t index = ctx.convertUint8(yystack_[1].value.as < std::string > (), yystack_[1].location);
1351 TokenPtr vendor_class(new TokenVendorClass(ctx.getUniverse(), yystack_[6].value.as < uint32_t > (),
1352 TokenVendor::DATA, index));
1353 ctx.expression.push_back(vendor_class);
1354 }
1355#line 1356 "parser.cc"
1356 break;
1357
1358 case 49: // string_expr: integer_expr
1359#line 496 "parser.yy"
1360 {
1361 TokenPtr integer(new TokenInteger(yystack_[0].value.as < uint32_t > ()));
1362 ctx.expression.push_back(integer);
1363 }
1364#line 1365 "parser.cc"
1365 break;
1366
1367 case 51: // integer_expr: "integer"
1368#line 504 "parser.yy"
1369 {
1370 yylhs.value.as < uint32_t > () = ctx.convertUint32(yystack_[0].value.as < std::string > (), yystack_[0].location);
1371 }
1372#line 1373 "parser.cc"
1373 break;
1374
1375 case 52: // option_code: "integer"
1376#line 510 "parser.yy"
1377 {
1378 yylhs.value.as < uint16_t > () = ctx.convertOptionCode(yystack_[0].value.as < std::string > (), yystack_[0].location);
1379 }
1380#line 1381 "parser.cc"
1381 break;
1382
1383 case 53: // option_code: "option name"
1384#line 514 "parser.yy"
1385 {
1386 yylhs.value.as < uint16_t > () = ctx.convertOptionName(yystack_[0].value.as < std::string > (), yystack_[0].location);
1387 }
1388#line 1389 "parser.cc"
1389 break;
1390
1391 case 54: // sub_option_code: "integer"
1392#line 520 "parser.yy"
1393 {
1394 yylhs.value.as < uint16_t > () = ctx.convertOptionCode(yystack_[0].value.as < std::string > (), yystack_[0].location);
1395 }
1396#line 1397 "parser.cc"
1397 break;
1398
1399 case 55: // option_repr_type: "text"
1400#line 526 "parser.yy"
1401 {
1403 }
1404#line 1405 "parser.cc"
1405 break;
1406
1407 case 56: // option_repr_type: "hex"
1408#line 530 "parser.yy"
1409 {
1411 }
1412#line 1413 "parser.cc"
1413 break;
1414
1415 case 57: // nest_level: "integer"
1416#line 536 "parser.yy"
1417 {
1418 yylhs.value.as < int8_t > () = ctx.convertNestLevelNumber(yystack_[0].value.as < std::string > (), yystack_[0].location);
1419 }
1420#line 1421 "parser.cc"
1421 break;
1422
1423 case 58: // pkt_metadata: "iface"
1424#line 545 "parser.yy"
1425 {
1426 yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::IFACE;
1427 }
1428#line 1429 "parser.cc"
1429 break;
1430
1431 case 59: // pkt_metadata: "src"
1432#line 549 "parser.yy"
1433 {
1434 yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::SRC;
1435 }
1436#line 1437 "parser.cc"
1437 break;
1438
1439 case 60: // pkt_metadata: "dst"
1440#line 553 "parser.yy"
1441 {
1442 yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::DST;
1443 }
1444#line 1445 "parser.cc"
1445 break;
1446
1447 case 61: // pkt_metadata: "len"
1448#line 557 "parser.yy"
1449 {
1450 yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::LEN;
1451 }
1452#line 1453 "parser.cc"
1453 break;
1454
1455 case 62: // enterprise_id: "integer"
1456#line 563 "parser.yy"
1457 {
1458 yylhs.value.as < uint32_t > () = ctx.convertUint32(yystack_[0].value.as < std::string > (), yystack_[0].location);
1459 }
1460#line 1461 "parser.cc"
1461 break;
1462
1463 case 63: // enterprise_id: "*"
1464#line 567 "parser.yy"
1465 {
1466 yylhs.value.as < uint32_t > () = 0;
1467 }
1468#line 1469 "parser.cc"
1469 break;
1470
1471 case 64: // pkt4_field: "mac"
1472#line 573 "parser.yy"
1473 {
1474 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::CHADDR;
1475 }
1476#line 1477 "parser.cc"
1477 break;
1478
1479 case 65: // pkt4_field: "hlen"
1480#line 577 "parser.yy"
1481 {
1482 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::HLEN;
1483 }
1484#line 1485 "parser.cc"
1485 break;
1486
1487 case 66: // pkt4_field: "htype"
1488#line 581 "parser.yy"
1489 {
1490 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::HTYPE;
1491 }
1492#line 1493 "parser.cc"
1493 break;
1494
1495 case 67: // pkt4_field: "ciaddr"
1496#line 585 "parser.yy"
1497 {
1498 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::CIADDR;
1499 }
1500#line 1501 "parser.cc"
1501 break;
1502
1503 case 68: // pkt4_field: "giaddr"
1504#line 589 "parser.yy"
1505 {
1506 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::GIADDR;
1507 }
1508#line 1509 "parser.cc"
1509 break;
1510
1511 case 69: // pkt4_field: "yiaddr"
1512#line 593 "parser.yy"
1513 {
1514 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::YIADDR;
1515 }
1516#line 1517 "parser.cc"
1517 break;
1518
1519 case 70: // pkt4_field: "siaddr"
1520#line 597 "parser.yy"
1521 {
1522 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::SIADDR;
1523 }
1524#line 1525 "parser.cc"
1525 break;
1526
1527 case 71: // pkt4_field: "msgtype"
1528#line 601 "parser.yy"
1529 {
1530 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::MSGTYPE;
1531 }
1532#line 1533 "parser.cc"
1533 break;
1534
1535 case 72: // pkt4_field: "transid"
1536#line 605 "parser.yy"
1537 {
1538 yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::TRANSID;
1539 }
1540#line 1541 "parser.cc"
1541 break;
1542
1543 case 73: // pkt6_field: "msgtype"
1544#line 611 "parser.yy"
1545 {
1546 yylhs.value.as < TokenPkt6::FieldType > () = TokenPkt6::MSGTYPE;
1547 }
1548#line 1549 "parser.cc"
1549 break;
1550
1551 case 74: // pkt6_field: "transid"
1552#line 615 "parser.yy"
1553 {
1554 yylhs.value.as < TokenPkt6::FieldType > () = TokenPkt6::TRANSID;
1555 }
1556#line 1557 "parser.cc"
1557 break;
1558
1559 case 75: // relay6_field: "peeraddr"
1560#line 621 "parser.yy"
1561 {
1563 }
1564#line 1565 "parser.cc"
1565 break;
1566
1567 case 76: // relay6_field: "linkaddr"
1568#line 625 "parser.yy"
1569 {
1571 }
1572#line 1573 "parser.cc"
1573 break;
1574
1575 case 77: // start_expr: "integer"
1576#line 631 "parser.yy"
1577 {
1578 TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ()));
1579 ctx.expression.push_back(str);
1580 }
1581#line 1582 "parser.cc"
1582 break;
1583
1584 case 78: // length_expr: "integer"
1585#line 638 "parser.yy"
1586 {
1587 TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ()));
1588 ctx.expression.push_back(str);
1589 }
1590#line 1591 "parser.cc"
1591 break;
1592
1593 case 79: // length_expr: "all"
1594#line 643 "parser.yy"
1595 {
1596 TokenPtr str(new TokenString("all"));
1597 ctx.expression.push_back(str);
1598 }
1599#line 1600 "parser.cc"
1600 break;
1601
1602 case 80: // int_expr: "integer"
1603#line 649 "parser.yy"
1604 {
1605 TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ()));
1606 ctx.expression.push_back(str);
1607 }
1608#line 1609 "parser.cc"
1609 break;
1610
1611
1612#line 1613 "parser.cc"
1613
1614 default:
1615 break;
1616 }
1617 }
1618#if YY_EXCEPTIONS
1619 catch (const syntax_error& yyexc)
1620 {
1621 YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
1622 error (yyexc);
1623 YYERROR;
1624 }
1625#endif // YY_EXCEPTIONS
1626 YY_SYMBOL_PRINT ("-> $$ =", yylhs);
1627 yypop_ (yylen);
1628 yylen = 0;
1629
1630 // Shift the result of the reduction.
1631 yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
1632 }
1633 goto yynewstate;
1634
1635
1636 /*--------------------------------------.
1637 | yyerrlab -- here on detecting error. |
1638 `--------------------------------------*/
1639 yyerrlab:
1640 // If not already recovering from an error, report this error.
1641 if (!yyerrstatus_)
1642 {
1643 ++yynerrs_;
1644 context yyctx (*this, yyla);
1645 std::string msg = yysyntax_error_ (yyctx);
1646 error (yyla.location, YY_MOVE (msg));
1647 }
1648
1649
1650 yyerror_range[1].location = yyla.location;
1651 if (yyerrstatus_ == 3)
1652 {
1653 /* If just tried and failed to reuse lookahead token after an
1654 error, discard it. */
1655
1656 // Return failure if at end of input.
1657 if (yyla.kind () == symbol_kind::S_YYEOF)
1658 YYABORT;
1659 else if (!yyla.empty ())
1660 {
1661 yy_destroy_ ("Error: discarding", yyla);
1662 yyla.clear ();
1663 }
1664 }
1665
1666 // Else will try to reuse lookahead token after shifting the error token.
1667 goto yyerrlab1;
1668
1669
1670 /*---------------------------------------------------.
1671 | yyerrorlab -- error raised explicitly by YYERROR. |
1672 `---------------------------------------------------*/
1673 yyerrorlab:
1674 /* Pacify compilers when the user code never invokes YYERROR and
1675 the label yyerrorlab therefore never appears in user code. */
1676 if (false)
1677 YYERROR;
1678
1679 /* Do not reclaim the symbols of the rule whose action triggered
1680 this YYERROR. */
1681 yypop_ (yylen);
1682 yylen = 0;
1683 YY_STACK_PRINT ();
1684 goto yyerrlab1;
1685
1686
1687 /*-------------------------------------------------------------.
1688 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1689 `-------------------------------------------------------------*/
1690 yyerrlab1:
1691 yyerrstatus_ = 3; // Each real token shifted decrements this.
1692 // Pop stack until we find a state that shifts the error token.
1693 for (;;)
1694 {
1695 yyn = yypact_[+yystack_[0].state];
1696 if (!yy_pact_value_is_default_ (yyn))
1697 {
1699 if (0 <= yyn && yyn <= yylast_
1700 && yycheck_[yyn] == symbol_kind::S_YYerror)
1701 {
1702 yyn = yytable_[yyn];
1703 if (0 < yyn)
1704 break;
1705 }
1706 }
1707
1708 // Pop the current state because it cannot handle the error token.
1709 if (yystack_.size () == 1)
1710 YYABORT;
1711
1712 yyerror_range[1].location = yystack_[0].location;
1713 yy_destroy_ ("Error: popping", yystack_[0]);
1714 yypop_ ();
1715 YY_STACK_PRINT ();
1716 }
1717 {
1718 stack_symbol_type error_token;
1719
1720 yyerror_range[2].location = yyla.location;
1721 YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
1722
1723 // Shift the error token.
1724 error_token.state = state_type (yyn);
1725 yypush_ ("Shifting", YY_MOVE (error_token));
1726 }
1727 goto yynewstate;
1728
1729
1730 /*-------------------------------------.
1731 | yyacceptlab -- YYACCEPT comes here. |
1732 `-------------------------------------*/
1733 yyacceptlab:
1734 yyresult = 0;
1735 goto yyreturn;
1736
1737
1738 /*-----------------------------------.
1739 | yyabortlab -- YYABORT comes here. |
1740 `-----------------------------------*/
1741 yyabortlab:
1742 yyresult = 1;
1743 goto yyreturn;
1744
1745
1746 /*-----------------------------------------------------.
1747 | yyreturn -- parsing is finished, return the result. |
1748 `-----------------------------------------------------*/
1749 yyreturn:
1750 if (!yyla.empty ())
1751 yy_destroy_ ("Cleanup: discarding lookahead", yyla);
1752
1753 /* Do not reclaim the symbols of the rule whose action triggered
1754 this YYABORT or YYACCEPT. */
1755 yypop_ (yylen);
1756 YY_STACK_PRINT ();
1757 while (1 < yystack_.size ())
1758 {
1759 yy_destroy_ ("Cleanup: popping", yystack_[0]);
1760 yypop_ ();
1761 }
1762
1763 return yyresult;
1764 }
1765#if YY_EXCEPTIONS
1766 catch (...)
1767 {
1768 YYCDEBUG << "Exception caught: cleaning lookahead and stack\n";
1769 // Do not try to display the values of the reclaimed symbols,
1770 // as their printers might throw an exception.
1771 if (!yyla.empty ())
1772 yy_destroy_ (YY_NULLPTR, yyla);
1773
1774 while (1 < yystack_.size ())
1775 {
1776 yy_destroy_ (YY_NULLPTR, yystack_[0]);
1777 yypop_ ();
1778 }
1779 throw;
1780 }
1781#endif // YY_EXCEPTIONS
1782 }
1783
1784 void
1786 {
1787 error (yyexc.location, yyexc.what ());
1788 }
1789
1790 /* Return YYSTR after stripping away unnecessary quotes and
1791 backslashes, so that it's suitable for yyerror. The heuristic is
1792 that double-quoting is unnecessary unless the string contains an
1793 apostrophe, a comma, or backslash (other than backslash-backslash).
1794 YYSTR is taken from yytname. */
1795 std::string
1796 EvalParser::yytnamerr_ (const char *yystr)
1797 {
1798 if (*yystr == '"')
1799 {
1800 std::string yyr;
1801 char const *yyp = yystr;
1802
1803 for (;;)
1804 switch (*++yyp)
1805 {
1806 case '\'':
1807 case ',':
1808 goto do_not_strip_quotes;
1809
1810 case '\\':
1811 if (*++yyp != '\\')
1812 goto do_not_strip_quotes;
1813 else
1814 goto append;
1815
1816 append:
1817 default:
1818 yyr += *yyp;
1819 break;
1820
1821 case '"':
1822 return yyr;
1823 }
1824 do_not_strip_quotes: ;
1825 }
1826
1827 return yystr;
1828 }
1829
1830 std::string
1832 {
1833 return yytnamerr_ (yytname_[yysymbol]);
1834 }
1835
1836
1837
1838 // EvalParser::context.
1840 : yyparser_ (yyparser)
1841 , yyla_ (yyla)
1842 {}
1843
1844 int
1846 {
1847 // Actual number of expected tokens
1848 int yycount = 0;
1849
1850 const int yyn = yypact_[+yyparser_.yystack_[0].state];
1851 if (!yy_pact_value_is_default_ (yyn))
1852 {
1853 /* Start YYX at -YYN if negative to avoid negative indexes in
1854 YYCHECK. In other words, skip the first -YYN actions for
1855 this state because they are default actions. */
1856 const int yyxbegin = yyn < 0 ? -yyn : 0;
1857 // Stay within bounds of both yycheck and yytname.
1858 const int yychecklim = yylast_ - yyn + 1;
1859 const int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1860 for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
1861 if (yycheck_[yyx + yyn] == yyx && yyx != symbol_kind::S_YYerror
1862 && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
1863 {
1864 if (!yyarg)
1865 ++yycount;
1866 else if (yycount == yyargn)
1867 return 0;
1868 else
1869 yyarg[yycount++] = YY_CAST (symbol_kind_type, yyx);
1870 }
1871 }
1872
1873 if (yyarg && yycount == 0 && 0 < yyargn)
1874 yyarg[0] = symbol_kind::S_YYEMPTY;
1875 return yycount;
1876 }
1877
1878
1879
1880
1881
1882
1883 int
1884 EvalParser::yy_syntax_error_arguments_ (const context& yyctx,
1885 symbol_kind_type yyarg[], int yyargn) const
1886 {
1887 /* There are many possibilities here to consider:
1888 - If this state is a consistent state with a default action, then
1889 the only way this function was invoked is if the default action
1890 is an error action. In that case, don't check for expected
1891 tokens because there are none.
1892 - The only way there can be no lookahead present (in yyla) is
1893 if this state is a consistent state with a default action.
1894 Thus, detecting the absence of a lookahead is sufficient to
1895 determine that there is no unexpected or expected token to
1896 report. In that case, just report a simple "syntax error".
1897 - Don't assume there isn't a lookahead just because this state is
1898 a consistent state with a default action. There might have
1899 been a previous inconsistent state, consistent state with a
1900 non-default action, or user semantic action that manipulated
1901 yyla. (However, yyla is currently not documented for users.)
1902 - Of course, the expected token list depends on states to have
1903 correct lookahead information, and it depends on the parser not
1904 to perform extra reductions after fetching a lookahead from the
1905 scanner and before detecting a syntax error. Thus, state merging
1906 (from LALR or IELR) and default reductions corrupt the expected
1907 token list. However, the list is correct for canonical LR with
1908 one exception: it will still contain any token that will not be
1909 accepted due to an error action in a later state.
1910 */
1911
1912 if (!yyctx.lookahead ().empty ())
1913 {
1914 if (yyarg)
1915 yyarg[0] = yyctx.token ();
1916 int yyn = yyctx.expected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn - 1);
1917 return yyn + 1;
1918 }
1919 return 0;
1920 }
1921
1922 // Generate an error message.
1923 std::string
1924 EvalParser::yysyntax_error_ (const context& yyctx) const
1925 {
1926 // Its maximum.
1927 enum { YYARGS_MAX = 5 };
1928 // Arguments of yyformat.
1929 symbol_kind_type yyarg[YYARGS_MAX];
1930 int yycount = yy_syntax_error_arguments_ (yyctx, yyarg, YYARGS_MAX);
1931
1932 char const* yyformat = YY_NULLPTR;
1933 switch (yycount)
1934 {
1935#define YYCASE_(N, S) \
1936 case N: \
1937 yyformat = S; \
1938 break
1939 default: // Avoid compiler warnings.
1940 YYCASE_ (0, YY_("syntax error"));
1941 YYCASE_ (1, YY_("syntax error, unexpected %s"));
1942 YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s"));
1943 YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1944 YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1945 YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1946#undef YYCASE_
1947 }
1948
1949 std::string yyres;
1950 // Argument number.
1951 std::ptrdiff_t yyi = 0;
1952 for (char const* yyp = yyformat; *yyp; ++yyp)
1953 if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
1954 {
1955 yyres += symbol_name (yyarg[yyi++]);
1956 ++yyp;
1957 }
1958 else
1959 yyres += *yyp;
1960 return yyres;
1961 }
1962
1963
1964 const short EvalParser::yypact_ninf_ = -160;
1965
1966 const signed char EvalParser::yytable_ninf_ = -1;
1967
1968 const short
1969 EvalParser::yypact_[] =
1970 {
1971 -38, 113, 162, 17, 113, 113, 23, 73, 88, 126,
1972 100, 132, 163, 166, 183, 191, 195, 198, 211, 212,
1973 219, 231, 233, 234, 235, 236, 153, 135, 167, -160,
1974 -160, -160, -160, -160, 36, 62, -160, 162, 180, 184,
1975 225, 170, 174, 138, -160, 124, 0, -160, 128, 179,
1976 185, 187, 86, -4, 162, 162, 162, 113, 162, 162,
1977 162, 162, 162, 162, 162, 162, 162, 162, 42, 31,
1978 186, 31, 188, 113, 113, 162, 162, 2, 128, 179,
1979 185, 31, 31, -160, -160, -160, -160, 226, -160, 227,
1980 -160, 229, 245, -160, -160, -160, -160, -160, -160, -160,
1981 -160, -160, -160, -160, -160, -160, -160, -160, 181, 182,
1982 189, 78, 192, 5, 6, 7, 8, 11, 12, 16,
1983 28, 29, -160, -160, -160, -160, -160, 237, -160, 238,
1984 -160, -160, 244, 138, -160, 239, 240, 241, 242, 243,
1985 246, 247, 248, -160, 190, 162, 162, 162, 162, -160,
1986 -160, -160, -160, -160, -160, -160, -160, -160, 249, 250,
1987 251, 252, 253, 254, 255, 72, 94, 91, -160, 214,
1988 193, 30, 196, 32, -17, 10, 80, 114, 93, 203,
1989 264, 259, -160, -160, -160, -160, -160, -160, 260, -160,
1990 -160, -160, -31, 199, -160, 162, -160, -160, 261, 262,
1991 -160, 263, 265, 266, 179, 179, -160, -160, 258, -160,
1992 275, 33, 220, 179, 179, 179, 179, 267, 268, -160,
1993 -160, -160, 269, 270, 271, 272, 273, 274, 276, -160,
1994 277, 278, 279, 280, 101, 122, 161, 114, 114, 114,
1995 -160, -160, -160, -160, -160, -160
1996 };
1997
1998 const signed char
1999 EvalParser::yydefact_[] =
2000 {
2001 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2002 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2003 0, 0, 0, 0, 0, 0, 0, 0, 0, 18,
2004 51, 19, 20, 2, 4, 0, 49, 0, 0, 0,
2005 0, 0, 0, 3, 1, 0, 0, 6, 0, 0,
2006 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2007 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2008 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2009 0, 0, 0, 5, 50, 52, 53, 0, 54, 0,
2010 57, 0, 0, 58, 59, 60, 61, 25, 64, 65,
2011 66, 67, 68, 69, 70, 71, 72, 26, 0, 0,
2012 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2013 0, 0, 73, 74, 27, 63, 62, 0, 45, 0,
2014 44, 7, 8, 9, 32, 0, 0, 0, 0, 0,
2015 0, 0, 0, 17, 0, 0, 0, 0, 0, 37,
2016 38, 39, 40, 41, 42, 43, 33, 34, 0, 0,
2017 0, 0, 0, 0, 0, 0, 0, 0, 77, 0,
2018 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2019 0, 0, 55, 56, 10, 21, 12, 23, 0, 75,
2020 76, 28, 0, 0, 31, 0, 36, 14, 47, 0,
2021 15, 0, 0, 0, 0, 0, 79, 78, 0, 80,
2022 0, 0, 0, 0, 0, 0, 0, 0, 0, 29,
2023 30, 35, 0, 0, 0, 0, 0, 0, 0, 48,
2024 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2025 11, 22, 13, 24, 16, 46
2026 };
2027
2028 const short
2029 EvalParser::yypgoto_[] =
2030 {
2031 -160, -160, -160, 9, -2, -160, 221, -78, -159, 210,
2032 -160, 15, -160, -160, -160, -160, -160, -160
2033 };
2034
2035 const unsigned char
2036 EvalParser::yydefgoto_[] =
2037 {
2038 0, 3, 33, 34, 35, 36, 87, 89, 185, 91,
2039 97, 127, 107, 124, 191, 169, 208, 210
2040 };
2041
2042 const unsigned char
2043 EvalParser::yytable_[] =
2044 {
2045 43, 136, 46, 197, 84, 206, 84, 187, 75, 149,
2046 150, 151, 152, 45, 47, 153, 154, 44, 187, 199,
2047 155, 1, 2, 98, 99, 100, 101, 102, 103, 104,
2048 200, 207, 156, 157, 194, 77, 196, 221, 48, 76,
2049 198, 76, 73, 74, 76, 76, 76, 76, 105, 106,
2050 76, 76, 108, 109, 110, 76, 112, 113, 114, 115,
2051 116, 117, 118, 119, 120, 121, 111, 76, 76, 76,
2052 75, 76, 76, 133, 134, 241, 243, 245, 241, 243,
2053 245, 181, 131, 132, 73, 74, 129, 125, 49, 201,
2054 182, 183, 184, 126, 122, 123, 138, 139, 182, 183,
2055 188, 76, 202, 50, 189, 190, 189, 190, 93, 94,
2056 95, 96, 182, 183, 186, 147, 4, 52, 5, 182,
2057 183, 240, 6, 7, 8, 9, 217, 218, 83, 51,
2058 73, 74, 182, 183, 10, 223, 224, 225, 226, 11,
2059 182, 183, 242, 170, 171, 172, 173, 12, 13, 53,
2060 69, 14, 70, 15, 16, 17, 18, 19, 20, 21,
2061 22, 23, 24, 25, 26, 37, 54, 27, 28, 55,
2062 68, 38, 39, 40, 29, 30, 31, 76, 32, 182,
2063 183, 244, 71, 10, 72, 81, 56, 70, 11, 82,
2064 85, 72, 86, 211, 57, 78, 12, 13, 58, 79,
2065 14, 59, 15, 16, 17, 18, 19, 20, 21, 22,
2066 23, 24, 25, 26, 60, 61, 41, 42, 144, 145,
2067 76, 76, 62, 29, 30, 31, 146, 32, 76, 148,
2068 193, 76, 76, 195, 63, 76, 64, 65, 66, 67,
2069 80, 88, 140, 141, 128, 142, 130, 90, 92, 143,
2070 73, 192, 168, 158, 159, 160, 161, 162, 163, 164,
2071 198, 209, 219, 165, 166, 167, 174, 175, 176, 177,
2072 178, 179, 180, 203, 204, 205, 212, 213, 214, 220,
2073 215, 216, 222, 227, 228, 229, 230, 231, 232, 233,
2074 137, 234, 0, 235, 236, 237, 238, 239, 0, 135
2075 };
2076
2077 const short
2078 EvalParser::yycheck_[] =
2079 {
2080 2, 79, 4, 20, 4, 36, 4, 166, 8, 4,
2081 4, 4, 4, 4, 5, 4, 4, 0, 177, 9,
2082 4, 59, 60, 27, 28, 29, 30, 31, 32, 33,
2083 20, 62, 4, 4, 4, 37, 4, 4, 15, 39,
2084 57, 39, 6, 7, 39, 39, 39, 39, 52, 53,
2085 39, 39, 54, 55, 56, 39, 58, 59, 60, 61,
2086 62, 63, 64, 65, 66, 67, 57, 39, 39, 39,
2087 8, 39, 39, 75, 76, 234, 235, 236, 237, 238,
2088 239, 9, 73, 74, 6, 7, 71, 56, 15, 9,
2089 18, 19, 20, 62, 52, 53, 81, 82, 18, 19,
2090 9, 39, 9, 15, 13, 14, 13, 14, 22, 23,
2091 24, 25, 18, 19, 20, 37, 3, 17, 5, 18,
2092 19, 20, 9, 10, 11, 12, 204, 205, 4, 3,
2093 6, 7, 18, 19, 21, 213, 214, 215, 216, 26,
2094 18, 19, 20, 145, 146, 147, 148, 34, 35, 17,
2095 15, 38, 17, 40, 41, 42, 43, 44, 45, 46,
2096 47, 48, 49, 50, 51, 3, 3, 54, 55, 3,
2097 17, 9, 10, 11, 61, 62, 63, 39, 65, 18,
2098 19, 20, 15, 21, 17, 15, 3, 17, 26, 15,
2099 62, 17, 64, 195, 3, 15, 34, 35, 3, 15,
2100 38, 3, 40, 41, 42, 43, 44, 45, 46, 47,
2101 48, 49, 50, 51, 3, 3, 54, 55, 37, 37,
2102 39, 39, 3, 61, 62, 63, 37, 65, 39, 37,
2103 37, 39, 39, 37, 3, 39, 3, 3, 3, 3,
2104 15, 62, 16, 16, 58, 16, 58, 62, 61, 4,
2105 6, 37, 62, 16, 16, 16, 16, 16, 16, 16,
2106 57, 62, 4, 17, 17, 17, 17, 17, 17, 17,
2107 17, 17, 17, 9, 15, 15, 15, 15, 15, 4,
2108 15, 15, 62, 16, 16, 16, 16, 16, 16, 16,
2109 80, 17, -1, 17, 17, 17, 17, 17, -1, 78
2110 };
2111
2112 const signed char
2113 EvalParser::yystos_[] =
2114 {
2115 0, 59, 60, 67, 3, 5, 9, 10, 11, 12,
2116 21, 26, 34, 35, 38, 40, 41, 42, 43, 44,
2117 45, 46, 47, 48, 49, 50, 51, 54, 55, 61,
2118 62, 63, 65, 68, 69, 70, 71, 3, 9, 10,
2119 11, 54, 55, 70, 0, 69, 70, 69, 15, 15,
2120 15, 3, 17, 17, 3, 3, 3, 3, 3, 3,
2121 3, 3, 3, 3, 3, 3, 3, 3, 17, 15,
2122 17, 15, 17, 6, 7, 8, 39, 70, 15, 15,
2123 15, 15, 15, 4, 4, 62, 64, 72, 62, 73,
2124 62, 75, 61, 22, 23, 24, 25, 76, 27, 28,
2125 29, 30, 31, 32, 33, 52, 53, 78, 70, 70,
2126 70, 69, 70, 70, 70, 70, 70, 70, 70, 70,
2127 70, 70, 52, 53, 79, 56, 62, 77, 58, 77,
2128 58, 69, 69, 70, 70, 72, 73, 75, 77, 77,
2129 16, 16, 16, 4, 37, 37, 37, 37, 37, 4,
2130 4, 4, 4, 4, 4, 4, 4, 4, 16, 16,
2131 16, 16, 16, 16, 16, 17, 17, 17, 62, 81,
2132 70, 70, 70, 70, 17, 17, 17, 17, 17, 17,
2133 17, 9, 18, 19, 20, 74, 20, 74, 9, 13,
2134 14, 80, 37, 37, 4, 37, 4, 20, 57, 9,
2135 20, 9, 9, 9, 15, 15, 36, 62, 82, 62,
2136 83, 70, 15, 15, 15, 15, 15, 73, 73, 4,
2137 4, 4, 62, 73, 73, 73, 73, 16, 16, 16,
2138 16, 16, 16, 16, 17, 17, 17, 17, 17, 17,
2139 20, 74, 20, 74, 20, 74
2140 };
2141
2142 const signed char
2143 EvalParser::yyr1_[] =
2144 {
2145 0, 66, 67, 67, 68, 69, 69, 69, 69, 69,
2146 69, 69, 69, 69, 69, 69, 69, 69, 70, 70,
2147 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
2148 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
2149 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
2150 70, 71, 72, 72, 73, 74, 74, 75, 76, 76,
2151 76, 76, 77, 77, 78, 78, 78, 78, 78, 78,
2152 78, 78, 78, 79, 79, 80, 80, 81, 82, 82,
2153 83
2154 };
2155
2156 const signed char
2157 EvalParser::yyr2_[] =
2158 {
2159 0, 2, 2, 2, 1, 3, 2, 3, 3, 3,
2160 6, 11, 6, 11, 6, 6, 11, 4, 1, 1,
2161 1, 6, 11, 6, 11, 3, 3, 3, 6, 8,
2162 8, 6, 3, 4, 4, 8, 6, 4, 4, 4,
2163 4, 4, 4, 4, 3, 3, 11, 6, 9, 1,
2164 3, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2165 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2166 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2167 1
2168 };
2169
2170
2171#if EVALDEBUG || 1
2172 // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2173 // First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
2174 const char*
2175 const EvalParser::yytname_[] =
2176 {
2177 "\"end of file\"", "error", "\"invalid token\"", "\"(\"", "\")\"",
2178 "\"not\"", "\"and\"", "\"or\"", "\"==\"", "\"option\"", "\"relay4\"",
2179 "\"relay6\"", "\"member\"", "\"peeraddr\"", "\"linkaddr\"", "\"[\"",
2180 "\"]\"", "\".\"", "\"text\"", "\"hex\"", "\"exists\"", "\"pkt\"",
2181 "\"iface\"", "\"src\"", "\"dst\"", "\"len\"", "\"pkt4\"", "\"mac\"",
2182 "\"hlen\"", "\"htype\"", "\"ciaddr\"", "\"giaddr\"", "\"yiaddr\"",
2183 "\"siaddr\"", "\"substring\"", "\"split\"", "\"all\"", "\",\"",
2184 "\"concat\"", "\"+\"", "\"ifelse\"", "\"hexstring\"", "\"addrtotext\"",
2185 "\"int8totext\"", "\"int16totext\"", "\"int32totext\"",
2186 "\"uint8totext\"", "\"uint16totext\"", "\"uint32totext\"", "\"lcase\"",
2187 "\"ucase\"", "\"pkt6\"", "\"msgtype\"", "\"transid\"",
2188 "\"vendor-class\"", "\"vendor\"", "\"*\"", "\"data\"", "\"enterprise\"",
2189 "\"top-level bool\"", "\"top-level string\"", "\"constant string\"",
2190 "\"integer\"", "\"constant hexstring\"", "\"option name\"",
2191 "\"ip address\"", "$accept", "start", "expression", "bool_expr",
2192 "string_expr", "integer_expr", "option_code", "sub_option_code",
2193 "option_repr_type", "nest_level", "pkt_metadata", "enterprise_id",
2194 "pkt4_field", "pkt6_field", "relay6_field", "start_expr", "length_expr",
2195 "int_expr", YY_NULLPTR
2196 };
2197#endif
2198
2199
2200#if EVALDEBUG
2201 const short
2202 EvalParser::yyrline_[] =
2203 {
2204 0, 138, 138, 139, 144, 147, 148, 153, 158, 163,
2205 168, 173, 178, 198, 212, 221, 230, 240, 257, 262,
2206 267, 272, 277, 282, 303, 318, 323, 337, 351, 366,
2207 371, 376, 381, 386, 391, 396, 401, 406, 411, 416,
2208 421, 426, 431, 436, 441, 450, 460, 469, 482, 495,
2209 500, 503, 509, 513, 519, 525, 529, 535, 544, 548,
2210 552, 556, 562, 566, 572, 576, 580, 584, 588, 592,
2211 596, 600, 604, 610, 614, 620, 624, 630, 637, 642,
2212 648
2213 };
2214
2215 void
2216 EvalParser::yy_stack_print_ () const
2217 {
2218 *yycdebug_ << "Stack now";
2219 for (stack_type::const_iterator
2220 i = yystack_.begin (),
2221 i_end = yystack_.end ();
2222 i != i_end; ++i)
2223 *yycdebug_ << ' ' << int (i->state);
2224 *yycdebug_ << '\n';
2225 }
2226
2227 void
2228 EvalParser::yy_reduce_print_ (int yyrule) const
2229 {
2230 int yylno = yyrline_[yyrule];
2231 int yynrhs = yyr2_[yyrule];
2232 // Print the symbols being reduced, and their result.
2233 *yycdebug_ << "Reducing stack by rule " << yyrule - 1
2234 << " (line " << yylno << "):\n";
2235 // The symbols being reduced.
2236 for (int yyi = 0; yyi < yynrhs; yyi++)
2237 YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
2238 yystack_[(yynrhs) - (yyi + 1)]);
2239 }
2240#endif // EVALDEBUG
2241
2242
2243#line 14 "parser.yy"
2244} } // isc::eval
2245#line 2246 "parser.cc"
2246
2247#line 655 "parser.yy"
2248
2249void
2251 const std::string& what)
2252{
2253 ctx.error(loc, what);
2254}
#define yylex
Definition: agent_lexer.cc:27
#define YYCDEBUG
#define YYABORT
#define YYLLOC_DEFAULT(Current, Rhs, N)
Definition: agent_parser.cc:87
#define YY_REDUCE_PRINT(Rule)
#define YY_SYMBOL_PRINT(Title, Symbol)
#define YYCASE_(N, S)
#define YY_STACK_PRINT()
#define YY_(msgid)
Definition: agent_parser.cc:67
#define YYACCEPT
#define YYERROR
#define YY_RVREF(Type)
Definition: agent_parser.h:85
#define YY_CAST(Type, Val)
Definition: agent_parser.h:177
#define YY_MOVE_REF(Type)
Definition: agent_parser.h:84
#define YY_NOEXCEPT
Definition: agent_parser.h:94
#define YY_MOVE
Definition: agent_parser.h:82
#define YY_NOTHROW
Definition: agent_parser.h:95
#define YY_USE(E)
Definition: agent_parser.h:130
Token that represents logical and operator.
Definition: token.h:994
Token that represents concat operator (concatenates two other tokens)
Definition: token.h:877
Token that represents equality operator (compares two other tokens)
Definition: token.h:751
Token representing a constant string in hexadecimal format.
Definition: token.h:134
Token that represents an alternative.
Definition: token.h:905
Token representing a 16 bit integer as a string.
Definition: token.h:280
Token representing a 32 bit integer as a string.
Definition: token.h:298
Token representing an 8 bit integer as a string.
Definition: token.h:262
Token representing an unsigned 32 bit integer.
Definition: token.h:195
Token representing an IP address as a string.
Definition: token.h:245
Token representing an IP address as a constant string.
Definition: token.h:222
Token representing a constant lower case string.
Definition: token.h:159
Token that represents client class membership.
Definition: token.h:1044
Token that represents logical negation operator.
Definition: token.h:970
Token that represents a value of an option.
Definition: token.h:375
RepresentationType
Token representation type.
Definition: token.h:385
Token that represents logical or operator.
Definition: token.h:1019
Token that represents fields of a DHCPv4 packet.
Definition: token.h:589
FieldType
enum value that determines the field.
Definition: token.h:593
@ CIADDR
ciaddr (IPv4 address)
Definition: token.h:596
@ HLEN
hlen (hardware address length)
Definition: token.h:599
@ HTYPE
htype (hardware address type)
Definition: token.h:600
@ GIADDR
giaddr (IPv4 address)
Definition: token.h:595
@ CHADDR
chaddr field (up to 16 bytes link-layer address)
Definition: token.h:594
@ YIADDR
yiaddr (IPv4 address)
Definition: token.h:597
@ SIADDR
siaddr (IPv4 address)
Definition: token.h:598
@ TRANSID
transaction-id (xid)
Definition: token.h:602
@ MSGTYPE
message type (not really a field, content of option 53)
Definition: token.h:601
Token that represents fields of DHCPv6 packet.
Definition: token.h:643
FieldType
enum value that determines the field.
Definition: token.h:646
@ TRANSID
transaction id (integer but manipulated as a string)
Definition: token.h:648
@ MSGTYPE
msg type
Definition: token.h:647
Token that represents meta data of a DHCP packet.
Definition: token.h:540
MetadataType
enum value that determines the field.
Definition: token.h:544
@ LEN
length (4 octets)
Definition: token.h:548
@ DST
destination (IP address)
Definition: token.h:547
@ IFACE
interface name (string)
Definition: token.h:545
@ SRC
source (IP address)
Definition: token.h:546
Represents a sub-option inserted by the DHCPv4 relay.
Definition: token.h:466
Token that represents a value of a field within a DHCPv6 relay encapsulation.
Definition: token.h:694
FieldType
enum value that determines the field.
Definition: token.h:698
@ LINKADDR
Link address field (IPv6 address)
Definition: token.h:700
@ PEERADDR
Peer address field (IPv6 address)
Definition: token.h:699
Token that represents a value of an option within a DHCPv6 relay encapsulation.
Definition: token.h:498
The order where Token subtypes are declared should be:
Definition: token.h:113
Token that represents sub-options in DHCPv4 and DHCPv6.
Definition: token.h:1275
Token that represents the substring operator (returns a portion of the supplied string)
Definition: token.h:776
Token that converts to hexadecimal string.
Definition: token.h:935
Token representing a 16 bit unsigned integer as a string.
Definition: token.h:334
Token representing a 32 bit unsigned integer as a string.
Definition: token.h:352
Token representing an 8 bit unsigned integer as a string.
Definition: token.h:316
Token representing a constant upper case string.
Definition: token.h:176
Token that represents vendor class options in DHCPv4 and DHCPv6.
Definition: token.h:1203
Token that represents vendor options in DHCPv4 and DHCPv6.
Definition: token.h:1089
@ DATA
data chunk, used in derived vendor-class only
Definition: token.h:1097
@ ENTERPRISE_ID
enterprise-id field (vendor-info, vendor-class)
Definition: token.h:1095
Evaluation context, an interface to the expression evaluation.
Definition: eval_context.h:34
int8_t convertNestLevelNumber(const std::string &nest_level, const isc::eval::location &loc)
Nest level conversion.
uint16_t convertOptionCode(const std::string &option_code, const isc::eval::location &loc)
Option code conversion.
Definition: eval_context.cc:65
uint16_t convertOptionName(const std::string &option_name, const isc::eval::location &loc)
Option name conversion.
Definition: eval_context.cc:89
isc::dhcp::Expression expression
Parsed expression (output tokens are stored here)
Definition: eval_context.h:67
Option::Universe getUniverse()
Returns the universe (v4 or v6)
Definition: eval_context.h:218
static uint32_t convertUint32(const std::string &number, const isc::eval::location &loc)
Attempts to convert string to unsigned 32bit integer.
bool isClientClassDefined(const ClientClass &client_class)
Check if a client class is already defined.
static uint8_t convertUint8(const std::string &number, const isc::eval::location &loc)
Attempts to convert string to unsigned 8bit integer.
const symbol_type & lookahead() const YY_NOEXCEPT
Definition: parser.h:2126
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:1845
context(const EvalParser &yyparser, const symbol_type &yyla)
Definition: parser.cc:1839
symbol_kind_type token() const YY_NOEXCEPT
Definition: parser.h:2127
Present a slice of the top of a stack.
Definition: parser.h:2393
A Bison parser.
Definition: parser.h:215
symbol_kind::symbol_kind_type symbol_kind_type
(Internal) symbol kind.
Definition: parser.h:680
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:683
virtual void error(const location_type &loc, const std::string &msg)
Report a syntax error.
Definition: parser.cc:2250
static std::string symbol_name(symbol_kind_type yysymbol)
The user-facing name of the symbol whose (internal) number is YYSYMBOL.
Definition: parser.cc:1831
@ error
Definition: db_log.h:118
boost::shared_ptr< Token > TokenPtr
Pointer to a single Token.
Definition: token.h:20
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:2593
location_type location
The location.
Definition: parser.h:995
bool empty() const YY_NOEXCEPT
Whether empty.
Definition: parser.h:2586
void clear() YY_NOEXCEPT
Destroy contents, and record that is empty.
Definition: parser.h:912
"External" symbols: returned by the scanner.
Definition: parser.h:1049
Syntax errors thrown from user actions.
Definition: parser.h:486
~syntax_error() YY_NOEXCEPT YY_NOTHROW
Definition: parser.cc:165