[location_stack_@{m4_eval([$1 - $2])@}])
-m4_define([b4_inherit],
- [m4_ifdef([b4_root],
- [: public b4_root
-],
- [])])
-
-m4_define([b4_param],
- [m4_ifdef([b4_root],
- [,
- const Param& param],
- [])])
-
-m4_define([b4_constructor],
- [m4_ifdef([b4_root],
- [b4_root (param),
- ],
- [])])
-
-
# b4_parse_param_decl
# -------------------
# Extra formal arguments of the constructor.
# argument name in the constructor.
m4_define([b4_parse_param_decl],
[m4_ifset([b4_parse_param],
- [, m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
+ [m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
m4_define([b4_parse_param_decl_1],
[$1_yyarg])
namespace yy
{
- class ]b4_parser_class_name b4_inherit[
+ class ]b4_parser_class_name[
{
public:
typedef Stack<SemanticType> SemanticStack;
typedef Stack<LocationType> LocationStack;
- ]b4_parser_class_name[ (bool debug][]b4_param[]b4_parse_param_decl[) :
- ]b4_constructor[][debug_ (debug),
+ ]b4_parser_class_name[ (]b4_parse_param_decl[) :
+ yydebug_ (false),
yycdebug_ (&std::cerr)]b4_parse_param_cons[
{
}
- ]b4_parser_class_name[ (bool debug,
- LocationType][]b4_param[]b4_parse_param_decl[) :
- ]b4_constructor[][debug_ (debug),
- yycdebug_ (&std::cerr)]b4_parse_param_cons[
- {
- *yycdebug_ << __FILE__ << ':' << __LINE__
- << ": this constructor is provided by backward compatibility"
- << ", but will be removed in the near future."
- << std::endl;
- }
-
virtual ~]b4_parser_class_name[ ()
{
}
+ /// Parse.
+ /// \returns 0 iff parsing succeeded.
virtual int parse ();
- /// Return the current debugging stream.
+ /// The current debugging stream.
std::ostream& debug_stream () const;
/// Set the current debugging stream.
void set_debug_stream (std::ostream &);
+ /// Type for debugging levels.
+ typedef int debug_level_type;
+ /// The current debugging level.
+ debug_level_type debug_level () const;
+ /// Set the current debugging level.
+ void set_debug_level (debug_level_type l);
+
private:
- virtual void lex_ ();
+ /// Call the scanner.
+ virtual void yylex_ ();
virtual void error_ ();
- virtual void report_syntax_error_ ();
+ /// Generate an error message, and invoke error. */
+ virtual void yyreport_syntax_error_ ();
#if YYDEBUG
- virtual void symprint_ (int yytype,
- const SemanticType* yyvaluep,
- const LocationType* yylocationp);
+ /// \brief Report a symbol on the debug stream.
+ /// \param yytype The token type.
+ /// \param yyvaluep Its semantic value.
+ /// \param yylocationp Its location.
+ virtual void yysymprint_ (int yytype,
+ const SemanticType* yyvaluep,
+ const LocationType* yylocationp);
#endif /* ! YYDEBUG */
- /* Stacks. */
+ /// The state stack.
StateStack state_stack_;
+ /// The semantic value stack.
SemanticStack semantic_stack_;
+ /// The location stack.
LocationStack location_stack_;
/* Tables. */
static const ]b4_int_type_for([b4_prhs])[ prhs_[];
static const ]b4_int_type_for([b4_rline])[ rline_[];
static const ]b4_int_type_for([b4_toknum])[ token_number_[];
- virtual void reduce_print_ (int yyrule);
- virtual void stack_print_ ();
+ virtual void yyreduce_print_ (int yyrule);
+ virtual void yystack_print_ ();
#endif
- /* Even more tables. */
- inline TokenNumberType translate_ (int token);
- inline void destruct_ (const char* yymsg,
- int yytype,
- SemanticType* yyvaluep, LocationType* yylocationp);
+ /// Convert a scanner token number to a symbol number.
+ inline TokenNumberType yytranslate_ (int token);
+
+ /// \brief Reclaim the memory associated to a symbol.
+ /// \param yymsg Why this token is reclaimed.
+ /// \param yytype The symbol type.
+ /// \param yyvaluep Its semantic value.
+ /// \param yylocationp Its location.
+ inline void yydestruct_ (const char* yymsg,
+ int yytype,
+ SemanticType* yyvaluep,
+ LocationType* yylocationp);
/// Pop \a n symbols the three stacks.
- inline void pop (unsigned int n = 1);
+ inline void yypop_ (unsigned int n = 1);
/* Constants. */
static const int eof_;
int errstatus_;
/* Debugging. */
- int debug_;
+ int yydebug_;
std::ostream* yycdebug_;
/* Look-ahead and look-ahead in internal form. */
m4_if(b4_defines_flag, 0, [], [#include @output_header_name@])[
-/* A pseudo ostream that takes debug_ into account. */
+/* A pseudo ostream that takes yydebug_ into account. */
# define YYCDEBUG \
- for (bool yydebugcond_ = debug_; yydebugcond_; yydebugcond_ = false) \
+ for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
(*yycdebug_)
/* Enable debugging if requested. */
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
- if (debug_) \
+ if (yydebug_) \
{ \
*yycdebug_ << (Title) << ' '; \
- symprint_ ((Type), (Value), (Location)); \
+ yysymprint_ ((Type), (Value), (Location)); \
*yycdebug_ << std::endl; \
} \
} while (0)
# define YY_REDUCE_PRINT(Rule) \
do { \
- if (debug_) \
- reduce_print_ (Rule); \
+ if (yydebug_) \
+ yyreduce_print_ (Rule); \
} while (0)
# define YY_STACK_PRINT() \
do { \
- if (debug_) \
- stack_print_ (); \
+ if (yydebug_) \
+ yystack_print_ (); \
} while (0)
#else /* !YYDEBUG */
`--------------------------------*/
void
-yy::]b4_parser_class_name[::symprint_ (int yytype,
+yy::]b4_parser_class_name[::yysymprint_ (int yytype,
const SemanticType* yyvaluep, const LocationType* yylocationp)
{
/* Pacify ``unused variable'' warnings. */
#endif /* ! YYDEBUG */
void
-yy::]b4_parser_class_name[::destruct_ (const char* yymsg,
+yy::]b4_parser_class_name[::yydestruct_ (const char* yymsg,
int yytype, SemanticType* yyvaluep, LocationType* yylocationp)
{
/* Pacify ``unused variable'' warnings. */
}
void
-yy::]b4_parser_class_name[::pop (unsigned int n)
+yy::]b4_parser_class_name[::yypop_ (unsigned int n)
{
state_stack_.pop (n);
semantic_stack_.pop (n);
}
+yy::]b4_parser_class_name[::debug_level_type
+yy::]b4_parser_class_name[::debug_level () const
+{
+ return yydebug_;
+}
+
+void
+yy::]b4_parser_class_name[::set_debug_level (debug_level_type l)
+{
+ yydebug_ = l;
+}
+
+
int
yy::]b4_parser_class_name[::parse ()
{
/* Read a look-ahead token. */
if (looka_ == empty_)
- {
- YYCDEBUG << "Reading a token: ";
- lex_ ();
- }
+ yylex_ ();
/* Convert token to internal form. */
if (looka_ <= eof_)
}
else
{
- ilooka_ = translate_ (looka_);
+ ilooka_ = yytranslate_ (looka_);
YY_SYMBOL_PRINT ("Next token is", ilooka_, &value, &location);
}
]/* Line __line__ of lalr1.cc. */
b4_syncline([@oline@], [@ofile@])[
- pop (len_);
+ yypop_ (len_);
YY_STACK_PRINT ();
`------------------------------------*/
yyerrlab:
/* If not already recovering from an error, report this error. */
- report_syntax_error_ ();
+ yyreport_syntax_error_ ();
error_range_[0] = location;
if (errstatus_ == 3)
for (;;)
{
error_range_[0] = location_stack_[0];
- pop ();
+ yypop_ ();
if (state_stack_.height () == 1)
YYABORT;
- destruct_ ("Error: popping",
- stos_[state_stack_[0]],
- &semantic_stack_[0],
- &location_stack_[0]);
+ yydestruct_ ("Error: popping",
+ stos_[state_stack_[0]],
+ &semantic_stack_[0],
+ &location_stack_[0]);
}
}
else
{
- destruct_ ("Error: discarding", ilooka_, &value, &location);
+ yydestruct_ ("Error: discarding", ilooka_, &value, &location);
looka_ = empty_;
}
}
#endif
error_range_[0] = location_stack_[len_ - 1];
- pop (len_);
+ yypop_ (len_);
state_ = state_stack_[0];
goto yyerrlab1;
YYABORT;
error_range_[0] = location_stack_[0];
- destruct_ ("Error: popping",
- stos_[state_], &semantic_stack_[0], &location_stack_[0]);
- pop ();
+ yydestruct_ ("Error: popping",
+ stos_[state_], &semantic_stack_[0], &location_stack_[0]);
+ yypop_ ();
state_ = state_stack_[0];
YY_STACK_PRINT ();
}
/* Abort. */
yyabortlab:
/* Free the lookahead. */
- destruct_ ("Error: discarding lookahead", ilooka_, &value, &location);
+ yydestruct_ ("Error: discarding lookahead", ilooka_, &value, &location);
looka_ = empty_;
return 1;
}
void
-yy::]b4_parser_class_name[::lex_ ()
+yy::]b4_parser_class_name[::yylex_ ()
{
+ YYCDEBUG << "Reading a token: ";
#if YYLSP_NEEDED
- looka_ = yylex (&value, &location);
+ looka_ = ]m4_default(b4_prefix, [yy])[lex (&value, &location);
#else
- looka_ = yylex (&value);
+ looka_ = ]m4_default(b4_prefix, [yy])[lex (&value);
#endif
}
-/** Generate an error message, and invoke yyerror. */
+// Generate an error message, and invoke error.
void
-yy::]b4_parser_class_name[::report_syntax_error_ ()
+yy::]b4_parser_class_name[::yyreport_syntax_error_ ()
{
/* If not already recovering from an error, report this error. */
if (!errstatus_)
]b4_rline[
};
-/** Print the state stack from its BOTTOM up to its TOP (included). */
-
+/// Print the state stack on the debug stream.
void
-yy::]b4_parser_class_name[::stack_print_ ()
+yy::]b4_parser_class_name[::yystack_print_ ()
{
*yycdebug_ << "Stack now";
for (StateStack::const_iterator i = state_stack_.begin ();
*yycdebug_ << std::endl;
}
-/** Report that the YYRULE is going to be reduced. */
-
+/// Report on the debug stream that the rule \a yyrule is going to be reduced.
void
-yy::]b4_parser_class_name[::reduce_print_ (int yyrule)
+yy::]b4_parser_class_name[::yyreduce_print_ (int yyrule)
{
unsigned int yylno = rline_[yyrule];
/* Print the symbols being reduced, and their result. */
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
yy::]b4_parser_class_name[::TokenNumberType
-yy::]b4_parser_class_name[::translate_ (int token)
+yy::]b4_parser_class_name[::yytranslate_ (int token)
{
static
const TokenNumberType
namespace yy
{
- /** \brief Abstract a Position. */
+ /// Abstract a Position.
class Position
{
public:
- /** \brief Initial column number. */
+ /// Initial column number.
static const unsigned int initial_column = 0;
- /** \brief Initial line number. */
+ /// Initial line number.
static const unsigned int initial_line = 1;
/** \name Ctor & dtor.
** \{ */
public:
- /** \brief Construct a Position. */
+ /// Construct a Position.
Position () :
filename (),
line (initial_line),
/** \name Line and Column related manipulators
** \{ */
public:
- /** \brief (line related) Advance to the COUNT next lines. */
+ /// (line related) Advance to the COUNT next lines.
inline void lines (int count = 1)
{
column = initial_column;
line += count;
}
- /** \brief (column related) Advance to the COUNT next columns. */
+ /// (column related) Advance to the COUNT next columns.
inline void columns (int count = 1)
{
int leftmost = initial_column;
/** \} */
public:
- /** \brief File name to which this position refers. */
+ /// File name to which this position refers.
std::string filename;
- /** \brief Current line number. */
+ /// Current line number.
unsigned int line;
- /** \brief Current column number. */
+ /// Current column number.
unsigned int column;
};
- /** \brief Add and assign a Position. */
+ /// Add and assign a Position.
inline const Position&
operator+= (Position& res, const int width)
{
return res;
}
- /** \brief Add two Position objects. */
+ /// Add two Position objects.
inline const Position
operator+ (const Position& begin, const int width)
{
return res += width;
}
- /** \brief Add and assign a Position. */
+ /// Add and assign a Position.
inline const Position&
operator-= (Position& res, const int width)
{
return res += -width;
}
- /** \brief Add two Position objects. */
+ /// Add two Position objects.
inline const Position
operator- (const Position& begin, const int width)
{
namespace yy
{
- /** \brief Abstract a Location. */
+ /// Abstract a Location.
class Location
{
/** \name Ctor & dtor.
** \{ */
public:
- /** \brief Construct a Location. */
+ /// Construct a Location.
Location (void) :
begin (),
end ()
/** \name Line and Column related manipulators
** \{ */
public:
- /** \brief Reset initial location to final location. */
+ /// Reset initial location to final location.
inline void step (void)
{
begin = end;
}
- /** \brief Extend the current location to the COUNT next columns. */
+ /// Extend the current location to the COUNT next columns.
inline void columns (unsigned int count = 1)
{
end += count;
}
- /** \brief Extend the current location to the COUNT next lines. */
+ /// Extend the current location to the COUNT next lines.
inline void lines (unsigned int count = 1)
{
end.lines (count);
public:
- /** \brief Beginning of the located region. */
+ /// Beginning of the located region.
Position begin;
- /** \brief End of the located region. */
+ /// End of the located region.
Position end;
};
- /** \brief Join two Location objects to create a Location. */
+ /// Join two Location objects to create a Location.
inline const Location operator+ (const Location& begin, const Location& end)
{
Location res = begin;
return res;
}
- /** \brief Add two Location objects */
+ /// Add two Location objects.
inline const Location operator+ (const Location& begin, unsigned int width)
{
Location res = begin;
return res;
}
- /** \brief Add and assign a Location */
+ /// Add and assign a Location.
inline Location& operator+= (Location& res, unsigned int width)
{
res.columns (width);