parser.cc 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361
  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 32 "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 13 "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 34: // option_repr_type
  201. value.move< TokenOption::RepresentationType > (that.value);
  202. break;
  203. case 37: // relay6_field
  204. value.move< TokenRelay6::FieldType > (that.value);
  205. break;
  206. case 24: // "constant string"
  207. case 25: // "integer"
  208. case 26: // "constant hexstring"
  209. case 27: // "option name"
  210. case 28: // "ip address"
  211. value.move< std::string > (that.value);
  212. break;
  213. case 33: // option_code
  214. value.move< uint16_t > (that.value);
  215. break;
  216. case 38: // nest_level
  217. value.move< uint8_t > (that.value);
  218. break;
  219. default:
  220. break;
  221. }
  222. // that is emptied.
  223. that.type = empty_symbol;
  224. }
  225. inline
  226. EvalParser::stack_symbol_type&
  227. EvalParser::stack_symbol_type::operator= (const stack_symbol_type& that)
  228. {
  229. state = that.state;
  230. switch (that.type_get ())
  231. {
  232. case 34: // option_repr_type
  233. value.copy< TokenOption::RepresentationType > (that.value);
  234. break;
  235. case 37: // relay6_field
  236. value.copy< TokenRelay6::FieldType > (that.value);
  237. break;
  238. case 24: // "constant string"
  239. case 25: // "integer"
  240. case 26: // "constant hexstring"
  241. case 27: // "option name"
  242. case 28: // "ip address"
  243. value.copy< std::string > (that.value);
  244. break;
  245. case 33: // option_code
  246. value.copy< uint16_t > (that.value);
  247. break;
  248. case 38: // nest_level
  249. value.copy< uint8_t > (that.value);
  250. break;
  251. default:
  252. break;
  253. }
  254. location = that.location;
  255. return *this;
  256. }
  257. template <typename Base>
  258. inline
  259. void
  260. EvalParser::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
  261. {
  262. if (yymsg)
  263. YY_SYMBOL_PRINT (yymsg, yysym);
  264. }
  265. #if YYDEBUG
  266. template <typename Base>
  267. void
  268. EvalParser::yy_print_ (std::ostream& yyo,
  269. const basic_symbol<Base>& yysym) const
  270. {
  271. std::ostream& yyoutput = yyo;
  272. YYUSE (yyoutput);
  273. symbol_number_type yytype = yysym.type_get ();
  274. // Avoid a (spurious) G++ 4.8 warning about "array subscript is
  275. // below array bounds".
  276. if (yysym.empty ())
  277. std::abort ();
  278. yyo << (yytype < yyntokens_ ? "token" : "nterm")
  279. << ' ' << yytname_[yytype] << " ("
  280. << yysym.location << ": ";
  281. switch (yytype)
  282. {
  283. case 24: // "constant string"
  284. #line 78 "parser.yy" // lalr1.cc:636
  285. { yyoutput << yysym.value.template as< std::string > (); }
  286. #line 358 "parser.cc" // lalr1.cc:636
  287. break;
  288. case 25: // "integer"
  289. #line 78 "parser.yy" // lalr1.cc:636
  290. { yyoutput << yysym.value.template as< std::string > (); }
  291. #line 365 "parser.cc" // lalr1.cc:636
  292. break;
  293. case 26: // "constant hexstring"
  294. #line 78 "parser.yy" // lalr1.cc:636
  295. { yyoutput << yysym.value.template as< std::string > (); }
  296. #line 372 "parser.cc" // lalr1.cc:636
  297. break;
  298. case 27: // "option name"
  299. #line 78 "parser.yy" // lalr1.cc:636
  300. { yyoutput << yysym.value.template as< std::string > (); }
  301. #line 379 "parser.cc" // lalr1.cc:636
  302. break;
  303. case 28: // "ip address"
  304. #line 78 "parser.yy" // lalr1.cc:636
  305. { yyoutput << yysym.value.template as< std::string > (); }
  306. #line 386 "parser.cc" // lalr1.cc:636
  307. break;
  308. case 33: // option_code
  309. #line 78 "parser.yy" // lalr1.cc:636
  310. { yyoutput << yysym.value.template as< uint16_t > (); }
  311. #line 393 "parser.cc" // lalr1.cc:636
  312. break;
  313. case 34: // option_repr_type
  314. #line 78 "parser.yy" // lalr1.cc:636
  315. { yyoutput << yysym.value.template as< TokenOption::RepresentationType > (); }
  316. #line 400 "parser.cc" // lalr1.cc:636
  317. break;
  318. case 37: // relay6_field
  319. #line 78 "parser.yy" // lalr1.cc:636
  320. { yyoutput << yysym.value.template as< TokenRelay6::FieldType > (); }
  321. #line 407 "parser.cc" // lalr1.cc:636
  322. break;
  323. case 38: // nest_level
  324. #line 78 "parser.yy" // lalr1.cc:636
  325. { yyoutput << yysym.value.template as< uint8_t > (); }
  326. #line 414 "parser.cc" // lalr1.cc:636
  327. break;
  328. default:
  329. break;
  330. }
  331. yyo << ')';
  332. }
  333. #endif
  334. inline
  335. void
  336. EvalParser::yypush_ (const char* m, state_type s, symbol_type& sym)
  337. {
  338. stack_symbol_type t (s, sym);
  339. yypush_ (m, t);
  340. }
  341. inline
  342. void
  343. EvalParser::yypush_ (const char* m, stack_symbol_type& s)
  344. {
  345. if (m)
  346. YY_SYMBOL_PRINT (m, s);
  347. yystack_.push (s);
  348. }
  349. inline
  350. void
  351. EvalParser::yypop_ (unsigned int n)
  352. {
  353. yystack_.pop (n);
  354. }
  355. #if YYDEBUG
  356. std::ostream&
  357. EvalParser::debug_stream () const
  358. {
  359. return *yycdebug_;
  360. }
  361. void
  362. EvalParser::set_debug_stream (std::ostream& o)
  363. {
  364. yycdebug_ = &o;
  365. }
  366. EvalParser::debug_level_type
  367. EvalParser::debug_level () const
  368. {
  369. return yydebug_;
  370. }
  371. void
  372. EvalParser::set_debug_level (debug_level_type l)
  373. {
  374. yydebug_ = l;
  375. }
  376. #endif // YYDEBUG
  377. inline EvalParser::state_type
  378. EvalParser::yy_lr_goto_state_ (state_type yystate, int yysym)
  379. {
  380. int yyr = yypgoto_[yysym - yyntokens_] + yystate;
  381. if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
  382. return yytable_[yyr];
  383. else
  384. return yydefgoto_[yysym - yyntokens_];
  385. }
  386. inline bool
  387. EvalParser::yy_pact_value_is_default_ (int yyvalue)
  388. {
  389. return yyvalue == yypact_ninf_;
  390. }
  391. inline bool
  392. EvalParser::yy_table_value_is_error_ (int yyvalue)
  393. {
  394. return yyvalue == yytable_ninf_;
  395. }
  396. int
  397. EvalParser::parse ()
  398. {
  399. // State.
  400. int yyn;
  401. /// Length of the RHS of the rule being reduced.
  402. int yylen = 0;
  403. // Error handling.
  404. int yynerrs_ = 0;
  405. int yyerrstatus_ = 0;
  406. /// The lookahead symbol.
  407. symbol_type yyla;
  408. /// The locations where the error started and ended.
  409. stack_symbol_type yyerror_range[3];
  410. /// The return value of parse ().
  411. int yyresult;
  412. // FIXME: This shoud be completely indented. It is not yet to
  413. // avoid gratuitous conflicts when merging into the master branch.
  414. try
  415. {
  416. YYCDEBUG << "Starting parse" << std::endl;
  417. /* Initialize the stack. The initial state will be set in
  418. yynewstate, since the latter expects the semantical and the
  419. location values to have been already stored, initialize these
  420. stacks with a primary value. */
  421. yystack_.clear ();
  422. yypush_ (YY_NULLPTR, 0, yyla);
  423. // A new symbol was pushed on the stack.
  424. yynewstate:
  425. YYCDEBUG << "Entering state " << yystack_[0].state << std::endl;
  426. // Accept?
  427. if (yystack_[0].state == yyfinal_)
  428. goto yyacceptlab;
  429. goto yybackup;
  430. // Backup.
  431. yybackup:
  432. // Try to take a decision without lookahead.
  433. yyn = yypact_[yystack_[0].state];
  434. if (yy_pact_value_is_default_ (yyn))
  435. goto yydefault;
  436. // Read a lookahead token.
  437. if (yyla.empty ())
  438. {
  439. YYCDEBUG << "Reading a token: ";
  440. try
  441. {
  442. symbol_type yylookahead (yylex (ctx));
  443. yyla.move (yylookahead);
  444. }
  445. catch (const syntax_error& yyexc)
  446. {
  447. error (yyexc);
  448. goto yyerrlab1;
  449. }
  450. }
  451. YY_SYMBOL_PRINT ("Next token is", yyla);
  452. /* If the proper action on seeing token YYLA.TYPE is to reduce or
  453. to detect an error, take that action. */
  454. yyn += yyla.type_get ();
  455. if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type_get ())
  456. goto yydefault;
  457. // Reduce or error.
  458. yyn = yytable_[yyn];
  459. if (yyn <= 0)
  460. {
  461. if (yy_table_value_is_error_ (yyn))
  462. goto yyerrlab;
  463. yyn = -yyn;
  464. goto yyreduce;
  465. }
  466. // Count tokens shifted since error; after three, turn off error status.
  467. if (yyerrstatus_)
  468. --yyerrstatus_;
  469. // Shift the lookahead token.
  470. yypush_ ("Shifting", yyn, yyla);
  471. goto yynewstate;
  472. /*-----------------------------------------------------------.
  473. | yydefault -- do the default action for the current state. |
  474. `-----------------------------------------------------------*/
  475. yydefault:
  476. yyn = yydefact_[yystack_[0].state];
  477. if (yyn == 0)
  478. goto yyerrlab;
  479. goto yyreduce;
  480. /*-----------------------------.
  481. | yyreduce -- Do a reduction. |
  482. `-----------------------------*/
  483. yyreduce:
  484. yylen = yyr2_[yyn];
  485. {
  486. stack_symbol_type yylhs;
  487. yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]);
  488. /* Variants are always initialized to an empty instance of the
  489. correct type. The default '$$ = $1' action is NOT applied
  490. when using variants. */
  491. switch (yyr1_[yyn])
  492. {
  493. case 34: // option_repr_type
  494. yylhs.value.build< TokenOption::RepresentationType > ();
  495. break;
  496. case 37: // relay6_field
  497. yylhs.value.build< TokenRelay6::FieldType > ();
  498. break;
  499. case 24: // "constant string"
  500. case 25: // "integer"
  501. case 26: // "constant hexstring"
  502. case 27: // "option name"
  503. case 28: // "ip address"
  504. yylhs.value.build< std::string > ();
  505. break;
  506. case 33: // option_code
  507. yylhs.value.build< uint16_t > ();
  508. break;
  509. case 38: // nest_level
  510. yylhs.value.build< uint8_t > ();
  511. break;
  512. default:
  513. break;
  514. }
  515. // Compute the default @$.
  516. {
  517. slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
  518. YYLLOC_DEFAULT (yylhs.location, slice, yylen);
  519. }
  520. // Perform the reduction.
  521. YY_REDUCE_PRINT (yyn);
  522. try
  523. {
  524. switch (yyn)
  525. {
  526. case 4:
  527. #line 92 "parser.yy" // lalr1.cc:859
  528. {
  529. TokenPtr neg(new TokenNot());
  530. ctx.expression.push_back(neg);
  531. }
  532. #line 661 "parser.cc" // lalr1.cc:859
  533. break;
  534. case 5:
  535. #line 97 "parser.yy" // lalr1.cc:859
  536. {
  537. TokenPtr neg(new TokenAnd());
  538. ctx.expression.push_back(neg);
  539. }
  540. #line 670 "parser.cc" // lalr1.cc:859
  541. break;
  542. case 6:
  543. #line 102 "parser.yy" // lalr1.cc:859
  544. {
  545. TokenPtr neg(new TokenOr());
  546. ctx.expression.push_back(neg);
  547. }
  548. #line 679 "parser.cc" // lalr1.cc:859
  549. break;
  550. case 7:
  551. #line 107 "parser.yy" // lalr1.cc:859
  552. {
  553. TokenPtr eq(new TokenEqual());
  554. ctx.expression.push_back(eq);
  555. }
  556. #line 688 "parser.cc" // lalr1.cc:859
  557. break;
  558. case 8:
  559. #line 112 "parser.yy" // lalr1.cc:859
  560. {
  561. TokenPtr opt(new TokenOption(yystack_[3].value.as< uint16_t > (), TokenOption::EXISTS));
  562. ctx.expression.push_back(opt);
  563. }
  564. #line 697 "parser.cc" // lalr1.cc:859
  565. break;
  566. case 9:
  567. #line 117 "parser.yy" // lalr1.cc:859
  568. {
  569. switch (ctx.getUniverse()) {
  570. case Option::V4:
  571. {
  572. TokenPtr opt(new TokenRelay4Option(yystack_[3].value.as< uint16_t > (), TokenOption::EXISTS));
  573. ctx.expression.push_back(opt);
  574. break;
  575. }
  576. case Option::V6:
  577. // We will have relay6[123] for the DHCPv6.
  578. // In a very distant future we'll possibly be able
  579. // to mix both if we have DHCPv4-over-DHCPv6, so it
  580. // has some sense to make it explicit whether we
  581. // talk about DHCPv4 relay or DHCPv6 relay. However,
  582. // for the time being relay4 can be used in DHCPv4
  583. // only.
  584. error(yystack_[5].location, "relay4 can only be used in DHCPv4.");
  585. }
  586. }
  587. #line 721 "parser.cc" // lalr1.cc:859
  588. break;
  589. case 10:
  590. #line 137 "parser.yy" // lalr1.cc:859
  591. {
  592. switch (ctx.getUniverse()) {
  593. case Option::V6:
  594. {
  595. TokenPtr opt(new TokenRelay6Option(yystack_[8].value.as< uint8_t > (), yystack_[3].value.as< uint16_t > (), TokenOption::EXISTS));
  596. ctx.expression.push_back(opt);
  597. break;
  598. }
  599. case Option::V4:
  600. // For now we only use relay6 in DHCPv6.
  601. error(yystack_[10].location, "relay6 can only be used in DHCPv6.");
  602. }
  603. }
  604. #line 739 "parser.cc" // lalr1.cc:859
  605. break;
  606. case 11:
  607. #line 153 "parser.yy" // lalr1.cc:859
  608. {
  609. TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
  610. ctx.expression.push_back(str);
  611. }
  612. #line 748 "parser.cc" // lalr1.cc:859
  613. break;
  614. case 12:
  615. #line 158 "parser.yy" // lalr1.cc:859
  616. {
  617. TokenPtr hex(new TokenHexString(yystack_[0].value.as< std::string > ()));
  618. ctx.expression.push_back(hex);
  619. }
  620. #line 757 "parser.cc" // lalr1.cc:859
  621. break;
  622. case 13:
  623. #line 163 "parser.yy" // lalr1.cc:859
  624. {
  625. TokenPtr ip(new TokenIpAddress(yystack_[0].value.as< std::string > ()));
  626. ctx.expression.push_back(ip);
  627. }
  628. #line 766 "parser.cc" // lalr1.cc:859
  629. break;
  630. case 14:
  631. #line 168 "parser.yy" // lalr1.cc:859
  632. {
  633. TokenPtr opt(new TokenOption(yystack_[3].value.as< uint16_t > (), yystack_[0].value.as< TokenOption::RepresentationType > ()));
  634. ctx.expression.push_back(opt);
  635. }
  636. #line 775 "parser.cc" // lalr1.cc:859
  637. break;
  638. case 15:
  639. #line 173 "parser.yy" // lalr1.cc:859
  640. {
  641. switch (ctx.getUniverse()) {
  642. case Option::V4:
  643. {
  644. TokenPtr opt(new TokenRelay4Option(yystack_[3].value.as< uint16_t > (), yystack_[0].value.as< TokenOption::RepresentationType > ()));
  645. ctx.expression.push_back(opt);
  646. break;
  647. }
  648. case Option::V6:
  649. // We will have relay6[123] for the DHCPv6.
  650. // In a very distant future we'll possibly be able
  651. // to mix both if we have DHCPv4-over-DHCPv6, so it
  652. // has some sense to make it explicit whether we
  653. // talk about DHCPv4 relay or DHCPv6 relay. However,
  654. // for the time being relay4 can be used in DHCPv4
  655. // only.
  656. error(yystack_[5].location, "relay4 can only be used in DHCPv4.");
  657. }
  658. }
  659. #line 799 "parser.cc" // lalr1.cc:859
  660. break;
  661. case 16:
  662. #line 194 "parser.yy" // lalr1.cc:859
  663. {
  664. switch (ctx.getUniverse()) {
  665. case Option::V6:
  666. {
  667. TokenPtr opt(new TokenRelay6Option(yystack_[8].value.as< uint8_t > (), yystack_[3].value.as< uint16_t > (), yystack_[0].value.as< TokenOption::RepresentationType > ()));
  668. ctx.expression.push_back(opt);
  669. break;
  670. }
  671. case Option::V4:
  672. // For now we only use relay6 in DHCPv6.
  673. error(yystack_[10].location, "relay6 can only be used in DHCPv6.");
  674. }
  675. }
  676. #line 817 "parser.cc" // lalr1.cc:859
  677. break;
  678. case 17:
  679. #line 209 "parser.yy" // lalr1.cc:859
  680. {
  681. switch (ctx.getUniverse()) {
  682. case Option::V6:
  683. {
  684. TokenPtr relay6field(new TokenRelay6(yystack_[3].value.as< uint8_t > (), yystack_[0].value.as< TokenRelay6::FieldType > ()));
  685. ctx.expression.push_back(relay6field);
  686. break;
  687. }
  688. case Option::V4:
  689. // For now we only use relay6 in DHCPv6.
  690. error(yystack_[5].location, "relay6 can only be used in DHCPv6.");
  691. }
  692. }
  693. #line 835 "parser.cc" // lalr1.cc:859
  694. break;
  695. case 18:
  696. #line 225 "parser.yy" // lalr1.cc:859
  697. {
  698. TokenPtr sub(new TokenSubstring());
  699. ctx.expression.push_back(sub);
  700. }
  701. #line 844 "parser.cc" // lalr1.cc:859
  702. break;
  703. case 19:
  704. #line 230 "parser.yy" // lalr1.cc:859
  705. {
  706. TokenPtr conc(new TokenConcat());
  707. ctx.expression.push_back(conc);
  708. }
  709. #line 853 "parser.cc" // lalr1.cc:859
  710. break;
  711. case 20:
  712. #line 237 "parser.yy" // lalr1.cc:859
  713. {
  714. yylhs.value.as< uint16_t > () = ctx.convertOptionCode(yystack_[0].value.as< std::string > (), yystack_[0].location);
  715. }
  716. #line 861 "parser.cc" // lalr1.cc:859
  717. break;
  718. case 21:
  719. #line 241 "parser.yy" // lalr1.cc:859
  720. {
  721. yylhs.value.as< uint16_t > () = ctx.convertOptionName(yystack_[0].value.as< std::string > (), yystack_[0].location);
  722. }
  723. #line 869 "parser.cc" // lalr1.cc:859
  724. break;
  725. case 22:
  726. #line 247 "parser.yy" // lalr1.cc:859
  727. {
  728. yylhs.value.as< TokenOption::RepresentationType > () = TokenOption::TEXTUAL;
  729. }
  730. #line 877 "parser.cc" // lalr1.cc:859
  731. break;
  732. case 23:
  733. #line 251 "parser.yy" // lalr1.cc:859
  734. {
  735. yylhs.value.as< TokenOption::RepresentationType > () = TokenOption::HEXADECIMAL;
  736. }
  737. #line 885 "parser.cc" // lalr1.cc:859
  738. break;
  739. case 24:
  740. #line 257 "parser.yy" // lalr1.cc:859
  741. {
  742. TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
  743. ctx.expression.push_back(str);
  744. }
  745. #line 894 "parser.cc" // lalr1.cc:859
  746. break;
  747. case 25:
  748. #line 264 "parser.yy" // lalr1.cc:859
  749. {
  750. TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
  751. ctx.expression.push_back(str);
  752. }
  753. #line 903 "parser.cc" // lalr1.cc:859
  754. break;
  755. case 26:
  756. #line 269 "parser.yy" // lalr1.cc:859
  757. {
  758. TokenPtr str(new TokenString("all"));
  759. ctx.expression.push_back(str);
  760. }
  761. #line 912 "parser.cc" // lalr1.cc:859
  762. break;
  763. case 27:
  764. #line 275 "parser.yy" // lalr1.cc:859
  765. { yylhs.value.as< TokenRelay6::FieldType > () = TokenRelay6::PEERADDR; }
  766. #line 918 "parser.cc" // lalr1.cc:859
  767. break;
  768. case 28:
  769. #line 276 "parser.yy" // lalr1.cc:859
  770. { yylhs.value.as< TokenRelay6::FieldType > () = TokenRelay6::LINKADDR; }
  771. #line 924 "parser.cc" // lalr1.cc:859
  772. break;
  773. case 29:
  774. #line 280 "parser.yy" // lalr1.cc:859
  775. {
  776. yylhs.value.as< uint8_t > () = ctx.convertNestLevelNumber(yystack_[0].value.as< std::string > (), yystack_[0].location);
  777. }
  778. #line 932 "parser.cc" // lalr1.cc:859
  779. break;
  780. #line 936 "parser.cc" // lalr1.cc:859
  781. default:
  782. break;
  783. }
  784. }
  785. catch (const syntax_error& yyexc)
  786. {
  787. error (yyexc);
  788. YYERROR;
  789. }
  790. YY_SYMBOL_PRINT ("-> $$ =", yylhs);
  791. yypop_ (yylen);
  792. yylen = 0;
  793. YY_STACK_PRINT ();
  794. // Shift the result of the reduction.
  795. yypush_ (YY_NULLPTR, yylhs);
  796. }
  797. goto yynewstate;
  798. /*--------------------------------------.
  799. | yyerrlab -- here on detecting error. |
  800. `--------------------------------------*/
  801. yyerrlab:
  802. // If not already recovering from an error, report this error.
  803. if (!yyerrstatus_)
  804. {
  805. ++yynerrs_;
  806. error (yyla.location, yysyntax_error_ (yystack_[0].state, yyla));
  807. }
  808. yyerror_range[1].location = yyla.location;
  809. if (yyerrstatus_ == 3)
  810. {
  811. /* If just tried and failed to reuse lookahead token after an
  812. error, discard it. */
  813. // Return failure if at end of input.
  814. if (yyla.type_get () == yyeof_)
  815. YYABORT;
  816. else if (!yyla.empty ())
  817. {
  818. yy_destroy_ ("Error: discarding", yyla);
  819. yyla.clear ();
  820. }
  821. }
  822. // Else will try to reuse lookahead token after shifting the error token.
  823. goto yyerrlab1;
  824. /*---------------------------------------------------.
  825. | yyerrorlab -- error raised explicitly by YYERROR. |
  826. `---------------------------------------------------*/
  827. yyerrorlab:
  828. /* Pacify compilers like GCC when the user code never invokes
  829. YYERROR and the label yyerrorlab therefore never appears in user
  830. code. */
  831. if (false)
  832. goto yyerrorlab;
  833. yyerror_range[1].location = yystack_[yylen - 1].location;
  834. /* Do not reclaim the symbols of the rule whose action triggered
  835. this YYERROR. */
  836. yypop_ (yylen);
  837. yylen = 0;
  838. goto yyerrlab1;
  839. /*-------------------------------------------------------------.
  840. | yyerrlab1 -- common code for both syntax error and YYERROR. |
  841. `-------------------------------------------------------------*/
  842. yyerrlab1:
  843. yyerrstatus_ = 3; // Each real token shifted decrements this.
  844. {
  845. stack_symbol_type error_token;
  846. for (;;)
  847. {
  848. yyn = yypact_[yystack_[0].state];
  849. if (!yy_pact_value_is_default_ (yyn))
  850. {
  851. yyn += yyterror_;
  852. if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
  853. {
  854. yyn = yytable_[yyn];
  855. if (0 < yyn)
  856. break;
  857. }
  858. }
  859. // Pop the current state because it cannot handle the error token.
  860. if (yystack_.size () == 1)
  861. YYABORT;
  862. yyerror_range[1].location = yystack_[0].location;
  863. yy_destroy_ ("Error: popping", yystack_[0]);
  864. yypop_ ();
  865. YY_STACK_PRINT ();
  866. }
  867. yyerror_range[2].location = yyla.location;
  868. YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
  869. // Shift the error token.
  870. error_token.state = yyn;
  871. yypush_ ("Shifting", error_token);
  872. }
  873. goto yynewstate;
  874. // Accept.
  875. yyacceptlab:
  876. yyresult = 0;
  877. goto yyreturn;
  878. // Abort.
  879. yyabortlab:
  880. yyresult = 1;
  881. goto yyreturn;
  882. yyreturn:
  883. if (!yyla.empty ())
  884. yy_destroy_ ("Cleanup: discarding lookahead", yyla);
  885. /* Do not reclaim the symbols of the rule whose action triggered
  886. this YYABORT or YYACCEPT. */
  887. yypop_ (yylen);
  888. while (1 < yystack_.size ())
  889. {
  890. yy_destroy_ ("Cleanup: popping", yystack_[0]);
  891. yypop_ ();
  892. }
  893. return yyresult;
  894. }
  895. catch (...)
  896. {
  897. YYCDEBUG << "Exception caught: cleaning lookahead and stack"
  898. << std::endl;
  899. // Do not try to display the values of the reclaimed symbols,
  900. // as their printer might throw an exception.
  901. if (!yyla.empty ())
  902. yy_destroy_ (YY_NULLPTR, yyla);
  903. while (1 < yystack_.size ())
  904. {
  905. yy_destroy_ (YY_NULLPTR, yystack_[0]);
  906. yypop_ ();
  907. }
  908. throw;
  909. }
  910. }
  911. void
  912. EvalParser::error (const syntax_error& yyexc)
  913. {
  914. error (yyexc.location, yyexc.what());
  915. }
  916. // Generate an error message.
  917. std::string
  918. EvalParser::yysyntax_error_ (state_type yystate, const symbol_type& yyla) const
  919. {
  920. // Number of reported tokens (one for the "unexpected", one per
  921. // "expected").
  922. size_t yycount = 0;
  923. // Its maximum.
  924. enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
  925. // Arguments of yyformat.
  926. char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
  927. /* There are many possibilities here to consider:
  928. - If this state is a consistent state with a default action, then
  929. the only way this function was invoked is if the default action
  930. is an error action. In that case, don't check for expected
  931. tokens because there are none.
  932. - The only way there can be no lookahead present (in yyla) is
  933. if this state is a consistent state with a default action.
  934. Thus, detecting the absence of a lookahead is sufficient to
  935. determine that there is no unexpected or expected token to
  936. report. In that case, just report a simple "syntax error".
  937. - Don't assume there isn't a lookahead just because this state is
  938. a consistent state with a default action. There might have
  939. been a previous inconsistent state, consistent state with a
  940. non-default action, or user semantic action that manipulated
  941. yyla. (However, yyla is currently not documented for users.)
  942. - Of course, the expected token list depends on states to have
  943. correct lookahead information, and it depends on the parser not
  944. to perform extra reductions after fetching a lookahead from the
  945. scanner and before detecting a syntax error. Thus, state
  946. merging (from LALR or IELR) and default reductions corrupt the
  947. expected token list. However, the list is correct for
  948. canonical LR with one exception: it will still contain any
  949. token that will not be accepted due to an error action in a
  950. later state.
  951. */
  952. if (!yyla.empty ())
  953. {
  954. int yytoken = yyla.type_get ();
  955. yyarg[yycount++] = yytname_[yytoken];
  956. int yyn = yypact_[yystate];
  957. if (!yy_pact_value_is_default_ (yyn))
  958. {
  959. /* Start YYX at -YYN if negative to avoid negative indexes in
  960. YYCHECK. In other words, skip the first -YYN actions for
  961. this state because they are default actions. */
  962. int yyxbegin = yyn < 0 ? -yyn : 0;
  963. // Stay within bounds of both yycheck and yytname.
  964. int yychecklim = yylast_ - yyn + 1;
  965. int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
  966. for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
  967. if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
  968. && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
  969. {
  970. if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
  971. {
  972. yycount = 1;
  973. break;
  974. }
  975. else
  976. yyarg[yycount++] = yytname_[yyx];
  977. }
  978. }
  979. }
  980. char const* yyformat = YY_NULLPTR;
  981. switch (yycount)
  982. {
  983. #define YYCASE_(N, S) \
  984. case N: \
  985. yyformat = S; \
  986. break
  987. YYCASE_(0, YY_("syntax error"));
  988. YYCASE_(1, YY_("syntax error, unexpected %s"));
  989. YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
  990. YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
  991. YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
  992. YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
  993. #undef YYCASE_
  994. }
  995. std::string yyres;
  996. // Argument number.
  997. size_t yyi = 0;
  998. for (char const* yyp = yyformat; *yyp; ++yyp)
  999. if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
  1000. {
  1001. yyres += yytnamerr_ (yyarg[yyi++]);
  1002. ++yyp;
  1003. }
  1004. else
  1005. yyres += *yyp;
  1006. return yyres;
  1007. }
  1008. const signed char EvalParser::yypact_ninf_ = -47;
  1009. const signed char EvalParser::yytable_ninf_ = -1;
  1010. const signed char
  1011. EvalParser::yypact_[] =
  1012. {
  1013. 11, 11, 11, -4, -1, 3, 21, 27, -47, -47,
  1014. -47, 49, 51, 28, 44, -47, -2, -2, 19, 36,
  1015. 36, -47, 11, 11, 36, -47, -47, -47, 46, 48,
  1016. -47, 57, 59, 60, 61, 43, 54, -47, 71, -47,
  1017. 62, 63, 64, -2, -2, 19, 56, 36, 23, 35,
  1018. -5, 67, 68, 69, -47, 65, 81, -47, -47, -47,
  1019. -47, -47, -47, 72, -47, -47, -47, 73, 74, 75,
  1020. -16, -47, -2, 53, 53, 6, -47, -47, 84, 77,
  1021. 79, -47, 78, -2, 50, 80, -47, -47, 82, 53
  1022. };
  1023. const unsigned char
  1024. EvalParser::yydefact_[] =
  1025. {
  1026. 0, 0, 0, 0, 0, 0, 0, 0, 11, 12,
  1027. 13, 0, 2, 0, 0, 4, 0, 0, 0, 0,
  1028. 0, 1, 0, 0, 0, 3, 20, 21, 0, 0,
  1029. 29, 0, 0, 0, 0, 0, 0, 5, 6, 7,
  1030. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  1031. 0, 0, 0, 0, 24, 0, 0, 22, 23, 8,
  1032. 14, 9, 15, 0, 27, 28, 17, 0, 0, 0,
  1033. 0, 19, 0, 0, 0, 0, 26, 25, 0, 0,
  1034. 0, 18, 0, 0, 0, 0, 10, 16, 0, 0
  1035. };
  1036. const signed char
  1037. EvalParser::yypgoto_[] =
  1038. {
  1039. -47, -47, 10, -18, -17, -46, -47, -47, -47, 52
  1040. };
  1041. const signed char
  1042. EvalParser::yydefgoto_[] =
  1043. {
  1044. -1, 11, 12, 13, 28, 60, 55, 78, 66, 31
  1045. };
  1046. const unsigned char
  1047. EvalParser::yytable_[] =
  1048. {
  1049. 29, 35, 36, 62, 63, 76, 39, 64, 65, 77,
  1050. 16, 14, 15, 17, 1, 80, 2, 18, 64, 65,
  1051. 3, 4, 5, 26, 19, 27, 51, 52, 62, 56,
  1052. 20, 6, 37, 38, 7, 8, 24, 9, 87, 10,
  1053. 57, 58, 59, 87, 30, 32, 33, 34, 25, 21,
  1054. 22, 23, 57, 58, 61, 79, 6, 22, 23, 7,
  1055. 8, 40, 9, 41, 10, 46, 85, 57, 58, 86,
  1056. 57, 58, 42, 43, 44, 45, 47, 22, 48, 49,
  1057. 50, 54, 67, 68, 69, 71, 72, 70, 81, 73,
  1058. 74, 75, 82, 83, 84, 88, 0, 53, 89
  1059. };
  1060. const signed char
  1061. EvalParser::yycheck_[] =
  1062. {
  1063. 17, 19, 20, 49, 9, 21, 24, 12, 13, 25,
  1064. 14, 1, 2, 14, 3, 9, 5, 14, 12, 13,
  1065. 9, 10, 11, 25, 3, 27, 43, 44, 74, 47,
  1066. 3, 20, 22, 23, 23, 24, 8, 26, 84, 28,
  1067. 17, 18, 19, 89, 25, 9, 10, 11, 4, 0,
  1068. 6, 7, 17, 18, 19, 72, 20, 6, 7, 23,
  1069. 24, 15, 26, 15, 28, 22, 83, 17, 18, 19,
  1070. 17, 18, 15, 14, 14, 14, 22, 6, 16, 16,
  1071. 16, 25, 15, 15, 15, 4, 14, 22, 4, 16,
  1072. 16, 16, 15, 14, 16, 15, -1, 45, 16
  1073. };
  1074. const unsigned char
  1075. EvalParser::yystos_[] =
  1076. {
  1077. 0, 3, 5, 9, 10, 11, 20, 23, 24, 26,
  1078. 28, 30, 31, 32, 31, 31, 14, 14, 14, 3,
  1079. 3, 0, 6, 7, 8, 4, 25, 27, 33, 33,
  1080. 25, 38, 9, 10, 11, 32, 32, 31, 31, 32,
  1081. 15, 15, 15, 14, 14, 14, 22, 22, 16, 16,
  1082. 16, 33, 33, 38, 25, 35, 32, 17, 18, 19,
  1083. 34, 19, 34, 9, 12, 13, 37, 15, 15, 15,
  1084. 22, 4, 14, 16, 16, 16, 21, 25, 36, 33,
  1085. 9, 4, 15, 14, 16, 33, 19, 34, 15, 16
  1086. };
  1087. const unsigned char
  1088. EvalParser::yyr1_[] =
  1089. {
  1090. 0, 29, 30, 31, 31, 31, 31, 31, 31, 31,
  1091. 31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
  1092. 33, 33, 34, 34, 35, 36, 36, 37, 37, 38
  1093. };
  1094. const unsigned char
  1095. EvalParser::yyr2_[] =
  1096. {
  1097. 0, 2, 1, 3, 2, 3, 3, 3, 6, 6,
  1098. 11, 1, 1, 1, 6, 6, 11, 6, 8, 6,
  1099. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  1100. };
  1101. // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  1102. // First, the terminals, then, starting at \a yyntokens_, nonterminals.
  1103. const char*
  1104. const EvalParser::yytname_[] =
  1105. {
  1106. "\"end of file\"", "error", "$undefined", "\"(\"", "\")\"", "\"not\"",
  1107. "\"and\"", "\"or\"", "\"==\"", "\"option\"", "\"relay4\"", "\"relay6\"",
  1108. "\"peeraddr\"", "\"linkaddr\"", "\"[\"", "\"]\"", "\".\"", "\"text\"",
  1109. "\"hex\"", "\"exists\"", "\"substring\"", "\"all\"", "\",\"",
  1110. "\"concat\"", "\"constant string\"", "\"integer\"",
  1111. "\"constant hexstring\"", "\"option name\"", "\"ip address\"", "$accept",
  1112. "expression", "bool_expr", "string_expr", "option_code",
  1113. "option_repr_type", "start_expr", "length_expr", "relay6_field",
  1114. "nest_level", YY_NULLPTR
  1115. };
  1116. #if YYDEBUG
  1117. const unsigned short int
  1118. EvalParser::yyrline_[] =
  1119. {
  1120. 0, 87, 87, 90, 91, 96, 101, 106, 111, 116,
  1121. 136, 152, 157, 162, 167, 172, 193, 208, 224, 229,
  1122. 236, 240, 246, 250, 256, 263, 268, 275, 276, 279
  1123. };
  1124. // Print the state stack on the debug stream.
  1125. void
  1126. EvalParser::yystack_print_ ()
  1127. {
  1128. *yycdebug_ << "Stack now";
  1129. for (stack_type::const_iterator
  1130. i = yystack_.begin (),
  1131. i_end = yystack_.end ();
  1132. i != i_end; ++i)
  1133. *yycdebug_ << ' ' << i->state;
  1134. *yycdebug_ << std::endl;
  1135. }
  1136. // Report on the debug stream that the rule \a yyrule is going to be reduced.
  1137. void
  1138. EvalParser::yy_reduce_print_ (int yyrule)
  1139. {
  1140. unsigned int yylno = yyrline_[yyrule];
  1141. int yynrhs = yyr2_[yyrule];
  1142. // Print the symbols being reduced, and their result.
  1143. *yycdebug_ << "Reducing stack by rule " << yyrule - 1
  1144. << " (line " << yylno << "):" << std::endl;
  1145. // The symbols being reduced.
  1146. for (int yyi = 0; yyi < yynrhs; yyi++)
  1147. YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
  1148. yystack_[(yynrhs) - (yyi + 1)]);
  1149. }
  1150. #endif // YYDEBUG
  1151. #line 13 "parser.yy" // lalr1.cc:1167
  1152. } } // isc::eval
  1153. #line 1354 "parser.cc" // lalr1.cc:1167
  1154. #line 288 "parser.yy" // lalr1.cc:1168
  1155. void
  1156. isc::eval::EvalParser::error(const location_type& loc,
  1157. const std::string& what)
  1158. {
  1159. ctx.error(loc, what);
  1160. }