librostlab-blast  1.0.1
blast-parser-parser.h
Go to the documentation of this file.
1 // A Bison parser, made by GNU Bison 3.3.2.
2 
3 // Skeleton interface for Bison LALR(1) parsers in C++
4 
5 // Copyright (C) 2002-2015, 2018-2019 Free Software Foundation, Inc.
6 
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
20 // As a special exception, you may create a larger work that contains
21 // part or all of the Bison parser skeleton and distribute that work
22 // under terms of your choice, so long as that work isn't itself a
23 // parser generator using the skeleton or a modified version thereof
24 // as a parser skeleton. Alternatively, if you modify or redistribute
25 // the parser skeleton itself, you may (at your option) remove this
26 // special exception, which will cause the skeleton and the resulting
27 // Bison output files to be licensed under the GNU General Public
28 // License without this special exception.
29 
30 // This special exception was added by the Free Software Foundation in
31 // version 2.2 of Bison.
32 
33 
39 // C++ LALR(1) parser skeleton written by Akim Demaille.
40 
41 // Undocumented macros, especially those whose name start with YY_,
42 // are private implementation details. Do not rely on them.
43 
44 #ifndef YY_YY_ROSTLAB_BLAST_PARSER_PARSER_H_INCLUDED
45 # define YY_YY_ROSTLAB_BLAST_PARSER_PARSER_H_INCLUDED
46 // // "%code requires" blocks.
47 #line 24 "blast-parser-parser.ypp" // lalr1.cc:401
48 
49 #include <string>
50 #include "rostlab/blast-result.h"
51 namespace rostlab { namespace blast { class parser_driver; } }
52 
53 #line 54 "rostlab/blast-parser-parser.h" // lalr1.cc:401
54 
55 
56 # include <cstdlib> // std::abort
57 # include <iostream>
58 # include <stdexcept>
59 # include <string>
60 # include <vector>
61 
62 #if defined __cplusplus
63 # define YY_CPLUSPLUS __cplusplus
64 #else
65 # define YY_CPLUSPLUS 199711L
66 #endif
67 
68 // Support move semantics when possible.
69 #if 201103L <= YY_CPLUSPLUS
70 # define YY_MOVE std::move
71 # define YY_MOVE_OR_COPY move
72 # define YY_MOVE_REF(Type) Type&&
73 # define YY_RVREF(Type) Type&&
74 # define YY_COPY(Type) Type
75 #else
76 # define YY_MOVE
77 # define YY_MOVE_OR_COPY copy
78 # define YY_MOVE_REF(Type) Type&
79 # define YY_RVREF(Type) const Type&
80 # define YY_COPY(Type) const Type&
81 #endif
82 
83 // Support noexcept when possible.
84 #if 201103L <= YY_CPLUSPLUS
85 # define YY_NOEXCEPT noexcept
86 # define YY_NOTHROW
87 #else
88 # define YY_NOEXCEPT
89 # define YY_NOTHROW throw ()
90 #endif
91 
92 // Support constexpr when possible.
93 #if 201703 <= YY_CPLUSPLUS
94 # define YY_CONSTEXPR constexpr
95 #else
96 # define YY_CONSTEXPR
97 #endif
99 
100 
101 #ifndef YY_ATTRIBUTE
102 # if (defined __GNUC__ \
103  && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
104  || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
105 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
106 # else
107 # define YY_ATTRIBUTE(Spec) /* empty */
108 # endif
109 #endif
110 
111 #ifndef YY_ATTRIBUTE_PURE
112 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
113 #endif
114 
115 #ifndef YY_ATTRIBUTE_UNUSED
116 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
117 #endif
118 
119 /* Suppress unused-variable warnings by "using" E. */
120 #if ! defined lint || defined __GNUC__
121 # define YYUSE(E) ((void) (E))
122 #else
123 # define YYUSE(E) /* empty */
124 #endif
125 
126 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
127 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
128 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
129  _Pragma ("GCC diagnostic push") \
130  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
131  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
132 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
133  _Pragma ("GCC diagnostic pop")
134 #else
135 # define YY_INITIAL_VALUE(Value) Value
136 #endif
137 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
138 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
139 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
140 #endif
141 #ifndef YY_INITIAL_VALUE
142 # define YY_INITIAL_VALUE(Value) /* Nothing. */
143 #endif
144 
145 # ifndef YY_NULLPTR
146 # if defined __cplusplus
147 # if 201103L <= __cplusplus
148 # define YY_NULLPTR nullptr
149 # else
150 # define YY_NULLPTR 0
151 # endif
152 # else
153 # define YY_NULLPTR ((void*)0)
154 # endif
155 # endif
156 
157 /* Debug traces. */
158 #ifndef YYDEBUG
159 # define YYDEBUG 1
160 #endif
161 
162 #line 22 "blast-parser-parser.ypp" // lalr1.cc:401
163 namespace rostlab { namespace blast {
164 #line 165 "rostlab/blast-parser-parser.h" // lalr1.cc:401
165 
166 
167 
169  class parser
170  {
171  public:
172 #ifndef YYSTYPE
173  union semantic_type
175  {
176  #line 47 "/build/librostlab-blast-3IsXj4/librostlab-blast-1.0.1/lib/blast-parser-parser.ypp" // lalr1.cc:401
177 
178  long int ival;
179  double dval;
180  std::string* sval;
181 
182 #line 183 "rostlab/blast-parser-parser.h" // lalr1.cc:401
183  };
184 #else
185  typedef YYSTYPE semantic_type;
186 #endif
187  typedef location location_type;
189 
191  struct syntax_error : std::runtime_error
192  {
193  syntax_error (const location_type& l, const std::string& m)
194  : std::runtime_error (m)
195  , location (l)
196  {}
197 
199  : std::runtime_error (s.what ())
200  , location (s.location)
201  {}
202 
204 
205  location_type location;
206  };
207 
209  struct token
210  {
212  {
213  END = 0,
214  BLAST_VERSION = 258,
215  REFERENCE = 259,
216  STRING = 260,
217  INT = 261,
218  DBL = 262,
219  SEARCHING = 263,
220  NOHITS = 264,
221  ONELINE_DESC_HEADER = 265,
222  SEQ_FOUND_AGAIN = 266,
223  SEQ_FOUND_NEW = 267,
224  CONVERGED = 268,
225  TAIL = 269,
226  QUERYEQ = 270,
227  DATABASECOLON = 271,
228  RESFROMROUND = 272,
229  SCOREEQ = 273,
230  EXPECTEQ = 274,
231  METHODCOLON = 275,
232  IDENTITIESEQ = 276,
233  POSITIVESEQ = 277,
234  GAPSEQ = 278,
235  STRANDEQ = 279,
236  FRAMEEQ = 280,
237  QUERYCOLON = 281,
238  SBJCTCOLON = 282
239  };
240  };
241 
244 
246  typedef int symbol_number_type;
247 
249  enum { empty_symbol = -2 };
250 
252  typedef unsigned char token_number_type;
253 
260  template <typename Base>
261  struct basic_symbol : Base
262  {
264  typedef Base super_type;
265 
268  : value ()
269  , location ()
270  {}
271 
272 #if 201103L <= YY_CPLUSPLUS
273  basic_symbol (basic_symbol&& that);
275 #endif
276 
278  basic_symbol (const basic_symbol& that);
280  basic_symbol (typename Base::kind_type t,
281  YY_MOVE_REF (location_type) l);
282 
284  basic_symbol (typename Base::kind_type t,
285  YY_RVREF (semantic_type) v,
286  YY_RVREF (location_type) l);
287 
290  {
291  clear ();
292  }
293 
295  void clear ()
296  {
297  Base::clear ();
298  }
299 
301  bool empty () const YY_NOEXCEPT;
302 
304  void move (basic_symbol& s);
305 
307  semantic_type value;
308 
310  location_type location;
311 
312  private:
313 #if YY_CPLUSPLUS < 201103L
314  basic_symbol& operator= (const basic_symbol& that);
316 #endif
317  };
318 
320  struct by_type
321  {
323  by_type ();
324 
325 #if 201103L <= YY_CPLUSPLUS
326  by_type (by_type&& that);
328 #endif
329 
331  by_type (const by_type& that);
332 
334  typedef token_type kind_type;
335 
337  by_type (kind_type t);
338 
340  void clear ();
341 
343  void move (by_type& that);
344 
347  symbol_number_type type_get () const YY_NOEXCEPT;
348 
350  token_type token () const YY_NOEXCEPT;
351 
355  int type;
356  };
357 
360  {};
361 
363  parser (rostlab::blast::parser_driver& drv_yyarg, void* yyscanner_yyarg);
364  virtual ~parser ();
365 
368  int operator() ();
369 
372  virtual int parse ();
373 
374 #if YYDEBUG
375  std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
378  void set_debug_stream (std::ostream &);
379 
381  typedef int debug_level_type;
383  debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
385  void set_debug_level (debug_level_type l);
386 #endif
387 
391  virtual void error (const location_type& loc, const std::string& msg);
392 
394  void error (const syntax_error& err);
395 
396 
397 
398  private:
400  parser (const parser&);
401  parser& operator= (const parser&);
402 
404  typedef int state_type;
405 
409  virtual std::string yysyntax_error_ (state_type yystate,
410  const symbol_type& yyla) const;
411 
415  state_type yy_lr_goto_state_ (state_type yystate, int yysym);
416 
419  static bool yy_pact_value_is_default_ (int yyvalue);
420 
423  static bool yy_table_value_is_error_ (int yyvalue);
424 
425  static const signed char yypact_ninf_;
426  static const signed char yytable_ninf_;
427 
429  static token_number_type yytranslate_ (int t);
430 
431  // Tables.
432  // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
433  // STATE-NUM.
434  static const signed char yypact_[];
435 
436  // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
437  // Performed when YYTABLE does not specify something else to do. Zero
438  // means the default is an error.
439  static const unsigned char yydefact_[];
440 
441  // YYPGOTO[NTERM-NUM].
442  static const signed char yypgoto_[];
443 
444  // YYDEFGOTO[NTERM-NUM].
445  static const signed char yydefgoto_[];
446 
447  // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
448  // positive, shift that token. If negative, reduce the rule whose
449  // number is the opposite. If YYTABLE_NINF, syntax error.
450  static const unsigned char yytable_[];
451 
452  static const unsigned char yycheck_[];
453 
454  // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
455  // symbol of state STATE-NUM.
456  static const unsigned char yystos_[];
457 
458  // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
459  static const unsigned char yyr1_[];
460 
461  // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
462  static const unsigned char yyr2_[];
463 
464 
466  static std::string yytnamerr_ (const char *n);
467 
468 
470  static const char* const yytname_[];
471 #if YYDEBUG
472  // YYRLINE[YYN] -- Source line where rule number YYN was defined.
473  static const unsigned char yyrline_[];
475  virtual void yy_reduce_print_ (int r);
477  virtual void yystack_print_ ();
478 
480  int yydebug_;
482  std::ostream* yycdebug_;
483 
487  template <typename Base>
488  void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
489 #endif
490 
495  template <typename Base>
496  void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
497 
498  private:
500  struct by_state
501  {
503  by_state () YY_NOEXCEPT;
504 
506  typedef state_type kind_type;
507 
509  by_state (kind_type s) YY_NOEXCEPT;
510 
512  by_state (const by_state& that) YY_NOEXCEPT;
513 
515  void clear () YY_NOEXCEPT;
516 
518  void move (by_state& that);
519 
522  symbol_number_type type_get () const YY_NOEXCEPT;
523 
525  enum { empty_state = -1 };
526 
529  state_type state;
530  };
531 
533  struct stack_symbol_type : basic_symbol<by_state>
534  {
536  typedef basic_symbol<by_state> super_type;
538  stack_symbol_type ();
540  stack_symbol_type (YY_RVREF (stack_symbol_type) that);
542  stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym);
543 #if YY_CPLUSPLUS < 201103L
544  stack_symbol_type& operator= (stack_symbol_type& that);
547 #endif
548  };
549 
551  template <typename T, typename S = std::vector<T> >
552  class stack
553  {
554  public:
555  // Hide our reversed order.
556  typedef typename S::reverse_iterator iterator;
557  typedef typename S::const_reverse_iterator const_iterator;
558  typedef typename S::size_type size_type;
559 
560  stack (size_type n = 200)
561  : seq_ (n)
562  {}
563 
567  T&
568  operator[] (size_type i)
569  {
570  return seq_[size () - 1 - i];
571  }
572 
576  T&
577  operator[] (int i)
578  {
579  return operator[] (size_type (i));
580  }
581 
585  const T&
586  operator[] (size_type i) const
587  {
588  return seq_[size () - 1 - i];
589  }
590 
594  const T&
595  operator[] (int i) const
596  {
597  return operator[] (size_type (i));
598  }
599 
603  void
604  push (YY_MOVE_REF (T) t)
605  {
606  seq_.push_back (T ());
607  operator[] (0).move (t);
608  }
609 
611  void
612  pop (int n = 1) YY_NOEXCEPT
613  {
614  for (; 0 < n; --n)
615  seq_.pop_back ();
616  }
617 
619  void
620  clear () YY_NOEXCEPT
621  {
622  seq_.clear ();
623  }
624 
626  size_type
627  size () const YY_NOEXCEPT
628  {
629  return seq_.size ();
630  }
631 
633  const_iterator
634  begin () const YY_NOEXCEPT
635  {
636  return seq_.rbegin ();
637  }
638 
640  const_iterator
641  end () const YY_NOEXCEPT
642  {
643  return seq_.rend ();
644  }
645 
647  class slice
648  {
649  public:
650  slice (const stack& stack, int range)
651  : stack_ (stack)
652  , range_ (range)
653  {}
654 
655  const T&
656  operator[] (int i) const
657  {
658  return stack_[range_ - i];
659  }
660 
661  private:
662  const stack& stack_;
663  int range_;
664  };
665 
666  private:
667  stack (const stack&);
668  stack& operator= (const stack&);
670  S seq_;
671  };
672 
673 
675  typedef stack<stack_symbol_type> stack_type;
676 
678  stack_type yystack_;
679 
685  void yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym);
686 
693  void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
694 
696  void yypop_ (int n = 1);
697 
699  enum
700  {
701  yyeof_ = 0,
702  yylast_ = 81,
703  yynnts_ = 24,
704  yyfinal_ = 6,
705  yyterror_ = 1,
706  yyerrcode_ = 256,
707  yyntokens_ = 31
708  };
709 
710 
711  // User arguments.
713  void* yyscanner;
714  };
715 
716 
717 #line 22 "blast-parser-parser.ypp" // lalr1.cc:401
718 } } // rostlab::blast
719 #line 720 "rostlab/blast-parser-parser.h" // lalr1.cc:401
720 
721 
722 
723 
724 #endif // !YY_YY_ROSTLAB_BLAST_PARSER_PARSER_H_INCLUDED
#define YY_NOEXCEPT
"External" symbols: returned by the scanner.
Type access provider for token (enum) based symbols.
#define YY_RVREF(Type)
unsigned char token_number_type
Internal symbol number for tokens (subsumed by symbol_number_type).
Present a slice of the top of a stack.
syntax_error(const location_type &l, const std::string &m)
int debug_level_type
Type for debugging levels.
#define YY_ATTRIBUTE_PURE
void clear()
Destroy contents, and record that is empty.
location_type location
The location.
Two points in a source file.
slice(const stack &stack, int range)
token::yytokentype token_type
(External) token type, as returned by yylex.
int symbol_number_type
Symbol type: an internal symbol number.
#define YY_MOVE_REF(Type)
token_type kind_type
The symbol type as needed by the constructor.
Syntax errors thrown from user actions.
#define YY_NOTHROW
semantic_type value
The semantic value.
Blast (default, -m 0) output parser.