summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2006-12-29 04:42:48 (GMT)
committerFred Drake <fdrake@acm.org>2006-12-29 04:42:48 (GMT)
commit34e4f52fea47567f51a9ce952b57ea29d6f64f3f (patch)
treeb7cc7980a7092a5b69f1f494082268782a452324 /Parser
parent3203bdc676ab94aab74753e46247e0fa91d1963e (diff)
downloadcpython-34e4f52fea47567f51a9ce952b57ea29d6f64f3f.zip
cpython-34e4f52fea47567f51a9ce952b57ea29d6f64f3f.tar.gz
cpython-34e4f52fea47567f51a9ce952b57ea29d6f64f3f.tar.bz2
avoid dict.has_key, since this might get used by a Py3K built in the
working copy
Diffstat (limited to 'Parser')
-rw-r--r--Parser/asdl.py2
-rw-r--r--Parser/spark.py28
2 files changed, 15 insertions, 15 deletions
diff --git a/Parser/asdl.py b/Parser/asdl.py
index d6f5ec5..08dc848 100644
--- a/Parser/asdl.py
+++ b/Parser/asdl.py
@@ -373,7 +373,7 @@ def check(mod):
v.visit(mod)
for t in v.types:
- if not mod.types.has_key(t) and not t in builtin_types:
+ if t not in mod.types and not t in builtin_types:
v.errors += 1
uses = ", ".join(v.types[t])
print "Undefined type %s, used in %s" % (t, uses)
diff --git a/Parser/spark.py b/Parser/spark.py
index 2c18623..0b3292f 100644
--- a/Parser/spark.py
+++ b/Parser/spark.py
@@ -31,7 +31,7 @@ def _namelist(instance):
for b in c.__bases__:
classlist.append(b)
for name in c.__dict__.keys():
- if not namedict.has_key(name):
+ if name not in namedict:
namelist.append(name)
namedict[name] = 1
return namelist
@@ -73,7 +73,7 @@ class GenericScanner:
groups = m.groups()
for i in range(len(groups)):
- if groups[i] and self.index2func.has_key(i):
+ if groups[i] and i in self.index2func:
self.index2func[i](groups[i])
pos = m.end()
@@ -141,7 +141,7 @@ class GenericParser:
for k, v in self.edges.items():
if v is None:
state, sym = k
- if self.states.has_key(state):
+ if state in self.states:
self.goto(state, sym)
changes = 1
rv = self.__dict__.copy()
@@ -188,7 +188,7 @@ class GenericParser:
if _preprocess:
rule, fn = self.preprocess(rule, func)
- if self.rules.has_key(lhs):
+ if lhs in self.rules:
self.rules[lhs].append(rule)
else:
self.rules[lhs] = [ rule ]
@@ -226,7 +226,7 @@ class GenericParser:
# grammars.
#
for sym in rhs:
- if not self.rules.has_key(sym):
+ if sym not in self.rules:
break
else:
tbd.append(rule)
@@ -269,7 +269,7 @@ class GenericParser:
n = len(rhs)
while i < n:
sym = rhs[i]
- if not self.rules.has_key(sym) or \
+ if sym not in self.rules or \
not self.nullable[sym]:
candidate = 0
i = i + 1
@@ -286,7 +286,7 @@ class GenericParser:
if candidate:
lhs = self._NULLABLE+lhs
rule = (lhs, rhs)
- if self.newrules.has_key(lhs):
+ if lhs in self.newrules:
self.newrules[lhs].append(rule)
else:
self.newrules[lhs] = [ rule ]
@@ -365,7 +365,7 @@ class GenericParser:
core.sort()
tcore = tuple(core)
- if self.cores.has_key(tcore):
+ if tcore in self.cores:
return self.cores[tcore]
#
# Nope, doesn't exist. Compute it and the associated
@@ -389,13 +389,13 @@ class GenericParser:
nextSym = rhs[pos]
key = (X.stateno, nextSym)
- if not rules.has_key(nextSym):
- if not edges.has_key(key):
+ if nextSym not in rules:
+ if key not in edges:
edges[key] = None
X.T.append(nextSym)
else:
edges[key] = None
- if not predicted.has_key(nextSym):
+ if nextSym not in predicted:
predicted[nextSym] = 1
for prule in rules[nextSym]:
ppos = self.skip(prule)
@@ -422,7 +422,7 @@ class GenericParser:
core = predicted.keys()
core.sort()
tcore = tuple(core)
- if self.cores.has_key(tcore):
+ if tcore in self.cores:
self.edges[(k, None)] = self.cores[tcore]
return k
@@ -433,7 +433,7 @@ class GenericParser:
def goto(self, state, sym):
key = (state, sym)
- if not self.edges.has_key(key):
+ if key not in self.edges:
#
# No transitions from state on sym.
#
@@ -631,7 +631,7 @@ class GenericParser:
for i in range(len(rhs)-1, -1, -1):
sym = rhs[i]
- if not self.newrules.has_key(sym):
+ if sym not in self.newrules:
if sym != self._BOF:
attr[i] = tokens[k-1]
key = (item, k)