librostlab-blast  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
blast-parser-stack.h
Go to the documentation of this file.
1 /* A Bison parser, made by GNU Bison 2.5. */
2 
3 /* Stack handling for Bison parsers in C++
4 
5  Copyright (C) 2002-2011 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 #ifndef BISON_ROSTLAB_BLAST_PARSER_STACK_H
34 # define BISON_ROSTLAB_BLAST_PARSER_STACK_H
35 
36 #include <deque>
37 
38 
39 /* Line 1149 of lalr1.cc */
40 #line 22 "blast-parser-parser.ypp"
41 namespace rostlab { namespace blast {
42 
43 /* Line 1149 of lalr1.cc */
44 #line 45 "rostlab/blast-parser-stack.h"
45  template <class T, class S = std::deque<T> >
46  class stack
47  {
48  public:
49 
50  // Hide our reversed order.
51  typedef typename S::reverse_iterator iterator;
52  typedef typename S::const_reverse_iterator const_iterator;
53 
54  stack () : seq_ ()
55  {
56  }
57 
58  stack (unsigned int n) : seq_ (n)
59  {
60  }
61 
62  inline
63  T&
64  operator [] (unsigned int i)
65  {
66  return seq_[i];
67  }
68 
69  inline
70  const T&
71  operator [] (unsigned int i) const
72  {
73  return seq_[i];
74  }
75 
76  inline
77  void
78  push (const T& t)
79  {
80  seq_.push_front (t);
81  }
82 
83  inline
84  void
85  pop (unsigned int n = 1)
86  {
87  for (; n; --n)
88  seq_.pop_front ();
89  }
90 
91  inline
92  unsigned int
93  height () const
94  {
95  return seq_.size ();
96  }
97 
98  inline const_iterator begin () const { return seq_.rbegin (); }
99  inline const_iterator end () const { return seq_.rend (); }
100 
101  private:
102 
103  S seq_;
104  };
105 
107  template <class T, class S = stack<T> >
108  class slice
109  {
110  public:
111 
112  slice (const S& stack,
113  unsigned int range) : stack_ (stack),
114  range_ (range)
115  {
116  }
117 
118  inline
119  const T&
120  operator [] (unsigned int i) const
121  {
122  return stack_[range_ - i];
123  }
124 
125  private:
126 
127  const S& stack_;
128  unsigned int range_;
129  };
130 
131 /* Line 1235 of lalr1.cc */
132 #line 22 "blast-parser-parser.ypp"
133 } } // rostlab::blast
134 
135 /* Line 1235 of lalr1.cc */
136 #line 137 "rostlab/blast-parser-stack.h"
137 
138 #endif // not BISON_ROSTLAB_BLAST_PARSER_STACK_H[]dnl
139