mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-23 19:23:02 +00:00
* data/lalr1.cc (lex_): Rename as...
(yylex_): this. Move the trace here. Take the %name-prefix into account. Reported by Alexandre Duret-Lutz.
This commit is contained in:
147
data/lalr1.cc
147
data/lalr1.cc
@@ -227,9 +227,11 @@ namespace yy
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Parse.
|
||||||
|
/// \returns 0 iff parsing succeeded.
|
||||||
virtual int parse ();
|
virtual int parse ();
|
||||||
|
|
||||||
/// Return the current debugging stream.
|
/// The current debugging stream.
|
||||||
std::ostream& debug_stream () const;
|
std::ostream& debug_stream () const;
|
||||||
/// Set the current debugging stream.
|
/// Set the current debugging stream.
|
||||||
void set_debug_stream (std::ostream &);
|
void set_debug_stream (std::ostream &);
|
||||||
@@ -243,19 +245,27 @@ namespace yy
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/// Call the scanner.
|
||||||
virtual void yylex_ ();
|
virtual void yylex_ ();
|
||||||
virtual void error_ ();
|
virtual void error_ ();
|
||||||
virtual void report_syntax_error_ ();
|
/// Generate an error message, and invoke error. */
|
||||||
|
virtual void yyreport_syntax_error_ ();
|
||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
virtual void symprint_ (int yytype,
|
/// \brief Report a symbol on the debug stream.
|
||||||
const SemanticType* yyvaluep,
|
/// \param yytype The token type.
|
||||||
const LocationType* yylocationp);
|
/// \param yyvaluep Its semantic value.
|
||||||
|
/// \param yylocationp Its location.
|
||||||
|
virtual void yysymprint_ (int yytype,
|
||||||
|
const SemanticType* yyvaluep,
|
||||||
|
const LocationType* yylocationp);
|
||||||
#endif /* ! YYDEBUG */
|
#endif /* ! YYDEBUG */
|
||||||
|
|
||||||
|
|
||||||
/* Stacks. */
|
/// The state stack.
|
||||||
StateStack state_stack_;
|
StateStack state_stack_;
|
||||||
|
/// The semantic value stack.
|
||||||
SemanticStack semantic_stack_;
|
SemanticStack semantic_stack_;
|
||||||
|
/// The location stack.
|
||||||
LocationStack location_stack_;
|
LocationStack location_stack_;
|
||||||
|
|
||||||
/* Tables. */
|
/* Tables. */
|
||||||
@@ -281,18 +291,25 @@ namespace yy
|
|||||||
static const ]b4_int_type_for([b4_prhs])[ prhs_[];
|
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_rline])[ rline_[];
|
||||||
static const ]b4_int_type_for([b4_toknum])[ token_number_[];
|
static const ]b4_int_type_for([b4_toknum])[ token_number_[];
|
||||||
virtual void reduce_print_ (int yyrule);
|
virtual void yyreduce_print_ (int yyrule);
|
||||||
virtual void stack_print_ ();
|
virtual void yystack_print_ ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Even more tables. */
|
/// Convert a scanner token number to a symbol number.
|
||||||
inline TokenNumberType translate_ (int token);
|
inline TokenNumberType yytranslate_ (int token);
|
||||||
inline void destruct_ (const char* yymsg,
|
|
||||||
int yytype,
|
/// \brief Reclaim the memory associated to a symbol.
|
||||||
SemanticType* yyvaluep, LocationType* yylocationp);
|
/// \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.
|
/// Pop \a n symbols the three stacks.
|
||||||
inline void pop (unsigned int n = 1);
|
inline void yypop_ (unsigned int n = 1);
|
||||||
|
|
||||||
/* Constants. */
|
/* Constants. */
|
||||||
static const int eof_;
|
static const int eof_;
|
||||||
@@ -363,7 +380,7 @@ do { \
|
|||||||
if (yydebug_) \
|
if (yydebug_) \
|
||||||
{ \
|
{ \
|
||||||
*yycdebug_ << (Title) << ' '; \
|
*yycdebug_ << (Title) << ' '; \
|
||||||
symprint_ ((Type), (Value), (Location)); \
|
yysymprint_ ((Type), (Value), (Location)); \
|
||||||
*yycdebug_ << std::endl; \
|
*yycdebug_ << std::endl; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@@ -371,13 +388,13 @@ do { \
|
|||||||
# define YY_REDUCE_PRINT(Rule) \
|
# define YY_REDUCE_PRINT(Rule) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug_) \
|
if (yydebug_) \
|
||||||
reduce_print_ (Rule); \
|
yyreduce_print_ (Rule); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
# define YY_STACK_PRINT() \
|
# define YY_STACK_PRINT() \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug_) \
|
if (yydebug_) \
|
||||||
stack_print_ (); \
|
yystack_print_ (); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#else /* !YYDEBUG */
|
#else /* !YYDEBUG */
|
||||||
@@ -398,7 +415,7 @@ do { \
|
|||||||
`--------------------------------*/
|
`--------------------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
yy::]b4_parser_class_name[::symprint_ (int yytype,
|
yy::]b4_parser_class_name[::yysymprint_ (int yytype,
|
||||||
const SemanticType* yyvaluep, const LocationType* yylocationp)
|
const SemanticType* yyvaluep, const LocationType* yylocationp)
|
||||||
{
|
{
|
||||||
/* Pacify ``unused variable'' warnings. */
|
/* Pacify ``unused variable'' warnings. */
|
||||||
@@ -422,7 +439,7 @@ yy::]b4_parser_class_name[::symprint_ (int yytype,
|
|||||||
#endif /* ! YYDEBUG */
|
#endif /* ! YYDEBUG */
|
||||||
|
|
||||||
void
|
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)
|
int yytype, SemanticType* yyvaluep, LocationType* yylocationp)
|
||||||
{
|
{
|
||||||
/* Pacify ``unused variable'' warnings. */
|
/* Pacify ``unused variable'' warnings. */
|
||||||
@@ -440,7 +457,7 @@ yy::]b4_parser_class_name[::destruct_ (const char* yymsg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
yy::]b4_parser_class_name[::pop (unsigned int n)
|
yy::]b4_parser_class_name[::yypop_ (unsigned int n)
|
||||||
{
|
{
|
||||||
state_stack_.pop (n);
|
state_stack_.pop (n);
|
||||||
semantic_stack_.pop (n);
|
semantic_stack_.pop (n);
|
||||||
@@ -531,7 +548,7 @@ yybackup:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ilooka_ = translate_ (looka_);
|
ilooka_ = yytranslate_ (looka_);
|
||||||
YY_SYMBOL_PRINT ("Next token is", ilooka_, &value, &location);
|
YY_SYMBOL_PRINT ("Next token is", ilooka_, &value, &location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,7 +633,7 @@ yyreduce:
|
|||||||
]/* Line __line__ of lalr1.cc. */
|
]/* Line __line__ of lalr1.cc. */
|
||||||
b4_syncline([@oline@], [@ofile@])[
|
b4_syncline([@oline@], [@ofile@])[
|
||||||
|
|
||||||
pop (len_);
|
yypop_ (len_);
|
||||||
|
|
||||||
YY_STACK_PRINT ();
|
YY_STACK_PRINT ();
|
||||||
|
|
||||||
@@ -637,7 +654,7 @@ b4_syncline([@oline@], [@ofile@])[
|
|||||||
`------------------------------------*/
|
`------------------------------------*/
|
||||||
yyerrlab:
|
yyerrlab:
|
||||||
/* If not already recovering from an error, report this error. */
|
/* If not already recovering from an error, report this error. */
|
||||||
report_syntax_error_ ();
|
yyreport_syntax_error_ ();
|
||||||
|
|
||||||
error_range_[0] = location;
|
error_range_[0] = location;
|
||||||
if (errstatus_ == 3)
|
if (errstatus_ == 3)
|
||||||
@@ -654,18 +671,18 @@ yyerrlab:
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
error_range_[0] = location_stack_[0];
|
error_range_[0] = location_stack_[0];
|
||||||
pop ();
|
yypop_ ();
|
||||||
if (state_stack_.height () == 1)
|
if (state_stack_.height () == 1)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
destruct_ ("Error: popping",
|
yydestruct_ ("Error: popping",
|
||||||
stos_[state_stack_[0]],
|
stos_[state_stack_[0]],
|
||||||
&semantic_stack_[0],
|
&semantic_stack_[0],
|
||||||
&location_stack_[0]);
|
&location_stack_[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
destruct_ ("Error: discarding", ilooka_, &value, &location);
|
yydestruct_ ("Error: discarding", ilooka_, &value, &location);
|
||||||
looka_ = empty_;
|
looka_ = empty_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -688,7 +705,7 @@ yyerrorlab:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
error_range_[0] = location_stack_[len_ - 1];
|
error_range_[0] = location_stack_[len_ - 1];
|
||||||
pop (len_);
|
yypop_ (len_);
|
||||||
state_ = state_stack_[0];
|
state_ = state_stack_[0];
|
||||||
goto yyerrlab1;
|
goto yyerrlab1;
|
||||||
|
|
||||||
@@ -717,9 +734,9 @@ yyerrlab1:
|
|||||||
YYABORT;
|
YYABORT;
|
||||||
|
|
||||||
error_range_[0] = location_stack_[0];
|
error_range_[0] = location_stack_[0];
|
||||||
destruct_ ("Error: popping",
|
yydestruct_ ("Error: popping",
|
||||||
stos_[state_], &semantic_stack_[0], &location_stack_[0]);
|
stos_[state_], &semantic_stack_[0], &location_stack_[0]);
|
||||||
pop ();
|
yypop_ ();
|
||||||
state_ = state_stack_[0];
|
state_ = state_stack_[0];
|
||||||
YY_STACK_PRINT ();
|
YY_STACK_PRINT ();
|
||||||
}
|
}
|
||||||
@@ -748,7 +765,7 @@ yyacceptlab:
|
|||||||
/* Abort. */
|
/* Abort. */
|
||||||
yyabortlab:
|
yyabortlab:
|
||||||
/* Free the lookahead. */
|
/* Free the lookahead. */
|
||||||
destruct_ ("Error: discarding lookahead", ilooka_, &value, &location);
|
yydestruct_ ("Error: discarding lookahead", ilooka_, &value, &location);
|
||||||
looka_ = empty_;
|
looka_ = empty_;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -764,9 +781,9 @@ yy::]b4_parser_class_name[::yylex_ ()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Generate an error message, and invoke yyerror. */
|
// Generate an error message, and invoke error.
|
||||||
void
|
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 not already recovering from an error, report this error. */
|
||||||
if (!errstatus_)
|
if (!errstatus_)
|
||||||
@@ -918,10 +935,9 @@ yy::]b4_parser_class_name[::rline_[] =
|
|||||||
]b4_rline[
|
]b4_rline[
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Print the state stack from its BOTTOM up to its TOP (included). */
|
/// Print the state stack on the debug stream.
|
||||||
|
|
||||||
void
|
void
|
||||||
yy::]b4_parser_class_name[::stack_print_ ()
|
yy::]b4_parser_class_name[::yystack_print_ ()
|
||||||
{
|
{
|
||||||
*yycdebug_ << "Stack now";
|
*yycdebug_ << "Stack now";
|
||||||
for (StateStack::const_iterator i = state_stack_.begin ();
|
for (StateStack::const_iterator i = state_stack_.begin ();
|
||||||
@@ -930,10 +946,9 @@ yy::]b4_parser_class_name[::stack_print_ ()
|
|||||||
*yycdebug_ << std::endl;
|
*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
|
void
|
||||||
yy::]b4_parser_class_name[::reduce_print_ (int yyrule)
|
yy::]b4_parser_class_name[::yyreduce_print_ (int yyrule)
|
||||||
{
|
{
|
||||||
unsigned int yylno = rline_[yyrule];
|
unsigned int yylno = rline_[yyrule];
|
||||||
/* Print the symbols being reduced, and their result. */
|
/* Print the symbols being reduced, and their result. */
|
||||||
@@ -948,7 +963,7 @@ yy::]b4_parser_class_name[::reduce_print_ (int yyrule)
|
|||||||
|
|
||||||
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||||
yy::]b4_parser_class_name[::TokenNumberType
|
yy::]b4_parser_class_name[::TokenNumberType
|
||||||
yy::]b4_parser_class_name[::translate_ (int token)
|
yy::]b4_parser_class_name[::yytranslate_ (int token)
|
||||||
{
|
{
|
||||||
static
|
static
|
||||||
const TokenNumberType
|
const TokenNumberType
|
||||||
@@ -1090,19 +1105,19 @@ b4_copyright([Position class for Bison C++ parsers], [2002, 2003, 2004])[
|
|||||||
|
|
||||||
namespace yy
|
namespace yy
|
||||||
{
|
{
|
||||||
/** \brief Abstract a Position. */
|
/// Abstract a Position.
|
||||||
class Position
|
class Position
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** \brief Initial column number. */
|
/// Initial column number.
|
||||||
static const unsigned int initial_column = 0;
|
static const unsigned int initial_column = 0;
|
||||||
/** \brief Initial line number. */
|
/// Initial line number.
|
||||||
static const unsigned int initial_line = 1;
|
static const unsigned int initial_line = 1;
|
||||||
|
|
||||||
/** \name Ctor & dtor.
|
/** \name Ctor & dtor.
|
||||||
** \{ */
|
** \{ */
|
||||||
public:
|
public:
|
||||||
/** \brief Construct a Position. */
|
/// Construct a Position.
|
||||||
Position () :
|
Position () :
|
||||||
filename (),
|
filename (),
|
||||||
line (initial_line),
|
line (initial_line),
|
||||||
@@ -1115,14 +1130,14 @@ namespace yy
|
|||||||
/** \name Line and Column related manipulators
|
/** \name Line and Column related manipulators
|
||||||
** \{ */
|
** \{ */
|
||||||
public:
|
public:
|
||||||
/** \brief (line related) Advance to the COUNT next lines. */
|
/// (line related) Advance to the COUNT next lines.
|
||||||
inline void lines (int count = 1)
|
inline void lines (int count = 1)
|
||||||
{
|
{
|
||||||
column = initial_column;
|
column = initial_column;
|
||||||
line += count;
|
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)
|
inline void columns (int count = 1)
|
||||||
{
|
{
|
||||||
int leftmost = initial_column;
|
int leftmost = initial_column;
|
||||||
@@ -1135,15 +1150,15 @@ namespace yy
|
|||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** \brief File name to which this position refers. */
|
/// File name to which this position refers.
|
||||||
std::string filename;
|
std::string filename;
|
||||||
/** \brief Current line number. */
|
/// Current line number.
|
||||||
unsigned int line;
|
unsigned int line;
|
||||||
/** \brief Current column number. */
|
/// Current column number.
|
||||||
unsigned int column;
|
unsigned int column;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief Add and assign a Position. */
|
/// Add and assign a Position.
|
||||||
inline const Position&
|
inline const Position&
|
||||||
operator+= (Position& res, const int width)
|
operator+= (Position& res, const int width)
|
||||||
{
|
{
|
||||||
@@ -1151,7 +1166,7 @@ namespace yy
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Add two Position objects. */
|
/// Add two Position objects.
|
||||||
inline const Position
|
inline const Position
|
||||||
operator+ (const Position& begin, const int width)
|
operator+ (const Position& begin, const int width)
|
||||||
{
|
{
|
||||||
@@ -1159,14 +1174,14 @@ namespace yy
|
|||||||
return res += width;
|
return res += width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Add and assign a Position. */
|
/// Add and assign a Position.
|
||||||
inline const Position&
|
inline const Position&
|
||||||
operator-= (Position& res, const int width)
|
operator-= (Position& res, const int width)
|
||||||
{
|
{
|
||||||
return res += -width;
|
return res += -width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Add two Position objects. */
|
/// Add two Position objects.
|
||||||
inline const Position
|
inline const Position
|
||||||
operator- (const Position& begin, const int width)
|
operator- (const Position& begin, const int width)
|
||||||
{
|
{
|
||||||
@@ -1205,13 +1220,13 @@ b4_copyright([Location class for Bison C++ parsers], [2002, 2003, 2004])[
|
|||||||
namespace yy
|
namespace yy
|
||||||
{
|
{
|
||||||
|
|
||||||
/** \brief Abstract a Location. */
|
/// Abstract a Location.
|
||||||
class Location
|
class Location
|
||||||
{
|
{
|
||||||
/** \name Ctor & dtor.
|
/** \name Ctor & dtor.
|
||||||
** \{ */
|
** \{ */
|
||||||
public:
|
public:
|
||||||
/** \brief Construct a Location. */
|
/// Construct a Location.
|
||||||
Location (void) :
|
Location (void) :
|
||||||
begin (),
|
begin (),
|
||||||
end ()
|
end ()
|
||||||
@@ -1223,19 +1238,19 @@ namespace yy
|
|||||||
/** \name Line and Column related manipulators
|
/** \name Line and Column related manipulators
|
||||||
** \{ */
|
** \{ */
|
||||||
public:
|
public:
|
||||||
/** \brief Reset initial location to final location. */
|
/// Reset initial location to final location.
|
||||||
inline void step (void)
|
inline void step (void)
|
||||||
{
|
{
|
||||||
begin = end;
|
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)
|
inline void columns (unsigned int count = 1)
|
||||||
{
|
{
|
||||||
end += count;
|
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)
|
inline void lines (unsigned int count = 1)
|
||||||
{
|
{
|
||||||
end.lines (count);
|
end.lines (count);
|
||||||
@@ -1244,13 +1259,13 @@ namespace yy
|
|||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** \brief Beginning of the located region. */
|
/// Beginning of the located region.
|
||||||
Position begin;
|
Position begin;
|
||||||
/** \brief End of the located region. */
|
/// End of the located region.
|
||||||
Position end;
|
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)
|
inline const Location operator+ (const Location& begin, const Location& end)
|
||||||
{
|
{
|
||||||
Location res = begin;
|
Location res = begin;
|
||||||
@@ -1258,7 +1273,7 @@ namespace yy
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Add two Location objects */
|
/// Add two Location objects.
|
||||||
inline const Location operator+ (const Location& begin, unsigned int width)
|
inline const Location operator+ (const Location& begin, unsigned int width)
|
||||||
{
|
{
|
||||||
Location res = begin;
|
Location res = begin;
|
||||||
@@ -1266,7 +1281,7 @@ namespace yy
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Add and assign a Location */
|
/// Add and assign a Location.
|
||||||
inline Location& operator+= (Location& res, unsigned int width)
|
inline Location& operator+= (Location& res, unsigned int width)
|
||||||
{
|
{
|
||||||
res.columns (width);
|
res.columns (width);
|
||||||
|
|||||||
Reference in New Issue
Block a user