parser.cc 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  1. // A Bison parser, made by GNU Bison 3.0.4.
  2. // Skeleton implementation for Bison LALR(1) parsers in C++
  3. // Copyright (C) 2002-2015 Free Software Foundation, Inc.
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. // You should have received a copy of the GNU General Public License
  13. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. // As a special exception, you may create a larger work that contains
  15. // part or all of the Bison parser skeleton and distribute that work
  16. // under terms of your choice, so long as that work isn't itself a
  17. // parser generator using the skeleton or a modified version thereof
  18. // as a parser skeleton. Alternatively, if you modify or redistribute
  19. // the parser skeleton itself, you may (at your option) remove this
  20. // special exception, which will cause the skeleton and the resulting
  21. // Bison output files to be licensed under the GNU General Public
  22. // License without this special exception.
  23. // This special exception was added by the Free Software Foundation in
  24. // version 2.2 of Bison.
  25. // First part of user declarations.
  26. #line 37 "parser.cc" // lalr1.cc:404
  27. # ifndef YY_NULLPTR
  28. # if defined __cplusplus && 201103L <= __cplusplus
  29. # define YY_NULLPTR nullptr
  30. # else
  31. # define YY_NULLPTR 0
  32. # endif
  33. # endif
  34. #include "parser.h"
  35. // User implementation prologue.
  36. #line 51 "parser.cc" // lalr1.cc:412
  37. // Unqualified %code blocks.
  38. #line 38 "parser.yy" // lalr1.cc:413
  39. # include "eval_context.h"
  40. #line 57 "parser.cc" // lalr1.cc:413
  41. #ifndef YY_
  42. # if defined YYENABLE_NLS && YYENABLE_NLS
  43. # if ENABLE_NLS
  44. # include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE.
  45. # define YY_(msgid) dgettext ("bison-runtime", msgid)
  46. # endif
  47. # endif
  48. # ifndef YY_
  49. # define YY_(msgid) msgid
  50. # endif
  51. #endif
  52. #define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
  53. /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
  54. If N is 0, then set CURRENT to the empty location which ends
  55. the previous symbol: RHS[0] (always defined). */
  56. # ifndef YYLLOC_DEFAULT
  57. # define YYLLOC_DEFAULT(Current, Rhs, N) \
  58. do \
  59. if (N) \
  60. { \
  61. (Current).begin = YYRHSLOC (Rhs, 1).begin; \
  62. (Current).end = YYRHSLOC (Rhs, N).end; \
  63. } \
  64. else \
  65. { \
  66. (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
  67. } \
  68. while (/*CONSTCOND*/ false)
  69. # endif
  70. // Suppress unused-variable warnings by "using" E.
  71. #define YYUSE(E) ((void) (E))
  72. // Enable debugging if requested.
  73. #if YYDEBUG
  74. // A pseudo ostream that takes yydebug_ into account.
  75. # define YYCDEBUG if (yydebug_) (*yycdebug_)
  76. # define YY_SYMBOL_PRINT(Title, Symbol) \
  77. do { \
  78. if (yydebug_) \
  79. { \
  80. *yycdebug_ << Title << ' '; \
  81. yy_print_ (*yycdebug_, Symbol); \
  82. *yycdebug_ << std::endl; \
  83. } \
  84. } while (false)
  85. # define YY_REDUCE_PRINT(Rule) \
  86. do { \
  87. if (yydebug_) \
  88. yy_reduce_print_ (Rule); \
  89. } while (false)
  90. # define YY_STACK_PRINT() \
  91. do { \
  92. if (yydebug_) \
  93. yystack_print_ (); \
  94. } while (false)
  95. #else // !YYDEBUG
  96. # define YYCDEBUG if (false) std::cerr
  97. # define YY_SYMBOL_PRINT(Title, Symbol) YYUSE(Symbol)
  98. # define YY_REDUCE_PRINT(Rule) static_cast<void>(0)
  99. # define YY_STACK_PRINT() static_cast<void>(0)
  100. #endif // !YYDEBUG
  101. #define yyerrok (yyerrstatus_ = 0)
  102. #define yyclearin (yyla.clear ())
  103. #define YYACCEPT goto yyacceptlab
  104. #define YYABORT goto yyabortlab
  105. #define YYERROR goto yyerrorlab
  106. #define YYRECOVERING() (!!yyerrstatus_)
  107. #line 21 "parser.yy" // lalr1.cc:479
  108. namespace isc { namespace eval {
  109. #line 143 "parser.cc" // lalr1.cc:479
  110. /* Return YYSTR after stripping away unnecessary quotes and
  111. backslashes, so that it's suitable for yyerror. The heuristic is
  112. that double-quoting is unnecessary unless the string contains an
  113. apostrophe, a comma, or backslash (other than backslash-backslash).
  114. YYSTR is taken from yytname. */
  115. std::string
  116. EvalParser::yytnamerr_ (const char *yystr)
  117. {
  118. if (*yystr == '"')
  119. {
  120. std::string yyr = "";
  121. char const *yyp = yystr;
  122. for (;;)
  123. switch (*++yyp)
  124. {
  125. case '\'':
  126. case ',':
  127. goto do_not_strip_quotes;
  128. case '\\':
  129. if (*++yyp != '\\')
  130. goto do_not_strip_quotes;
  131. // Fall through.
  132. default:
  133. yyr += *yyp;
  134. break;
  135. case '"':
  136. return yyr;
  137. }
  138. do_not_strip_quotes: ;
  139. }
  140. return yystr;
  141. }
  142. /// Build a parser object.
  143. EvalParser::EvalParser (EvalContext& ctx_yyarg)
  144. :
  145. #if YYDEBUG
  146. yydebug_ (false),
  147. yycdebug_ (&std::cerr),
  148. #endif
  149. ctx (ctx_yyarg)
  150. {}
  151. EvalParser::~EvalParser ()
  152. {}
  153. /*---------------.
  154. | Symbol types. |
  155. `---------------*/
  156. // by_state.
  157. inline
  158. EvalParser::by_state::by_state ()
  159. : state (empty_state)
  160. {}
  161. inline
  162. EvalParser::by_state::by_state (const by_state& other)
  163. : state (other.state)
  164. {}
  165. inline
  166. void
  167. EvalParser::by_state::clear ()
  168. {
  169. state = empty_state;
  170. }
  171. inline
  172. void
  173. EvalParser::by_state::move (by_state& that)
  174. {
  175. state = that.state;
  176. that.clear ();
  177. }
  178. inline
  179. EvalParser::by_state::by_state (state_type s)
  180. : state (s)
  181. {}
  182. inline
  183. EvalParser::symbol_number_type
  184. EvalParser::by_state::type_get () const
  185. {
  186. if (state == empty_state)
  187. return empty_symbol;
  188. else
  189. return yystos_[state];
  190. }
  191. inline
  192. EvalParser::stack_symbol_type::stack_symbol_type ()
  193. {}
  194. inline
  195. EvalParser::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that)
  196. : super_type (s, that.location)
  197. {
  198. switch (that.type_get ())
  199. {
  200. case 12: // "a number in a constant string"
  201. case 13: // "the all constant string"
  202. case 14: // "constant string"
  203. case 15: // "constant hexstring"
  204. value.move< std::string > (that.value);
  205. break;
  206. case 16: // "option code"
  207. value.move< uint16_t > (that.value);
  208. break;
  209. default:
  210. break;
  211. }
  212. // that is emptied.
  213. that.type = empty_symbol;
  214. }
  215. inline
  216. EvalParser::stack_symbol_type&
  217. EvalParser::stack_symbol_type::operator= (const stack_symbol_type& that)
  218. {
  219. state = that.state;
  220. switch (that.type_get ())
  221. {
  222. case 12: // "a number in a constant string"
  223. case 13: // "the all constant string"
  224. case 14: // "constant string"
  225. case 15: // "constant hexstring"
  226. value.copy< std::string > (that.value);
  227. break;
  228. case 16: // "option code"
  229. value.copy< uint16_t > (that.value);
  230. break;
  231. default:
  232. break;
  233. }
  234. location = that.location;
  235. return *this;
  236. }
  237. template <typename Base>
  238. inline
  239. void
  240. EvalParser::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
  241. {
  242. if (yymsg)
  243. YY_SYMBOL_PRINT (yymsg, yysym);
  244. }
  245. #if YYDEBUG
  246. template <typename Base>
  247. void
  248. EvalParser::yy_print_ (std::ostream& yyo,
  249. const basic_symbol<Base>& yysym) const
  250. {
  251. std::ostream& yyoutput = yyo;
  252. YYUSE (yyoutput);
  253. symbol_number_type yytype = yysym.type_get ();
  254. // Avoid a (spurious) G++ 4.8 warning about "array subscript is
  255. // below array bounds".
  256. if (yysym.empty ())
  257. std::abort ();
  258. yyo << (yytype < yyntokens_ ? "token" : "nterm")
  259. << ' ' << yytname_[yytype] << " ("
  260. << yysym.location << ": ";
  261. switch (yytype)
  262. {
  263. case 12: // "a number in a constant string"
  264. #line 59 "parser.yy" // lalr1.cc:636
  265. { yyoutput << yysym.value.template as< std::string > (); }
  266. #line 332 "parser.cc" // lalr1.cc:636
  267. break;
  268. case 13: // "the all constant string"
  269. #line 59 "parser.yy" // lalr1.cc:636
  270. { yyoutput << yysym.value.template as< std::string > (); }
  271. #line 339 "parser.cc" // lalr1.cc:636
  272. break;
  273. case 14: // "constant string"
  274. #line 59 "parser.yy" // lalr1.cc:636
  275. { yyoutput << yysym.value.template as< std::string > (); }
  276. #line 346 "parser.cc" // lalr1.cc:636
  277. break;
  278. case 15: // "constant hexstring"
  279. #line 59 "parser.yy" // lalr1.cc:636
  280. { yyoutput << yysym.value.template as< std::string > (); }
  281. #line 353 "parser.cc" // lalr1.cc:636
  282. break;
  283. case 16: // "option code"
  284. #line 59 "parser.yy" // lalr1.cc:636
  285. { yyoutput << yysym.value.template as< uint16_t > (); }
  286. #line 360 "parser.cc" // lalr1.cc:636
  287. break;
  288. default:
  289. break;
  290. }
  291. yyo << ')';
  292. }
  293. #endif
  294. inline
  295. void
  296. EvalParser::yypush_ (const char* m, state_type s, symbol_type& sym)
  297. {
  298. stack_symbol_type t (s, sym);
  299. yypush_ (m, t);
  300. }
  301. inline
  302. void
  303. EvalParser::yypush_ (const char* m, stack_symbol_type& s)
  304. {
  305. if (m)
  306. YY_SYMBOL_PRINT (m, s);
  307. yystack_.push (s);
  308. }
  309. inline
  310. void
  311. EvalParser::yypop_ (unsigned int n)
  312. {
  313. yystack_.pop (n);
  314. }
  315. #if YYDEBUG
  316. std::ostream&
  317. EvalParser::debug_stream () const
  318. {
  319. return *yycdebug_;
  320. }
  321. void
  322. EvalParser::set_debug_stream (std::ostream& o)
  323. {
  324. yycdebug_ = &o;
  325. }
  326. EvalParser::debug_level_type
  327. EvalParser::debug_level () const
  328. {
  329. return yydebug_;
  330. }
  331. void
  332. EvalParser::set_debug_level (debug_level_type l)
  333. {
  334. yydebug_ = l;
  335. }
  336. #endif // YYDEBUG
  337. inline EvalParser::state_type
  338. EvalParser::yy_lr_goto_state_ (state_type yystate, int yysym)
  339. {
  340. int yyr = yypgoto_[yysym - yyntokens_] + yystate;
  341. if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
  342. return yytable_[yyr];
  343. else
  344. return yydefgoto_[yysym - yyntokens_];
  345. }
  346. inline bool
  347. EvalParser::yy_pact_value_is_default_ (int yyvalue)
  348. {
  349. return yyvalue == yypact_ninf_;
  350. }
  351. inline bool
  352. EvalParser::yy_table_value_is_error_ (int yyvalue)
  353. {
  354. return yyvalue == yytable_ninf_;
  355. }
  356. int
  357. EvalParser::parse ()
  358. {
  359. // State.
  360. int yyn;
  361. /// Length of the RHS of the rule being reduced.
  362. int yylen = 0;
  363. // Error handling.
  364. int yynerrs_ = 0;
  365. int yyerrstatus_ = 0;
  366. /// The lookahead symbol.
  367. symbol_type yyla;
  368. /// The locations where the error started and ended.
  369. stack_symbol_type yyerror_range[3];
  370. /// The return value of parse ().
  371. int yyresult;
  372. // FIXME: This shoud be completely indented. It is not yet to
  373. // avoid gratuitous conflicts when merging into the master branch.
  374. try
  375. {
  376. YYCDEBUG << "Starting parse" << std::endl;
  377. /* Initialize the stack. The initial state will be set in
  378. yynewstate, since the latter expects the semantical and the
  379. location values to have been already stored, initialize these
  380. stacks with a primary value. */
  381. yystack_.clear ();
  382. yypush_ (YY_NULLPTR, 0, yyla);
  383. // A new symbol was pushed on the stack.
  384. yynewstate:
  385. YYCDEBUG << "Entering state " << yystack_[0].state << std::endl;
  386. // Accept?
  387. if (yystack_[0].state == yyfinal_)
  388. goto yyacceptlab;
  389. goto yybackup;
  390. // Backup.
  391. yybackup:
  392. // Try to take a decision without lookahead.
  393. yyn = yypact_[yystack_[0].state];
  394. if (yy_pact_value_is_default_ (yyn))
  395. goto yydefault;
  396. // Read a lookahead token.
  397. if (yyla.empty ())
  398. {
  399. YYCDEBUG << "Reading a token: ";
  400. try
  401. {
  402. symbol_type yylookahead (yylex (ctx));
  403. yyla.move (yylookahead);
  404. }
  405. catch (const syntax_error& yyexc)
  406. {
  407. error (yyexc);
  408. goto yyerrlab1;
  409. }
  410. }
  411. YY_SYMBOL_PRINT ("Next token is", yyla);
  412. /* If the proper action on seeing token YYLA.TYPE is to reduce or
  413. to detect an error, take that action. */
  414. yyn += yyla.type_get ();
  415. if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type_get ())
  416. goto yydefault;
  417. // Reduce or error.
  418. yyn = yytable_[yyn];
  419. if (yyn <= 0)
  420. {
  421. if (yy_table_value_is_error_ (yyn))
  422. goto yyerrlab;
  423. yyn = -yyn;
  424. goto yyreduce;
  425. }
  426. // Count tokens shifted since error; after three, turn off error status.
  427. if (yyerrstatus_)
  428. --yyerrstatus_;
  429. // Shift the lookahead token.
  430. yypush_ ("Shifting", yyn, yyla);
  431. goto yynewstate;
  432. /*-----------------------------------------------------------.
  433. | yydefault -- do the default action for the current state. |
  434. `-----------------------------------------------------------*/
  435. yydefault:
  436. yyn = yydefact_[yystack_[0].state];
  437. if (yyn == 0)
  438. goto yyerrlab;
  439. goto yyreduce;
  440. /*-----------------------------.
  441. | yyreduce -- Do a reduction. |
  442. `-----------------------------*/
  443. yyreduce:
  444. yylen = yyr2_[yyn];
  445. {
  446. stack_symbol_type yylhs;
  447. yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]);
  448. /* Variants are always initialized to an empty instance of the
  449. correct type. The default '$$ = $1' action is NOT applied
  450. when using variants. */
  451. switch (yyr1_[yyn])
  452. {
  453. case 12: // "a number in a constant string"
  454. case 13: // "the all constant string"
  455. case 14: // "constant string"
  456. case 15: // "constant hexstring"
  457. yylhs.value.build< std::string > ();
  458. break;
  459. case 16: // "option code"
  460. yylhs.value.build< uint16_t > ();
  461. break;
  462. default:
  463. break;
  464. }
  465. // Compute the default @$.
  466. {
  467. slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
  468. YYLLOC_DEFAULT (yylhs.location, slice, yylen);
  469. }
  470. // Perform the reduction.
  471. YY_REDUCE_PRINT (yyn);
  472. try
  473. {
  474. switch (yyn)
  475. {
  476. case 4:
  477. #line 73 "parser.yy" // lalr1.cc:859
  478. {
  479. TokenPtr eq(new TokenEqual());
  480. ctx.expression.push_back(eq);
  481. }
  482. #line 594 "parser.cc" // lalr1.cc:859
  483. break;
  484. case 6:
  485. #line 81 "parser.yy" // lalr1.cc:859
  486. {
  487. TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
  488. ctx.expression.push_back(str);
  489. }
  490. #line 603 "parser.cc" // lalr1.cc:859
  491. break;
  492. case 7:
  493. #line 85 "parser.yy" // lalr1.cc:859
  494. {
  495. TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
  496. ctx.expression.push_back(str);
  497. }
  498. #line 612 "parser.cc" // lalr1.cc:859
  499. break;
  500. case 8:
  501. #line 89 "parser.yy" // lalr1.cc:859
  502. {
  503. TokenPtr str(new TokenString("all"));
  504. ctx.expression.push_back(str);
  505. }
  506. #line 621 "parser.cc" // lalr1.cc:859
  507. break;
  508. case 9:
  509. #line 93 "parser.yy" // lalr1.cc:859
  510. {
  511. TokenPtr hex(new TokenHexString(yystack_[0].value.as< std::string > ()));
  512. ctx.expression.push_back(hex);
  513. }
  514. #line 630 "parser.cc" // lalr1.cc:859
  515. break;
  516. case 10:
  517. #line 97 "parser.yy" // lalr1.cc:859
  518. {
  519. TokenPtr opt(new TokenOption(yystack_[1].value.as< uint16_t > ()));
  520. ctx.expression.push_back(opt);
  521. }
  522. #line 639 "parser.cc" // lalr1.cc:859
  523. break;
  524. case 11:
  525. #line 101 "parser.yy" // lalr1.cc:859
  526. {
  527. TokenPtr sub(new TokenSubstring());
  528. ctx.expression.push_back(sub);
  529. }
  530. #line 648 "parser.cc" // lalr1.cc:859
  531. break;
  532. case 12:
  533. #line 108 "parser.yy" // lalr1.cc:859
  534. {
  535. TokenPtr eq(new TokenEqual());
  536. ctx.expression.push_back(eq);
  537. }
  538. #line 657 "parser.cc" // lalr1.cc:859
  539. break;
  540. case 13:
  541. #line 115 "parser.yy" // lalr1.cc:859
  542. {
  543. TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
  544. ctx.expression.push_back(str);
  545. }
  546. #line 666 "parser.cc" // lalr1.cc:859
  547. break;
  548. case 14:
  549. #line 119 "parser.yy" // lalr1.cc:859
  550. {
  551. TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
  552. ctx.expression.push_back(str);
  553. }
  554. #line 675 "parser.cc" // lalr1.cc:859
  555. break;
  556. case 15:
  557. #line 123 "parser.yy" // lalr1.cc:859
  558. {
  559. TokenPtr str(new TokenString("all"));
  560. ctx.expression.push_back(str);
  561. }
  562. #line 684 "parser.cc" // lalr1.cc:859
  563. break;
  564. case 16:
  565. #line 127 "parser.yy" // lalr1.cc:859
  566. {
  567. TokenPtr hex(new TokenHexString(yystack_[0].value.as< std::string > ()));
  568. ctx.expression.push_back(hex);
  569. }
  570. #line 693 "parser.cc" // lalr1.cc:859
  571. break;
  572. case 17:
  573. #line 131 "parser.yy" // lalr1.cc:859
  574. {
  575. TokenPtr opt(new TokenOption(yystack_[1].value.as< uint16_t > ()));
  576. ctx.expression.push_back(opt);
  577. }
  578. #line 702 "parser.cc" // lalr1.cc:859
  579. break;
  580. case 18:
  581. #line 135 "parser.yy" // lalr1.cc:859
  582. {
  583. TokenPtr sub(new TokenSubstring());
  584. ctx.expression.push_back(sub);
  585. }
  586. #line 711 "parser.cc" // lalr1.cc:859
  587. break;
  588. case 19:
  589. #line 142 "parser.yy" // lalr1.cc:859
  590. {
  591. TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
  592. ctx.expression.push_back(str);
  593. }
  594. #line 720 "parser.cc" // lalr1.cc:859
  595. break;
  596. case 20:
  597. #line 149 "parser.yy" // lalr1.cc:859
  598. {
  599. TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
  600. ctx.expression.push_back(str);
  601. }
  602. #line 729 "parser.cc" // lalr1.cc:859
  603. break;
  604. case 21:
  605. #line 153 "parser.yy" // lalr1.cc:859
  606. {
  607. TokenPtr str(new TokenString("all"));
  608. ctx.expression.push_back(str);
  609. }
  610. #line 738 "parser.cc" // lalr1.cc:859
  611. break;
  612. #line 742 "parser.cc" // lalr1.cc:859
  613. default:
  614. break;
  615. }
  616. }
  617. catch (const syntax_error& yyexc)
  618. {
  619. error (yyexc);
  620. YYERROR;
  621. }
  622. YY_SYMBOL_PRINT ("-> $$ =", yylhs);
  623. yypop_ (yylen);
  624. yylen = 0;
  625. YY_STACK_PRINT ();
  626. // Shift the result of the reduction.
  627. yypush_ (YY_NULLPTR, yylhs);
  628. }
  629. goto yynewstate;
  630. /*--------------------------------------.
  631. | yyerrlab -- here on detecting error. |
  632. `--------------------------------------*/
  633. yyerrlab:
  634. // If not already recovering from an error, report this error.
  635. if (!yyerrstatus_)
  636. {
  637. ++yynerrs_;
  638. error (yyla.location, yysyntax_error_ (yystack_[0].state, yyla));
  639. }
  640. yyerror_range[1].location = yyla.location;
  641. if (yyerrstatus_ == 3)
  642. {
  643. /* If just tried and failed to reuse lookahead token after an
  644. error, discard it. */
  645. // Return failure if at end of input.
  646. if (yyla.type_get () == yyeof_)
  647. YYABORT;
  648. else if (!yyla.empty ())
  649. {
  650. yy_destroy_ ("Error: discarding", yyla);
  651. yyla.clear ();
  652. }
  653. }
  654. // Else will try to reuse lookahead token after shifting the error token.
  655. goto yyerrlab1;
  656. /*---------------------------------------------------.
  657. | yyerrorlab -- error raised explicitly by YYERROR. |
  658. `---------------------------------------------------*/
  659. yyerrorlab:
  660. /* Pacify compilers like GCC when the user code never invokes
  661. YYERROR and the label yyerrorlab therefore never appears in user
  662. code. */
  663. if (false)
  664. goto yyerrorlab;
  665. yyerror_range[1].location = yystack_[yylen - 1].location;
  666. /* Do not reclaim the symbols of the rule whose action triggered
  667. this YYERROR. */
  668. yypop_ (yylen);
  669. yylen = 0;
  670. goto yyerrlab1;
  671. /*-------------------------------------------------------------.
  672. | yyerrlab1 -- common code for both syntax error and YYERROR. |
  673. `-------------------------------------------------------------*/
  674. yyerrlab1:
  675. yyerrstatus_ = 3; // Each real token shifted decrements this.
  676. {
  677. stack_symbol_type error_token;
  678. for (;;)
  679. {
  680. yyn = yypact_[yystack_[0].state];
  681. if (!yy_pact_value_is_default_ (yyn))
  682. {
  683. yyn += yyterror_;
  684. if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
  685. {
  686. yyn = yytable_[yyn];
  687. if (0 < yyn)
  688. break;
  689. }
  690. }
  691. // Pop the current state because it cannot handle the error token.
  692. if (yystack_.size () == 1)
  693. YYABORT;
  694. yyerror_range[1].location = yystack_[0].location;
  695. yy_destroy_ ("Error: popping", yystack_[0]);
  696. yypop_ ();
  697. YY_STACK_PRINT ();
  698. }
  699. yyerror_range[2].location = yyla.location;
  700. YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
  701. // Shift the error token.
  702. error_token.state = yyn;
  703. yypush_ ("Shifting", error_token);
  704. }
  705. goto yynewstate;
  706. // Accept.
  707. yyacceptlab:
  708. yyresult = 0;
  709. goto yyreturn;
  710. // Abort.
  711. yyabortlab:
  712. yyresult = 1;
  713. goto yyreturn;
  714. yyreturn:
  715. if (!yyla.empty ())
  716. yy_destroy_ ("Cleanup: discarding lookahead", yyla);
  717. /* Do not reclaim the symbols of the rule whose action triggered
  718. this YYABORT or YYACCEPT. */
  719. yypop_ (yylen);
  720. while (1 < yystack_.size ())
  721. {
  722. yy_destroy_ ("Cleanup: popping", yystack_[0]);
  723. yypop_ ();
  724. }
  725. return yyresult;
  726. }
  727. catch (...)
  728. {
  729. YYCDEBUG << "Exception caught: cleaning lookahead and stack"
  730. << std::endl;
  731. // Do not try to display the values of the reclaimed symbols,
  732. // as their printer might throw an exception.
  733. if (!yyla.empty ())
  734. yy_destroy_ (YY_NULLPTR, yyla);
  735. while (1 < yystack_.size ())
  736. {
  737. yy_destroy_ (YY_NULLPTR, yystack_[0]);
  738. yypop_ ();
  739. }
  740. throw;
  741. }
  742. }
  743. void
  744. EvalParser::error (const syntax_error& yyexc)
  745. {
  746. error (yyexc.location, yyexc.what());
  747. }
  748. // Generate an error message.
  749. std::string
  750. EvalParser::yysyntax_error_ (state_type yystate, const symbol_type& yyla) const
  751. {
  752. // Number of reported tokens (one for the "unexpected", one per
  753. // "expected").
  754. size_t yycount = 0;
  755. // Its maximum.
  756. enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
  757. // Arguments of yyformat.
  758. char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
  759. /* There are many possibilities here to consider:
  760. - If this state is a consistent state with a default action, then
  761. the only way this function was invoked is if the default action
  762. is an error action. In that case, don't check for expected
  763. tokens because there are none.
  764. - The only way there can be no lookahead present (in yyla) is
  765. if this state is a consistent state with a default action.
  766. Thus, detecting the absence of a lookahead is sufficient to
  767. determine that there is no unexpected or expected token to
  768. report. In that case, just report a simple "syntax error".
  769. - Don't assume there isn't a lookahead just because this state is
  770. a consistent state with a default action. There might have
  771. been a previous inconsistent state, consistent state with a
  772. non-default action, or user semantic action that manipulated
  773. yyla. (However, yyla is currently not documented for users.)
  774. - Of course, the expected token list depends on states to have
  775. correct lookahead information, and it depends on the parser not
  776. to perform extra reductions after fetching a lookahead from the
  777. scanner and before detecting a syntax error. Thus, state
  778. merging (from LALR or IELR) and default reductions corrupt the
  779. expected token list. However, the list is correct for
  780. canonical LR with one exception: it will still contain any
  781. token that will not be accepted due to an error action in a
  782. later state.
  783. */
  784. if (!yyla.empty ())
  785. {
  786. int yytoken = yyla.type_get ();
  787. yyarg[yycount++] = yytname_[yytoken];
  788. int yyn = yypact_[yystate];
  789. if (!yy_pact_value_is_default_ (yyn))
  790. {
  791. /* Start YYX at -YYN if negative to avoid negative indexes in
  792. YYCHECK. In other words, skip the first -YYN actions for
  793. this state because they are default actions. */
  794. int yyxbegin = yyn < 0 ? -yyn : 0;
  795. // Stay within bounds of both yycheck and yytname.
  796. int yychecklim = yylast_ - yyn + 1;
  797. int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
  798. for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
  799. if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
  800. && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
  801. {
  802. if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
  803. {
  804. yycount = 1;
  805. break;
  806. }
  807. else
  808. yyarg[yycount++] = yytname_[yyx];
  809. }
  810. }
  811. }
  812. char const* yyformat = YY_NULLPTR;
  813. switch (yycount)
  814. {
  815. #define YYCASE_(N, S) \
  816. case N: \
  817. yyformat = S; \
  818. break
  819. YYCASE_(0, YY_("syntax error"));
  820. YYCASE_(1, YY_("syntax error, unexpected %s"));
  821. YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
  822. YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
  823. YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
  824. YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
  825. #undef YYCASE_
  826. }
  827. std::string yyres;
  828. // Argument number.
  829. size_t yyi = 0;
  830. for (char const* yyp = yyformat; *yyp; ++yyp)
  831. if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
  832. {
  833. yyres += yytnamerr_ (yyarg[yyi++]);
  834. ++yyp;
  835. }
  836. else
  837. yyres += *yyp;
  838. return yyres;
  839. }
  840. const signed char EvalParser::yypact_ninf_ = -27;
  841. const signed char EvalParser::yytable_ninf_ = -1;
  842. const signed char
  843. EvalParser::yypact_[] =
  844. {
  845. 0, -3, 1, 14, -27, -27, -27, -27, 8, -27,
  846. 13, 5, 18, 15, 16, -27, -27, -27, -27, -27,
  847. 31, -27, 18, 24, 29, 21, 14, 14, -27, -27,
  848. 26, 28, 33, -27, -27, 34, -27, 14, -10, 35,
  849. -27, -27, 36, 14, -27, 37, -27
  850. };
  851. const unsigned char
  852. EvalParser::yydefact_[] =
  853. {
  854. 0, 0, 0, 0, 14, 15, 13, 16, 0, 3,
  855. 0, 0, 0, 0, 0, 7, 8, 6, 9, 2,
  856. 5, 1, 0, 0, 0, 0, 0, 0, 12, 17,
  857. 0, 0, 0, 4, 19, 0, 10, 0, 0, 0,
  858. 20, 21, 0, 0, 18, 0, 11
  859. };
  860. const signed char
  861. EvalParser::yypgoto_[] =
  862. {
  863. -27, -27, -27, -26, -27, -2, -27, -27
  864. };
  865. const signed char
  866. EvalParser::yydefgoto_[] =
  867. {
  868. -1, 8, 19, 20, 9, 10, 35, 42
  869. };
  870. const unsigned char
  871. EvalParser::yytable_[] =
  872. {
  873. 32, 33, 40, 41, 1, 2, 3, 11, 21, 12,
  874. 24, 39, 4, 5, 6, 7, 22, 45, 13, 14,
  875. 28, 23, 1, 2, 26, 25, 15, 16, 17, 18,
  876. 4, 5, 6, 7, 27, 29, 30, 31, 34, 36,
  877. 37, 38, 43, 0, 0, 44, 46
  878. };
  879. const signed char
  880. EvalParser::yycheck_[] =
  881. {
  882. 26, 27, 12, 13, 4, 5, 6, 10, 0, 8,
  883. 12, 37, 12, 13, 14, 15, 3, 43, 4, 5,
  884. 22, 16, 4, 5, 8, 10, 12, 13, 14, 15,
  885. 12, 13, 14, 15, 3, 11, 7, 16, 12, 11,
  886. 7, 7, 7, -1, -1, 9, 9
  887. };
  888. const unsigned char
  889. EvalParser::yystos_[] =
  890. {
  891. 0, 4, 5, 6, 12, 13, 14, 15, 18, 21,
  892. 22, 10, 8, 4, 5, 12, 13, 14, 15, 19,
  893. 20, 0, 3, 16, 22, 10, 8, 3, 22, 11,
  894. 7, 16, 20, 20, 12, 23, 11, 7, 7, 20,
  895. 12, 13, 24, 7, 9, 20, 9
  896. };
  897. const unsigned char
  898. EvalParser::yyr1_[] =
  899. {
  900. 0, 17, 18, 18, 19, 19, 20, 20, 20, 20,
  901. 20, 20, 21, 22, 22, 22, 22, 22, 22, 23,
  902. 24, 24
  903. };
  904. const unsigned char
  905. EvalParser::yyr2_[] =
  906. {
  907. 0, 2, 2, 1, 3, 1, 1, 1, 1, 1,
  908. 4, 8, 3, 1, 1, 1, 1, 4, 8, 1,
  909. 1, 1
  910. };
  911. // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  912. // First, the terminals, then, starting at \a yyntokens_, nonterminals.
  913. const char*
  914. const EvalParser::yytname_[] =
  915. {
  916. "\"end of file\"", "error", "$undefined", "\"==\"", "\"option\"",
  917. "\"substring\"", "\"untyped:\"", "\",\"", "\"(\"", "\")\"", "\"[\"",
  918. "\"]\"", "\"a number in a constant string\"",
  919. "\"the all constant string\"", "\"constant string\"",
  920. "\"constant hexstring\"", "\"option code\"", "$accept", "expression",
  921. "untyped_expr", "token", "bool_expr", "string_expr", "start_expr",
  922. "length_expr", YY_NULLPTR
  923. };
  924. #if YYDEBUG
  925. const unsigned char
  926. EvalParser::yyrline_[] =
  927. {
  928. 0, 68, 68, 69, 73, 77, 81, 85, 89, 93,
  929. 97, 101, 108, 115, 119, 123, 127, 131, 135, 142,
  930. 149, 153
  931. };
  932. // Print the state stack on the debug stream.
  933. void
  934. EvalParser::yystack_print_ ()
  935. {
  936. *yycdebug_ << "Stack now";
  937. for (stack_type::const_iterator
  938. i = yystack_.begin (),
  939. i_end = yystack_.end ();
  940. i != i_end; ++i)
  941. *yycdebug_ << ' ' << i->state;
  942. *yycdebug_ << std::endl;
  943. }
  944. // Report on the debug stream that the rule \a yyrule is going to be reduced.
  945. void
  946. EvalParser::yy_reduce_print_ (int yyrule)
  947. {
  948. unsigned int yylno = yyrline_[yyrule];
  949. int yynrhs = yyr2_[yyrule];
  950. // Print the symbols being reduced, and their result.
  951. *yycdebug_ << "Reducing stack by rule " << yyrule - 1
  952. << " (line " << yylno << "):" << std::endl;
  953. // The symbols being reduced.
  954. for (int yyi = 0; yyi < yynrhs; yyi++)
  955. YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
  956. yystack_[(yynrhs) - (yyi + 1)]);
  957. }
  958. #endif // YYDEBUG
  959. #line 21 "parser.yy" // lalr1.cc:1167
  960. } } // isc::eval
  961. #line 1136 "parser.cc" // lalr1.cc:1167
  962. #line 159 "parser.yy" // lalr1.cc:1168
  963. void
  964. isc::eval::EvalParser::error(const location_type& loc,
  965. const std::string& what)
  966. {
  967. ctx.error(loc, what);
  968. }