diff options
author | Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org> | 2016-09-08 00:46:26 +0000 |
---|---|---|
committer | Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org> | 2016-09-08 00:46:26 +0000 |
commit | 0c578d62fce2b98ee4e3be1e171569a67fe56178 (patch) | |
tree | a39ae918d07825ec196ff03c80a971ab70d0e5d8 /Lib/lib2to3/pgen2/pgen.py | |
parent | ef37dfcd841bc1565a3e40bbcd0f5354aa150965 (diff) | |
parent | dd1c638b92ae1552207451c82ed95aa2c1f07201 (diff) | |
download | cpython-git-0c578d62fce2b98ee4e3be1e171569a67fe56178.tar.gz |
lib2to3.pgen3.driver.load_grammar() now creates a stable cache file
between runs given the same Grammar.txt input regardless of the hash
randomization setting.
Diffstat (limited to 'Lib/lib2to3/pgen2/pgen.py')
-rw-r--r-- | Lib/lib2to3/pgen2/pgen.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/lib2to3/pgen2/pgen.py b/Lib/lib2to3/pgen2/pgen.py index 2c51eef913..b0cbd16c4d 100644 --- a/Lib/lib2to3/pgen2/pgen.py +++ b/Lib/lib2to3/pgen2/pgen.py @@ -39,7 +39,7 @@ class ParserGenerator(object): states = [] for state in dfa: arcs = [] - for label, next in state.arcs.items(): + for label, next in sorted(state.arcs.items()): arcs.append((self.make_label(c, label), dfa.index(next))) if state.isfinal: arcs.append((0, dfa.index(state))) @@ -52,7 +52,7 @@ class ParserGenerator(object): def make_first(self, c, name): rawfirst = self.first[name] first = {} - for label in rawfirst: + for label in sorted(rawfirst): ilabel = self.make_label(c, label) ##assert ilabel not in first # XXX failed on <> ... != first[ilabel] = 1 @@ -192,7 +192,7 @@ class ParserGenerator(object): for label, next in nfastate.arcs: if label is not None: addclosure(next, arcs.setdefault(label, {})) - for label, nfaset in arcs.items(): + for label, nfaset in sorted(arcs.items()): for st in states: if st.nfaset == nfaset: break @@ -222,7 +222,7 @@ class ParserGenerator(object): print("Dump of DFA for", name) for i, state in enumerate(dfa): print(" State", i, state.isfinal and "(final)" or "") - for label, next in state.arcs.items(): + for label, next in sorted(state.arcs.items()): print(" %s -> %d" % (label, dfa.index(next))) def simplify_dfa(self, dfa): |