parser: Fix simple quote setvar in the end of the line.

Fix #1831
This commit is contained in:
Felipe Zimmerle 2018-09-11 15:30:09 -03:00
parent 738e328723
commit 764a2e43ff
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277
8 changed files with 6520 additions and 6256 deletions

View File

@ -1,6 +1,8 @@
v3.0.3 - YYYY-MMM-DD (to be released) v3.0.3 - YYYY-MMM-DD (to be released)
------------------------------------- -------------------------------------
- parser: Fix simple quote setvar in the end of the line
[Issue #1831 - @zimmerle, @csanders-git]
- Fix pc file - Fix pc file
[Issue #1847 - @gquintard] [Issue #1847 - @gquintard]
- modsec_rules_check: uses the gnu `.la' instead of `.a' file - modsec_rules_check: uses the gnu `.la' instead of `.a' file

View File

@ -1,8 +1,8 @@
// A Bison parser, made by GNU Bison 3.0.4. // A Bison parser, made by GNU Bison 3.0.5.
// Locations for Bison parsers in C++ // Locations for Bison parsers in C++
// Copyright (C) 2002-2015 Free Software Foundation, Inc. // Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -42,7 +42,7 @@
namespace yy { namespace yy {
#line 46 "location.hh" // location.cc:296 #line 46 "location.hh" // location.cc:292
/// Abstract a location. /// Abstract a location.
class location class location
{ {
@ -52,30 +52,27 @@ namespace yy {
location (const position& b, const position& e) location (const position& b, const position& e)
: begin (b) : begin (b)
, end (e) , end (e)
{ {}
}
/// Construct a 0-width location in \a p. /// Construct a 0-width location in \a p.
explicit location (const position& p = position ()) explicit location (const position& p = position ())
: begin (p) : begin (p)
, end (p) , end (p)
{ {}
}
/// Construct a 0-width location in \a f, \a l, \a c. /// Construct a 0-width location in \a f, \a l, \a c.
explicit location (std::string* f, explicit location (std::string* f,
unsigned int l = 1u, unsigned l = 1u,
unsigned int c = 1u) unsigned c = 1u)
: begin (f, l, c) : begin (f, l, c)
, end (f, l, c) , end (f, l, c)
{ {}
}
/// Initialization. /// Initialization.
void initialize (std::string* f = YY_NULLPTR, void initialize (std::string* f = YY_NULLPTR,
unsigned int l = 1u, unsigned l = 1u,
unsigned int c = 1u) unsigned c = 1u)
{ {
begin.initialize (f, l, c); begin.initialize (f, l, c);
end = begin; end = begin;
@ -173,7 +170,7 @@ namespace yy {
inline std::basic_ostream<YYChar>& inline std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc) operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
{ {
unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0; unsigned end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
ostr << loc.begin; ostr << loc.begin;
if (loc.end.filename if (loc.end.filename
&& (!loc.begin.filename && (!loc.begin.filename
@ -188,5 +185,5 @@ namespace yy {
} // yy } // yy
#line 192 "location.hh" // location.cc:296 #line 189 "location.hh" // location.cc:292
#endif // !YY_YY_LOCATION_HH_INCLUDED #endif // !YY_YY_LOCATION_HH_INCLUDED

View File

@ -1,8 +1,8 @@
// A Bison parser, made by GNU Bison 3.0.4. // A Bison parser, made by GNU Bison 3.0.5.
// Positions for Bison parsers in C++ // Positions for Bison parsers in C++
// Copyright (C) 2002-2015 Free Software Foundation, Inc. // Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -52,26 +52,25 @@
namespace yy { namespace yy {
#line 56 "position.hh" // location.cc:296 #line 56 "position.hh" // location.cc:292
/// Abstract a position. /// Abstract a position.
class position class position
{ {
public: public:
/// Construct a position. /// Construct a position.
explicit position (std::string* f = YY_NULLPTR, explicit position (std::string* f = YY_NULLPTR,
unsigned int l = 1u, unsigned l = 1u,
unsigned int c = 1u) unsigned c = 1u)
: filename (f) : filename (f)
, line (l) , line (l)
, column (c) , column (c)
{ {}
}
/// Initialization. /// Initialization.
void initialize (std::string* fn = YY_NULLPTR, void initialize (std::string* fn = YY_NULLPTR,
unsigned int l = 1u, unsigned l = 1u,
unsigned int c = 1u) unsigned c = 1u)
{ {
filename = fn; filename = fn;
line = l; line = l;
@ -100,15 +99,15 @@ namespace yy {
/// File name to which this position refers. /// File name to which this position refers.
std::string* filename; std::string* filename;
/// Current line number. /// Current line number.
unsigned int line; unsigned line;
/// Current column number. /// Current column number.
unsigned int column; unsigned column;
private: private:
/// Compute max(min, lhs+rhs) (provided min <= lhs). /// Compute max(min, lhs+rhs) (provided min <= lhs).
static unsigned int add_ (unsigned int lhs, int rhs, unsigned int min) static unsigned add_ (unsigned lhs, int rhs, unsigned min)
{ {
return (0 < rhs || -static_cast<unsigned int>(rhs) < lhs return (0 < rhs || -static_cast<unsigned>(rhs) < lhs
? rhs + lhs ? rhs + lhs
: min); : min);
} }
@ -176,5 +175,5 @@ namespace yy {
} // yy } // yy
#line 180 "position.hh" // location.cc:296 #line 179 "position.hh" // location.cc:292
#endif // !YY_YY_POSITION_HH_INCLUDED #endif // !YY_YY_POSITION_HH_INCLUDED

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
// A Bison parser, made by GNU Bison 3.0.2. // A Bison parser, made by GNU Bison 3.0.5.
// Skeleton interface for Bison LALR(1) parsers in C++ // Skeleton interface for Bison LALR(1) parsers in C++
// Copyright (C) 2002-2013 Free Software Foundation, Inc. // Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -40,7 +40,7 @@
#ifndef YY_YY_SECLANG_PARSER_HH_INCLUDED #ifndef YY_YY_SECLANG_PARSER_HH_INCLUDED
# define YY_YY_SECLANG_PARSER_HH_INCLUDED # define YY_YY_SECLANG_PARSER_HH_INCLUDED
// // "%code requires" blocks. // // "%code requires" blocks.
#line 10 "seclang-parser.yy" // lalr1.cc:372 #line 10 "seclang-parser.yy" // lalr1.cc:379
#include <string> #include <string>
#include <iterator> #include <iterator>
@ -380,13 +380,14 @@ using modsecurity::operators::Operator;
#line 384 "seclang-parser.hh" // lalr1.cc:372 #line 384 "seclang-parser.hh" // lalr1.cc:379
# include <cassert> # include <cassert>
# include <vector> # include <cstdlib> // std::abort
# include <iostream> # include <iostream>
# include <stdexcept> # include <stdexcept>
# include <string> # include <string>
# include <vector>
# include "stack.hh" # include "stack.hh"
# include "location.hh" # include "location.hh"
#include <typeinfo> #include <typeinfo>
@ -456,7 +457,7 @@ using modsecurity::operators::Operator;
namespace yy { namespace yy {
#line 460 "seclang-parser.hh" // lalr1.cc:372 #line 461 "seclang-parser.hh" // lalr1.cc:379
@ -473,13 +474,13 @@ namespace yy {
/// Empty construction. /// Empty construction.
variant () variant ()
: yytname_ (YY_NULLPTR) : yytypeid_ (YY_NULLPTR)
{} {}
/// Construct and fill. /// Construct and fill.
template <typename T> template <typename T>
variant (const T& t) variant (const T& t)
: yytname_ (typeid (T).name ()) : yytypeid_ (&typeid (T))
{ {
YYASSERT (sizeof (T) <= S); YYASSERT (sizeof (T) <= S);
new (yyas_<T> ()) T (t); new (yyas_<T> ()) T (t);
@ -488,7 +489,7 @@ namespace yy {
/// Destruction, allowed only if empty. /// Destruction, allowed only if empty.
~variant () ~variant ()
{ {
YYASSERT (!yytname_); YYASSERT (!yytypeid_);
} }
/// Instantiate an empty \a T in here. /// Instantiate an empty \a T in here.
@ -496,9 +497,9 @@ namespace yy {
T& T&
build () build ()
{ {
YYASSERT (!yytname_); YYASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= S); YYASSERT (sizeof (T) <= S);
yytname_ = typeid (T).name (); yytypeid_ = & typeid (T);
return *new (yyas_<T> ()) T; return *new (yyas_<T> ()) T;
} }
@ -507,9 +508,9 @@ namespace yy {
T& T&
build (const T& t) build (const T& t)
{ {
YYASSERT (!yytname_); YYASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= S); YYASSERT (sizeof (T) <= S);
yytname_ = typeid (T).name (); yytypeid_ = & typeid (T);
return *new (yyas_<T> ()) T (std::move((T&)t)); return *new (yyas_<T> ()) T (std::move((T&)t));
} }
@ -518,7 +519,7 @@ namespace yy {
T& T&
as () as ()
{ {
YYASSERT (yytname_ == typeid (T).name ()); YYASSERT (*yytypeid_ == typeid (T));
YYASSERT (sizeof (T) <= S); YYASSERT (sizeof (T) <= S);
return *yyas_<T> (); return *yyas_<T> ();
} }
@ -528,7 +529,7 @@ namespace yy {
const T& const T&
as () const as () const
{ {
YYASSERT (yytname_ == typeid (T).name ()); YYASSERT (*yytypeid_ == typeid (T));
YYASSERT (sizeof (T) <= S); YYASSERT (sizeof (T) <= S);
return *yyas_<T> (); return *yyas_<T> ();
} }
@ -545,8 +546,8 @@ namespace yy {
void void
swap (self_type& other) swap (self_type& other)
{ {
YYASSERT (yytname_); YYASSERT (yytypeid_);
YYASSERT (yytname_ == other.yytname_); YYASSERT (*yytypeid_ == *other.yytypeid_);
std::swap (as<T> (), other.as<T> ()); std::swap (as<T> (), other.as<T> ());
} }
@ -576,7 +577,7 @@ namespace yy {
destroy () destroy ()
{ {
as<T> ().~T (); as<T> ().~T ();
yytname_ = YY_NULLPTR; yytypeid_ = YY_NULLPTR;
} }
private: private:
@ -611,7 +612,7 @@ namespace yy {
} yybuffer_; } yybuffer_;
/// Whether the content is built: if defined, the name of the stored type. /// Whether the content is built: if defined, the name of the stored type.
const char *yytname_; const std::type_info *yytypeid_;
}; };
@ -1206,9 +1207,12 @@ namespace yy {
/// (External) token type, as returned by yylex. /// (External) token type, as returned by yylex.
typedef token::yytokentype token_type; typedef token::yytokentype token_type;
/// Internal symbol number. /// Symbol type: an internal symbol number.
typedef int symbol_number_type; typedef int symbol_number_type;
/// The symbol type number to denote an empty symbol.
enum { empty_symbol = -2 };
/// Internal symbol number for tokens (subsumed by symbol_number_type). /// Internal symbol number for tokens (subsumed by symbol_number_type).
typedef unsigned short int token_number_type; typedef unsigned short int token_number_type;
@ -1254,8 +1258,15 @@ namespace yy {
const semantic_type& v, const semantic_type& v,
const location_type& l); const location_type& l);
/// Destroy the symbol.
~basic_symbol (); ~basic_symbol ();
/// Destroy contents, and record that is empty.
void clear ();
/// Whether empty.
bool empty () const;
/// Destructive move, \a s is emptied into this. /// Destructive move, \a s is emptied into this.
void move (basic_symbol& s); void move (basic_symbol& s);
@ -1285,21 +1296,23 @@ namespace yy {
/// Constructor from (external) token numbers. /// Constructor from (external) token numbers.
by_type (kind_type t); by_type (kind_type t);
/// Record that this symbol is empty.
void clear ();
/// Steal the symbol type from \a that. /// Steal the symbol type from \a that.
void move (by_type& that); void move (by_type& that);
/// The (internal) type number (corresponding to \a type). /// The (internal) type number (corresponding to \a type).
/// -1 when this symbol is empty. /// \a empty when empty.
symbol_number_type type_get () const; symbol_number_type type_get () const;
/// The token. /// The token.
token_type token () const; token_type token () const;
enum { empty = 0 };
/// The symbol type. /// The symbol type.
/// -1 when this symbol is empty. /// \a empty_symbol when empty.
token_number_type type; /// An int, not token_number_type, to be able to store empty_symbol.
int type;
}; };
/// "External" symbols: returned by the scanner. /// "External" symbols: returned by the scanner.
@ -2695,9 +2708,9 @@ namespace yy {
/// Generate an error message. /// Generate an error message.
/// \param yystate the state where the error occurred. /// \param yystate the state where the error occurred.
/// \param yytoken the lookahead token type, or yyempty_. /// \param yyla the lookahead token.
virtual std::string yysyntax_error_ (state_type yystate, virtual std::string yysyntax_error_ (state_type yystate,
symbol_number_type yytoken) const; const symbol_type& yyla) const;
/// Compute post-reduction state. /// Compute post-reduction state.
/// \param yystate the current state /// \param yystate the current state
@ -2800,16 +2813,21 @@ namespace yy {
/// Copy constructor. /// Copy constructor.
by_state (const by_state& other); by_state (const by_state& other);
/// Record that this symbol is empty.
void clear ();
/// Steal the symbol type from \a that. /// Steal the symbol type from \a that.
void move (by_state& that); void move (by_state& that);
/// The (internal) type number (corresponding to \a state). /// The (internal) type number (corresponding to \a state).
/// "empty" when empty. /// \a empty_symbol when empty.
symbol_number_type type_get () const; symbol_number_type type_get () const;
enum { empty = 0 }; /// The state number used to denote an empty symbol.
enum { empty_state = -1 };
/// The state. /// The state.
/// \a empty when empty.
state_type state; state_type state;
}; };
@ -2820,6 +2838,8 @@ namespace yy {
typedef basic_symbol<by_state> super_type; typedef basic_symbol<by_state> super_type;
/// Construct an empty symbol. /// Construct an empty symbol.
stack_symbol_type (); stack_symbol_type ();
/// Copy construct.
stack_symbol_type (const stack_symbol_type& that);
/// Steal the contents from \a sym to build this. /// Steal the contents from \a sym to build this.
stack_symbol_type (state_type s, symbol_type& sym); stack_symbol_type (state_type s, symbol_type& sym);
/// Assignment, needed by push_back. /// Assignment, needed by push_back.
@ -2848,15 +2868,14 @@ namespace yy {
void yypush_ (const char* m, state_type s, symbol_type& sym); void yypush_ (const char* m, state_type s, symbol_type& sym);
/// Pop \a n symbols the three stacks. /// Pop \a n symbols the three stacks.
void yypop_ (unsigned int n = 1); void yypop_ (unsigned n = 1);
// Constants. /// Constants.
enum enum
{ {
yyeof_ = 0, yyeof_ = 0,
yylast_ = 3319, ///< Last index in yytable_. yylast_ = 3319, ///< Last index in yytable_.
yynnts_ = 15, ///< Number of nonterminal symbols. yynnts_ = 15, ///< Number of nonterminal symbols.
yyempty_ = -2,
yyfinal_ = 335, ///< Termination state number. yyfinal_ = 335, ///< Termination state number.
yyterror_ = 1, yyterror_ = 1,
yyerrcode_ = 256, yyerrcode_ = 256,
@ -2938,12 +2957,12 @@ namespace yy {
325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
335, 336, 337, 338 335, 336, 337, 338
}; };
const unsigned int user_token_number_max_ = 593; const unsigned user_token_number_max_ = 593;
const token_number_type undef_token_ = 2; const token_number_type undef_token_ = 2;
if (static_cast<int> (t) <= yyeof_) if (static_cast<int> (t) <= yyeof_)
return yyeof_; return yyeof_;
else if (static_cast<unsigned int> (t) <= user_token_number_max_) else if (static_cast<unsigned> (t) <= user_token_number_max_)
return translate_table[t]; return translate_table[t];
else else
return undef_token_; return undef_token_;
@ -2957,13 +2976,11 @@ namespace yy {
// basic_symbol. // basic_symbol.
template <typename Base> template <typename Base>
inline
seclang_parser::basic_symbol<Base>::basic_symbol () seclang_parser::basic_symbol<Base>::basic_symbol ()
: value () : value ()
{} {}
template <typename Base> template <typename Base>
inline
seclang_parser::basic_symbol<Base>::basic_symbol (const basic_symbol& other) seclang_parser::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
: Base (other) : Base (other)
, value () , value ()
@ -3203,9 +3220,7 @@ namespace yy {
} }
template <typename Base> template <typename Base>
inline
seclang_parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const semantic_type& v, const location_type& l) seclang_parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const semantic_type& v, const location_type& l)
: Base (t) : Base (t)
, value () , value ()
@ -3506,11 +3521,19 @@ namespace yy {
template <typename Base> template <typename Base>
inline
seclang_parser::basic_symbol<Base>::~basic_symbol () seclang_parser::basic_symbol<Base>::~basic_symbol ()
{
clear ();
}
template <typename Base>
void
seclang_parser::basic_symbol<Base>::clear ()
{ {
// User destructor. // User destructor.
symbol_number_type yytype = this->type_get (); symbol_number_type yytype = this->type_get ();
basic_symbol<Base>& yysym = *this;
(void) yysym;
switch (yytype) switch (yytype)
{ {
default: default:
@ -3750,10 +3773,17 @@ namespace yy {
break; break;
} }
Base::clear ();
}
template <typename Base>
bool
seclang_parser::basic_symbol<Base>::empty () const
{
return Base::type_get () == empty_symbol;
} }
template <typename Base> template <typename Base>
inline
void void
seclang_parser::basic_symbol<Base>::move (basic_symbol& s) seclang_parser::basic_symbol<Base>::move (basic_symbol& s)
{ {
@ -3996,7 +4026,7 @@ namespace yy {
// by_type. // by_type.
inline inline
seclang_parser::by_type::by_type () seclang_parser::by_type::by_type ()
: type (empty) : type (empty_symbol)
{} {}
inline inline
@ -4009,12 +4039,19 @@ namespace yy {
: type (yytranslate_ (t)) : type (yytranslate_ (t))
{} {}
inline
void
seclang_parser::by_type::clear ()
{
type = empty_symbol;
}
inline inline
void void
seclang_parser::by_type::move (by_type& that) seclang_parser::by_type::move (by_type& that)
{ {
type = that.type; type = that.type;
that.type = empty; that.clear ();
} }
inline inline
@ -6097,7 +6134,7 @@ namespace yy {
} // yy } // yy
#line 6101 "seclang-parser.hh" // lalr1.cc:372 #line 6138 "seclang-parser.hh" // lalr1.cc:379

File diff suppressed because it is too large Load Diff

View File

@ -1040,6 +1040,7 @@ EQUALS_MINUS (?i:=\-)
[\/]{DICT_ELEMENT_NO_PIPE}[\/][|] { BEGIN_PREVIOUS(); yyless(yyleng - 1); return p::make_DICT_ELEMENT_REGEXP(std::string(yytext, 1, yyleng-2), *driver.loc.back()); } [\/]{DICT_ELEMENT_NO_PIPE}[\/][|] { BEGIN_PREVIOUS(); yyless(yyleng - 1); return p::make_DICT_ELEMENT_REGEXP(std::string(yytext, 1, yyleng-2), *driver.loc.back()); }
['][\/]{DICT_ELEMENT_WITH_PIPE}[\/]['] { BEGIN_PREVIOUS(); yyless(yyleng - 0); return p::make_DICT_ELEMENT_REGEXP(std::string(yytext, 2, yyleng-4), *driver.loc.back()); } ['][\/]{DICT_ELEMENT_WITH_PIPE}[\/]['] { BEGIN_PREVIOUS(); yyless(yyleng - 0); return p::make_DICT_ELEMENT_REGEXP(std::string(yytext, 2, yyleng-4), *driver.loc.back()); }
['][\/]{DICT_ELEMENT_WITH_PIPE}[\/]['][|] { BEGIN_PREVIOUS(); yyless(yyleng - 1); return p::make_DICT_ELEMENT_REGEXP(std::string(yytext, 2, yyleng-4), *driver.loc.back()); } ['][\/]{DICT_ELEMENT_WITH_PIPE}[\/]['][|] { BEGIN_PREVIOUS(); yyless(yyleng - 1); return p::make_DICT_ELEMENT_REGEXP(std::string(yytext, 2, yyleng-4), *driver.loc.back()); }
{FREE_TEXT_EQUALS_MACRO_EXPANSION}['] { yyless(yyleng - 1); BEGIN_PREVIOUS(); return p::make_FREE_TEXT_QUOTE_MACRO_EXPANSION(yytext, *driver.loc.back()); }
{FREE_TEXT_EQUALS_MACRO_EXPANSION} { return p::make_FREE_TEXT_QUOTE_MACRO_EXPANSION(yytext, *driver.loc.back()); } {FREE_TEXT_EQUALS_MACRO_EXPANSION} { return p::make_FREE_TEXT_QUOTE_MACRO_EXPANSION(yytext, *driver.loc.back()); }
[\/]{DICT_ELEMENT_NO_PIPE}[\/][,] { BEGIN_PREVIOUS(); yyless(yyleng - 1); return p::make_DICT_ELEMENT_REGEXP(std::string(yytext, 1, yyleng-2), *driver.loc.back()); } [\/]{DICT_ELEMENT_NO_PIPE}[\/][,] { BEGIN_PREVIOUS(); yyless(yyleng - 1); return p::make_DICT_ELEMENT_REGEXP(std::string(yytext, 1, yyleng-2), *driver.loc.back()); }

View File

@ -1,8 +1,8 @@
// A Bison parser, made by GNU Bison 3.0.4. // A Bison parser, made by GNU Bison 3.0.5.
// Stack handling for Bison parsers in C++ // Stack handling for Bison parsers in C++
// Copyright (C) 2002-2015 Free Software Foundation, Inc. // Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -42,7 +42,8 @@
namespace yy { namespace yy {
#line 46 "stack.hh" // stack.hh:132 #line 46 "stack.hh" // stack.hh:131
/// A stack with random access from its top.
template <class T, class S = std::vector<T> > template <class T, class S = std::vector<T> >
class stack class stack
{ {
@ -57,20 +58,24 @@ namespace yy {
seq_.reserve (200); seq_.reserve (200);
} }
stack (unsigned int n) stack (unsigned n)
: seq_ (n) : seq_ (n)
{} {}
inline /// Random access.
///
/// Index 0 returns the topmost element.
T& T&
operator[] (unsigned int i) operator[] (unsigned i)
{ {
return seq_[seq_.size () - 1 - i]; return seq_[seq_.size () - 1 - i];
} }
inline /// Random access.
///
/// Index 0 returns the topmost element.
const T& const T&
operator[] (unsigned int i) const operator[] (unsigned i) const
{ {
return seq_[seq_.size () - 1 - i]; return seq_[seq_.size () - 1 - i];
} }
@ -78,7 +83,6 @@ namespace yy {
/// Steal the contents of \a t. /// Steal the contents of \a t.
/// ///
/// Close to move-semantics. /// Close to move-semantics.
inline
void void
push (T& t) push (T& t)
{ {
@ -86,9 +90,8 @@ namespace yy {
operator[](0).move (t); operator[](0).move (t);
} }
inline
void void
pop (unsigned int n = 1) pop (unsigned n = 1)
{ {
for (; n; --n) for (; n; --n)
seq_.pop_back (); seq_.pop_back ();
@ -100,21 +103,18 @@ namespace yy {
seq_.clear (); seq_.clear ();
} }
inline
typename S::size_type typename S::size_type
size () const size () const
{ {
return seq_.size (); return seq_.size ();
} }
inline
const_iterator const_iterator
begin () const begin () const
{ {
return seq_.rbegin (); return seq_.rbegin ();
} }
inline
const_iterator const_iterator
end () const end () const
{ {
@ -133,25 +133,24 @@ namespace yy {
class slice class slice
{ {
public: public:
slice (const S& stack, unsigned int range) slice (const S& stack, unsigned range)
: stack_ (stack) : stack_ (stack)
, range_ (range) , range_ (range)
{} {}
inline
const T& const T&
operator [] (unsigned int i) const operator [] (unsigned i) const
{ {
return stack_[range_ - i]; return stack_[range_ - i];
} }
private: private:
const S& stack_; const S& stack_;
unsigned int range_; unsigned range_;
}; };
} // yy } // yy
#line 156 "stack.hh" // stack.hh:132 #line 155 "stack.hh" // stack.hh:131
#endif // !YY_YY_STACK_HH_INCLUDED #endif // !YY_YY_STACK_HH_INCLUDED