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

Side by Side Diff: tools/lexer_generator/rule_parser_test.py

Issue 64213002: Experimental parser: some cleanup and assertions for rule_parser (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/lexer_generator/rule_parser.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 the V8 project authors. All rights reserved. 1 # Copyright 2013 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 26 matching lines...) Expand all
37 def parse(self, string): 37 def parse(self, string):
38 return self.state.parse(string) 38 return self.state.parse(string)
39 39
40 def test_basic(self): 40 def test_basic(self):
41 self.parse(''' 41 self.parse('''
42 alias = /regex/; 42 alias = /regex/;
43 <cond1> /regex/ <<cond2>> 43 <cond1> /regex/ <<cond2>>
44 <cond1> alias <<cond2>> 44 <cond1> alias <<cond2>>
45 <cond2> /regex/ {body} 45 <cond2> /regex/ {body}
46 <cond2> alias {body} 46 <cond2> alias {body}
47 <cond3> /regex/ {body} <<cond4>> 47 <cond3> /regex/ {body} <<cond1>>
48 <cond3> alias {body} <<cond4>>''') 48 <cond3> alias {body} <<cond1>>''')
49 49
50 self.assertTrue(len(self.state.aliases), 1) 50 self.assertTrue(len(self.state.aliases), 1)
51 self.assertTrue('alias' in self.state.aliases) 51 self.assertTrue('alias' in self.state.aliases)
52 self.assertEquals(self.state.aliases['alias'], RegexParser.parse('regex')) 52 self.assertEquals(self.state.aliases['alias'], RegexParser.parse('regex'))
53 53
54 self.assertTrue(len(self.state.rules), 2) 54 self.assertTrue(len(self.state.rules), 2)
55 self.assertTrue('cond1' in self.state.rules) 55 self.assertTrue('cond1' in self.state.rules)
56 self.assertEquals(len(self.state.rules['cond1']), 2) 56 self.assertEquals(len(self.state.rules['cond1']), 2)
57 # self.assertTrue('regex2' in self.state.rules['cond1']) 57 # self.assertTrue('regex2' in self.state.rules['cond1'])
58 # self.assertEquals(self.state.rules['cond1']['regex2'], 58 # self.assertEquals(self.state.rules['cond1']['regex2'],
(...skipping 30 matching lines...) Expand all
89 self.parse('<cond> "regex" { if (foo) { bar } }') 89 self.parse('<cond> "regex" { if (foo) { bar } }')
90 # self.assertEquals( 90 # self.assertEquals(
91 # self.parse['cond']['regex'], 91 # self.parse['cond']['regex'],
92 # ('body', 'if (foo) { bar }')) 92 # ('body', 'if (foo) { bar }'))
93 93
94 def test_regexp_with_count(self): 94 def test_regexp_with_count(self):
95 self.parse('<cond> /regex{1,3}/ { if (foo) { bar } }') 95 self.parse('<cond> /regex{1,3}/ { if (foo) { bar } }')
96 # self.assertEquals( 96 # self.assertEquals(
97 # self.parse['cond']['regex{1,3}'], 97 # self.parse['cond']['regex{1,3}'],
98 # ('body', 'if (foo) { bar }')) 98 # ('body', 'if (foo) { bar }'))
OLDNEW
« no previous file with comments | « tools/lexer_generator/rule_parser.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698