Kea  2.3.9
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"
148 namespace 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)
204  return symbol_kind::S_YYEMPTY;
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 127 "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 127 "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 127 "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 127 "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 127 "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 127 "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 127 "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 127 "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 127 "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 127 "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 127 "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 127 "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 127 "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 127 "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 127 "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&
591  {
592  return *yycdebug_;
593  }
594 
595  void
597  {
598  yycdebug_ = &o;
599  }
600 
601 
604  {
605  return yydebug_;
606  }
607 
608  void
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';
682  YY_STACK_PRINT ();
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 147 "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 152 "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 157 "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 162 "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 167 "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 172 "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 177 "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 197 "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 211 "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 220 "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 229 "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 239 "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 256 "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 261 "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 266 "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 271 "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 276 "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 281 "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 302 "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 317 "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 322 "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 336 "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 350 "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 365 "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 370 "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 375 "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 380 "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: "ifelse" "(" bool_expr "," string_expr "," string_expr ")"
1186 #line 385 "parser.yy"
1187  {
1188  TokenPtr cond(new TokenIfElse());
1189  ctx.expression.push_back(cond);
1190  }
1191 #line 1192 "parser.cc"
1192  break;
1193 
1194  case 34: // string_expr: "hexstring" "(" string_expr "," string_expr ")"
1195 #line 390 "parser.yy"
1196  {
1197  TokenPtr tohex(new TokenToHexString());
1198  ctx.expression.push_back(tohex);
1199  }
1200 #line 1201 "parser.cc"
1201  break;
1202 
1203  case 35: // string_expr: "addrtotext" "(" string_expr ")"
1204 #line 395 "parser.yy"
1205  {
1206  TokenPtr addrtotext(new TokenIpAddressToText());
1207  ctx.expression.push_back(addrtotext);
1208  }
1209 #line 1210 "parser.cc"
1210  break;
1211 
1212  case 36: // string_expr: "int8totext" "(" string_expr ")"
1213 #line 400 "parser.yy"
1214  {
1215  TokenPtr int8totext(new TokenInt8ToText());
1216  ctx.expression.push_back(int8totext);
1217  }
1218 #line 1219 "parser.cc"
1219  break;
1220 
1221  case 37: // string_expr: "int16totext" "(" string_expr ")"
1222 #line 405 "parser.yy"
1223  {
1224  TokenPtr int16totext(new TokenInt16ToText());
1225  ctx.expression.push_back(int16totext);
1226  }
1227 #line 1228 "parser.cc"
1228  break;
1229 
1230  case 38: // string_expr: "int32totext" "(" string_expr ")"
1231 #line 410 "parser.yy"
1232  {
1233  TokenPtr int32totext(new TokenInt32ToText());
1234  ctx.expression.push_back(int32totext);
1235  }
1236 #line 1237 "parser.cc"
1237  break;
1238 
1239  case 39: // string_expr: "uint8totext" "(" string_expr ")"
1240 #line 415 "parser.yy"
1241  {
1242  TokenPtr uint8totext(new TokenUInt8ToText());
1243  ctx.expression.push_back(uint8totext);
1244  }
1245 #line 1246 "parser.cc"
1246  break;
1247 
1248  case 40: // string_expr: "uint16totext" "(" string_expr ")"
1249 #line 420 "parser.yy"
1250  {
1251  TokenPtr uint16totext(new TokenUInt16ToText());
1252  ctx.expression.push_back(uint16totext);
1253  }
1254 #line 1255 "parser.cc"
1255  break;
1256 
1257  case 41: // string_expr: "uint32totext" "(" string_expr ")"
1258 #line 425 "parser.yy"
1259  {
1260  TokenPtr uint32totext(new TokenUInt32ToText());
1261  ctx.expression.push_back(uint32totext);
1262  }
1263 #line 1264 "parser.cc"
1264  break;
1265 
1266  case 42: // string_expr: "vendor" "." "enterprise"
1267 #line 430 "parser.yy"
1268  {
1269  // expression: vendor.enterprise
1270  //
1271  // This token will return enterprise-id number of
1272  // received vendor option.
1273  TokenPtr vendor(new TokenVendor(ctx.getUniverse(), 0, TokenVendor::ENTERPRISE_ID));
1274  ctx.expression.push_back(vendor);
1275  }
1276 #line 1277 "parser.cc"
1277  break;
1278 
1279  case 43: // string_expr: "vendor-class" "." "enterprise"
1280 #line 439 "parser.yy"
1281  {
1282  // expression: vendor-class.enterprise
1283  //
1284  // This token will return enterprise-id number of
1285  // received vendor class option.
1286  TokenPtr vendor(new TokenVendorClass(ctx.getUniverse(), 0,
1287  TokenVendor::ENTERPRISE_ID));
1288  ctx.expression.push_back(vendor);
1289  }
1290 #line 1291 "parser.cc"
1291  break;
1292 
1293  case 44: // string_expr: "vendor" "[" enterprise_id "]" "." "option" "[" sub_option_code "]" "." option_repr_type
1294 #line 449 "parser.yy"
1295  {
1296  // This token will search for vendor option with
1297  // specified enterprise-id. If found, will search
1298  // for specified suboption and finally will return
1299  // its content.
1300  TokenPtr opt(new TokenVendor(ctx.getUniverse(), yystack_[8].value.as < uint32_t > (), yystack_[0].value.as < TokenOption::RepresentationType > (), yystack_[3].value.as < uint16_t > ()));
1301  ctx.expression.push_back(opt);
1302  }
1303 #line 1304 "parser.cc"
1304  break;
1305 
1306  case 45: // string_expr: "vendor-class" "[" enterprise_id "]" "." "data"
1307 #line 458 "parser.yy"
1308  {
1309  // expression: vendor-class[1234].data
1310  //
1311  // Vendor class option does not have suboptions,
1312  // but chunks of data (typically 1, but the option
1313  // structure allows multiple of them). If chunk
1314  // offset is not specified, we assume the first (0th)
1315  // is requested.
1316  TokenPtr vendor_class(new TokenVendorClass(ctx.getUniverse(), yystack_[3].value.as < uint32_t > (),
1317  TokenVendor::DATA, 0));
1318  ctx.expression.push_back(vendor_class);
1319  }
1320 #line 1321 "parser.cc"
1321  break;
1322 
1323  case 46: // string_expr: "vendor-class" "[" enterprise_id "]" "." "data" "[" "integer" "]"
1324 #line 471 "parser.yy"
1325  {
1326  // expression: vendor-class[1234].data[5]
1327  //
1328  // Vendor class option does not have suboptions,
1329  // but chunks of data (typically 1, but the option
1330  // structure allows multiple of them). This syntax
1331  // specifies which data chunk (tuple) we want.
1332  uint8_t index = ctx.convertUint8(yystack_[1].value.as < std::string > (), yystack_[1].location);
1333  TokenPtr vendor_class(new TokenVendorClass(ctx.getUniverse(), yystack_[6].value.as < uint32_t > (),
1334  TokenVendor::DATA, index));
1335  ctx.expression.push_back(vendor_class);
1336  }
1337 #line 1338 "parser.cc"
1338  break;
1339 
1340  case 47: // string_expr: integer_expr
1341 #line 484 "parser.yy"
1342  {
1343  TokenPtr integer(new TokenInteger(yystack_[0].value.as < uint32_t > ()));
1344  ctx.expression.push_back(integer);
1345  }
1346 #line 1347 "parser.cc"
1347  break;
1348 
1349  case 49: // integer_expr: "integer"
1350 #line 492 "parser.yy"
1351  {
1352  yylhs.value.as < uint32_t > () = ctx.convertUint32(yystack_[0].value.as < std::string > (), yystack_[0].location);
1353  }
1354 #line 1355 "parser.cc"
1355  break;
1356 
1357  case 50: // option_code: "integer"
1358 #line 498 "parser.yy"
1359  {
1360  yylhs.value.as < uint16_t > () = ctx.convertOptionCode(yystack_[0].value.as < std::string > (), yystack_[0].location);
1361  }
1362 #line 1363 "parser.cc"
1363  break;
1364 
1365  case 51: // option_code: "option name"
1366 #line 502 "parser.yy"
1367  {
1368  yylhs.value.as < uint16_t > () = ctx.convertOptionName(yystack_[0].value.as < std::string > (), yystack_[0].location);
1369  }
1370 #line 1371 "parser.cc"
1371  break;
1372 
1373  case 52: // sub_option_code: "integer"
1374 #line 508 "parser.yy"
1375  {
1376  yylhs.value.as < uint16_t > () = ctx.convertOptionCode(yystack_[0].value.as < std::string > (), yystack_[0].location);
1377  }
1378 #line 1379 "parser.cc"
1379  break;
1380 
1381  case 53: // option_repr_type: "text"
1382 #line 514 "parser.yy"
1383  {
1384  yylhs.value.as < TokenOption::RepresentationType > () = TokenOption::TEXTUAL;
1385  }
1386 #line 1387 "parser.cc"
1387  break;
1388 
1389  case 54: // option_repr_type: "hex"
1390 #line 518 "parser.yy"
1391  {
1392  yylhs.value.as < TokenOption::RepresentationType > () = TokenOption::HEXADECIMAL;
1393  }
1394 #line 1395 "parser.cc"
1395  break;
1396 
1397  case 55: // nest_level: "integer"
1398 #line 524 "parser.yy"
1399  {
1400  yylhs.value.as < int8_t > () = ctx.convertNestLevelNumber(yystack_[0].value.as < std::string > (), yystack_[0].location);
1401  }
1402 #line 1403 "parser.cc"
1403  break;
1404 
1405  case 56: // pkt_metadata: "iface"
1406 #line 533 "parser.yy"
1407  {
1408  yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::IFACE;
1409  }
1410 #line 1411 "parser.cc"
1411  break;
1412 
1413  case 57: // pkt_metadata: "src"
1414 #line 537 "parser.yy"
1415  {
1416  yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::SRC;
1417  }
1418 #line 1419 "parser.cc"
1419  break;
1420 
1421  case 58: // pkt_metadata: "dst"
1422 #line 541 "parser.yy"
1423  {
1424  yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::DST;
1425  }
1426 #line 1427 "parser.cc"
1427  break;
1428 
1429  case 59: // pkt_metadata: "len"
1430 #line 545 "parser.yy"
1431  {
1432  yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::LEN;
1433  }
1434 #line 1435 "parser.cc"
1435  break;
1436 
1437  case 60: // enterprise_id: "integer"
1438 #line 551 "parser.yy"
1439  {
1440  yylhs.value.as < uint32_t > () = ctx.convertUint32(yystack_[0].value.as < std::string > (), yystack_[0].location);
1441  }
1442 #line 1443 "parser.cc"
1443  break;
1444 
1445  case 61: // enterprise_id: "*"
1446 #line 555 "parser.yy"
1447  {
1448  yylhs.value.as < uint32_t > () = 0;
1449  }
1450 #line 1451 "parser.cc"
1451  break;
1452 
1453  case 62: // pkt4_field: "mac"
1454 #line 561 "parser.yy"
1455  {
1456  yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::CHADDR;
1457  }
1458 #line 1459 "parser.cc"
1459  break;
1460 
1461  case 63: // pkt4_field: "hlen"
1462 #line 565 "parser.yy"
1463  {
1464  yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::HLEN;
1465  }
1466 #line 1467 "parser.cc"
1467  break;
1468 
1469  case 64: // pkt4_field: "htype"
1470 #line 569 "parser.yy"
1471  {
1472  yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::HTYPE;
1473  }
1474 #line 1475 "parser.cc"
1475  break;
1476 
1477  case 65: // pkt4_field: "ciaddr"
1478 #line 573 "parser.yy"
1479  {
1480  yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::CIADDR;
1481  }
1482 #line 1483 "parser.cc"
1483  break;
1484 
1485  case 66: // pkt4_field: "giaddr"
1486 #line 577 "parser.yy"
1487  {
1488  yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::GIADDR;
1489  }
1490 #line 1491 "parser.cc"
1491  break;
1492 
1493  case 67: // pkt4_field: "yiaddr"
1494 #line 581 "parser.yy"
1495  {
1496  yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::YIADDR;
1497  }
1498 #line 1499 "parser.cc"
1499  break;
1500 
1501  case 68: // pkt4_field: "siaddr"
1502 #line 585 "parser.yy"
1503  {
1504  yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::SIADDR;
1505  }
1506 #line 1507 "parser.cc"
1507  break;
1508 
1509  case 69: // pkt4_field: "msgtype"
1510 #line 589 "parser.yy"
1511  {
1512  yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::MSGTYPE;
1513  }
1514 #line 1515 "parser.cc"
1515  break;
1516 
1517  case 70: // pkt4_field: "transid"
1518 #line 593 "parser.yy"
1519  {
1520  yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::TRANSID;
1521  }
1522 #line 1523 "parser.cc"
1523  break;
1524 
1525  case 71: // pkt6_field: "msgtype"
1526 #line 599 "parser.yy"
1527  {
1528  yylhs.value.as < TokenPkt6::FieldType > () = TokenPkt6::MSGTYPE;
1529  }
1530 #line 1531 "parser.cc"
1531  break;
1532 
1533  case 72: // pkt6_field: "transid"
1534 #line 603 "parser.yy"
1535  {
1536  yylhs.value.as < TokenPkt6::FieldType > () = TokenPkt6::TRANSID;
1537  }
1538 #line 1539 "parser.cc"
1539  break;
1540 
1541  case 73: // relay6_field: "peeraddr"
1542 #line 609 "parser.yy"
1543  {
1544  yylhs.value.as < TokenRelay6Field::FieldType > () = TokenRelay6Field::PEERADDR;
1545  }
1546 #line 1547 "parser.cc"
1547  break;
1548 
1549  case 74: // relay6_field: "linkaddr"
1550 #line 613 "parser.yy"
1551  {
1552  yylhs.value.as < TokenRelay6Field::FieldType > () = TokenRelay6Field::LINKADDR;
1553  }
1554 #line 1555 "parser.cc"
1555  break;
1556 
1557  case 75: // start_expr: "integer"
1558 #line 619 "parser.yy"
1559  {
1560  TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ()));
1561  ctx.expression.push_back(str);
1562  }
1563 #line 1564 "parser.cc"
1564  break;
1565 
1566  case 76: // length_expr: "integer"
1567 #line 626 "parser.yy"
1568  {
1569  TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ()));
1570  ctx.expression.push_back(str);
1571  }
1572 #line 1573 "parser.cc"
1573  break;
1574 
1575  case 77: // length_expr: "all"
1576 #line 631 "parser.yy"
1577  {
1578  TokenPtr str(new TokenString("all"));
1579  ctx.expression.push_back(str);
1580  }
1581 #line 1582 "parser.cc"
1582  break;
1583 
1584  case 78: // int_expr: "integer"
1585 #line 637 "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 
1594 #line 1595 "parser.cc"
1595 
1596  default:
1597  break;
1598  }
1599  }
1600 #if YY_EXCEPTIONS
1601  catch (const syntax_error& yyexc)
1602  {
1603  YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
1604  error (yyexc);
1605  YYERROR;
1606  }
1607 #endif // YY_EXCEPTIONS
1608  YY_SYMBOL_PRINT ("-> $$ =", yylhs);
1609  yypop_ (yylen);
1610  yylen = 0;
1611 
1612  // Shift the result of the reduction.
1613  yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
1614  }
1615  goto yynewstate;
1616 
1617 
1618  /*--------------------------------------.
1619  | yyerrlab -- here on detecting error. |
1620  `--------------------------------------*/
1621  yyerrlab:
1622  // If not already recovering from an error, report this error.
1623  if (!yyerrstatus_)
1624  {
1625  ++yynerrs_;
1626  context yyctx (*this, yyla);
1627  std::string msg = yysyntax_error_ (yyctx);
1628  error (yyla.location, YY_MOVE (msg));
1629  }
1630 
1631 
1632  yyerror_range[1].location = yyla.location;
1633  if (yyerrstatus_ == 3)
1634  {
1635  /* If just tried and failed to reuse lookahead token after an
1636  error, discard it. */
1637 
1638  // Return failure if at end of input.
1639  if (yyla.kind () == symbol_kind::S_YYEOF)
1640  YYABORT;
1641  else if (!yyla.empty ())
1642  {
1643  yy_destroy_ ("Error: discarding", yyla);
1644  yyla.clear ();
1645  }
1646  }
1647 
1648  // Else will try to reuse lookahead token after shifting the error token.
1649  goto yyerrlab1;
1650 
1651 
1652  /*---------------------------------------------------.
1653  | yyerrorlab -- error raised explicitly by YYERROR. |
1654  `---------------------------------------------------*/
1655  yyerrorlab:
1656  /* Pacify compilers when the user code never invokes YYERROR and
1657  the label yyerrorlab therefore never appears in user code. */
1658  if (false)
1659  YYERROR;
1660 
1661  /* Do not reclaim the symbols of the rule whose action triggered
1662  this YYERROR. */
1663  yypop_ (yylen);
1664  yylen = 0;
1665  YY_STACK_PRINT ();
1666  goto yyerrlab1;
1667 
1668 
1669  /*-------------------------------------------------------------.
1670  | yyerrlab1 -- common code for both syntax error and YYERROR. |
1671  `-------------------------------------------------------------*/
1672  yyerrlab1:
1673  yyerrstatus_ = 3; // Each real token shifted decrements this.
1674  // Pop stack until we find a state that shifts the error token.
1675  for (;;)
1676  {
1677  yyn = yypact_[+yystack_[0].state];
1678  if (!yy_pact_value_is_default_ (yyn))
1679  {
1680  yyn += symbol_kind::S_YYerror;
1681  if (0 <= yyn && yyn <= yylast_
1682  && yycheck_[yyn] == symbol_kind::S_YYerror)
1683  {
1684  yyn = yytable_[yyn];
1685  if (0 < yyn)
1686  break;
1687  }
1688  }
1689 
1690  // Pop the current state because it cannot handle the error token.
1691  if (yystack_.size () == 1)
1692  YYABORT;
1693 
1694  yyerror_range[1].location = yystack_[0].location;
1695  yy_destroy_ ("Error: popping", yystack_[0]);
1696  yypop_ ();
1697  YY_STACK_PRINT ();
1698  }
1699  {
1700  stack_symbol_type error_token;
1701 
1702  yyerror_range[2].location = yyla.location;
1703  YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
1704 
1705  // Shift the error token.
1706  error_token.state = state_type (yyn);
1707  yypush_ ("Shifting", YY_MOVE (error_token));
1708  }
1709  goto yynewstate;
1710 
1711 
1712  /*-------------------------------------.
1713  | yyacceptlab -- YYACCEPT comes here. |
1714  `-------------------------------------*/
1715  yyacceptlab:
1716  yyresult = 0;
1717  goto yyreturn;
1718 
1719 
1720  /*-----------------------------------.
1721  | yyabortlab -- YYABORT comes here. |
1722  `-----------------------------------*/
1723  yyabortlab:
1724  yyresult = 1;
1725  goto yyreturn;
1726 
1727 
1728  /*-----------------------------------------------------.
1729  | yyreturn -- parsing is finished, return the result. |
1730  `-----------------------------------------------------*/
1731  yyreturn:
1732  if (!yyla.empty ())
1733  yy_destroy_ ("Cleanup: discarding lookahead", yyla);
1734 
1735  /* Do not reclaim the symbols of the rule whose action triggered
1736  this YYABORT or YYACCEPT. */
1737  yypop_ (yylen);
1738  YY_STACK_PRINT ();
1739  while (1 < yystack_.size ())
1740  {
1741  yy_destroy_ ("Cleanup: popping", yystack_[0]);
1742  yypop_ ();
1743  }
1744 
1745  return yyresult;
1746  }
1747 #if YY_EXCEPTIONS
1748  catch (...)
1749  {
1750  YYCDEBUG << "Exception caught: cleaning lookahead and stack\n";
1751  // Do not try to display the values of the reclaimed symbols,
1752  // as their printers might throw an exception.
1753  if (!yyla.empty ())
1754  yy_destroy_ (YY_NULLPTR, yyla);
1755 
1756  while (1 < yystack_.size ())
1757  {
1758  yy_destroy_ (YY_NULLPTR, yystack_[0]);
1759  yypop_ ();
1760  }
1761  throw;
1762  }
1763 #endif // YY_EXCEPTIONS
1764  }
1765 
1766  void
1768  {
1769  error (yyexc.location, yyexc.what ());
1770  }
1771 
1772  /* Return YYSTR after stripping away unnecessary quotes and
1773  backslashes, so that it's suitable for yyerror. The heuristic is
1774  that double-quoting is unnecessary unless the string contains an
1775  apostrophe, a comma, or backslash (other than backslash-backslash).
1776  YYSTR is taken from yytname. */
1777  std::string
1778  EvalParser::yytnamerr_ (const char *yystr)
1779  {
1780  if (*yystr == '"')
1781  {
1782  std::string yyr;
1783  char const *yyp = yystr;
1784 
1785  for (;;)
1786  switch (*++yyp)
1787  {
1788  case '\'':
1789  case ',':
1790  goto do_not_strip_quotes;
1791 
1792  case '\\':
1793  if (*++yyp != '\\')
1794  goto do_not_strip_quotes;
1795  else
1796  goto append;
1797 
1798  append:
1799  default:
1800  yyr += *yyp;
1801  break;
1802 
1803  case '"':
1804  return yyr;
1805  }
1806  do_not_strip_quotes: ;
1807  }
1808 
1809  return yystr;
1810  }
1811 
1812  std::string
1814  {
1815  return yytnamerr_ (yytname_[yysymbol]);
1816  }
1817 
1818 
1819 
1820  // EvalParser::context.
1821  EvalParser::context::context (const EvalParser& yyparser, const symbol_type& yyla)
1822  : yyparser_ (yyparser)
1823  , yyla_ (yyla)
1824  {}
1825 
1826  int
1828  {
1829  // Actual number of expected tokens
1830  int yycount = 0;
1831 
1832  const int yyn = yypact_[+yyparser_.yystack_[0].state];
1833  if (!yy_pact_value_is_default_ (yyn))
1834  {
1835  /* Start YYX at -YYN if negative to avoid negative indexes in
1836  YYCHECK. In other words, skip the first -YYN actions for
1837  this state because they are default actions. */
1838  const int yyxbegin = yyn < 0 ? -yyn : 0;
1839  // Stay within bounds of both yycheck and yytname.
1840  const int yychecklim = yylast_ - yyn + 1;
1841  const int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1842  for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
1843  if (yycheck_[yyx + yyn] == yyx && yyx != symbol_kind::S_YYerror
1844  && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
1845  {
1846  if (!yyarg)
1847  ++yycount;
1848  else if (yycount == yyargn)
1849  return 0;
1850  else
1851  yyarg[yycount++] = YY_CAST (symbol_kind_type, yyx);
1852  }
1853  }
1854 
1855  if (yyarg && yycount == 0 && 0 < yyargn)
1856  yyarg[0] = symbol_kind::S_YYEMPTY;
1857  return yycount;
1858  }
1859 
1860 
1861 
1862 
1863 
1864 
1865  int
1866  EvalParser::yy_syntax_error_arguments_ (const context& yyctx,
1867  symbol_kind_type yyarg[], int yyargn) const
1868  {
1869  /* There are many possibilities here to consider:
1870  - If this state is a consistent state with a default action, then
1871  the only way this function was invoked is if the default action
1872  is an error action. In that case, don't check for expected
1873  tokens because there are none.
1874  - The only way there can be no lookahead present (in yyla) is
1875  if this state is a consistent state with a default action.
1876  Thus, detecting the absence of a lookahead is sufficient to
1877  determine that there is no unexpected or expected token to
1878  report. In that case, just report a simple "syntax error".
1879  - Don't assume there isn't a lookahead just because this state is
1880  a consistent state with a default action. There might have
1881  been a previous inconsistent state, consistent state with a
1882  non-default action, or user semantic action that manipulated
1883  yyla. (However, yyla is currently not documented for users.)
1884  - Of course, the expected token list depends on states to have
1885  correct lookahead information, and it depends on the parser not
1886  to perform extra reductions after fetching a lookahead from the
1887  scanner and before detecting a syntax error. Thus, state merging
1888  (from LALR or IELR) and default reductions corrupt the expected
1889  token list. However, the list is correct for canonical LR with
1890  one exception: it will still contain any token that will not be
1891  accepted due to an error action in a later state.
1892  */
1893 
1894  if (!yyctx.lookahead ().empty ())
1895  {
1896  if (yyarg)
1897  yyarg[0] = yyctx.token ();
1898  int yyn = yyctx.expected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn - 1);
1899  return yyn + 1;
1900  }
1901  return 0;
1902  }
1903 
1904  // Generate an error message.
1905  std::string
1906  EvalParser::yysyntax_error_ (const context& yyctx) const
1907  {
1908  // Its maximum.
1909  enum { YYARGS_MAX = 5 };
1910  // Arguments of yyformat.
1911  symbol_kind_type yyarg[YYARGS_MAX];
1912  int yycount = yy_syntax_error_arguments_ (yyctx, yyarg, YYARGS_MAX);
1913 
1914  char const* yyformat = YY_NULLPTR;
1915  switch (yycount)
1916  {
1917 #define YYCASE_(N, S) \
1918  case N: \
1919  yyformat = S; \
1920  break
1921  default: // Avoid compiler warnings.
1922  YYCASE_ (0, YY_("syntax error"));
1923  YYCASE_ (1, YY_("syntax error, unexpected %s"));
1924  YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s"));
1925  YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1926  YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1927  YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1928 #undef YYCASE_
1929  }
1930 
1931  std::string yyres;
1932  // Argument number.
1933  std::ptrdiff_t yyi = 0;
1934  for (char const* yyp = yyformat; *yyp; ++yyp)
1935  if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
1936  {
1937  yyres += symbol_name (yyarg[yyi++]);
1938  ++yyp;
1939  }
1940  else
1941  yyres += *yyp;
1942  return yyres;
1943  }
1944 
1945 
1946  const short EvalParser::yypact_ninf_ = -156;
1947 
1948  const signed char EvalParser::yytable_ninf_ = -1;
1949 
1950  const short
1951  EvalParser::yypact_[] =
1952  {
1953  43, 109, 156, 20, 109, 109, 73, 94, 98, 90,
1954  79, 111, 133, 142, 157, 168, 177, 180, 185, 189,
1955  190, 192, 211, 219, 207, 112, 131, -156, -156, -156,
1956  -156, -156, 135, 29, -156, 156, 210, 212, 213, 161,
1957  164, 187, -156, 104, 0, -156, -34, 169, 170, 172,
1958  82, 52, 156, 156, 156, 109, 156, 156, 156, 156,
1959  156, 156, 156, 156, 113, -39, 176, -39, 178, 109,
1960  109, 156, 156, 1, -34, 169, 170, -39, -39, -156,
1961  -156, -156, -156, 217, -156, 220, -156, 221, 231, -156,
1962  -156, -156, -156, -156, -156, -156, -156, -156, -156, -156,
1963  -156, -156, -156, -156, 147, 150, 173, 10, 174, 2,
1964  3, 5, 6, 7, 14, 23, -156, -156, -156, -156,
1965  -156, 222, -156, 223, -156, -156, 234, 187, -156, 225,
1966  226, 227, 228, 229, 230, 232, 233, -156, 186, 156,
1967  156, 156, 156, -156, -156, -156, -156, -156, -156, -156,
1968  235, 236, 237, 238, 239, 240, 241, 16, 4, 78,
1969  -156, 214, 181, 25, 184, 26, 11, 77, 80, 188,
1970  81, 193, 250, 245, -156, -156, -156, -156, -156, -156,
1971  246, -156, -156, -156, -17, 202, -156, 156, -156, -156,
1972  248, 249, -156, 251, 252, 253, 169, 169, -156, -156,
1973  261, -156, 265, 28, 215, 169, 169, 169, 169, 254,
1974  255, -156, -156, -156, 256, 257, 258, 260, 262, 263,
1975  264, -156, 266, 267, 268, 269, 97, 106, 155, 188,
1976  188, 188, -156, -156, -156, -156, -156, -156
1977  };
1978 
1979  const signed char
1980  EvalParser::yydefact_[] =
1981  {
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, 18, 49, 19,
1985  20, 2, 4, 0, 47, 0, 0, 0, 0, 0,
1986  0, 3, 1, 0, 0, 6, 0, 0, 0, 0,
1987  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1988  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1989  0, 0, 0, 0, 0, 0, 0, 0, 0, 5,
1990  48, 50, 51, 0, 52, 0, 55, 0, 0, 56,
1991  57, 58, 59, 25, 62, 63, 64, 65, 66, 67,
1992  68, 69, 70, 26, 0, 0, 0, 0, 0, 0,
1993  0, 0, 0, 0, 0, 0, 71, 72, 27, 61,
1994  60, 0, 43, 0, 42, 7, 8, 9, 32, 0,
1995  0, 0, 0, 0, 0, 0, 0, 17, 0, 0,
1996  0, 0, 0, 35, 36, 37, 38, 39, 40, 41,
1997  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1998  75, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1999  0, 0, 0, 0, 53, 54, 10, 21, 12, 23,
2000  0, 73, 74, 28, 0, 0, 31, 0, 34, 14,
2001  45, 0, 15, 0, 0, 0, 0, 0, 77, 76,
2002  0, 78, 0, 0, 0, 0, 0, 0, 0, 0,
2003  0, 29, 30, 33, 0, 0, 0, 0, 0, 0,
2004  0, 46, 0, 0, 0, 0, 0, 0, 0, 0,
2005  0, 0, 11, 22, 13, 24, 16, 44
2006  };
2007 
2008  const short
2009  EvalParser::yypgoto_[] =
2010  {
2011  -156, -156, -156, 8, -2, -156, 203, -74, -155, 206,
2012  -156, -29, -156, -156, -156, -156, -156, -156
2013  };
2014 
2015  const unsigned char
2016  EvalParser::yydefgoto_[] =
2017  {
2018  0, 3, 31, 32, 33, 34, 83, 85, 177, 87,
2019  93, 121, 103, 118, 183, 161, 200, 202
2020  };
2021 
2022  const unsigned char
2023  EvalParser::yytable_[] =
2024  {
2025  41, 130, 44, 179, 80, 80, 143, 144, 71, 145,
2026  146, 147, 43, 45, 179, 119, 69, 70, 148, 198,
2027  42, 120, 174, 175, 178, 173, 81, 149, 82, 186,
2028  188, 189, 213, 73, 174, 175, 176, 71, 123, 72,
2029  72, 72, 72, 199, 72, 72, 72, 141, 132, 133,
2030  104, 105, 106, 72, 108, 109, 110, 111, 112, 113,
2031  114, 115, 72, 107, 72, 72, 190, 72, 72, 127,
2032  128, 233, 235, 237, 233, 235, 237, 125, 126, 94,
2033  95, 96, 97, 98, 99, 100, 191, 180, 46, 193,
2034  194, 181, 182, 49, 181, 182, 50, 192, 174, 175,
2035  1, 2, 101, 102, 89, 90, 91, 92, 79, 47,
2036  69, 70, 4, 48, 5, 174, 175, 232, 6, 7,
2037  8, 9, 209, 210, 174, 175, 234, 65, 51, 66,
2038  10, 215, 216, 217, 218, 11, 52, 162, 163, 164,
2039  165, 69, 70, 12, 13, 53, 67, 14, 68, 15,
2040  16, 17, 18, 19, 20, 21, 22, 23, 24, 35,
2041  54, 25, 26, 116, 117, 36, 37, 38, 27, 28,
2042  29, 55, 30, 174, 175, 236, 77, 10, 66, 78,
2043  56, 68, 11, 57, 138, 203, 72, 139, 58, 72,
2044  12, 13, 59, 60, 14, 61, 15, 16, 17, 18,
2045  19, 20, 21, 22, 23, 24, 174, 175, 39, 40,
2046  140, 142, 72, 72, 62, 27, 28, 29, 185, 30,
2047  72, 187, 63, 72, 64, 74, 72, 75, 76, 84,
2048  86, 88, 122, 134, 124, 137, 135, 136, 150, 151,
2049  69, 152, 153, 154, 155, 156, 160, 157, 190, 158,
2050  159, 184, 166, 167, 168, 169, 170, 171, 172, 195,
2051  196, 197, 201, 204, 205, 211, 206, 207, 208, 212,
2052  219, 220, 221, 222, 223, 214, 224, 129, 225, 0,
2053  226, 227, 131, 228, 229, 230, 231
2054  };
2055 
2056  const short
2057  EvalParser::yycheck_[] =
2058  {
2059  2, 75, 4, 158, 4, 4, 4, 4, 8, 4,
2060  4, 4, 4, 5, 169, 54, 6, 7, 4, 36,
2061  0, 60, 18, 19, 20, 9, 60, 4, 62, 4,
2062  4, 20, 4, 35, 18, 19, 20, 8, 67, 39,
2063  39, 39, 39, 60, 39, 39, 39, 37, 77, 78,
2064  52, 53, 54, 39, 56, 57, 58, 59, 60, 61,
2065  62, 63, 39, 55, 39, 39, 55, 39, 39, 71,
2066  72, 226, 227, 228, 229, 230, 231, 69, 70, 27,
2067  28, 29, 30, 31, 32, 33, 9, 9, 15, 9,
2068  9, 13, 14, 3, 13, 14, 17, 20, 18, 19,
2069  57, 58, 50, 51, 22, 23, 24, 25, 4, 15,
2070  6, 7, 3, 15, 5, 18, 19, 20, 9, 10,
2071  11, 12, 196, 197, 18, 19, 20, 15, 17, 17,
2072  21, 205, 206, 207, 208, 26, 3, 139, 140, 141,
2073  142, 6, 7, 34, 35, 3, 15, 38, 17, 40,
2074  41, 42, 43, 44, 45, 46, 47, 48, 49, 3,
2075  3, 52, 53, 50, 51, 9, 10, 11, 59, 60,
2076  61, 3, 63, 18, 19, 20, 15, 21, 17, 15,
2077  3, 17, 26, 3, 37, 187, 39, 37, 3, 39,
2078  34, 35, 3, 3, 38, 3, 40, 41, 42, 43,
2079  44, 45, 46, 47, 48, 49, 18, 19, 52, 53,
2080  37, 37, 39, 39, 3, 59, 60, 61, 37, 63,
2081  39, 37, 3, 39, 17, 15, 39, 15, 15, 60,
2082  60, 59, 56, 16, 56, 4, 16, 16, 16, 16,
2083  6, 16, 16, 16, 16, 16, 60, 17, 55, 17,
2084  17, 37, 17, 17, 17, 17, 17, 17, 17, 9,
2085  15, 15, 60, 15, 15, 4, 15, 15, 15, 4,
2086  16, 16, 16, 16, 16, 60, 16, 74, 16, -1,
2087  17, 17, 76, 17, 17, 17, 17
2088  };
2089 
2090  const signed char
2091  EvalParser::yystos_[] =
2092  {
2093  0, 57, 58, 65, 3, 5, 9, 10, 11, 12,
2094  21, 26, 34, 35, 38, 40, 41, 42, 43, 44,
2095  45, 46, 47, 48, 49, 52, 53, 59, 60, 61,
2096  63, 66, 67, 68, 69, 3, 9, 10, 11, 52,
2097  53, 68, 0, 67, 68, 67, 15, 15, 15, 3,
2098  17, 17, 3, 3, 3, 3, 3, 3, 3, 3,
2099  3, 3, 3, 3, 17, 15, 17, 15, 17, 6,
2100  7, 8, 39, 68, 15, 15, 15, 15, 15, 4,
2101  4, 60, 62, 70, 60, 71, 60, 73, 59, 22,
2102  23, 24, 25, 74, 27, 28, 29, 30, 31, 32,
2103  33, 50, 51, 76, 68, 68, 68, 67, 68, 68,
2104  68, 68, 68, 68, 68, 68, 50, 51, 77, 54,
2105  60, 75, 56, 75, 56, 67, 67, 68, 68, 70,
2106  71, 73, 75, 75, 16, 16, 16, 4, 37, 37,
2107  37, 37, 37, 4, 4, 4, 4, 4, 4, 4,
2108  16, 16, 16, 16, 16, 16, 16, 17, 17, 17,
2109  60, 79, 68, 68, 68, 68, 17, 17, 17, 17,
2110  17, 17, 17, 9, 18, 19, 20, 72, 20, 72,
2111  9, 13, 14, 78, 37, 37, 4, 37, 4, 20,
2112  55, 9, 20, 9, 9, 9, 15, 15, 36, 60,
2113  80, 60, 81, 68, 15, 15, 15, 15, 15, 71,
2114  71, 4, 4, 4, 60, 71, 71, 71, 71, 16,
2115  16, 16, 16, 16, 16, 16, 17, 17, 17, 17,
2116  17, 17, 20, 72, 20, 72, 20, 72
2117  };
2118 
2119  const signed char
2120  EvalParser::yyr1_[] =
2121  {
2122  0, 64, 65, 65, 66, 67, 67, 67, 67, 67,
2123  67, 67, 67, 67, 67, 67, 67, 67, 68, 68,
2124  68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
2125  68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
2126  68, 68, 68, 68, 68, 68, 68, 68, 68, 69,
2127  70, 70, 71, 72, 72, 73, 74, 74, 74, 74,
2128  75, 75, 76, 76, 76, 76, 76, 76, 76, 76,
2129  76, 77, 77, 78, 78, 79, 80, 80, 81
2130  };
2131 
2132  const signed char
2133  EvalParser::yyr2_[] =
2134  {
2135  0, 2, 2, 2, 1, 3, 2, 3, 3, 3,
2136  6, 11, 6, 11, 6, 6, 11, 4, 1, 1,
2137  1, 6, 11, 6, 11, 3, 3, 3, 6, 8,
2138  8, 6, 3, 8, 6, 4, 4, 4, 4, 4,
2139  4, 4, 3, 3, 11, 6, 9, 1, 3, 1,
2140  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2141  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2142  1, 1, 1, 1, 1, 1, 1, 1, 1
2143  };
2144 
2145 
2146 #if EVALDEBUG || 1
2147  // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2148  // First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
2149  const char*
2150  const EvalParser::yytname_[] =
2151  {
2152  "\"end of file\"", "error", "\"invalid token\"", "\"(\"", "\")\"",
2153  "\"not\"", "\"and\"", "\"or\"", "\"==\"", "\"option\"", "\"relay4\"",
2154  "\"relay6\"", "\"member\"", "\"peeraddr\"", "\"linkaddr\"", "\"[\"",
2155  "\"]\"", "\".\"", "\"text\"", "\"hex\"", "\"exists\"", "\"pkt\"",
2156  "\"iface\"", "\"src\"", "\"dst\"", "\"len\"", "\"pkt4\"", "\"mac\"",
2157  "\"hlen\"", "\"htype\"", "\"ciaddr\"", "\"giaddr\"", "\"yiaddr\"",
2158  "\"siaddr\"", "\"substring\"", "\"split\"", "\"all\"", "\",\"",
2159  "\"concat\"", "\"+\"", "\"ifelse\"", "\"hexstring\"", "\"addrtotext\"",
2160  "\"int8totext\"", "\"int16totext\"", "\"int32totext\"",
2161  "\"uint8totext\"", "\"uint16totext\"", "\"uint32totext\"", "\"pkt6\"",
2162  "\"msgtype\"", "\"transid\"", "\"vendor-class\"", "\"vendor\"", "\"*\"",
2163  "\"data\"", "\"enterprise\"", "\"top-level bool\"",
2164  "\"top-level string\"", "\"constant string\"", "\"integer\"",
2165  "\"constant hexstring\"", "\"option name\"", "\"ip address\"", "$accept",
2166  "start", "expression", "bool_expr", "string_expr", "integer_expr",
2167  "option_code", "sub_option_code", "option_repr_type", "nest_level",
2168  "pkt_metadata", "enterprise_id", "pkt4_field", "pkt6_field",
2169  "relay6_field", "start_expr", "length_expr", "int_expr", YY_NULLPTR
2170  };
2171 #endif
2172 
2173 
2174 #if EVALDEBUG
2175  const short
2176  EvalParser::yyrline_[] =
2177  {
2178  0, 136, 136, 137, 142, 145, 146, 151, 156, 161,
2179  166, 171, 176, 196, 210, 219, 228, 238, 255, 260,
2180  265, 270, 275, 280, 301, 316, 321, 335, 349, 364,
2181  369, 374, 379, 384, 389, 394, 399, 404, 409, 414,
2182  419, 424, 429, 438, 448, 457, 470, 483, 488, 491,
2183  497, 501, 507, 513, 517, 523, 532, 536, 540, 544,
2184  550, 554, 560, 564, 568, 572, 576, 580, 584, 588,
2185  592, 598, 602, 608, 612, 618, 625, 630, 636
2186  };
2187 
2188  void
2189  EvalParser::yy_stack_print_ () const
2190  {
2191  *yycdebug_ << "Stack now";
2192  for (stack_type::const_iterator
2193  i = yystack_.begin (),
2194  i_end = yystack_.end ();
2195  i != i_end; ++i)
2196  *yycdebug_ << ' ' << int (i->state);
2197  *yycdebug_ << '\n';
2198  }
2199 
2200  void
2201  EvalParser::yy_reduce_print_ (int yyrule) const
2202  {
2203  int yylno = yyrline_[yyrule];
2204  int yynrhs = yyr2_[yyrule];
2205  // Print the symbols being reduced, and their result.
2206  *yycdebug_ << "Reducing stack by rule " << yyrule - 1
2207  << " (line " << yylno << "):\n";
2208  // The symbols being reduced.
2209  for (int yyi = 0; yyi < yynrhs; yyi++)
2210  YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
2211  yystack_[(yynrhs) - (yyi + 1)]);
2212  }
2213 #endif // EVALDEBUG
2214 
2215 
2216 #line 14 "parser.yy"
2217 } } // isc::eval
2218 #line 2219 "parser.cc"
2219 
2220 #line 643 "parser.yy"
2221 
2222 void
2224  const std::string& what)
2225 {
2226  ctx.error(loc, what);
2227 }
#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:1827
context(const EvalParser &yyparser, const symbol_type &yyla)
Definition: parser.cc:1821
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:603
int operator()()
Parse.
Definition: parser.cc:638
virtual int parse()
Parse.
Definition: parser.cc:644
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:596
void set_debug_level(debug_level_type l)
Set the current debugging level.
Definition: parser.cc:609
std::ostream & debug_stream() const YY_ATTRIBUTE_PURE
The current debugging stream.
Definition: parser.cc:590
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:679
virtual void error(const location_type &loc, const std::string &msg)
Report a syntax error.
Definition: parser.cc:2223
static std::string symbol_name(symbol_kind_type yysymbol)
The user-facing name of the symbol whose (internal) number is YYSYMBOL.
Definition: parser.cc:1813
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:106
#define YYABORT
Definition: parser.cc:143
#define YYLLOC_DEFAULT(Current, Rhs, N)
Definition: parser.cc:87
#define YY_REDUCE_PRINT(Rule)
Definition: parser.cc:118
#define YY_SYMBOL_PRINT(Title, Symbol)
Definition: parser.cc:108
#define yylex
Definition: parser.cc:39
#define YYCASE_(N, S)
#define YY_STACK_PRINT()
Definition: parser.cc:124
#define YY_(msgid)
Definition: parser.cc:67
#define YYACCEPT
Definition: parser.cc:142
#define YYERROR
Definition: parser.cc:144
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:165