@@ -16,10 +16,6 @@ Author: Matthias Weiss, matthias.weiss@diffblue.com
1616
1717#include " statement_list_parse_tree.h"
1818
19- // / Defined in statement_list_y.tab.cpp. Main function for the parse process
20- // / generated by bison, performs all necessary steps to fill the parse tree.
21- int yystatement_listparse ();
22-
2319// / Responsible for starting the parse process and to translate the result into
2420// / a statement_list_parse_treet. This parser works by using the expression
2521// / stack of its base class. During the parse process, expressions with
@@ -34,6 +30,22 @@ int yystatement_listparse();
3430class statement_list_parsert : public parsert
3531{
3632public:
33+ // / Constructor
34+ explicit statement_list_parsert (message_handlert &message_handler)
35+ : parsert(message_handler)
36+ {
37+ // Simplistic check that we don't attempt to do reentrant parsing as the
38+ // Bison-generated parser has global state.
39+ PRECONDITION (++instance_count == 1 );
40+ }
41+
42+ statement_list_parsert (const statement_list_parsert &) = delete ;
43+
44+ ~statement_list_parsert () override
45+ {
46+ --instance_count;
47+ }
48+
3749 // / Starts the parsing process and saves the result inside of this instance's
3850 // / parse tree.
3951 // / \return False if successful.
@@ -69,19 +81,19 @@ class statement_list_parsert : public parsert
6981private:
7082 // / Tree that is being filled by the parsing process.
7183 statement_list_parse_treet parse_tree;
72- };
7384
74- // / Instance of the parser, used by other modules.
75- extern statement_list_parsert statement_list_parser ;
85+ static int instance_count;
86+ } ;
7687
7788// / Forwards any errors that are encountered during the parse process. This
7889// / function gets called by the generated files of flex and bison.
90+ // / \param parser: Parser object.
91+ // / \param scanner: Lexer state.
7992// / \param error: Error message.
8093// / \return Always 0.
81- int yystatement_listerror (const std::string &error);
82-
83- // / Defined in scanner.l. This function initialises the scanner by setting
84- // / debug flags (if present) and its initial state.
85- void statement_list_scanner_init ();
94+ int yystatement_listerror (
95+ statement_list_parsert &parser,
96+ void *scanner,
97+ const std::string &error);
8698
8799#endif // CPROVER_STATEMENT_LIST_STATEMENT_LIST_PARSER_H
0 commit comments