-
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.
JSIL front-end: make parser and lexer reentrant
This avoids hand-crafted init functions with possibly insufficient guards against reentrant use and also removes (file-local) global variables.
- Loading branch information
1 parent
09dca35
commit 800522a
Showing
4 changed files
with
155 additions
and
155 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,16 @@ Author: Michael Tautschnig, [email protected] | |
/// Jsil Language | ||
|
||
#include "jsil_parser.h" | ||
|
||
int yyjsillex_init_extra(jsil_parsert *, void **); | ||
int yyjsillex_destroy(void *); | ||
int yyjsilparse(jsil_parsert &, void *); | ||
|
||
bool jsil_parsert::parse() | ||
{ | ||
void *scanner; | ||
yyjsillex_init_extra(this, &scanner); | ||
bool parse_fail = yyjsilparse(*this, scanner) != 0; | ||
yyjsillex_destroy(scanner); | ||
return parse_fail; | ||
} |
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: Michael Tautschnig, [email protected] | |
|
||
#include "jsil_parse_tree.h" | ||
|
||
class jsil_parsert; | ||
int yyjsilparse(jsil_parsert &); | ||
void jsil_scanner_init(jsil_parsert &); | ||
|
||
class jsil_parsert:public parsert | ||
{ | ||
public: | ||
|
@@ -30,13 +26,9 @@ class jsil_parsert:public parsert | |
|
||
jsil_parse_treet parse_tree; | ||
|
||
virtual bool parse() override | ||
{ | ||
jsil_scanner_init(*this); | ||
return yyjsilparse(*this) != 0; | ||
} | ||
bool parse() override; | ||
|
||
virtual void clear() override | ||
void clear() override | ||
{ | ||
parsert::clear(); | ||
parse_tree.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
Oops, something went wrong.