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

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

Issue 54303002: Experimental parser: some unit tests (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/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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 assert (TransitionKey.__lower_bound <= char and 63 assert (TransitionKey.__lower_bound <= char and
64 char <= TransitionKey.__latin_1_upper_bound) 64 char <= TransitionKey.__latin_1_upper_bound)
65 return TransitionKey.__create([(char, char)]) 65 return TransitionKey.__create([(char, char)])
66 66
67 @staticmethod 67 @staticmethod
68 def character_class(invert, graph): 68 def character_class(invert, graph):
69 # TODO 69 # TODO
70 return TransitionKey.__create([(129, 129)]) 70 return TransitionKey.__create([(129, 129)])
71 71
72 def matches_char(self, char): 72 def matches_char(self, char):
73 char = ord(char)
73 for r in self.__ranges: 74 for r in self.__ranges:
74 if r[0] <= char and char <= r[1]: return True 75 if r[0] <= char and char <= r[1]: return True
75 return False 76 return False
76 77
77 def matches_key(self, key): 78 def matches_key(self, key):
78 assert isinstance(key, self.__class__) 79 assert isinstance(key, self.__class__)
79 assert key != TransitionKey.epsilon() 80 assert key != TransitionKey.epsilon()
80 if self == key: return True 81 if self == key: return True
81 if self == TransitionKey.epsilon(): return False 82 if self == TransitionKey.epsilon(): return False
82 # TODO 83 # TODO
(...skipping 21 matching lines...) Expand all
104 return "epsilon" 105 return "epsilon"
105 if self == self.any(): 106 if self == self.any():
106 return "any" 107 return "any"
107 return ", ".join(TransitionKey.__print_range(x) for x in self.__ranges) 108 return ", ".join(TransitionKey.__print_range(x) for x in self.__ranges)
108 109
109 @staticmethod 110 @staticmethod
110 def merge_key_set(key_set): 111 def merge_key_set(key_set):
111 key_set -= set([TransitionKey.epsilon()]) 112 key_set -= set([TransitionKey.epsilon()])
112 # TODO need intersections and symmetric differences 113 # TODO need intersections and symmetric differences
113 return key_set 114 return key_set
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