mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 01:33:03 +00:00
* data/bison.c++ (yy::b4_name::error_): New method, replaces yyerror in
C++ parsers. (yy::b4_name::parse): Build verbose error messages, and use error_.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2002-02-07 Robert Anisko <robert@lrde.epita.fr>
|
||||||
|
|
||||||
|
* data/bison.c++ (yy::b4_name::error_): New method, replaces yyerror in
|
||||||
|
C++ parsers.
|
||||||
|
(yy::b4_name::parse): Build verbose error messages, and use error_.
|
||||||
|
|
||||||
2002-02-06 Robert Anisko <robert@lrde.epita.fr>
|
2002-02-06 Robert Anisko <robert@lrde.epita.fr>
|
||||||
|
|
||||||
* data/bison.c++: Fix m4 quoting in comments.
|
* data/bison.c++: Fix m4 quoting in comments.
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ namespace yy
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
virtual void error_ ();
|
||||||
|
|
||||||
/* Call to lexical analyser. */
|
/* Call to lexical analyser. */
|
||||||
virtual
|
virtual
|
||||||
void
|
void
|
||||||
@@ -129,6 +131,9 @@ namespace yy
|
|||||||
int looka;
|
int looka;
|
||||||
int ilooka;
|
int ilooka;
|
||||||
|
|
||||||
|
/* Message. */
|
||||||
|
std::string message;
|
||||||
|
|
||||||
/* @$ and $$. */
|
/* @$ and $$. */
|
||||||
SemanticType value;
|
SemanticType value;
|
||||||
LocationType location;
|
LocationType location;
|
||||||
@@ -169,6 +174,9 @@ b4_tokendef
|
|||||||
int
|
int
|
||||||
yy::b4_name::parse ()
|
yy::b4_name::parse ()
|
||||||
{
|
{
|
||||||
|
int nerrs = 0;
|
||||||
|
int errstatus = 0;
|
||||||
|
|
||||||
/* Initialize stack. */
|
/* Initialize stack. */
|
||||||
state_stack = StateStack (0);
|
state_stack = StateStack (0);
|
||||||
semantic_stack = SemanticStack (1);
|
semantic_stack = SemanticStack (1);
|
||||||
@@ -333,7 +341,39 @@ yy::b4_name::parse ()
|
|||||||
|
|
||||||
/* Report and recover from errors. This is very incomplete. */
|
/* Report and recover from errors. This is very incomplete. */
|
||||||
yyerrlab:
|
yyerrlab:
|
||||||
std::cerr << "Parse error." << std::endl; // FIXME: Need something like yyerror?
|
/* If not already recovering from an error, report this error. */
|
||||||
|
if (!errstatus)
|
||||||
|
{
|
||||||
|
++nerrs;
|
||||||
|
|
||||||
|
// FIXME: Should be #if YYERROR_VERBOSE from here...
|
||||||
|
n = pact_[[state]];
|
||||||
|
if (n > b4_flag && n < b4_last)
|
||||||
|
{
|
||||||
|
message = "parse error, unexpected ";
|
||||||
|
message += name_[[ilooka]];
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (int x = (n < 0 ? -n : 0); x < b4_ntokens + b4_nnts; ++x)
|
||||||
|
if (check_[[x + n]] == x)
|
||||||
|
++count;
|
||||||
|
if (count < 5)
|
||||||
|
{
|
||||||
|
count = 0;
|
||||||
|
for (int x = (n < 0 ? -n : 0); x < b4_ntokens + b4_nnts; ++x)
|
||||||
|
if (check_[[x + n]] == x)
|
||||||
|
{
|
||||||
|
message += (!count++) ? ", expecting " : " or ";
|
||||||
|
message += name_[[x]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
// FIXME: to there...
|
||||||
|
message = "parse error";
|
||||||
|
}
|
||||||
|
error_ ();
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* Accept. */
|
/* Accept. */
|
||||||
|
|||||||
Reference in New Issue
Block a user