mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 21:21:19 +01:00
Handle invalid chars better, and do small cleanups around error output. (#657)
This adds a test for invalid characters (that would've failed before, because the printed char isn't escaped). Not sure if there's a good way to test the PrintDiagnostic code, as it appears to occur on bison parser errors, which I'm just not sure how to trigger.
This commit is contained in:
@@ -61,7 +61,7 @@
|
||||
|
||||
#include "executable_semantics/syntax/syntax_helpers.h"
|
||||
#include "executable_semantics/syntax/parse_and_lex_context.h"
|
||||
}
|
||||
} // %code top
|
||||
|
||||
%code requires {
|
||||
#include <optional>
|
||||
@@ -73,21 +73,19 @@
|
||||
|
||||
namespace Carbon {
|
||||
class ParseAndLexContext;
|
||||
}
|
||||
} // namespace Carbon
|
||||
|
||||
}
|
||||
} // %code requires
|
||||
|
||||
%code {
|
||||
|
||||
extern int yylineno;
|
||||
|
||||
void yy::parser::error(
|
||||
const location_type&, const std::string& message)
|
||||
{
|
||||
void yy::parser::error(const location_type&, const std::string& message) {
|
||||
context.PrintDiagnostic(message, yylineno);
|
||||
}
|
||||
|
||||
}
|
||||
} // %code
|
||||
|
||||
%token <int> integer_literal
|
||||
%token <char*> identifier
|
||||
|
||||
Reference in New Issue
Block a user