mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-23 11:13:03 +00:00
* data/bison.c++: Adapt expansion of $s and @s to the C++ parser.
Update the stack class, give a try to deque as the default container.
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
2002-05-02 Robert Anisko <robert@lrde.epita.fr>
|
||||||
|
|
||||||
|
* data/bison.c++: Adapt expansion of $s and @s to the C++ parser.
|
||||||
|
Update the stack class, give a try to deque as the default container.
|
||||||
|
|
||||||
2002-05-02 Akim Demaille <akim@epita.fr>
|
2002-05-02 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* data/bison.simple (yyparse): Do not implement @$ = @1.
|
* data/bison.simple (yyparse): Do not implement @$ = @1.
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ m4_define([b4_lhs_value],
|
|||||||
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
||||||
# symbols on RHS.
|
# symbols on RHS.
|
||||||
m4_define([b4_rhs_value],
|
m4_define([b4_rhs_value],
|
||||||
[yyvsp@<:@m4_eval([$2 - $1])@:>@m4_ifval([$3], [.$3])])
|
[semantic_stack_@<:@m4_eval([$1 - $2])@:>@m4_ifval([$3], [.$3])])
|
||||||
|
|
||||||
|
|
||||||
# b4_lhs_location()
|
# b4_lhs_location()
|
||||||
@@ -47,7 +47,7 @@ m4_define([b4_lhs_location],
|
|||||||
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
||||||
# on RHS.
|
# on RHS.
|
||||||
m4_define([b4_rhs_location],
|
m4_define([b4_rhs_location],
|
||||||
[yylsp@<:@m4_eval([$2 - $1])@:>@])
|
[location_stack_@<:@m4_eval([$1 - $2])@:>@])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_defines(TOKEN-NAME, TOKEN-NUMBER)
|
# b4_token_defines(TOKEN-NAME, TOKEN-NUMBER)
|
||||||
@@ -351,12 +351,6 @@ yy::b4_name::parse ()
|
|||||||
semantic_stack_ = SemanticStack (1);
|
semantic_stack_ = SemanticStack (1);
|
||||||
location_stack_ = LocationStack (1);
|
location_stack_ = LocationStack (1);
|
||||||
|
|
||||||
/* Reserve initial space. The C parser needed that, but is it really
|
|
||||||
useful here? */
|
|
||||||
state_stack_.reserve (initdepth_);
|
|
||||||
semantic_stack_.reserve (initdepth_);
|
|
||||||
location_stack_.reserve (initdepth_);
|
|
||||||
|
|
||||||
/* Start. */
|
/* Start. */
|
||||||
state_ = 0;
|
state_ = 0;
|
||||||
looka_ = empty_;
|
looka_ = empty_;
|
||||||
@@ -459,8 +453,8 @@ yy::b4_name::parse ()
|
|||||||
len_ = r2_[[n_]];
|
len_ = r2_[[n_]];
|
||||||
if (len_)
|
if (len_)
|
||||||
{
|
{
|
||||||
yyval = semantic_stack_[[1 - len_]];
|
yyval = semantic_stack_[[len_ - 1]];
|
||||||
yyloc = location_stack_[[1 - len_]];
|
yyloc = location_stack_[[len_ - 1]];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -485,15 +479,10 @@ yy::b4_name::parse ()
|
|||||||
YYLLOC_DEFAULT (yyloc, slice, len_);
|
YYLLOC_DEFAULT (yyloc, slice, len_);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
switch (n_)
|
||||||
SemanticStack& yyvsp (semantic_stack_);
|
{
|
||||||
LocationStack& yylsp (location_stack_);
|
b4_actions
|
||||||
|
}
|
||||||
switch (n_)
|
|
||||||
{
|
|
||||||
b4_actions
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Line __line__ of __file__. */
|
/* Line __line__ of __file__. */
|
||||||
#line __oline__ "__ofile__"
|
#line __oline__ "__ofile__"
|
||||||
@@ -786,11 +775,11 @@ b4_copyright
|
|||||||
#ifndef BISON_STACK_HH
|
#ifndef BISON_STACK_HH
|
||||||
# define BISON_STACK_HH
|
# define BISON_STACK_HH
|
||||||
|
|
||||||
#include <vector>
|
#include <deque>
|
||||||
|
|
||||||
namespace yy
|
namespace yy
|
||||||
{
|
{
|
||||||
template < class T, class S = std::vector< T > >
|
template < class T, class S = std::deque< T > >
|
||||||
class Stack
|
class Stack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -808,23 +797,23 @@ namespace yy
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
T&
|
T&
|
||||||
operator [[]] (int index)
|
operator [[]] (unsigned index)
|
||||||
{
|
{
|
||||||
return seq_[[height () - 1 + index]];
|
return seq_[[index]];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
const T&
|
const T&
|
||||||
operator [[]] (int index) const
|
operator [[]] (unsigned index) const
|
||||||
{
|
{
|
||||||
return seq_[[height () - 1 + index]];
|
return seq_[[index]];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void
|
void
|
||||||
push (const T& t)
|
push (const T& t)
|
||||||
{
|
{
|
||||||
seq_.push_back (t);
|
seq_.push_front (t);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
@@ -832,14 +821,7 @@ namespace yy
|
|||||||
pop (unsigned n = 1)
|
pop (unsigned n = 1)
|
||||||
{
|
{
|
||||||
for (; n; --n)
|
for (; n; --n)
|
||||||
seq_.pop_back ();
|
seq_.pop_front ();
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
reserve (unsigned n)
|
|
||||||
{
|
|
||||||
seq_.reserve (n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
@@ -872,7 +854,7 @@ namespace yy
|
|||||||
const T&
|
const T&
|
||||||
operator [[]] (unsigned index) const
|
operator [[]] (unsigned index) const
|
||||||
{
|
{
|
||||||
return stack_[[index - range_]];
|
return stack_[[range_ - index]];
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user