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

Unified Diff: tools/lexer_generator/lexer_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 | « tools/lexer_generator/dfa.py ('k') | tools/lexer_generator/rule_lexer.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/lexer_test.py
diff --git a/tools/lexer_generator/lexer_test.py b/tools/lexer_generator/lexer_test.py
index cb2fa41da7af8d5ad8ac66d898b3b35d585b9ddf..cd65207ce5d26ac867a61656a04224514b219039 100644
--- a/tools/lexer_generator/lexer_test.py
+++ b/tools/lexer_generator/lexer_test.py
@@ -32,8 +32,8 @@ from rule_parser import RuleProcessor
class LexerTestCase(unittest.TestCase):
def __verify_action_stream(self, rules, string, expected):
- expected = map(lambda (action, s) : (Action('code', action), s), expected)
- expected.append((Action('terminate'), '\0'))
+ expected = map(lambda (action, s) : (Action(None, (action, None)), s), expected)
+ expected.append((Action(None, ('terminate', None)), '\0'))
automata = RuleProcessor.parse(rules).default_automata()
for automaton in [automata.dfa(), automata.minimal_dfa()]:
for i, (action, start, stop) in enumerate(automaton.lex(string)):
@@ -42,12 +42,12 @@ class LexerTestCase(unittest.TestCase):
def test_simple(self):
rules = '''
- <default>
- "(" { LBRACE }
- ")" { RBRACE }
+ <<default>>
+ "(" <|LBRACE|>
+ ")" <|RBRACE|>
- "foo" { FOO }
- eof <<terminate>>'''
+ "foo" <|FOO|>
+ eof <|terminate|>'''
string = 'foo()\0'
self.__verify_action_stream(rules, string,
@@ -55,11 +55,11 @@ class LexerTestCase(unittest.TestCase):
def test_maximal_matching(self):
rules = '''
- <default>
- "<" { LT }
- "<<" { SHL }
- " " { SPACE }
- eof <<terminate>>'''
+ <<default>>
+ "<" <|LT|>
+ "<<" <|SHL|>
+ " " <|SPACE|>
+ eof <|terminate|>'''
string = '<< <\0'
self.__verify_action_stream(rules, string,
@@ -69,9 +69,9 @@ class LexerTestCase(unittest.TestCase):
rules = '''
digit = [0-9];
number = (digit+ ("." digit+)?);
- <default>
- number { NUMBER }
- eof <<terminate>>'''
+ <<default>>
+ number <|NUMBER|>
+ eof <|terminate|>'''
string = '555\0'
self.__verify_action_stream(rules, string, [('NUMBER', '555')])
« no previous file with comments | « tools/lexer_generator/dfa.py ('k') | tools/lexer_generator/rule_lexer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698