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

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

Issue 59953002: Experimental lexer generator: parse {} in regexps. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: rebased 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/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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 else: 188 else:
189 ranges.append((left, v)) 189 ranges.append((left, v))
190 left = v + 1 190 left = v + 1
191 if to_push: 191 if to_push:
192 current = range_map[i + 1] 192 current = range_map[i + 1]
193 range_map[i + 1] = (current[0], sort(current[1] + to_push)) 193 range_map[i + 1] = (current[0], sort(current[1] + to_push))
194 return ranges 194 return ranges
195 195
196 @staticmethod 196 @staticmethod
197 def disjoint_keys(key_set): 197 def disjoint_keys(key_set):
198 key_set.discard(TransitionKey.epsilon())
198 if not key_set: 199 if not key_set:
199 return [] 200 return []
200 range_map = {} 201 range_map = {}
201 for x in key_set: 202 for x in key_set:
202 for r in x.__ranges: 203 for r in x.__ranges:
203 if not r[0] in range_map: 204 if not r[0] in range_map:
204 range_map[r[0]] = [] 205 range_map[r[0]] = []
205 range_map[r[0]].append(r[1]) 206 range_map[r[0]].append(r[1])
206 ranges = TransitionKey.__disjoint_keys(range_map) 207 ranges = TransitionKey.__disjoint_keys(range_map)
207 TransitionKey.__verify_ranges(ranges, False) 208 TransitionKey.__verify_ranges(ranges, False)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 elif last[1] + 1 < r[0]: 263 elif last[1] + 1 < r[0]:
263 inverted.append((last[1] + 1, r[0] - 1)) 264 inverted.append((last[1] + 1, r[0] - 1))
264 last = r 265 last = r
265 if last != None and last[1] < TransitionKey.__latin_1_upper_bound: 266 if last != None and last[1] < TransitionKey.__latin_1_upper_bound:
266 inverted.append((last[1] + 1, TransitionKey.__latin_1_upper_bound)) 267 inverted.append((last[1] + 1, TransitionKey.__latin_1_upper_bound))
267 if not contains_whitespace: 268 if not contains_whitespace:
268 inverted.append(TransitionKey.__unicode_whitespace_bounds) 269 inverted.append(TransitionKey.__unicode_whitespace_bounds)
269 if not contains_literal: 270 if not contains_literal:
270 inverted.append(TransitionKey.__unicode_literal_bounds) 271 inverted.append(TransitionKey.__unicode_literal_bounds)
271 return inverted 272 return inverted
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