32 |
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH |
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH |
33 |
# symbols on RHS. |
# symbols on RHS. |
34 |
m4_define([b4_rhs_value], |
m4_define([b4_rhs_value], |
35 |
[yyvsp@<:@m4_eval([$2 - $1])@:>@m4_ifval([$3], [.$3])]) |
[semantic_stack_@<:@m4_eval([$1 - $2])@:>@m4_ifval([$3], [.$3])]) |
36 |
|
|
37 |
|
|
38 |
# b4_lhs_location() |
# b4_lhs_location() |
47 |
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols |
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols |
48 |
# on RHS. |
# on RHS. |
49 |
m4_define([b4_rhs_location], |
m4_define([b4_rhs_location], |
50 |
[yylsp@<:@m4_eval([$2 - $1])@:>@]) |
[location_stack_@<:@m4_eval([$1 - $2])@:>@]) |
51 |
|
|
52 |
|
|
53 |
# b4_token_defines(TOKEN-NAME, TOKEN-NUMBER) |
# b4_token_defines(TOKEN-NAME, TOKEN-NUMBER) |
351 |
semantic_stack_ = SemanticStack (1); |
semantic_stack_ = SemanticStack (1); |
352 |
location_stack_ = LocationStack (1); |
location_stack_ = LocationStack (1); |
353 |
|
|
|
/* 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_); |
|
|
|
|
354 |
/* Start. */ |
/* Start. */ |
355 |
state_ = 0; |
state_ = 0; |
356 |
looka_ = empty_; |
looka_ = empty_; |
453 |
len_ = r2_[[n_]]; |
len_ = r2_[[n_]]; |
454 |
if (len_) |
if (len_) |
455 |
{ |
{ |
456 |
yyval = semantic_stack_[[1 - len_]]; |
yyval = semantic_stack_[[len_ - 1]]; |
457 |
yyloc = location_stack_[[1 - len_]]; |
yyloc = location_stack_[[len_ - 1]]; |
458 |
} |
} |
459 |
else |
else |
460 |
{ |
{ |
479 |
YYLLOC_DEFAULT (yyloc, slice, len_); |
YYLLOC_DEFAULT (yyloc, slice, len_); |
480 |
} |
} |
481 |
|
|
482 |
{ |
switch (n_) |
483 |
SemanticStack& yyvsp (semantic_stack_); |
{ |
484 |
LocationStack& yylsp (location_stack_); |
b4_actions |
485 |
|
} |
|
switch (n_) |
|
|
{ |
|
|
b4_actions |
|
|
} |
|
|
} |
|
486 |
|
|
487 |
/* Line __line__ of __file__. */ |
/* Line __line__ of __file__. */ |
488 |
#line __oline__ "__ofile__" |
#line __oline__ "__ofile__" |
775 |
#ifndef BISON_STACK_HH |
#ifndef BISON_STACK_HH |
776 |
# define BISON_STACK_HH |
# define BISON_STACK_HH |
777 |
|
|
778 |
#include <vector> |
#include <deque> |
779 |
|
|
780 |
namespace yy |
namespace yy |
781 |
{ |
{ |
782 |
template < class T, class S = std::vector< T > > |
template < class T, class S = std::deque< T > > |
783 |
class Stack |
class Stack |
784 |
{ |
{ |
785 |
public: |
public: |
797 |
|
|
798 |
inline |
inline |
799 |
T& |
T& |
800 |
operator [[]] (int index) |
operator [[]] (unsigned index) |
801 |
{ |
{ |
802 |
return seq_[[height () - 1 + index]]; |
return seq_[[index]]; |
803 |
} |
} |
804 |
|
|
805 |
inline |
inline |
806 |
const T& |
const T& |
807 |
operator [[]] (int index) const |
operator [[]] (unsigned index) const |
808 |
{ |
{ |
809 |
return seq_[[height () - 1 + index]]; |
return seq_[[index]]; |
810 |
} |
} |
811 |
|
|
812 |
inline |
inline |
813 |
void |
void |
814 |
push (const T& t) |
push (const T& t) |
815 |
{ |
{ |
816 |
seq_.push_back (t); |
seq_.push_front (t); |
817 |
} |
} |
818 |
|
|
819 |
inline |
inline |
821 |
pop (unsigned n = 1) |
pop (unsigned n = 1) |
822 |
{ |
{ |
823 |
for (; n; --n) |
for (; n; --n) |
824 |
seq_.pop_back (); |
seq_.pop_front (); |
|
} |
|
|
|
|
|
inline |
|
|
void |
|
|
reserve (unsigned n) |
|
|
{ |
|
|
seq_.reserve (n); |
|
825 |
} |
} |
826 |
|
|
827 |
inline |
inline |
854 |
const T& |
const T& |
855 |
operator [[]] (unsigned index) const |
operator [[]] (unsigned index) const |
856 |
{ |
{ |
857 |
return stack_[[index - range_]]; |
return stack_[[range_ - index]]; |
858 |
} |
} |
859 |
|
|
860 |
private: |
private: |