Skip to content
Snippets Groups Projects
Commit a41f5afb authored by pycsham's avatar pycsham
Browse files

fixed a small bug for checking double local var declaration

parent 3c42d6f8
No related branches found
No related tags found
No related merge requests found
......@@ -51,14 +51,15 @@ class Env:
return self.parentEnv.getNode(name, namespace)
raise Exception("ERROR: Can't find definition of {} in the Environment".format(name))
# A wrapper around getNode to find if node exists in environment already
# A wrapper around getNode to find if node exists in environment already. Terminates before reaching the global Env (see compEnv implementation)
def findNode(self, name, namespace):
try:
self.getNode(name, namespace)
except:
return False # node is not found in environment
return True
key = (name, namespace)
if key in self.map:
return True
elif self.parentEnv:
return self.parentEnv.findNode(name, namespace)
return False
###################################
......@@ -124,7 +125,7 @@ class GlobalEnv(Env):
return self.map.get(name)
elif (i+name) in self.map:
return self.map.get(i+name)
raise Exception("ERROR: Can't find definition of {} in the Environment".format(key))
# method for getting all the nodes under a package (import All)
......@@ -149,4 +150,11 @@ class CompEnv(Env):
return self.map.get(key)
elif self.parentEnv: # globalEnv
return self.parentEnv.getNode(key, self.imported, self.packageName)
raise Exception("ERROR: Can't find definition of {} in the Environment".format(name))
\ No newline at end of file
raise Exception("ERROR: Can't find definition of {} in the Environment".format(name))
def findNode(self, name, namespace):
key = (name, namespace)
if key in self.map:
return True
else:
return False
\ No newline at end of file
......@@ -69,6 +69,8 @@ def run(testFiles):
for f in testFiles:
# print(f)
if f.split("/")[-1] == ".DS_Store":
continue
content = open(f, "r").read()
# Scanning
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment