-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
statement_list_parsert: construct with message handler
This both avoids an object of static lifetime as well as it fixes the (transitive) use of the deprecated messaget() constructor. Both the parser and lexer are now fully reentrant.
- Loading branch information
1 parent
09dca35
commit cb1f557
Showing
5 changed files
with
47 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,6 @@ Author: Matthias Weiss, [email protected] | |
#include <iostream> | ||
#include <iterator> | ||
|
||
statement_list_parsert statement_list_parser; | ||
|
||
extern char *yystatement_listtext; | ||
|
||
/// Searches for the name of the TIA module inside of its root | ||
/// expression. | ||
/// \param root: Expression that includes the element's name as a | ||
|
@@ -335,15 +331,23 @@ void statement_list_parsert::add_function(const exprt &function) | |
parse_tree.add_function(fn); | ||
} | ||
|
||
bool statement_list_parsert::parse() | ||
{ | ||
return yystatement_listparse() != 0; | ||
} | ||
int yystatement_listlex_init_extra(statement_list_parsert *, void **); | ||
int yystatement_listlex_destroy(void *); | ||
/// Defined in statement_list_y.tab.cpp. Main function for the parse process | ||
/// generated by bison, performs all necessary steps to fill the parse tree. | ||
int yystatement_listparse(statement_list_parsert &, void *); | ||
void yystatement_listset_debug(int, void *); | ||
|
||
int yystatement_listerror(const std::string &error) | ||
bool statement_list_parsert::parse() | ||
{ | ||
statement_list_parser.parse_error(error, yystatement_listtext); | ||
return 0; | ||
void *scanner; | ||
yystatement_listlex_init_extra(this, &scanner); | ||
#ifdef STATEMENT_LIST_DEBUG | ||
yystatement_listset_debug(1, scanner); | ||
#endif | ||
bool parse_fail = yystatement_listparse(*this, scanner) != 0; | ||
yystatement_listlex_destroy(scanner); | ||
return parse_fail; | ||
} | ||
|
||
void statement_list_parsert::clear() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,6 @@ Author: Matthias Weiss, [email protected] | |
|
||
#include "statement_list_parse_tree.h" | ||
|
||
/// Defined in statement_list_y.tab.cpp. Main function for the parse process | ||
/// generated by bison, performs all necessary steps to fill the parse tree. | ||
int yystatement_listparse(); | ||
|
||
/// Responsible for starting the parse process and to translate the result into | ||
/// a statement_list_parse_treet. This parser works by using the expression | ||
/// stack of its base class. During the parse process, expressions with | ||
|
@@ -34,6 +30,12 @@ int yystatement_listparse(); | |
class statement_list_parsert : public parsert | ||
{ | ||
public: | ||
/// Constructor | ||
explicit statement_list_parsert(message_handlert &message_handler) | ||
: parsert(message_handler) | ||
{ | ||
} | ||
|
||
/// Starts the parsing process and saves the result inside of this instance's | ||
/// parse tree. | ||
/// \return False if successful. | ||
|
@@ -71,17 +73,15 @@ class statement_list_parsert : public parsert | |
statement_list_parse_treet parse_tree; | ||
}; | ||
|
||
/// Instance of the parser, used by other modules. | ||
extern statement_list_parsert statement_list_parser; | ||
|
||
/// Forwards any errors that are encountered during the parse process. This | ||
/// function gets called by the generated files of flex and bison. | ||
/// \param parser: Parser object. | ||
/// \param scanner: Lexer state. | ||
/// \param error: Error message. | ||
/// \return Always 0. | ||
int yystatement_listerror(const std::string &error); | ||
|
||
/// Defined in scanner.l. This function initialises the scanner by setting | ||
/// debug flags (if present) and its initial state. | ||
void statement_list_scanner_init(); | ||
int yystatement_listerror( | ||
statement_list_parsert &parser, | ||
void *scanner, | ||
const std::string &error); | ||
|
||
#endif // CPROVER_STATEMENT_LIST_STATEMENT_LIST_PARSER_H |