[ $1;])
-# b4_yysymprint_generate(FUNCTION-DECLARATOR)
-# -------------------------------------------
-# Generate the "symprint_" member function.
-m4_define([b4_yysymprint_generate],
-[[/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-]void
-yy::b4_parser_class_name::symprint_ (int yytype, const SemanticType *yyvaluep, const LocationType *yylocationp)[
-{
- /* Pacify ``unused variable'' warnings. */
- (void) yyvaluep;
- (void) yylocationp;
-
- cdebug_ << (yytype < ntokens_ ? "token" : "nterm")
- << ' ' << name_[yytype] << " (";
- switch (yytype)
- {
-]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
-[ default:
- break;
- }
- cdebug_ << ')';
-}
-]])
-
-
-# b4_cxx_destruct_def(IGNORED-ARGUMENTS)
-# --------------------------------------
-# Declare the destruct_ method.
-m4_define([b4_cxx_destruct_def],
-[void
-yy::b4_parser_class_name::destruct_ (int yytype, SemanticType *yyvaluep, LocationType *yylocationp)[]dnl
-])
-
# We do want M4 expansion after # for CPP macros.
m4_changecom()
/* Even more tables. */
inline TokenNumberType translate_ (int token);
- inline void destruct_ (int yytype, SemanticType *yyvaluep,
- LocationType *yylocationp);
+ inline void destruct_ (const char *yymsg,
+ int yytype,
+ SemanticType *yyvaluep, LocationType *yylocationp);
+
+ /// Pop \a n symbols the three stacks.
+ inline void pop (unsigned int n = 1);
/* Constants. */
static const int eof_;
#define YYERROR goto yyerrorlab
#if YYDEBUG
-]b4_yysymprint_generate([b4_cxx_symprint_def])[
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+void
+yy::]b4_parser_class_name[::symprint_ (int yytype,
+ const SemanticType *yyvaluep, const LocationType *yylocationp)
+{
+ /* Pacify ``unused variable'' warnings. */
+ (void) yyvaluep;
+ (void) yylocationp;
+
+ cdebug_ << (yytype < ntokens_ ? "token" : "nterm")
+ << ' ' << name_[yytype] << " ("
+ << *yylocationp << ": ";
+ switch (yytype)
+ {
+]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
+[ default:
+ break;
+ }
+ cdebug_ << ')';
+}
#endif /* ! YYDEBUG */
-]b4_yydestruct_generate([b4_cxx_destruct_def])[
+
+void
+yy::]b4_parser_class_name[::destruct_ (const char *yymsg,
+ int yytype, SemanticType *yyvaluep, LocationType *yylocationp)
+{
+ /* Pacify ``unused variable'' warnings. */
+ (void) yyvaluep;
+ (void) yylocationp;
+
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+ switch (yytype)
+ {
+]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[
+ default:
+ break;
+ }
+}
+
+void
+yy::]b4_parser_class_name[::pop (unsigned int n)
+{
+ state_stack_.pop (n);
+ semantic_stack_.pop (n);
+ location_stack_.pop (n);
+}
int
yy::]b4_parser_class_name[::parse ()
YYCDEBUG << "Starting parse" << std::endl;
/* New state. */
- yynewstate:
+yynewstate:
state_stack_.push (state_);
YYCDEBUG << "Entering state " << state_ << std::endl;
goto yybackup;
/* Backup. */
- yybackup:
+yybackup:
/* Try to take a decision without look-ahead. */
n_ = pact_[state_];
goto yyacceptlab;
/* Shift the look-ahead token. */
-#if YYDEBUG
- YYCDEBUG << "Shifting token " << looka_
- << " (" << name_[ilooka_] << "), ";
-#endif
+ YY_SYMBOL_PRINT ("Shifting", ilooka_, &value, &location);
/* Discard the token being shifted unless it is eof. */
if (looka_ != eof_)
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
- yydefault:
+yydefault:
n_ = defact_[state_];
if (n_ == 0)
goto yyerrlab;
/*-----------------------------.
| yyreduce -- Do a reduction. |
`-----------------------------*/
- yyreduce:
+yyreduce:
len_ = r2_[n_];
/* If LEN_ is nonzero, implement the default value of the action:
`$$ = $1'. Otherwise, use the top of the stack.
]/* Line __line__ of lalr1.cc. */
b4_syncline([@oline@], [@ofile@])[
- state_stack_.pop (len_);
- semantic_stack_.pop (len_);
- location_stack_.pop (len_);
+ pop (len_);
YY_STACK_PRINT ();
for (;;)
{
error_start_ = location_stack_[0].begin;
- state_stack_.pop ();
- semantic_stack_.pop ();
- location_stack_.pop ();
+ pop ();
if (state_stack_.height () == 1)
YYABORT;
- YY_SYMBOL_PRINT ("Error: popping",
- stos_[state_stack_[0]],
- &semantic_stack_[0],
- &location_stack_[0]);
- destruct_ (stos_[state_stack_[0]],
+ destruct_ ("Error: popping",
+ stos_[state_stack_[0]],
&semantic_stack_[0],
&location_stack_[0]);
}
}
else
{
- YY_SYMBOL_PRINT ("Error: discarding", ilooka_, &value, &location);
- destruct_ (ilooka_, &value, &location);
+ destruct_ ("Error: discarding", ilooka_, &value, &location);
looka_ = empty_;
}
}
goto yyerrorlab;
#endif
- state_stack_.pop (len_);
- semantic_stack_.pop (len_);
error_start_ = location_stack_[len_ - 1].begin;
- location_stack_.pop (len_);
+ pop (len_);
state_ = state_stack_[0];
goto yyerrlab1;
if (state_stack_.height () == 1)
YYABORT;
- YY_SYMBOL_PRINT ("Error: popping",
- stos_[state_],
- &semantic_stack_[0], &location_stack_[0]);
- destruct_ (stos_[state_], &semantic_stack_[0], &location_stack_[0]);
+ destruct_ ("Error: popping",
+ stos_[state_], &semantic_stack_[0], &location_stack_[0]);
error_start_ = location_stack_[0].begin;
- state_stack_.pop ();
- semantic_stack_.pop ();
- location_stack_.pop ();
+ pop ();
state_ = state_stack_[0];
YY_STACK_PRINT ();
}
if (n_ == final_)
goto yyacceptlab;
- YYCDEBUG << "Shifting error token, ";
-
{
Location errloc;
errloc.begin = error_start_;
location_stack_.push (errloc);
}
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", stos_[n_],
+ &semantic_stack_[0], &location_stack_[0]);
+
state_ = n_;
goto yynewstate;
/* Abort. */
yyabortlab:
/* Free the lookahead. */
- YY_SYMBOL_PRINT ("Error: discarding lookahead", ilooka_, &value, &location);
- destruct_ (ilooka_, &value, &location);
+ destruct_ ("Error: discarding lookahead", ilooka_, &value, &location);
looka_ = empty_;
return 1;
}
void
yy::]b4_parser_class_name[::stack_print_ ()
{
- cdebug_ << "state stack now";
- for (StateStack::ConstIterator i = state_stack_.begin ();
+ cdebug_ << "Stack now";
+ for (StateStack::const_iterator i = state_stack_.begin ();
i != state_stack_.end (); ++i)
cdebug_ << ' ' << *i;
cdebug_ << std::endl;
{
unsigned int yylno = rline_[yyrule];
/* Print the symbols being reduced, and their result. */
- cdebug_ << "Reducing via rule " << n_ - 1 << " (line " << yylno << "), ";
+ cdebug_ << "Reducing stack by rule " << n_ - 1 << " (line " << yylno << "), ";
for (]b4_int_type_for([b4_prhs])[ i = prhs_[n_];
0 <= rhs_[i]; ++i)
cdebug_ << name_[rhs_[i]] << ' ';
{
public:
- typedef typename S::iterator Iterator;
- typedef typename S::const_iterator ConstIterator;
+ // Hide our reversed order.
+ typedef typename S::reverse_iterator iterator;
+ typedef typename S::const_reverse_iterator const_iterator;
Stack () : seq_ ()
{
return seq_.size ();
}
- inline ConstIterator begin () const { return seq_.begin (); }
- inline ConstIterator end () const { return seq_.end (); }
+ inline const_iterator begin () const { return seq_.rbegin (); }
+ inline const_iterator end () const { return seq_.rend (); }
private: