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

Unified Diff: tools/lexer_generator/transition_keys.py

Issue 74713004: Experimental lexer generator: Clarify TransitionKeys.disjoint_keys. (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/transition_key_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/transition_keys.py
diff --git a/tools/lexer_generator/transition_keys.py b/tools/lexer_generator/transition_keys.py
index ba0d9db40cb615605929d0619f752d0326d7a60a..f2035d4f4aecd476898b7879c165663ac412fbaf 100644
--- a/tools/lexer_generator/transition_keys.py
+++ b/tools/lexer_generator/transition_keys.py
@@ -161,7 +161,7 @@ class TransitionKey:
already constructed aliases for character classes (they can be used in the
new character class). It is a map from strings (character class names) to
TransitionKeys. For example, graph might represent the character class
- [a-z:digit:] where 'digit' is a previously constructed characte class found
+ [a-z:digit:] where 'digit' is a previously constructed character class found
in "key_map".'''
ranges = []
assert graph[0] == 'CLASS' or graph[0] == 'NOT_CLASS'
@@ -316,7 +316,12 @@ class TransitionKey:
def disjoint_keys(key_set):
'''Takes a set of possibly overlapping TransitionKeys, returns a list of
TransitionKeys which don't overlap and whose union is the same as the union
- of the original key_set. key_set is a set of TransitionKeys.'''
+ of the original key_set. In addition, TransitionKeys are not merged, only
+ split.
+
+ For example, if key_set contains two TransitionKeys for ranges [1-10] and
+ [5-15], disjoint_keys returns a set of three TransitionKeys: [1-4], [5-10],
+ [11-16].'''
ranges = TransitionKey.__disjoint_ranges_from_key_set(key_set)
return map(lambda x : TransitionKey([x]), ranges)
« no previous file with comments | « tools/lexer_generator/transition_key_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698