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