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

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

Issue 63183007: Experimental parser: dfa minimization (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 24 matching lines...) Expand all
35 "literal" : (257, 257), 35 "literal" : (257, 257),
36 } 36 }
37 __lower_bound = 0 37 __lower_bound = 0
38 __upper_bound = reduce(lambda acc, (k, v): max(acc, v[1]), __class_bounds.item s(), 0) 38 __upper_bound = reduce(lambda acc, (k, v): max(acc, v[1]), __class_bounds.item s(), 0)
39 39
40 __cached_keys = {} 40 __cached_keys = {}
41 41
42 __unique_key_counter = -1 42 __unique_key_counter = -1
43 43
44 @staticmethod 44 @staticmethod
45 def alphabet_iter():
46 for k, (lower, upper) in TransitionKey.__class_bounds.items():
47 for i in range(lower, upper + 1):
48 yield i
49
50 @staticmethod
51 def __in_latin_1(char): 45 def __in_latin_1(char):
52 bound = TransitionKey.__class_bounds["latin_1"] 46 bound = TransitionKey.__class_bounds["latin_1"]
53 return (bound[0] <= char and char <= bound[1]) 47 return (bound[0] <= char and char <= bound[1])
54 48
55 @staticmethod 49 @staticmethod
56 def __is_class_range(r): 50 def __is_class_range(r):
57 return r[0] == r[1] and not TransitionKey.__in_latin_1(r[0]) 51 return r[0] == r[1] and not TransitionKey.__in_latin_1(r[0])
58 52
59 @staticmethod 53 @staticmethod
60 def __is_unique_range(r): 54 def __is_unique_range(r):
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 elif last[1] + 1 < r[0]: 330 elif last[1] + 1 < r[0]:
337 inverted.append((last[1] + 1, r[0] - 1)) 331 inverted.append((last[1] + 1, r[0] - 1))
338 last = r 332 last = r
339 upper_bound = latin_1[1] 333 upper_bound = latin_1[1]
340 if last == None: 334 if last == None:
341 inverted.append(latin_1) 335 inverted.append(latin_1)
342 elif last[1] < upper_bound: 336 elif last[1] < upper_bound:
343 inverted.append((last[1] + 1, upper_bound)) 337 inverted.append((last[1] + 1, upper_bound))
344 inverted += list(classes) 338 inverted += list(classes)
345 return inverted 339 return inverted
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