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

Unified Diff: tools/lexer_generator/dfa.py

Issue 82983002: Experimental parser: KeyEncoding class added (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/lexer_generator/code_generator_test.py ('k') | tools/lexer_generator/generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/dfa.py
diff --git a/tools/lexer_generator/dfa.py b/tools/lexer_generator/dfa.py
index d389ab41f530cebfb6e74f6f989bd0b7ad671da4..b004e24d59ac9fbb766d12c1b8886126d6e4468b 100644
--- a/tools/lexer_generator/dfa.py
+++ b/tools/lexer_generator/dfa.py
@@ -78,8 +78,8 @@ class DfaState(AutomatonState):
class Dfa(Automaton):
- def __init__(self, start_name, mapping):
- super(Dfa, self).__init__()
+ def __init__(self, encoding, start_name, mapping):
+ super(Dfa, self).__init__(encoding)
self.__terminal_set = set()
name_map = {}
for name, node_data in mapping.items():
@@ -95,7 +95,7 @@ class Dfa(Automaton):
inversion[state] = []
inversion[state].append(key)
for state, keys in inversion.items():
- merged_key = TransitionKey.merged_key(keys)
+ merged_key = TransitionKey.merged_key(encoding, keys)
node.add_transition(merged_key, name_map[state])
self.__start = name_map[start_name]
self.__node_count = len(mapping)
@@ -223,7 +223,9 @@ class DfaMinimizer:
# TransitionKey [c-h], S1 and S3 cannot be in the same partition. This will
# become clear when we check the transition for TransitionKey [c-d] (S1 has
# a transition to S2, S3 has a transition to S4).
- self.__alphabet = list(TransitionKey.disjoint_keys(chain(*all_keys)))
+ encoding = self.__dfa.encoding()
+ self.__alphabet = list(
+ TransitionKey.disjoint_keys(encoding, chain(*all_keys)))
# For each state and each TransitionKey in the alphabet, find out which
# transition we take from the state with the TransitionKey.
@@ -388,4 +390,4 @@ class DfaMinimizer:
if new_partitions:
partitions |= new_partitions
(start_name, mapping) = self.__create_states_from_partitions(partitions)
- return Dfa(start_name, mapping)
+ return Dfa(self.__dfa.encoding(), start_name, mapping)
« no previous file with comments | « tools/lexer_generator/code_generator_test.py ('k') | tools/lexer_generator/generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698