| OLD | NEW |
| 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 25 matching lines...) Expand all Loading... |
| 36 self.__operation_map = {} | 36 self.__operation_map = {} |
| 37 self.__members = getmembers(self) | 37 self.__members = getmembers(self) |
| 38 self.__character_classes = {} | 38 self.__character_classes = {} |
| 39 self.__states = [] | 39 self.__states = [] |
| 40 | 40 |
| 41 def set_character_classes(self, classes): | 41 def set_character_classes(self, classes): |
| 42 self.__character_classes = classes | 42 self.__character_classes = classes |
| 43 | 43 |
| 44 def __new_state(self): | 44 def __new_state(self): |
| 45 self.__node_number += 1 | 45 self.__node_number += 1 |
| 46 return NfaState(self.__node_number - 1) | 46 return NfaState() |
| 47 | 47 |
| 48 def __or(self, graph): | 48 def __or(self, graph): |
| 49 start = self.__new_state() | 49 start = self.__new_state() |
| 50 ends = [] | 50 ends = [] |
| 51 for x in [self.__process(graph[1]), self.__process(graph[2])]: | 51 for x in [self.__process(graph[1]), self.__process(graph[2])]: |
| 52 start.add_epsilon_transition(x[0]) | 52 start.add_epsilon_transition(x[0]) |
| 53 ends += x[1] | 53 ends += x[1] |
| 54 start.close(None) | 54 start.close(None) |
| 55 return (start, ends) | 55 return (start, ends) |
| 56 | 56 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 275 |
| 276 __modifer_map = { | 276 __modifer_map = { |
| 277 '+': 'ONE_OR_MORE', | 277 '+': 'ONE_OR_MORE', |
| 278 '?': 'ZERO_OR_ONE', | 278 '?': 'ZERO_OR_ONE', |
| 279 '*': 'ZERO_OR_MORE', | 279 '*': 'ZERO_OR_MORE', |
| 280 } | 280 } |
| 281 | 281 |
| 282 @staticmethod | 282 @staticmethod |
| 283 def apply_modifier(modifier, graph): | 283 def apply_modifier(modifier, graph): |
| 284 return (NfaBuilder.__modifer_map[modifier], graph) | 284 return (NfaBuilder.__modifer_map[modifier], graph) |
| OLD | NEW |