Configure reentrant bison/flex (#789)

Make the parser reentrant, working towards #769 and the ability to load other packages cleanly.
This commit is contained in:
Jon Meow
2021-08-30 14:23:16 -07:00
committed by GitHub
parent 0ac220b30f
commit ed2d171703
14 changed files with 51 additions and 29 deletions
+8 -4
View File
@@ -29,8 +29,10 @@
// Enable support for parser debugging
%define parse.trace true
//
// Parameters to the parser and lexer
// Generate location structs.
%locations
// Parameters to the parser and lexer.
//
// Parameters to the parser are stored therein as protected data members, and
// thus available to its methods.
@@ -38,7 +40,8 @@
// "out" parameter passed to the parser, where the AST is written.
%parse-param {std::optional<AST>& parsed_program}
// "inout" parameter passed to both the parser and the lexer.
// "inout" parameters passed to both the parser and the lexer.
%param {yyscan_t yyscanner}
%param {ParseAndLexContext& context}
// No shift-reduce conflicts are expected.
@@ -77,6 +80,8 @@ namespace Carbon {
class ParseAndLexContext;
} // namespace Carbon
typedef void* yyscan_t;
} // %code requires
%code {
@@ -206,7 +211,6 @@ void Carbon::Parser::error(const location_type&, const std::string& message) {
%precedence "(" ")" "[" "]"
%start input
%locations
%%
input: declaration_list
{ parsed_program = $1; }