summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/pgen2/pgen.py
diff options
context:
space:
mode:
authorGregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org>2016-09-08 00:40:07 (GMT)
committerGregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org>2016-09-08 00:40:07 (GMT)
commitdd1c638b92ae1552207451c82ed95aa2c1f07201 (patch)
tree17c9785172126ca63631dc9207380ff7ac583671 /Lib/lib2to3/pgen2/pgen.py
parentd61910c598876788c9b4bf0e116370bbfc5a2f85 (diff)
downloadcpython-dd1c638b92ae1552207451c82ed95aa2c1f07201.zip
cpython-dd1c638b92ae1552207451c82ed95aa2c1f07201.tar.gz
cpython-dd1c638b92ae1552207451c82ed95aa2c1f07201.tar.bz2
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.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/lib2to3/pgen2/pgen.py b/Lib/lib2to3/pgen2/pgen.py
index 2c51eef..b0cbd16 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):