Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

136 lignes
3.0 KiB

  1. /* A Bison parser, made by GNU Bison 2.4.2. */
  2. /* Stack handling for Bison parsers in C++
  3. Copyright (C) 2002-2010 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. #ifndef BISON_STACK_HH
  26. # define BISON_STACK_HH
  27. #include <deque>
  28. namespace lol {
  29. /* Line 1066 of lalr1.cc */
  30. #line 43 "generated/stack.hh"
  31. template <class T, class S = std::deque<T> >
  32. class stack
  33. {
  34. public:
  35. // Hide our reversed order.
  36. typedef typename S::reverse_iterator iterator;
  37. typedef typename S::const_reverse_iterator const_iterator;
  38. stack () : seq_ ()
  39. {
  40. }
  41. stack (unsigned int n) : seq_ (n)
  42. {
  43. }
  44. inline
  45. T&
  46. operator [] (unsigned int i)
  47. {
  48. return seq_[i];
  49. }
  50. inline
  51. const T&
  52. operator [] (unsigned int i) const
  53. {
  54. return seq_[i];
  55. }
  56. inline
  57. void
  58. push (const T& t)
  59. {
  60. seq_.push_front (t);
  61. }
  62. inline
  63. void
  64. pop (unsigned int n = 1)
  65. {
  66. for (; n; --n)
  67. seq_.pop_front ();
  68. }
  69. inline
  70. unsigned int
  71. height () const
  72. {
  73. return seq_.size ();
  74. }
  75. inline const_iterator begin () const { return seq_.rbegin (); }
  76. inline const_iterator end () const { return seq_.rend (); }
  77. private:
  78. S seq_;
  79. };
  80. /// Present a slice of the top of a stack.
  81. template <class T, class S = stack<T> >
  82. class slice
  83. {
  84. public:
  85. slice (const S& stack,
  86. unsigned int range) : stack_ (stack),
  87. range_ (range)
  88. {
  89. }
  90. inline
  91. const T&
  92. operator [] (unsigned int i) const
  93. {
  94. return stack_[range_ - i];
  95. }
  96. private:
  97. const S& stack_;
  98. unsigned int range_;
  99. };
  100. } // lol
  101. /* Line 1152 of lalr1.cc */
  102. #line 133 "generated/stack.hh"
  103. #endif // not BISON_STACK_HH[]dnl