diff --git a/Test.py b/Test.py index 5e1195a53ed0f06bc11ddc94c2a73bad1396367c..0a434959180eccf450a3b62922b43524e6dbb9ba 100644 --- a/Test.py +++ b/Test.py @@ -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)) diff --git a/TypeNodes.py b/TypeNodes.py index 2967c2d27f45b40d77247075d18d19b5fa0fb294..20cd7a5a001fb394f250ce40be429ea9ecf03dbd 100644 --- a/TypeNodes.py +++ b/TypeNodes.py @@ -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