From a0dfc2faf783dcc9f824da3bb1f0a69d43f33bcc Mon Sep 17 00:00:00 2001
From: Sven Gestegard Robertz <sven.robertz@cs.lth.se>
Date: Fri, 28 Mar 2014 10:23:36 +0100
Subject: [PATCH] added names to error messages

---
 compiler/DeclNames.jrag | 7 +++++++
 compiler/LabComm.java   | 4 ++++
 compiler/TypeCheck.jrag | 6 +++---
 3 files changed, 14 insertions(+), 3 deletions(-)
 create mode 100644 compiler/DeclNames.jrag

diff --git a/compiler/DeclNames.jrag b/compiler/DeclNames.jrag
new file mode 100644
index 0000000..4e58087
--- /dev/null
+++ b/compiler/DeclNames.jrag
@@ -0,0 +1,7 @@
+aspect DeclNames {
+	inh String Type.declName();
+	eq Decl.getType().declName() = getName();
+
+	inh String Field.declName();
+	eq StructType.getField(int i).declName() = declName();
+}
diff --git a/compiler/LabComm.java b/compiler/LabComm.java
index c1c7251..c86125a 100644
--- a/compiler/LabComm.java
+++ b/compiler/LabComm.java
@@ -249,6 +249,10 @@ public class LabComm {
 	if (prettyOnStdout) {
 	  ast.pp(System.out);
 	}
+      } else {
+          // Catch-all for compilation errors
+          System.err.println("Error in specification");
+          System.exit(3);
       }
     }
   } 
diff --git a/compiler/TypeCheck.jrag b/compiler/TypeCheck.jrag
index 747d830..a640ace 100644
--- a/compiler/TypeCheck.jrag
+++ b/compiler/TypeCheck.jrag
@@ -18,19 +18,19 @@ aspect TypeCheck {
  
   public void Field.nullTypeCheck() {
     if(getType().isNull()) {
-      error("field " + getName() + " may not be of type void");
+      error("field " + getName() + " of struct "+ declName()+ " may not be of type void");
     }
   }
 
   public void ParseArrayType.nullTypeCheck() {
     if(getType().isNull()) {
-      error("array elements may not be of type void");
+      error("elements of array "+declName()+" may not be of type void");
     }
   }
 
   public void ArrayType.nullTypeCheck() {
     if(getType().isNull()) {
-      error("array elements may not be of type void");
+      error("elements of array "+declName()+" may not be of type void");
     }
   }
 } 
-- 
GitLab