avoid dict.has_key, since this might get used by a Py3K built in the
working copy
This commit is contained in:
parent
3203bdc676
commit
34e4f52fea
|
@ -373,7 +373,7 @@ def check(mod):
|
||||||
v.visit(mod)
|
v.visit(mod)
|
||||||
|
|
||||||
for t in v.types:
|
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
|
v.errors += 1
|
||||||
uses = ", ".join(v.types[t])
|
uses = ", ".join(v.types[t])
|
||||||
print "Undefined type %s, used in %s" % (t, uses)
|
print "Undefined type %s, used in %s" % (t, uses)
|
||||||
|
|
|
@ -31,7 +31,7 @@ def _namelist(instance):
|
||||||
for b in c.__bases__:
|
for b in c.__bases__:
|
||||||
classlist.append(b)
|
classlist.append(b)
|
||||||
for name in c.__dict__.keys():
|
for name in c.__dict__.keys():
|
||||||
if not namedict.has_key(name):
|
if name not in namedict:
|
||||||
namelist.append(name)
|
namelist.append(name)
|
||||||
namedict[name] = 1
|
namedict[name] = 1
|
||||||
return namelist
|
return namelist
|
||||||
|
@ -73,7 +73,7 @@ class GenericScanner:
|
||||||
|
|
||||||
groups = m.groups()
|
groups = m.groups()
|
||||||
for i in range(len(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])
|
self.index2func[i](groups[i])
|
||||||
pos = m.end()
|
pos = m.end()
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ class GenericParser:
|
||||||
for k, v in self.edges.items():
|
for k, v in self.edges.items():
|
||||||
if v is None:
|
if v is None:
|
||||||
state, sym = k
|
state, sym = k
|
||||||
if self.states.has_key(state):
|
if state in self.states:
|
||||||
self.goto(state, sym)
|
self.goto(state, sym)
|
||||||
changes = 1
|
changes = 1
|
||||||
rv = self.__dict__.copy()
|
rv = self.__dict__.copy()
|
||||||
|
@ -188,7 +188,7 @@ class GenericParser:
|
||||||
if _preprocess:
|
if _preprocess:
|
||||||
rule, fn = self.preprocess(rule, func)
|
rule, fn = self.preprocess(rule, func)
|
||||||
|
|
||||||
if self.rules.has_key(lhs):
|
if lhs in self.rules:
|
||||||
self.rules[lhs].append(rule)
|
self.rules[lhs].append(rule)
|
||||||
else:
|
else:
|
||||||
self.rules[lhs] = [ rule ]
|
self.rules[lhs] = [ rule ]
|
||||||
|
@ -226,7 +226,7 @@ class GenericParser:
|
||||||
# grammars.
|
# grammars.
|
||||||
#
|
#
|
||||||
for sym in rhs:
|
for sym in rhs:
|
||||||
if not self.rules.has_key(sym):
|
if sym not in self.rules:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
tbd.append(rule)
|
tbd.append(rule)
|
||||||
|
@ -269,7 +269,7 @@ class GenericParser:
|
||||||
n = len(rhs)
|
n = len(rhs)
|
||||||
while i < n:
|
while i < n:
|
||||||
sym = rhs[i]
|
sym = rhs[i]
|
||||||
if not self.rules.has_key(sym) or \
|
if sym not in self.rules or \
|
||||||
not self.nullable[sym]:
|
not self.nullable[sym]:
|
||||||
candidate = 0
|
candidate = 0
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
@ -286,7 +286,7 @@ class GenericParser:
|
||||||
if candidate:
|
if candidate:
|
||||||
lhs = self._NULLABLE+lhs
|
lhs = self._NULLABLE+lhs
|
||||||
rule = (lhs, rhs)
|
rule = (lhs, rhs)
|
||||||
if self.newrules.has_key(lhs):
|
if lhs in self.newrules:
|
||||||
self.newrules[lhs].append(rule)
|
self.newrules[lhs].append(rule)
|
||||||
else:
|
else:
|
||||||
self.newrules[lhs] = [ rule ]
|
self.newrules[lhs] = [ rule ]
|
||||||
|
@ -365,7 +365,7 @@ class GenericParser:
|
||||||
|
|
||||||
core.sort()
|
core.sort()
|
||||||
tcore = tuple(core)
|
tcore = tuple(core)
|
||||||
if self.cores.has_key(tcore):
|
if tcore in self.cores:
|
||||||
return self.cores[tcore]
|
return self.cores[tcore]
|
||||||
#
|
#
|
||||||
# Nope, doesn't exist. Compute it and the associated
|
# Nope, doesn't exist. Compute it and the associated
|
||||||
|
@ -389,13 +389,13 @@ class GenericParser:
|
||||||
|
|
||||||
nextSym = rhs[pos]
|
nextSym = rhs[pos]
|
||||||
key = (X.stateno, nextSym)
|
key = (X.stateno, nextSym)
|
||||||
if not rules.has_key(nextSym):
|
if nextSym not in rules:
|
||||||
if not edges.has_key(key):
|
if key not in edges:
|
||||||
edges[key] = None
|
edges[key] = None
|
||||||
X.T.append(nextSym)
|
X.T.append(nextSym)
|
||||||
else:
|
else:
|
||||||
edges[key] = None
|
edges[key] = None
|
||||||
if not predicted.has_key(nextSym):
|
if nextSym not in predicted:
|
||||||
predicted[nextSym] = 1
|
predicted[nextSym] = 1
|
||||||
for prule in rules[nextSym]:
|
for prule in rules[nextSym]:
|
||||||
ppos = self.skip(prule)
|
ppos = self.skip(prule)
|
||||||
|
@ -422,7 +422,7 @@ class GenericParser:
|
||||||
core = predicted.keys()
|
core = predicted.keys()
|
||||||
core.sort()
|
core.sort()
|
||||||
tcore = tuple(core)
|
tcore = tuple(core)
|
||||||
if self.cores.has_key(tcore):
|
if tcore in self.cores:
|
||||||
self.edges[(k, None)] = self.cores[tcore]
|
self.edges[(k, None)] = self.cores[tcore]
|
||||||
return k
|
return k
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ class GenericParser:
|
||||||
|
|
||||||
def goto(self, state, sym):
|
def goto(self, state, sym):
|
||||||
key = (state, sym)
|
key = (state, sym)
|
||||||
if not self.edges.has_key(key):
|
if key not in self.edges:
|
||||||
#
|
#
|
||||||
# No transitions from state on sym.
|
# No transitions from state on sym.
|
||||||
#
|
#
|
||||||
|
@ -631,7 +631,7 @@ class GenericParser:
|
||||||
|
|
||||||
for i in range(len(rhs)-1, -1, -1):
|
for i in range(len(rhs)-1, -1, -1):
|
||||||
sym = rhs[i]
|
sym = rhs[i]
|
||||||
if not self.newrules.has_key(sym):
|
if sym not in self.newrules:
|
||||||
if sym != self._BOF:
|
if sym != self._BOF:
|
||||||
attr[i] = tokens[k-1]
|
attr[i] = tokens[k-1]
|
||||||
key = (item, k)
|
key = (item, k)
|
||||||
|
|
Loading…
Reference in New Issue