Skip to content

Commit 9d7eced

Browse files
authored
Merge pull request #8153 from tautschnig/cleanup/jsil-reentrant
JSIL front-end: no need for parser reentrancy
2 parents 69bb2b6 + 6682802 commit 9d7eced

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/jsil/jsil_parser.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ Author: Michael Tautschnig, [email protected]
1010
/// Jsil Language
1111

1212
#include "jsil_parser.h"
13+
14+
int jsil_parsert::instance_count = 0;

src/jsil/jsil_parser.h

+15-2
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,27 @@ class jsil_parsert:public parsert
2626
explicit jsil_parsert(message_handlert &message_handler)
2727
: parsert(message_handler)
2828
{
29+
// Simplistic check that we don't attempt to do reentrant parsing as the
30+
// Bison-generated parser has global state.
31+
PRECONDITION(++instance_count == 1);
32+
}
33+
34+
jsil_parsert(const jsil_parsert &) = delete;
35+
36+
~jsil_parsert() override
37+
{
38+
--instance_count;
2939
}
3040

3141
jsil_parse_treet parse_tree;
3242

33-
virtual bool parse() override
43+
bool parse() override
3444
{
3545
jsil_scanner_init(*this);
3646
return yyjsilparse(*this) != 0;
3747
}
3848

39-
virtual void clear() override
49+
void clear() override
4050
{
4151
parsert::clear();
4252
parse_tree.clear();
@@ -47,6 +57,9 @@ class jsil_parsert:public parsert
4757

4858
// internal state of the scanner
4959
std::string string_literal;
60+
61+
protected:
62+
static int instance_count;
5063
};
5164

5265
#endif // CPROVER_JSIL_JSIL_PARSER_H

0 commit comments

Comments
 (0)