diff --git a/compiler/2014/ErrorCheck.jrag b/compiler/2014/ErrorCheck.jrag index caa80815456d4c1a390f2f80f7a5a7e5f74c0b8d..6953c7c61b05f241126658677c0acf5bb6367864 100644 --- a/compiler/2014/ErrorCheck.jrag +++ b/compiler/2014/ErrorCheck.jrag @@ -2,30 +2,29 @@ import java.util.Collection; aspect ErrorCheck { - syn int ASTNode.lineNumber() = getLine(getStart()); + syn int ASTNode.lineNumber() = getLine(getStart()); - protected String ASTNode.errors = null; - - protected void ASTNode.error(String s) { - s = "Error at " + lineNumber() + ": " + s; - if(errors == null) { - errors = s; - } else { - errors = errors + "\n" + s; - } - } + protected String ASTNode.errors = null; - protected boolean ASTNode.hasErrors() { - return errors != null; - } - public void ASTNode.errorCheck(Collection collection) { - nameCheck(); - typeCheck(); - if(hasErrors()) - collection.add(errors); - for(int i = 0; i < getNumChild(); i++) { - getChild(i).errorCheck(collection); - } - } + protected void ASTNode.error(String s) { + s = "Error at " + lineNumber() + ": " + s; + if(errors == null) { + errors = s; + } else { + errors = errors + "\n" + s; + } + } + protected boolean ASTNode.hasErrors() { + return errors != null; + } + public void ASTNode.errorCheck(Collection collection) { + nameCheck(); + typeCheck(); + if(hasErrors()) + collection.add(errors); + for(int i = 0; i < getNumChild(); i++) { + getChild(i).errorCheck(collection); + } + } } diff --git a/compiler/2014/TypeCheck.jrag b/compiler/2014/TypeCheck.jrag index 4d8c40a137ce92a5310d9e957dfdc921301f5cdd..3e6dd9c28c56af2a1ef112bf9fae3dd33c80a244 100644 --- a/compiler/2014/TypeCheck.jrag +++ b/compiler/2014/TypeCheck.jrag @@ -5,7 +5,7 @@ aspect TypeCheck { } // void is not allowed as a field in a struct or an array element - + syn boolean DataType.isNull(); eq DataType.isNull() = false; eq VoidType.isNull() = true; @@ -13,9 +13,9 @@ aspect TypeCheck { syn boolean TypeDecl.isNull(); eq TypeDecl.isNull() = getDataType().isNull(); - + public void ASTNode.nullTypeCheck() {} - + public void Field.nullTypeCheck() { if(getDataType().isNull()) { error("field " + getName() + " of struct "+ declName()+ " may not be of type void"); @@ -33,4 +33,19 @@ aspect TypeCheck { error("elements of array "+declName()+" may not be of type void"); } } -} +} + +aspect AnnotationCheck { + + refine TypeCheck void ASTNode.typeCheck() { + refined(); // similar to call to super + annotationCheck(); + } + public void ASTNode.annotationCheck() {} + + public void TypeDecl.annotationCheck() { + if(getTypeInstance().hasIntentions()) { + error("TypeDecl " + getName() + " has intentions. (Not allowed for typedefs)"); + } + } +}