Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Unified Diff: tools/lexer_generator/rule_parser.py

Issue 64053002: Experimental parser: fixup unit tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/lexer_generator/regex_parser.py ('k') | tools/lexer_generator/rule_parser_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/rule_parser.py
diff --git a/tools/lexer_generator/rule_parser.py b/tools/lexer_generator/rule_parser.py
index 9dc0b4e9672f14e89e71e797c3c075c80e517361..a616fec33d1c2faa49c833e85cf83b94b11f5003 100644
--- a/tools/lexer_generator/rule_parser.py
+++ b/tools/lexer_generator/rule_parser.py
@@ -179,7 +179,7 @@ class RuleParser:
'empty :'
def p_error(self, p):
- raise Exception("Syntax error in input '%s'" % p)
+ raise Exception("Syntax error in input '%s'" % str(p))
def build(self, **kwargs):
self.parser = yacc.yacc(module=self, debug=0, write_tables=0, **kwargs)
@@ -189,10 +189,15 @@ class RuleParser:
__static_instance = None
@staticmethod
def parse(data, parser_state):
- if not RuleParser.__static_instance:
- RuleParser.__static_instance = RuleParser()
- RuleParser.__static_instance.build()
parser = RuleParser.__static_instance
+ if not parser:
+ parser = RuleParser()
+ parser.build()
+ RuleParser.__static_instance = parser
parser.__state = parser_state
- parser.parser.parse(data, lexer=parser.lexer.lexer)
+ try:
+ parser.parser.parse(data, lexer=parser.lexer.lexer)
+ except Exception as e:
+ RuleParser.__static_instance = None
+ raise e
parser.__state = None
« no previous file with comments | « tools/lexer_generator/regex_parser.py ('k') | tools/lexer_generator/rule_parser_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698