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

Unified Diff: tools/lexer_generator/action_test.py

Issue 62103017: Experimental parser: rule grammar refactor (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 | « src/lexer/lexer_py.re ('k') | tools/lexer_generator/automaton.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/action_test.py
diff --git a/tools/lexer_generator/action_test.py b/tools/lexer_generator/action_test.py
index d89254b6210d3adb34d7c0d41f08fe035a4363bb..64f63701b02eccfa36d912c828ebaf66adab859b 100644
--- a/tools/lexer_generator/action_test.py
+++ b/tools/lexer_generator/action_test.py
@@ -40,15 +40,16 @@ def process_rules(rules):
class ActionTestCase(unittest.TestCase):
def __verify_last_action(self, automata, string, expected_code):
+ expected_code = (expected_code, None)
for automaton in [automata.dfa(), automata.minimal_dfa()]:
actions = list(automaton.collect_actions(string))
self.assertEqual(actions[-1], Action('TERMINATE'))
- self.assertEqual(actions[-2].data(), expected_code)
+ self.assertEqual(actions[-2].match_action(), expected_code)
def test_action_precedence(self):
- rules = '''<default>
- "key" { KEYWORD } <<break>>
- /[a-z]+/ { ID } <<break>>'''
+ rules = '''<<default>>
+ "key" <|KEYWORD|>
+ /[a-z]+/ <|ID|>'''
automata_for_conditions = process_rules(rules)
self.assertEqual(len(automata_for_conditions), 1)
self.assertTrue('default' in automata_for_conditions)
@@ -61,9 +62,9 @@ class ActionTestCase(unittest.TestCase):
self.__verify_last_action(automata, 'keys', 'ID')
def test_wrong_action_precedence(self):
- rules = '''<default>
- /[a-z]+/ { ID } <<break>>
- "key" { KEYWORD } <<break>>'''
+ rules = '''<<default>>
+ /[a-z]+/ <|ID|>
+ "key" <|KEYWORD|>'''
automata_for_conditions = process_rules(rules)
self.assertEqual(len(automata_for_conditions), 1)
self.assertTrue('default' in automata_for_conditions)
« no previous file with comments | « src/lexer/lexer_py.re ('k') | tools/lexer_generator/automaton.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698