Miscellaneous parser cleanup (#429)

- Give unary `-` and `not` the same precedence as in C++
- Add detail to parse error messages, and make the --trace flag also enable parser debug tracing
- Make any new shift-reduce conflicts into build errors
- Use `%precedence` rather than `%nonassoc` where possible, in order to catch more grammar bugs at build time
This commit is contained in:
Geoff Romer
2021-04-06 10:09:03 -07:00
committed by GitHub
parent 2606046477
commit e324935139
3 changed files with 30 additions and 8 deletions
+5 -1
View File
@@ -29,7 +29,11 @@ auto parse(const std::string& input_file_name)
std::optional<AST> parsed_input = std::nullopt;
ParseAndLexContext context(input_file_name);
auto syntax_error_code = yy::parser(parsed_input, context)();
auto parser = yy::parser(parsed_input, context);
if (tracing_output) {
parser.set_debug_level(1);
}
auto syntax_error_code = parser();
if (syntax_error_code != 0) {
return syntax_error_code;
}