-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C and C++ parsers: 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. The C scanner is now fully reentrant.
- Loading branch information
1 parent
58f1ecb
commit f0501e4
Showing
15 changed files
with
759 additions
and
720 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,22 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include "c_storage_spec.h" | ||
|
||
ansi_c_parsert ansi_c_parser; | ||
int yyansi_clex_init_extra(ansi_c_parsert *, void **); | ||
int yyansi_clex_destroy(void *); | ||
int yyansi_cparse(ansi_c_parsert &, void *); | ||
void yyansi_cset_debug(int, void *); | ||
|
||
bool ansi_c_parsert::parse() | ||
{ | ||
void *scanner; | ||
yyansi_clex_init_extra(this, &scanner); | ||
#ifdef ANSI_C_DEBUG | ||
yyansi_cset_debug(1, scanner); | ||
#endif | ||
bool parse_fail = yyansi_cparse(*this, scanner) != 0; | ||
yyansi_clex_destroy(scanner); | ||
return parse_fail; | ||
} | ||
|
||
ansi_c_id_classt ansi_c_parsert::lookup( | ||
const irep_idt &base_name, | ||
|
@@ -73,14 +88,6 @@ void ansi_c_parsert::add_tag_with_body(irept &tag) | |
} | ||
} | ||
|
||
extern char *yyansi_ctext; | ||
|
||
int yyansi_cerror(const std::string &error) | ||
{ | ||
ansi_c_parser.parse_error(error, yyansi_ctext); | ||
return 0; | ||
} | ||
|
||
void ansi_c_parsert::add_declarator( | ||
exprt &declaration, | ||
irept &declarator) | ||
|
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 |
---|---|---|
|
@@ -18,15 +18,14 @@ Author: Daniel Kroening, [email protected] | |
#include "ansi_c_parse_tree.h" | ||
#include "ansi_c_scope.h" | ||
|
||
int yyansi_cparse(); | ||
|
||
class ansi_c_parsert:public parsert | ||
{ | ||
public: | ||
ansi_c_parse_treet parse_tree; | ||
|
||
ansi_c_parsert() | ||
: tag_following(false), | ||
explicit ansi_c_parsert(message_handlert &message_handler) | ||
: parsert(message_handler), | ||
tag_following(false), | ||
asm_block_following(false), | ||
parenthesis_counter(0), | ||
mode(modet::NONE), | ||
|
@@ -35,14 +34,14 @@ class ansi_c_parsert:public parsert | |
for_has_scope(false), | ||
ts_18661_3_Floatn_types(false) | ||
{ | ||
// set up global scope | ||
scopes.clear(); | ||
scopes.push_back(scopet()); | ||
} | ||
|
||
virtual bool parse() override | ||
{ | ||
return yyansi_cparse()!=0; | ||
} | ||
bool parse() override; | ||
|
||
virtual void clear() override | ||
void clear() override | ||
{ | ||
parsert::clear(); | ||
parse_tree.clear(); | ||
|
@@ -166,9 +165,4 @@ class ansi_c_parsert:public parsert | |
std::list<std::map<const irep_idt, bool>> pragma_cprover_stack; | ||
}; | ||
|
||
extern ansi_c_parsert ansi_c_parser; | ||
|
||
int yyansi_cerror(const std::string &error); | ||
void ansi_c_scanner_init(); | ||
|
||
#endif // CPROVER_ANSI_C_ANSI_C_PARSER_H |
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
Oops, something went wrong.