mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 14:11:04 +01:00
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:
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user