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

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

Issue 71313002: Experimental parser: action refactor (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/nfa.py ('k') | tools/lexer_generator/rule_parser.py » ('j') | 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 25 matching lines...) Expand all
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
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)
OLDNEW
« no previous file with comments | « tools/lexer_generator/nfa.py ('k') | tools/lexer_generator/rule_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698