From ad8d7fdaeda51840a5310646c66cc0621240b312 Mon Sep 17 00:00:00 2001
From: Sven Gestegard Robertz <sven.robertz@cs.lth.se>
Date: Wed, 29 Apr 2015 16:52:03 +0200
Subject: [PATCH] refactored grammar/parser to unify arrays with other types

---
 compiler/2014/DeclNames.jrag                        | 10 +++++-----
 compiler/2014/LabCommParser.parser                  |  4 +---
 lib/java/se/lth/control/labcomm2014/ASTbuilder.java |  6 +++---
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/compiler/2014/DeclNames.jrag b/compiler/2014/DeclNames.jrag
index c82ad18..3f23cda 100644
--- a/compiler/2014/DeclNames.jrag
+++ b/compiler/2014/DeclNames.jrag
@@ -5,10 +5,10 @@ aspect DeclNames {
 	inh String Field.declName();
 	eq StructType.getField(int i).declName() = declName();
 
-        //TODO: aspect should be renamed to parent-something
+    //TODO: aspect should be renamed to parent-something
 
-        inh Decl DataType.parentDecl();
-        inh Decl Field.parentDecl();
-        eq Decl.getTypeInstance().parentDecl() = this;
-        eq StructType.getField(int i).parentDecl() = parentDecl();
+    inh Decl DataType.parentDecl();
+    inh Decl Field.parentDecl();
+    eq Decl.getTypeInstance().parentDecl() = this;
+    eq StructType.getField(int i).parentDecl() = parentDecl();
 }
diff --git a/compiler/2014/LabCommParser.parser b/compiler/2014/LabCommParser.parser
index b1252ac..3a5d774 100644
--- a/compiler/2014/LabCommParser.parser
+++ b/compiler/2014/LabCommParser.parser
@@ -61,9 +61,7 @@ TypeInstance type_instance =
   ;
 
 Field var_decl =
-    type.t IDENTIFIER SEMICOLON     {: return new Field(t, IDENTIFIER); :}
-  | type.t IDENTIFIER dim_list.d SEMICOLON
-    {: return new Field(new ParseArrayType(t, d), IDENTIFIER); :}
+    concrete_type.t SEMICOLON     {: return new Field(t); :}
   ;
 
 TypeDecl type_decl =
diff --git a/lib/java/se/lth/control/labcomm2014/ASTbuilder.java b/lib/java/se/lth/control/labcomm2014/ASTbuilder.java
index c21c881..dccb39c 100644
--- a/lib/java/se/lth/control/labcomm2014/ASTbuilder.java
+++ b/lib/java/se/lth/control/labcomm2014/ASTbuilder.java
@@ -52,10 +52,10 @@ public class ASTbuilder implements TypeDefParser.ParsedSymbolVisitor {
 
         private void assertStacksEmpty() throws RuntimeException {
             if(!typeStack.isEmpty()) {
-               throw new RuntimeException("Error: type stack not empty"); 
+               throw new RuntimeException("Error: type stack not empty");
             }
             if(!fieldStack.isEmpty()) {
-               throw new RuntimeException("Error: field stack not empty"); 
+               throw new RuntimeException("Error: field stack not empty");
             }
         }
 
@@ -144,7 +144,7 @@ public class ASTbuilder implements TypeDefParser.ParsedSymbolVisitor {
                 throw new RuntimeException("Internal error: parsed labcomm declaration has errors: "+sb.toString());
             }
        }
-       
+
        public Specification makeSpecification(TypeDefParser.ParsedTypeDef d) {
            assertStacksEmpty();
            List<Decl> ds = new List<Decl>();
-- 
GitLab