parser.h 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109
  1. // A Bison parser, made by GNU Bison 3.0.4.
  2. // Skeleton interface 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. /**
  26. ** \file parser.h
  27. ** Define the isc::eval::parser class.
  28. */
  29. // C++ LALR(1) parser skeleton written by Akim Demaille.
  30. #ifndef YY_YY_PARSER_H_INCLUDED
  31. # define YY_YY_PARSER_H_INCLUDED
  32. // // "%code requires" blocks.
  33. #line 24 "parser.yy" // lalr1.cc:392
  34. #include <string>
  35. #include <eval/token.h>
  36. #include <eval/eval_context_decl.h>
  37. #include <dhcp/option.h>
  38. #include <boost/lexical_cast.hpp>
  39. using namespace isc::dhcp;
  40. using namespace isc::eval;
  41. #line 55 "parser.h" // lalr1.cc:392
  42. # include <cassert>
  43. # include <cstdlib> // std::abort
  44. # include <iostream>
  45. # include <stdexcept>
  46. # include <string>
  47. # include <vector>
  48. # include "stack.hh"
  49. # include "location.hh"
  50. #include <typeinfo>
  51. #ifndef YYASSERT
  52. # include <cassert>
  53. # define YYASSERT assert
  54. #endif
  55. #ifndef YY_ATTRIBUTE
  56. # if (defined __GNUC__ \
  57. && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
  58. || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
  59. # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
  60. # else
  61. # define YY_ATTRIBUTE(Spec) /* empty */
  62. # endif
  63. #endif
  64. #ifndef YY_ATTRIBUTE_PURE
  65. # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
  66. #endif
  67. #ifndef YY_ATTRIBUTE_UNUSED
  68. # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
  69. #endif
  70. #if !defined _Noreturn \
  71. && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
  72. # if defined _MSC_VER && 1200 <= _MSC_VER
  73. # define _Noreturn __declspec (noreturn)
  74. # else
  75. # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
  76. # endif
  77. #endif
  78. /* Suppress unused-variable warnings by "using" E. */
  79. #if ! defined lint || defined __GNUC__
  80. # define YYUSE(E) ((void) (E))
  81. #else
  82. # define YYUSE(E) /* empty */
  83. #endif
  84. #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
  85. /* Suppress an incorrect diagnostic about yylval being uninitialized. */
  86. # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
  87. _Pragma ("GCC diagnostic push") \
  88. _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
  89. _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
  90. # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
  91. _Pragma ("GCC diagnostic pop")
  92. #else
  93. # define YY_INITIAL_VALUE(Value) Value
  94. #endif
  95. #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  96. # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  97. # define YY_IGNORE_MAYBE_UNINITIALIZED_END
  98. #endif
  99. #ifndef YY_INITIAL_VALUE
  100. # define YY_INITIAL_VALUE(Value) /* Nothing. */
  101. #endif
  102. /* Debug traces. */
  103. #ifndef YYDEBUG
  104. # define YYDEBUG 1
  105. #endif
  106. #line 21 "parser.yy" // lalr1.cc:392
  107. namespace isc { namespace eval {
  108. #line 132 "parser.h" // lalr1.cc:392
  109. /// A char[S] buffer to store and retrieve objects.
  110. ///
  111. /// Sort of a variant, but does not keep track of the nature
  112. /// of the stored data, since that knowledge is available
  113. /// via the current state.
  114. template <size_t S>
  115. struct variant
  116. {
  117. /// Type of *this.
  118. typedef variant<S> self_type;
  119. /// Empty construction.
  120. variant ()
  121. : yytypeid_ (YY_NULLPTR)
  122. {}
  123. /// Construct and fill.
  124. template <typename T>
  125. variant (const T& t)
  126. : yytypeid_ (&typeid (T))
  127. {
  128. YYASSERT (sizeof (T) <= S);
  129. new (yyas_<T> ()) T (t);
  130. }
  131. /// Destruction, allowed only if empty.
  132. ~variant ()
  133. {
  134. YYASSERT (!yytypeid_);
  135. }
  136. /// Instantiate an empty \a T in here.
  137. template <typename T>
  138. T&
  139. build ()
  140. {
  141. YYASSERT (!yytypeid_);
  142. YYASSERT (sizeof (T) <= S);
  143. yytypeid_ = & typeid (T);
  144. return *new (yyas_<T> ()) T;
  145. }
  146. /// Instantiate a \a T in here from \a t.
  147. template <typename T>
  148. T&
  149. build (const T& t)
  150. {
  151. YYASSERT (!yytypeid_);
  152. YYASSERT (sizeof (T) <= S);
  153. yytypeid_ = & typeid (T);
  154. return *new (yyas_<T> ()) T (t);
  155. }
  156. /// Accessor to a built \a T.
  157. template <typename T>
  158. T&
  159. as ()
  160. {
  161. YYASSERT (*yytypeid_ == typeid (T));
  162. YYASSERT (sizeof (T) <= S);
  163. return *yyas_<T> ();
  164. }
  165. /// Const accessor to a built \a T (for %printer).
  166. template <typename T>
  167. const T&
  168. as () const
  169. {
  170. YYASSERT (*yytypeid_ == typeid (T));
  171. YYASSERT (sizeof (T) <= S);
  172. return *yyas_<T> ();
  173. }
  174. /// Swap the content with \a other, of same type.
  175. ///
  176. /// Both variants must be built beforehand, because swapping the actual
  177. /// data requires reading it (with as()), and this is not possible on
  178. /// unconstructed variants: it would require some dynamic testing, which
  179. /// should not be the variant's responsability.
  180. /// Swapping between built and (possibly) non-built is done with
  181. /// variant::move ().
  182. template <typename T>
  183. void
  184. swap (self_type& other)
  185. {
  186. YYASSERT (yytypeid_);
  187. YYASSERT (*yytypeid_ == *other.yytypeid_);
  188. std::swap (as<T> (), other.as<T> ());
  189. }
  190. /// Move the content of \a other to this.
  191. ///
  192. /// Destroys \a other.
  193. template <typename T>
  194. void
  195. move (self_type& other)
  196. {
  197. build<T> ();
  198. swap<T> (other);
  199. other.destroy<T> ();
  200. }
  201. /// Copy the content of \a other to this.
  202. template <typename T>
  203. void
  204. copy (const self_type& other)
  205. {
  206. build<T> (other.as<T> ());
  207. }
  208. /// Destroy the stored \a T.
  209. template <typename T>
  210. void
  211. destroy ()
  212. {
  213. as<T> ().~T ();
  214. yytypeid_ = YY_NULLPTR;
  215. }
  216. private:
  217. /// Prohibit blind copies.
  218. self_type& operator=(const self_type&);
  219. variant (const self_type&);
  220. /// Accessor to raw memory as \a T.
  221. template <typename T>
  222. T*
  223. yyas_ ()
  224. {
  225. void *yyp = yybuffer_.yyraw;
  226. return static_cast<T*> (yyp);
  227. }
  228. /// Const accessor to raw memory as \a T.
  229. template <typename T>
  230. const T*
  231. yyas_ () const
  232. {
  233. const void *yyp = yybuffer_.yyraw;
  234. return static_cast<const T*> (yyp);
  235. }
  236. union
  237. {
  238. /// Strongest alignment constraints.
  239. long double yyalign_me;
  240. /// A buffer large enough to store any of the semantic values.
  241. char yyraw[S];
  242. } yybuffer_;
  243. /// Whether the content is built: if defined, the name of the stored type.
  244. const std::type_info *yytypeid_;
  245. };
  246. /// A Bison parser.
  247. class EvalParser
  248. {
  249. public:
  250. #ifndef YYSTYPE
  251. /// An auxiliary type to compute the largest semantic type.
  252. union union_type
  253. {
  254. // "constant string"
  255. // "integer"
  256. // "constant hexstring"
  257. // "option name"
  258. // TOKEN
  259. char dummy1[sizeof(std::string)];
  260. };
  261. /// Symbol semantic values.
  262. typedef variant<sizeof(union_type)> semantic_type;
  263. #else
  264. typedef YYSTYPE semantic_type;
  265. #endif
  266. /// Symbol locations.
  267. typedef location location_type;
  268. /// Syntax errors thrown from user actions.
  269. struct syntax_error : std::runtime_error
  270. {
  271. syntax_error (const location_type& l, const std::string& m);
  272. location_type location;
  273. };
  274. /// Tokens.
  275. struct token
  276. {
  277. enum yytokentype
  278. {
  279. TOKEN_END = 0,
  280. TOKEN_EQUAL = 258,
  281. TOKEN_OPTION = 259,
  282. TOKEN_SUBSTRING = 260,
  283. TOKEN_TEXT = 261,
  284. TOKEN_HEX = 262,
  285. TOKEN_ALL = 263,
  286. TOKEN_DOT = 264,
  287. TOKEN_COMA = 265,
  288. TOKEN_LPAREN = 266,
  289. TOKEN_RPAREN = 267,
  290. TOKEN_LBRACKET = 268,
  291. TOKEN_RBRACKET = 269,
  292. TOKEN_STRING = 270,
  293. TOKEN_INTEGER = 271,
  294. TOKEN_HEXSTRING = 272,
  295. TOKEN_OPTION_NAME = 273,
  296. TOKEN_TOKEN = 274
  297. };
  298. };
  299. /// (External) token type, as returned by yylex.
  300. typedef token::yytokentype token_type;
  301. /// Symbol type: an internal symbol number.
  302. typedef int symbol_number_type;
  303. /// The symbol type number to denote an empty symbol.
  304. enum { empty_symbol = -2 };
  305. /// Internal symbol number for tokens (subsumed by symbol_number_type).
  306. typedef unsigned char token_number_type;
  307. /// A complete symbol.
  308. ///
  309. /// Expects its Base type to provide access to the symbol type
  310. /// via type_get().
  311. ///
  312. /// Provide access to semantic value and location.
  313. template <typename Base>
  314. struct basic_symbol : Base
  315. {
  316. /// Alias to Base.
  317. typedef Base super_type;
  318. /// Default constructor.
  319. basic_symbol ();
  320. /// Copy constructor.
  321. basic_symbol (const basic_symbol& other);
  322. /// Constructor for valueless symbols, and symbols from each type.
  323. basic_symbol (typename Base::kind_type t, const location_type& l);
  324. basic_symbol (typename Base::kind_type t, const std::string v, const location_type& l);
  325. /// Constructor for symbols with semantic value.
  326. basic_symbol (typename Base::kind_type t,
  327. const semantic_type& v,
  328. const location_type& l);
  329. /// Destroy the symbol.
  330. ~basic_symbol ();
  331. /// Destroy contents, and record that is empty.
  332. void clear ();
  333. /// Whether empty.
  334. bool empty () const;
  335. /// Destructive move, \a s is emptied into this.
  336. void move (basic_symbol& s);
  337. /// The semantic value.
  338. semantic_type value;
  339. /// The location.
  340. location_type location;
  341. private:
  342. /// Assignment operator.
  343. basic_symbol& operator= (const basic_symbol& other);
  344. };
  345. /// Type access provider for token (enum) based symbols.
  346. struct by_type
  347. {
  348. /// Default constructor.
  349. by_type ();
  350. /// Copy constructor.
  351. by_type (const by_type& other);
  352. /// The symbol type as needed by the constructor.
  353. typedef token_type kind_type;
  354. /// Constructor from (external) token numbers.
  355. by_type (kind_type t);
  356. /// Record that this symbol is empty.
  357. void clear ();
  358. /// Steal the symbol type from \a that.
  359. void move (by_type& that);
  360. /// The (internal) type number (corresponding to \a type).
  361. /// \a empty when empty.
  362. symbol_number_type type_get () const;
  363. /// The token.
  364. token_type token () const;
  365. /// The symbol type.
  366. /// \a empty_symbol when empty.
  367. /// An int, not token_number_type, to be able to store empty_symbol.
  368. int type;
  369. };
  370. /// "External" symbols: returned by the scanner.
  371. typedef basic_symbol<by_type> symbol_type;
  372. // Symbol constructors declarations.
  373. static inline
  374. symbol_type
  375. make_END (const location_type& l);
  376. static inline
  377. symbol_type
  378. make_EQUAL (const location_type& l);
  379. static inline
  380. symbol_type
  381. make_OPTION (const location_type& l);
  382. static inline
  383. symbol_type
  384. make_SUBSTRING (const location_type& l);
  385. static inline
  386. symbol_type
  387. make_TEXT (const location_type& l);
  388. static inline
  389. symbol_type
  390. make_HEX (const location_type& l);
  391. static inline
  392. symbol_type
  393. make_ALL (const location_type& l);
  394. static inline
  395. symbol_type
  396. make_DOT (const location_type& l);
  397. static inline
  398. symbol_type
  399. make_COMA (const location_type& l);
  400. static inline
  401. symbol_type
  402. make_LPAREN (const location_type& l);
  403. static inline
  404. symbol_type
  405. make_RPAREN (const location_type& l);
  406. static inline
  407. symbol_type
  408. make_LBRACKET (const location_type& l);
  409. static inline
  410. symbol_type
  411. make_RBRACKET (const location_type& l);
  412. static inline
  413. symbol_type
  414. make_STRING (const std::string& v, const location_type& l);
  415. static inline
  416. symbol_type
  417. make_INTEGER (const std::string& v, const location_type& l);
  418. static inline
  419. symbol_type
  420. make_HEXSTRING (const std::string& v, const location_type& l);
  421. static inline
  422. symbol_type
  423. make_OPTION_NAME (const std::string& v, const location_type& l);
  424. static inline
  425. symbol_type
  426. make_TOKEN (const std::string& v, const location_type& l);
  427. /// Build a parser object.
  428. EvalParser (EvalContext& ctx_yyarg, const Option::Universe& option_universe_yyarg);
  429. virtual ~EvalParser ();
  430. /// Parse.
  431. /// \returns 0 iff parsing succeeded.
  432. virtual int parse ();
  433. #if YYDEBUG
  434. /// The current debugging stream.
  435. std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
  436. /// Set the current debugging stream.
  437. void set_debug_stream (std::ostream &);
  438. /// Type for debugging levels.
  439. typedef int debug_level_type;
  440. /// The current debugging level.
  441. debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
  442. /// Set the current debugging level.
  443. void set_debug_level (debug_level_type l);
  444. #endif
  445. /// Report a syntax error.
  446. /// \param loc where the syntax error is found.
  447. /// \param msg a description of the syntax error.
  448. virtual void error (const location_type& loc, const std::string& msg);
  449. /// Report a syntax error.
  450. void error (const syntax_error& err);
  451. private:
  452. /// This class is not copyable.
  453. EvalParser (const EvalParser&);
  454. EvalParser& operator= (const EvalParser&);
  455. /// State numbers.
  456. typedef int state_type;
  457. /// Generate an error message.
  458. /// \param yystate the state where the error occurred.
  459. /// \param yyla the lookahead token.
  460. virtual std::string yysyntax_error_ (state_type yystate,
  461. const symbol_type& yyla) const;
  462. /// Compute post-reduction state.
  463. /// \param yystate the current state
  464. /// \param yysym the nonterminal to push on the stack
  465. state_type yy_lr_goto_state_ (state_type yystate, int yysym);
  466. /// Whether the given \c yypact_ value indicates a defaulted state.
  467. /// \param yyvalue the value to check
  468. static bool yy_pact_value_is_default_ (int yyvalue);
  469. /// Whether the given \c yytable_ value indicates a syntax error.
  470. /// \param yyvalue the value to check
  471. static bool yy_table_value_is_error_ (int yyvalue);
  472. static const signed char yypact_ninf_;
  473. static const signed char yytable_ninf_;
  474. /// Convert a scanner token number \a t to a symbol number.
  475. static token_number_type yytranslate_ (token_type t);
  476. // Tables.
  477. // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
  478. // STATE-NUM.
  479. static const signed char yypact_[];
  480. // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
  481. // Performed when YYTABLE does not specify something else to do. Zero
  482. // means the default is an error.
  483. static const unsigned char yydefact_[];
  484. // YYPGOTO[NTERM-NUM].
  485. static const signed char yypgoto_[];
  486. // YYDEFGOTO[NTERM-NUM].
  487. static const signed char yydefgoto_[];
  488. // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
  489. // positive, shift that token. If negative, reduce the rule whose
  490. // number is the opposite. If YYTABLE_NINF, syntax error.
  491. static const unsigned char yytable_[];
  492. static const signed char yycheck_[];
  493. // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
  494. // symbol of state STATE-NUM.
  495. static const unsigned char yystos_[];
  496. // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
  497. static const unsigned char yyr1_[];
  498. // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
  499. static const unsigned char yyr2_[];
  500. /// Convert the symbol name \a n to a form suitable for a diagnostic.
  501. static std::string yytnamerr_ (const char *n);
  502. /// For a symbol, its name in clear.
  503. static const char* const yytname_[];
  504. #if YYDEBUG
  505. // YYRLINE[YYN] -- Source line where rule number YYN was defined.
  506. static const unsigned char yyrline_[];
  507. /// Report on the debug stream that the rule \a r is going to be reduced.
  508. virtual void yy_reduce_print_ (int r);
  509. /// Print the state stack on the debug stream.
  510. virtual void yystack_print_ ();
  511. // Debugging.
  512. int yydebug_;
  513. std::ostream* yycdebug_;
  514. /// \brief Display a symbol type, value and location.
  515. /// \param yyo The output stream.
  516. /// \param yysym The symbol.
  517. template <typename Base>
  518. void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
  519. #endif
  520. /// \brief Reclaim the memory associated to a symbol.
  521. /// \param yymsg Why this token is reclaimed.
  522. /// If null, print nothing.
  523. /// \param yysym The symbol.
  524. template <typename Base>
  525. void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
  526. private:
  527. /// Type access provider for state based symbols.
  528. struct by_state
  529. {
  530. /// Default constructor.
  531. by_state ();
  532. /// The symbol type as needed by the constructor.
  533. typedef state_type kind_type;
  534. /// Constructor.
  535. by_state (kind_type s);
  536. /// Copy constructor.
  537. by_state (const by_state& other);
  538. /// Record that this symbol is empty.
  539. void clear ();
  540. /// Steal the symbol type from \a that.
  541. void move (by_state& that);
  542. /// The (internal) type number (corresponding to \a state).
  543. /// \a empty_symbol when empty.
  544. symbol_number_type type_get () const;
  545. /// The state number used to denote an empty symbol.
  546. enum { empty_state = -1 };
  547. /// The state.
  548. /// \a empty when empty.
  549. state_type state;
  550. };
  551. /// "Internal" symbol: element of the stack.
  552. struct stack_symbol_type : basic_symbol<by_state>
  553. {
  554. /// Superclass.
  555. typedef basic_symbol<by_state> super_type;
  556. /// Construct an empty symbol.
  557. stack_symbol_type ();
  558. /// Steal the contents from \a sym to build this.
  559. stack_symbol_type (state_type s, symbol_type& sym);
  560. /// Assignment, needed by push_back.
  561. stack_symbol_type& operator= (const stack_symbol_type& that);
  562. };
  563. /// Stack type.
  564. typedef stack<stack_symbol_type> stack_type;
  565. /// The stack.
  566. stack_type yystack_;
  567. /// Push a new state on the stack.
  568. /// \param m a debug message to display
  569. /// if null, no trace is output.
  570. /// \param s the symbol
  571. /// \warning the contents of \a s.value is stolen.
  572. void yypush_ (const char* m, stack_symbol_type& s);
  573. /// Push a new look ahead token on the state on the stack.
  574. /// \param m a debug message to display
  575. /// if null, no trace is output.
  576. /// \param s the state
  577. /// \param sym the symbol (for its value and location).
  578. /// \warning the contents of \a s.value is stolen.
  579. void yypush_ (const char* m, state_type s, symbol_type& sym);
  580. /// Pop \a n symbols the three stacks.
  581. void yypop_ (unsigned int n = 1);
  582. /// Constants.
  583. enum
  584. {
  585. yyeof_ = 0,
  586. yylast_ = 31, ///< Last index in yytable_.
  587. yynnts_ = 6, ///< Number of nonterminal symbols.
  588. yyfinal_ = 11, ///< Termination state number.
  589. yyterror_ = 1,
  590. yyerrcode_ = 256,
  591. yyntokens_ = 20 ///< Number of tokens.
  592. };
  593. // User arguments.
  594. EvalContext& ctx;
  595. const Option::Universe& option_universe;
  596. };
  597. // Symbol number corresponding to token number t.
  598. inline
  599. EvalParser::token_number_type
  600. EvalParser::yytranslate_ (token_type t)
  601. {
  602. static
  603. const token_number_type
  604. translate_table[] =
  605. {
  606. 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  607. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  608. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  609. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  610. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  611. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  612. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  613. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  614. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  615. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  616. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  617. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  618. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  619. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  620. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  621. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  622. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  623. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  624. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  625. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  626. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  627. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  628. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  629. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  630. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  631. 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
  632. 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  633. 15, 16, 17, 18, 19
  634. };
  635. const unsigned int user_token_number_max_ = 274;
  636. const token_number_type undef_token_ = 2;
  637. if (static_cast<int>(t) <= yyeof_)
  638. return yyeof_;
  639. else if (static_cast<unsigned int> (t) <= user_token_number_max_)
  640. return translate_table[t];
  641. else
  642. return undef_token_;
  643. }
  644. inline
  645. EvalParser::syntax_error::syntax_error (const location_type& l, const std::string& m)
  646. : std::runtime_error (m)
  647. , location (l)
  648. {}
  649. // basic_symbol.
  650. template <typename Base>
  651. inline
  652. EvalParser::basic_symbol<Base>::basic_symbol ()
  653. : value ()
  654. {}
  655. template <typename Base>
  656. inline
  657. EvalParser::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
  658. : Base (other)
  659. , value ()
  660. , location (other.location)
  661. {
  662. switch (other.type_get ())
  663. {
  664. case 15: // "constant string"
  665. case 16: // "integer"
  666. case 17: // "constant hexstring"
  667. case 18: // "option name"
  668. case 19: // TOKEN
  669. value.copy< std::string > (other.value);
  670. break;
  671. default:
  672. break;
  673. }
  674. }
  675. template <typename Base>
  676. inline
  677. EvalParser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const semantic_type& v, const location_type& l)
  678. : Base (t)
  679. , value ()
  680. , location (l)
  681. {
  682. (void) v;
  683. switch (this->type_get ())
  684. {
  685. case 15: // "constant string"
  686. case 16: // "integer"
  687. case 17: // "constant hexstring"
  688. case 18: // "option name"
  689. case 19: // TOKEN
  690. value.copy< std::string > (v);
  691. break;
  692. default:
  693. break;
  694. }
  695. }
  696. // Implementation of basic_symbol constructor for each type.
  697. template <typename Base>
  698. EvalParser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const location_type& l)
  699. : Base (t)
  700. , value ()
  701. , location (l)
  702. {}
  703. template <typename Base>
  704. EvalParser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const std::string v, const location_type& l)
  705. : Base (t)
  706. , value (v)
  707. , location (l)
  708. {}
  709. template <typename Base>
  710. inline
  711. EvalParser::basic_symbol<Base>::~basic_symbol ()
  712. {
  713. clear ();
  714. }
  715. template <typename Base>
  716. inline
  717. void
  718. EvalParser::basic_symbol<Base>::clear ()
  719. {
  720. // User destructor.
  721. symbol_number_type yytype = this->type_get ();
  722. basic_symbol<Base>& yysym = *this;
  723. (void) yysym;
  724. switch (yytype)
  725. {
  726. default:
  727. break;
  728. }
  729. // Type destructor.
  730. switch (yytype)
  731. {
  732. case 15: // "constant string"
  733. case 16: // "integer"
  734. case 17: // "constant hexstring"
  735. case 18: // "option name"
  736. case 19: // TOKEN
  737. value.template destroy< std::string > ();
  738. break;
  739. default:
  740. break;
  741. }
  742. Base::clear ();
  743. }
  744. template <typename Base>
  745. inline
  746. bool
  747. EvalParser::basic_symbol<Base>::empty () const
  748. {
  749. return Base::type_get () == empty_symbol;
  750. }
  751. template <typename Base>
  752. inline
  753. void
  754. EvalParser::basic_symbol<Base>::move (basic_symbol& s)
  755. {
  756. super_type::move(s);
  757. switch (this->type_get ())
  758. {
  759. case 15: // "constant string"
  760. case 16: // "integer"
  761. case 17: // "constant hexstring"
  762. case 18: // "option name"
  763. case 19: // TOKEN
  764. value.move< std::string > (s.value);
  765. break;
  766. default:
  767. break;
  768. }
  769. location = s.location;
  770. }
  771. // by_type.
  772. inline
  773. EvalParser::by_type::by_type ()
  774. : type (empty_symbol)
  775. {}
  776. inline
  777. EvalParser::by_type::by_type (const by_type& other)
  778. : type (other.type)
  779. {}
  780. inline
  781. EvalParser::by_type::by_type (token_type t)
  782. : type (yytranslate_ (t))
  783. {}
  784. inline
  785. void
  786. EvalParser::by_type::clear ()
  787. {
  788. type = empty_symbol;
  789. }
  790. inline
  791. void
  792. EvalParser::by_type::move (by_type& that)
  793. {
  794. type = that.type;
  795. that.clear ();
  796. }
  797. inline
  798. int
  799. EvalParser::by_type::type_get () const
  800. {
  801. return type;
  802. }
  803. inline
  804. EvalParser::token_type
  805. EvalParser::by_type::token () const
  806. {
  807. // YYTOKNUM[NUM] -- (External) token number corresponding to the
  808. // (internal) symbol number NUM (which must be that of a token). */
  809. static
  810. const unsigned short int
  811. yytoken_number_[] =
  812. {
  813. 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
  814. 265, 266, 267, 268, 269, 270, 271, 272, 273, 274
  815. };
  816. return static_cast<token_type> (yytoken_number_[type]);
  817. }
  818. // Implementation of make_symbol for each symbol type.
  819. EvalParser::symbol_type
  820. EvalParser::make_END (const location_type& l)
  821. {
  822. return symbol_type (token::TOKEN_END, l);
  823. }
  824. EvalParser::symbol_type
  825. EvalParser::make_EQUAL (const location_type& l)
  826. {
  827. return symbol_type (token::TOKEN_EQUAL, l);
  828. }
  829. EvalParser::symbol_type
  830. EvalParser::make_OPTION (const location_type& l)
  831. {
  832. return symbol_type (token::TOKEN_OPTION, l);
  833. }
  834. EvalParser::symbol_type
  835. EvalParser::make_SUBSTRING (const location_type& l)
  836. {
  837. return symbol_type (token::TOKEN_SUBSTRING, l);
  838. }
  839. EvalParser::symbol_type
  840. EvalParser::make_TEXT (const location_type& l)
  841. {
  842. return symbol_type (token::TOKEN_TEXT, l);
  843. }
  844. EvalParser::symbol_type
  845. EvalParser::make_HEX (const location_type& l)
  846. {
  847. return symbol_type (token::TOKEN_HEX, l);
  848. }
  849. EvalParser::symbol_type
  850. EvalParser::make_ALL (const location_type& l)
  851. {
  852. return symbol_type (token::TOKEN_ALL, l);
  853. }
  854. EvalParser::symbol_type
  855. EvalParser::make_DOT (const location_type& l)
  856. {
  857. return symbol_type (token::TOKEN_DOT, l);
  858. }
  859. EvalParser::symbol_type
  860. EvalParser::make_COMA (const location_type& l)
  861. {
  862. return symbol_type (token::TOKEN_COMA, l);
  863. }
  864. EvalParser::symbol_type
  865. EvalParser::make_LPAREN (const location_type& l)
  866. {
  867. return symbol_type (token::TOKEN_LPAREN, l);
  868. }
  869. EvalParser::symbol_type
  870. EvalParser::make_RPAREN (const location_type& l)
  871. {
  872. return symbol_type (token::TOKEN_RPAREN, l);
  873. }
  874. EvalParser::symbol_type
  875. EvalParser::make_LBRACKET (const location_type& l)
  876. {
  877. return symbol_type (token::TOKEN_LBRACKET, l);
  878. }
  879. EvalParser::symbol_type
  880. EvalParser::make_RBRACKET (const location_type& l)
  881. {
  882. return symbol_type (token::TOKEN_RBRACKET, l);
  883. }
  884. EvalParser::symbol_type
  885. EvalParser::make_STRING (const std::string& v, const location_type& l)
  886. {
  887. return symbol_type (token::TOKEN_STRING, v, l);
  888. }
  889. EvalParser::symbol_type
  890. EvalParser::make_INTEGER (const std::string& v, const location_type& l)
  891. {
  892. return symbol_type (token::TOKEN_INTEGER, v, l);
  893. }
  894. EvalParser::symbol_type
  895. EvalParser::make_HEXSTRING (const std::string& v, const location_type& l)
  896. {
  897. return symbol_type (token::TOKEN_HEXSTRING, v, l);
  898. }
  899. EvalParser::symbol_type
  900. EvalParser::make_OPTION_NAME (const std::string& v, const location_type& l)
  901. {
  902. return symbol_type (token::TOKEN_OPTION_NAME, v, l);
  903. }
  904. EvalParser::symbol_type
  905. EvalParser::make_TOKEN (const std::string& v, const location_type& l)
  906. {
  907. return symbol_type (token::TOKEN_TOKEN, v, l);
  908. }
  909. #line 21 "parser.yy" // lalr1.cc:392
  910. } } // isc::eval
  911. #line 1105 "parser.h" // lalr1.cc:392
  912. #endif // !YY_YY_PARSER_H_INCLUDED