Skip to content

Commit

Permalink
Merge pull request #8153 from tautschnig/cleanup/jsil-reentrant
Browse files Browse the repository at this point in the history
JSIL front-end: no need for parser reentrancy
  • Loading branch information
kroening authored Jan 11, 2024
2 parents 69bb2b6 + 6682802 commit 9d7eced
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/jsil/jsil_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ Author: Michael Tautschnig, [email protected]
/// Jsil Language

#include "jsil_parser.h"

int jsil_parsert::instance_count = 0;
17 changes: 15 additions & 2 deletions src/jsil/jsil_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,27 @@ class jsil_parsert:public parsert
explicit jsil_parsert(message_handlert &message_handler)
: parsert(message_handler)
{
// Simplistic check that we don't attempt to do reentrant parsing as the
// Bison-generated parser has global state.
PRECONDITION(++instance_count == 1);
}

jsil_parsert(const jsil_parsert &) = delete;

~jsil_parsert() override
{
--instance_count;
}

jsil_parse_treet parse_tree;

virtual bool parse() override
bool parse() override
{
jsil_scanner_init(*this);
return yyjsilparse(*this) != 0;
}

virtual void clear() override
void clear() override
{
parsert::clear();
parse_tree.clear();
Expand All @@ -47,6 +57,9 @@ class jsil_parsert:public parsert

// internal state of the scanner
std::string string_literal;

protected:
static int instance_count;
};

#endif // CPROVER_JSIL_JSIL_PARSER_H

0 comments on commit 9d7eced

Please sign in to comment.