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

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

Issue 209473005: Experimental parser: dfa path iteration test (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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/generator.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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 other_keys = sorted(other_keys, cmp=TransitionKey.__component_compare) 418 other_keys = sorted(other_keys, cmp=TransitionKey.__component_compare)
419 range_terms = map( 419 range_terms = map(
420 lambda x : encoding.numeric_range_term(x[0], x[1]), ranges) 420 lambda x : encoding.numeric_range_term(x[0], x[1]), ranges)
421 return chain(iter(range_terms), iter(other_keys)) 421 return chain(iter(range_terms), iter(other_keys))
422 422
423 @staticmethod 423 @staticmethod
424 def __key_from_components(encoding, invert, components): 424 def __key_from_components(encoding, invert, components):
425 components = TransitionKey.__disjoint_components(encoding, components, True) 425 components = TransitionKey.__disjoint_components(encoding, components, True)
426 if invert: 426 if invert:
427 components = TransitionKey.__invert_components(encoding, components) 427 components = TransitionKey.__invert_components(encoding, components)
428 components = list(components) # must materialize for compare below
428 return None if not components else TransitionKey(encoding, components) 429 return None if not components else TransitionKey(encoding, components)
429 430
430 @staticmethod 431 @staticmethod
431 def disjoint_keys(encoding, keys): 432 def disjoint_keys(encoding, keys):
432 '''Takes a set of possibly overlapping TransitionKeys, returns a list of 433 '''Takes a set of possibly overlapping TransitionKeys, returns a list of
433 TransitionKeys which don't overlap and whose union is the same as the union 434 TransitionKeys which don't overlap and whose union is the same as the union
434 of the original key_set. In addition, TransitionKeys are not merged, only 435 of the original key_set. In addition, TransitionKeys are not merged, only
435 split. 436 split.
436 437
437 For example, if key_set contains two TransitionKeys for ranges [1-10] and 438 For example, if key_set contains two TransitionKeys for ranges [1-10] and
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 yield key(last[1] + 1, r[0] - 1) 475 yield key(last[1] + 1, r[0] - 1)
475 last = r 476 last = r
476 upper_bound = encoding.primary_range()[1] 477 upper_bound = encoding.primary_range()[1]
477 if last == None: 478 if last == None:
478 r = encoding.primary_range() 479 r = encoding.primary_range()
479 yield key(r[0], r[1]) 480 yield key(r[0], r[1])
480 elif last[1] < upper_bound: 481 elif last[1] < upper_bound:
481 yield key(last[1] + 1, upper_bound) 482 yield key(last[1] + 1, upper_bound)
482 for c in sorted(classes, TransitionKey.__component_compare): 483 for c in sorted(classes, TransitionKey.__component_compare):
483 yield c 484 yield c
OLDNEW
« no previous file with comments | « tools/lexer_generator/generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698