parser.h 26 KB

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