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

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

Issue 159853009: Experimental parser: split off dot processing (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/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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 elif component.name() == 'NAMED_RANGE_KEY': 234 elif component.name() == 'NAMED_RANGE_KEY':
235 return component.args()[0] 235 return component.args()[0]
236 elif component.name() == 'EPSILON_KEY': 236 elif component.name() == 'EPSILON_KEY':
237 return 'epsilon' 237 return 'epsilon'
238 elif component.name() == 'OMEGA_KEY': 238 elif component.name() == 'OMEGA_KEY':
239 return 'omega' 239 return 'omega'
240 elif component.name() == 'NUMERIC_RANGE_KEY': 240 elif component.name() == 'NUMERIC_RANGE_KEY':
241 r = component.args() 241 r = component.args()
242 to_str = lambda x: KeyEncoding.to_str(encoding, x) 242 to_str = lambda x: KeyEncoding.to_str(encoding, x)
243 if r[0] == r[1]: 243 if r[0] == r[1]:
244 return '%s' % to_str(r[0]) 244 return "'%s'" % to_str(r[0])
245 return '[%s-%s]' % (to_str(r[0]), to_str(r[1])) 245 return "['%s'-'%s']" % (to_str(r[0]), to_str(r[1]))
246 raise Exception('unprintable %s' % component) 246 raise Exception('unprintable %s' % component)
247 247
248 def __flatten(self): 248 def __flatten(self):
249 return self.__flatten_components([self.__term]) 249 return self.__flatten_components([self.__term])
250 250
251 @staticmethod 251 @staticmethod
252 def __flatten_components(components): 252 def __flatten_components(components):
253 for component in components: 253 for component in components:
254 if component.name() != 'COMPOSITE_KEY': 254 if component.name() != 'COMPOSITE_KEY':
255 yield component 255 yield component
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 yield key(last[1] + 1, r[0] - 1) 465 yield key(last[1] + 1, r[0] - 1)
466 last = r 466 last = r
467 upper_bound = encoding.primary_range()[1] 467 upper_bound = encoding.primary_range()[1]
468 if last == None: 468 if last == None:
469 r = encoding.primary_range() 469 r = encoding.primary_range()
470 yield key(r[0], r[1]) 470 yield key(r[0], r[1])
471 elif last[1] < upper_bound: 471 elif last[1] < upper_bound:
472 yield key(last[1] + 1, upper_bound) 472 yield key(last[1] + 1, upper_bound)
473 for c in sorted(classes, TransitionKey.__component_compare): 473 for c in sorted(classes, TransitionKey.__component_compare):
474 yield c 474 yield c
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