Error reporting improvements.

Don't print more than 3 lines of source file context with errors.
  (Any more than that is almost certainly not the Right Thing to do.)
Make some parsing error messages more clear.
This commit is contained in:
Matt Pharr
2011-10-03 21:09:04 -07:00
parent d5a48d9a1e
commit fa5050d5c7
2 changed files with 13 additions and 4 deletions

View File

@@ -946,7 +946,7 @@ parameter_list
else {
std::vector<std::string> alternates = MatchStrings(yytext, builtinTokens);
std::string alts = lGetAlternates(alternates);
Error(@1, "Syntax error--token \"%s\" unknown.%s", yytext, alts.c_str());
Error(@1, "Syntax error--token \"%s\" unexpected.%s", yytext, alts.c_str());
}
$$ = NULL;
}
@@ -1050,7 +1050,7 @@ statement
else {
std::vector<std::string> alternates = MatchStrings(yytext, builtinTokens);
std::string alts = lGetAlternates(alternates);
Error(@1, "Syntax error--token \"%s\" unknown.%s", yytext, alts.c_str());
Error(@1, "Syntax error--token \"%s\" unexpected.%s", yytext, alts.c_str());
}
$$ = NULL;
}
@@ -1209,7 +1209,7 @@ translation_unit
else {
std::vector<std::string> alternates = MatchStrings(yytext, builtinTokens);
std::string alts = lGetAlternates(alternates);
Error(@1, "Syntax error--token \"%s\" unknown.%s", yytext, alts.c_str());
Error(@1, "Syntax error--token \"%s\" unexpected.%s", yytext, alts.c_str());
}
}
;