Improve error handling and reporting in the parser.

Add a number of additional error cases in the grammar.

Enable bison's extended error reporting, to get better messages about the
context of errors and the expected (but not found) tokens at errors.

Improve the printing of these by providing an implementation of yytnamerr
that rewrites things like "TOKEN_MUL_ASSIGN" to "*=" in error messages.

Print the source location (using Error() when yyerror() is called; wiring
this up seems to require no longer building a 'pure parser' but having
yylloc as a global, which in turn led to having to update all of the uses of
it (which previously accessed it as a pointer).

Updated a number of tests_errors for resulting changesin error text.
This commit is contained in:
Matt Pharr
2012-02-07 11:11:40 -08:00
parent 157e7c97ae
commit f3089df086
8 changed files with 242 additions and 92 deletions

View File

@@ -161,6 +161,9 @@ Module::CompileFile() {
bool runPreprocessor = g->runCPP;
extern void ParserInit();
ParserInit();
if (runPreprocessor) {
if (filename != NULL) {
// Try to open the file first, since otherwise we crash in the