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

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

Issue 157013003: Experimental parser: cleanup RegexParser (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 10 months 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/regex_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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 name = '__' + name 181 name = '__' + name
182 return TransitionKey.__cached_key(None, name, get_bounds) 182 return TransitionKey.__cached_key(None, name, get_bounds)
183 183
184 @staticmethod 184 @staticmethod
185 def __process_term(encoding, term, ranges, key_map): 185 def __process_term(encoding, term, ranges, key_map):
186 key = term.name() 186 key = term.name()
187 args = term.args() 187 args = term.args()
188 if key == 'RANGE': 188 if key == 'RANGE':
189 ranges.append((ord(args[0]), ord(args[1]))) 189 ranges.append((ord(args[0]), ord(args[1])))
190 elif key == 'LITERAL': 190 elif key == 'LITERAL':
191 ranges.append((ord(args[0]), ord(args[0]))) 191 for char in args[0]:
192 ranges.append((ord(char), ord(char)))
192 elif key == 'CAT': 193 elif key == 'CAT':
193 for x in [args[0], args[1]]: 194 for x in args:
194 TransitionKey.__process_term(encoding, x, ranges, key_map) 195 TransitionKey.__process_term(encoding, x, ranges, key_map)
195 elif key == 'CHARACTER_CLASS': 196 elif key == 'CHARACTER_CLASS':
196 class_name = args[0] 197 class_name = args[0]
197 if encoding.class_range(class_name): 198 if encoding.class_range(class_name):
198 r = encoding.class_range(class_name) 199 r = encoding.class_range(class_name)
199 if class_name in key_map: 200 if class_name in key_map:
200 assert key_map[class_name] == TransitionKey(encoding, [r]) 201 assert key_map[class_name] == TransitionKey(encoding, [r])
201 ranges.append(r) 202 ranges.append(r)
202 elif encoding.predefined_range_iter(class_name): 203 elif encoding.predefined_range_iter(class_name):
203 rs = list(encoding.predefined_range_iter(class_name)) 204 rs = list(encoding.predefined_range_iter(class_name))
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 self.class_range('non_primary_whitespace')]) 535 self.class_range('non_primary_whitespace')])
535 self.add_predefined_range( 536 self.add_predefined_range(
536 'letter', [(65, 90), (97, 122), self.class_range('non_primary_letter')]) 537 'letter', [(65, 90), (97, 122), self.class_range('non_primary_letter')])
537 self.add_predefined_range( 538 self.add_predefined_range(
538 'line_terminator', 539 'line_terminator',
539 [(10, 10), (13, 13), self.class_range('non_primary_line_terminator')]) 540 [(10, 10), (13, 13), self.class_range('non_primary_line_terminator')])
540 self.add_predefined_range( 541 self.add_predefined_range(
541 'identifier_part_not_letter', 542 'identifier_part_not_letter',
542 [(48, 57), (95, 95), 543 [(48, 57), (95, 95),
543 self.class_range('non_primary_identifier_part_not_letter')]) 544 self.class_range('non_primary_identifier_part_not_letter')])
OLDNEW
« no previous file with comments | « tools/lexer_generator/regex_parser.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698