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

fixed test file and added a check for constructor name against class name

parent b5da1cb6
No related branches found
No related tags found
No related merge requests found
......@@ -94,8 +94,8 @@ def run(testFiles):
print(f)
print("ERROR in Scanning: " + error)
print("**********************************************************")
continue
return "ERROR in scanning"
# s = "All Tokens: "
# for token in tokens:
# if (token.name and token.lex):
......@@ -110,7 +110,7 @@ def run(testFiles):
print("ERROR in Weeding after Scanning:")
print(weeds)
print("**********************************************************")
continue
return "ERROR in weeding"
# Parsing
tree = None
......@@ -127,7 +127,7 @@ def run(testFiles):
# for n in error.args[1]: # the parse tree
# print(n)
print("**********************************************************")
continue
return "ERROR in parsing"
parseTrees.append((f, tree))
......
......@@ -251,10 +251,16 @@ class ClassNode(ClassInterNode):
# overlapping class/interface logic
super().checkHierarchy()
def getConstructor(self, argTypes):
for c in self.constructors:
if c.paramTypes == argTypes:
return c
def checkType(self):
super().checkType()
# Checking if constructor's name is the same as class name
for constructor in self.constructors:
if not self.name == constructor.name:
raise Exception("ERROR: Constructor {0} doesn't have the same name as class {1}".format(constructor.name, self.name))
return
#####################################################################
# interface
......
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