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.5.1.
2 
3 // Skeleton interface for Bison LALR(1) parsers in C++
4 
5 // Copyright (C) 2002-2015, 2018-2020 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"
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"
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_PURE
102 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
103 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
104 # else
105 # define YY_ATTRIBUTE_PURE
106 # endif
107 #endif
108 
109 #ifndef YY_ATTRIBUTE_UNUSED
110 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
111 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
112 # else
113 # define YY_ATTRIBUTE_UNUSED
114 # endif
115 #endif
116 
117 /* Suppress unused-variable warnings by "using" E. */
118 #if ! defined lint || defined __GNUC__
119 # define YYUSE(E) ((void) (E))
120 #else
121 # define YYUSE(E) /* empty */
122 #endif
123 
124 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
125 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
126 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
127  _Pragma ("GCC diagnostic push") \
128  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
129  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
130 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
131  _Pragma ("GCC diagnostic pop")
132 #else
133 # define YY_INITIAL_VALUE(Value) Value
134 #endif
135 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
136 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
137 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
138 #endif
139 #ifndef YY_INITIAL_VALUE
140 # define YY_INITIAL_VALUE(Value) /* Nothing. */
141 #endif
142 
143 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
144 # define YY_IGNORE_USELESS_CAST_BEGIN \
145  _Pragma ("GCC diagnostic push") \
146  _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
147 # define YY_IGNORE_USELESS_CAST_END \
148  _Pragma ("GCC diagnostic pop")
149 #endif
150 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
151 # define YY_IGNORE_USELESS_CAST_BEGIN
152 # define YY_IGNORE_USELESS_CAST_END
153 #endif
154 
155 # ifndef YY_CAST
156 # ifdef __cplusplus
157 # define YY_CAST(Type, Val) static_cast<Type> (Val)
158 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
159 # else
160 # define YY_CAST(Type, Val) ((Type) (Val))
161 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
162 # endif
163 # endif
164 # ifndef YY_NULLPTR
165 # if defined __cplusplus
166 # if 201103L <= __cplusplus
167 # define YY_NULLPTR nullptr
168 # else
169 # define YY_NULLPTR 0
170 # endif
171 # else
172 # define YY_NULLPTR ((void*)0)
173 # endif
174 # endif
175 
176 /* Debug traces. */
177 #ifndef YYDEBUG
178 # define YYDEBUG 1
179 #endif
180 
181 #line 22 "blast-parser-parser.ypp"
182 namespace rostlab { namespace blast {
183 #line 184 "rostlab/blast-parser-parser.h"
184 
185 
186 
187 
189  class parser
190  {
191  public:
192 #ifndef YYSTYPE
193  union semantic_type
195  {
196 #line 47 "blast-parser-parser.ypp"
197 
198  long int ival;
199  double dval;
200  std::string* sval;
201 
202 #line 203 "rostlab/blast-parser-parser.h"
203 
204  };
205 #else
206  typedef YYSTYPE semantic_type;
207 #endif
208  typedef location location_type;
210 
212  struct syntax_error : std::runtime_error
213  {
214  syntax_error (const location_type& l, const std::string& m)
215  : std::runtime_error (m)
216  , location (l)
217  {}
218 
220  : std::runtime_error (s.what ())
221  , location (s.location)
222  {}
223 
225 
227  };
228 
230  struct token
231  {
233  {
234  END = 0,
235  BLAST_VERSION = 258,
236  REFERENCE = 259,
237  STRING = 260,
238  INT = 261,
239  DBL = 262,
240  SEARCHING = 263,
241  NOHITS = 264,
242  ONELINE_DESC_HEADER = 265,
243  SEQ_FOUND_AGAIN = 266,
244  SEQ_FOUND_NEW = 267,
245  CONVERGED = 268,
246  TAIL = 269,
247  QUERYEQ = 270,
248  DATABASECOLON = 271,
249  RESFROMROUND = 272,
250  SCOREEQ = 273,
251  EXPECTEQ = 274,
252  METHODCOLON = 275,
253  IDENTITIESEQ = 276,
254  POSITIVESEQ = 277,
255  GAPSEQ = 278,
256  STRANDEQ = 279,
257  FRAMEEQ = 280,
258  QUERYCOLON = 281,
259  SBJCTCOLON = 282
260  };
261  };
262 
265 
267  typedef int symbol_number_type;
268 
270  enum { empty_symbol = -2 };
271 
273  typedef signed char token_number_type;
274 
281  template <typename Base>
282  struct basic_symbol : Base
283  {
285  typedef Base super_type;
286 
289  : value ()
290  , location ()
291  {}
292 
293 #if 201103L <= YY_CPLUSPLUS
294  basic_symbol (basic_symbol&& that);
296 #endif
297 
299  basic_symbol (const basic_symbol& that);
301  basic_symbol (typename Base::kind_type t,
303 
305  basic_symbol (typename Base::kind_type t,
307  YY_RVREF (location_type) l);
308 
311  {
312  clear ();
313  }
314 
316  void clear ()
317  {
318  Base::clear ();
319  }
320 
322  bool empty () const YY_NOEXCEPT;
323 
325  void move (basic_symbol& s);
326 
329 
332 
333  private:
334 #if YY_CPLUSPLUS < 201103L
335  basic_symbol& operator= (const basic_symbol& that);
337 #endif
338  };
339 
341  struct by_type
342  {
344  by_type ();
345 
346 #if 201103L <= YY_CPLUSPLUS
347  by_type (by_type&& that);
349 #endif
350 
352  by_type (const by_type& that);
353 
356 
358  by_type (kind_type t);
359 
361  void clear ();
362 
364  void move (by_type& that);
365 
368  symbol_number_type type_get () const YY_NOEXCEPT;
369 
373  int type;
374  };
375 
378  {};
379 
381  parser (rostlab::blast::parser_driver& drv_yyarg, void* yyscanner_yyarg);
382  virtual ~parser ();
383 
386  int operator() ();
387 
390  virtual int parse ();
391 
392 #if YYDEBUG
393  std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
396  void set_debug_stream (std::ostream &);
397 
399  typedef int debug_level_type;
404 #endif
405 
409  virtual void error (const location_type& loc, const std::string& msg);
410 
412  void error (const syntax_error& err);
413 
414 
415 
416  private:
418  parser (const parser&);
419  parser& operator= (const parser&);
420 
422  typedef signed char state_type;
423 
427  virtual std::string yysyntax_error_ (state_type yystate,
428  const symbol_type& yyla) const;
429 
433  static state_type yy_lr_goto_state_ (state_type yystate, int yysym);
434 
437  static bool yy_pact_value_is_default_ (int yyvalue);
438 
441  static bool yy_table_value_is_error_ (int yyvalue);
442 
443  static const signed char yypact_ninf_;
444  static const signed char yytable_ninf_;
445 
449  static token_number_type yytranslate_ (int t);
450 
451  // Tables.
452  // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
453  // STATE-NUM.
454  static const signed char yypact_[];
455 
456  // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
457  // Performed when YYTABLE does not specify something else to do. Zero
458  // means the default is an error.
459  static const signed char yydefact_[];
460 
461  // YYPGOTO[NTERM-NUM].
462  static const signed char yypgoto_[];
463 
464  // YYDEFGOTO[NTERM-NUM].
465  static const signed char yydefgoto_[];
466 
467  // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
468  // positive, shift that token. If negative, reduce the rule whose
469  // number is the opposite. If YYTABLE_NINF, syntax error.
470  static const signed char yytable_[];
471 
472  static const signed char yycheck_[];
473 
474  // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
475  // symbol of state STATE-NUM.
476  static const signed char yystos_[];
477 
478  // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
479  static const signed char yyr1_[];
480 
481  // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
482  static const signed char yyr2_[];
483 
484 
486  static std::string yytnamerr_ (const char *n);
487 
488 
490  static const char* const yytname_[];
491 #if YYDEBUG
492  // YYRLINE[YYN] -- Source line where rule number YYN was defined.
493  static const unsigned char yyrline_[];
495  virtual void yy_reduce_print_ (int r);
497  virtual void yystack_print_ ();
498 
500  int yydebug_;
502  std::ostream* yycdebug_;
503 
507  template <typename Base>
508  void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
509 #endif
510 
515  template <typename Base>
516  void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
517 
518  private:
520  struct by_state
521  {
523  by_state () YY_NOEXCEPT;
524 
526  typedef state_type kind_type;
527 
529  by_state (kind_type s) YY_NOEXCEPT;
530 
532  by_state (const by_state& that) YY_NOEXCEPT;
533 
535  void clear () YY_NOEXCEPT;
536 
538  void move (by_state& that);
539 
542  symbol_number_type type_get () const YY_NOEXCEPT;
543 
546  enum { empty_state = 0 };
547 
550  state_type state;
551  };
552 
554  struct stack_symbol_type : basic_symbol<by_state>
555  {
557  typedef basic_symbol<by_state> super_type;
559  stack_symbol_type ();
561  stack_symbol_type (YY_RVREF (stack_symbol_type) that);
563  stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym);
564 #if YY_CPLUSPLUS < 201103L
565  stack_symbol_type& operator= (stack_symbol_type& that);
568 
571  stack_symbol_type& operator= (const stack_symbol_type& that);
572 #endif
573  };
574 
576  template <typename T, typename S = std::vector<T> >
577  class stack
578  {
579  public:
580  // Hide our reversed order.
581  typedef typename S::reverse_iterator iterator;
582  typedef typename S::const_reverse_iterator const_iterator;
583  typedef typename S::size_type size_type;
584  typedef typename std::ptrdiff_t index_type;
585 
586  stack (size_type n = 200)
587  : seq_ (n)
588  {}
589 
593  const T&
594  operator[] (index_type i) const
595  {
596  return seq_[size_type (size () - 1 - i)];
597  }
598 
602  T&
603  operator[] (index_type i)
604  {
605  return seq_[size_type (size () - 1 - i)];
606  }
607 
611  void
612  push (YY_MOVE_REF (T) t)
613  {
614  seq_.push_back (T ());
615  operator[] (0).move (t);
616  }
617 
619  void
620  pop (std::ptrdiff_t n = 1) YY_NOEXCEPT
621  {
622  for (; 0 < n; --n)
623  seq_.pop_back ();
624  }
625 
627  void
628  clear () YY_NOEXCEPT
629  {
630  seq_.clear ();
631  }
632 
634  index_type
635  size () const YY_NOEXCEPT
636  {
637  return index_type (seq_.size ());
638  }
639 
640  std::ptrdiff_t
641  ssize () const YY_NOEXCEPT
642  {
643  return std::ptrdiff_t (size ());
644  }
645 
647  const_iterator
648  begin () const YY_NOEXCEPT
649  {
650  return seq_.rbegin ();
651  }
652 
654  const_iterator
655  end () const YY_NOEXCEPT
656  {
657  return seq_.rend ();
658  }
659 
661  class slice
662  {
663  public:
664  slice (const stack& stack, index_type range)
665  : stack_ (stack)
666  , range_ (range)
667  {}
668 
669  const T&
670  operator[] (index_type i) const
671  {
672  return stack_[range_ - i];
673  }
674 
675  private:
676  const stack& stack_;
677  index_type range_;
678  };
679 
680  private:
681  stack (const stack&);
682  stack& operator= (const stack&);
684  S seq_;
685  };
686 
687 
689  typedef stack<stack_symbol_type> stack_type;
690 
692  stack_type yystack_;
693 
699  void yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym);
700 
707  void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
708 
710  void yypop_ (int n = 1);
711 
713  static const token_number_type yy_error_token_ = 1;
714  static const token_number_type yy_undef_token_ = 2;
715 
717  enum
718  {
719  yyeof_ = 0,
720  yylast_ = 81,
721  yynnts_ = 24,
722  yyfinal_ = 6,
723  yyntokens_ = 31
724  };
725 
726 
727  // User arguments.
729  void* yyscanner;
730  };
731 
732 
733 #line 22 "blast-parser-parser.ypp"
734 } } // rostlab::blast
735 #line 736 "rostlab/blast-parser-parser.h"
736 
737 
738 
739 
740 
741 #endif // !YY_YY_ROSTLAB_BLAST_PARSER_PARSER_H_INCLUDED
rostlab::blast::parser::basic_symbol::super_type
Base super_type
Alias to Base.
Definition: blast-parser-parser.h:285
YY_NOEXCEPT
#define YY_NOEXCEPT
Definition: blast-parser-parser.h:88
rostlab::blast::parser::token_type
token::yytokentype token_type
(External) token type, as returned by yylex.
Definition: blast-parser-parser.h:264
rostlab::blast::parser::parser
parser(rostlab::blast::parser_driver &drv_yyarg, void *yyscanner_yyarg)
Build a parser object.
rostlab::blast::parser_driver
Blast (default, -m 0) output parser.
Definition: blast-parser-driver.h:59
rostlab::blast::parser::token_number_type
signed char token_number_type
Internal symbol number for tokens (subsumed by symbol_number_type).
Definition: blast-parser-parser.h:273
YY_RVREF
#define YY_RVREF(Type)
Definition: blast-parser-parser.h:79
rostlab::blast::parser::basic_symbol::~basic_symbol
~basic_symbol()
Destroy the symbol.
Definition: blast-parser-parser.h:310
rostlab::blast::parser::by_type
Type access provider for token (enum) based symbols.
Definition: blast-parser-parser.h:341
rostlab::blast::parser::token::yytokentype
yytokentype
Definition: blast-parser-parser.h:232
rostlab::blast::parser::operator()
int operator()()
rostlab::blast::parser::symbol_number_type
int symbol_number_type
Symbol type: an internal symbol number.
Definition: blast-parser-parser.h:267
rostlab::blast::parser::semantic_type
Symbol semantic values.
Definition: blast-parser-parser.h:194
rostlab::blast::parser::stack::slice::slice
slice(const stack &stack, index_type range)
Definition: blast-parser-parser.h:664
rostlab::blast::parser::syntax_error
Syntax errors thrown from user actions.
Definition: blast-parser-parser.h:212
YY_ATTRIBUTE_PURE
#define YY_ATTRIBUTE_PURE
Definition: blast-parser-parser.h:105
rostlab::blast::parser::syntax_error::~syntax_error
~syntax_error() YY_NOEXCEPT YY_NOTHROW
rostlab::blast::parser::~parser
virtual ~parser()
rostlab::blast::parser::basic_symbol::clear
void clear()
Destroy contents, and record that is empty.
Definition: blast-parser-parser.h:316
rostlab::blast::location
Two points in a source file.
Definition: blast-parser-location.h:182
rostlab::blast::parser
A Bison parser.
Definition: blast-parser-parser.h:189
rostlab::blast::parser::symbol_type
"External" symbols: returned by the scanner.
Definition: blast-parser-parser.h:377
rostlab::blast::parser::token
Tokens.
Definition: blast-parser-parser.h:230
rostlab::blast::parser::location_type
location location_type
Symbol locations.
Definition: blast-parser-parser.h:209
rostlab
Definition: blast-parser-driver.h:45
rostlab::blast::parser::debug_level_type
int debug_level_type
Type for debugging levels.
Definition: blast-parser-parser.h:399
rostlab::blast::parser::semantic_type::dval
double dval
Definition: blast-parser-parser.h:199
rostlab::blast::parser::empty_symbol
@ empty_symbol
Definition: blast-parser-parser.h:270
rostlab::blast::parser::semantic_type::sval
std::string * sval
Definition: blast-parser-parser.h:200
rostlab::blast::parser::syntax_error::syntax_error
syntax_error(const location_type &l, const std::string &m)
Definition: blast-parser-parser.h:214
rostlab::blast::parser::parse
virtual int parse()
rostlab::blast::parser::semantic_type::ival
long int ival
Definition: blast-parser-parser.h:198
rostlab::blast::parser::debug_stream
std::ostream & debug_stream() const YY_ATTRIBUTE_PURE
The current debugging stream.
rostlab::blast::parser::error
virtual void error(const location_type &loc, const std::string &msg)
YY_NOTHROW
#define YY_NOTHROW
Definition: blast-parser-parser.h:89
rostlab::blast::parser::by_type::kind_type
token_type kind_type
The symbol type as needed by the constructor.
Definition: blast-parser-parser.h:355
rostlab::blast::parser::debug_level
debug_level_type debug_level() const YY_ATTRIBUTE_PURE
The current debugging level.
rostlab::blast::parser::stack::slice
Present a slice of the top of a stack.
Definition: blast-parser-parser.h:661
rostlab::blast::parser::syntax_error::syntax_error
syntax_error(const syntax_error &s)
Definition: blast-parser-parser.h:219
blast-result.h
rostlab::blast::parser::basic_symbol::basic_symbol
basic_symbol()
Default constructor.
Definition: blast-parser-parser.h:288
blast-parser-location.h
rostlab::blast::parser::set_debug_stream
void set_debug_stream(std::ostream &)
Set the current debugging stream.
YY_MOVE_REF
#define YY_MOVE_REF(Type)
Definition: blast-parser-parser.h:78
rostlab::blast::parser::basic_symbol
Definition: blast-parser-parser.h:282
rostlab::blast::parser::set_debug_level
void set_debug_level(debug_level_type l)
Set the current debugging level.