Checking in various changes...
authorbdemsky <bdemsky>
Thu, 30 Sep 2004 19:14:10 +0000 (19:14 +0000)
committerbdemsky <bdemsky>
Thu, 30 Sep 2004 19:14:10 +0000 (19:14 +0000)
Repair/RepairCompiler/MCC/IR/Expr.java
Repair/RepairCompiler/MCC/IR/SemanticChecker.java
Repair/RepairCompiler/MCC/IR/SetInclusion.java
Repair/RepairCompiler/MCC/IR/VarExpr.java
Repair/RepairCompiler/MCC/Runtime/buildruntime
Repair/RepairCompiler/MCC/TDL.cup

index 51ae61360906a92f2568787aa8f795f8e38ec5cf..9eb610653591d7f8ac79a293cf916c0aadf0bef1 100755 (executable)
@@ -3,7 +3,7 @@ package MCC.IR;
 import java.util.*;
 
 public abstract class Expr {
 import java.util.*;
 
 public abstract class Expr {
-    
+
     TypeDescriptor td = null;
 
     public Expr() {}
     TypeDescriptor td = null;
 
     public Expr() {}
@@ -19,6 +19,10 @@ public abstract class Expr {
         return td;
     }
 
         return td;
     }
 
+    public String toString() {
+        return name();
+    }
+
     public String name() {
        System.out.println(this.getClass().getName());
        return "?";
     public String name() {
        System.out.println(this.getClass().getName());
        return "?";
index 23e83f4b785377173e563a645e09735e3da66ac4..2e54c87778d1ba03de910a10e0581ec949217d66 100755 (executable)
@@ -23,7 +23,7 @@ public class SemanticChecker {
     StructureTypeDescriptor dCurrentType;
 
     IRErrorReporter er;
     StructureTypeDescriptor dCurrentType;
 
     IRErrorReporter er;
-    
+
     public SemanticChecker () {
         dCurrentType = null;
        stTypes = null;
     public SemanticChecker () {
         dCurrentType = null;
        stTypes = null;
@@ -64,7 +64,7 @@ public class SemanticChecker {
         stGlobals = state.stGlobals;
 
         sts = new SymbolTableStack();
         stGlobals = state.stGlobals;
 
         sts = new SymbolTableStack();
-       
+
        // add int and bool to the types list
        stTypes.add(ReservedTypeDescriptor.BIT);
        stTypes.add(ReservedTypeDescriptor.BYTE);
        // add int and bool to the types list
        stTypes.add(ReservedTypeDescriptor.BIT);
        stTypes.add(ReservedTypeDescriptor.BYTE);
@@ -74,35 +74,40 @@ public class SemanticChecker {
         stSets.add(new ReservedSetDescriptor("int", ReservedTypeDescriptor.INT));
         stSets.add(new ReservedSetDescriptor("token", ReservedTypeDescriptor.INT));
 
         stSets.add(new ReservedSetDescriptor("int", ReservedTypeDescriptor.INT));
         stSets.add(new ReservedSetDescriptor("token", ReservedTypeDescriptor.INT));
 
-       boolean ok = true; 
+       boolean ok = true;
 
         er.setFilename(state.infile + ".struct");
         if (!parse_structures(state.ptStructures)) {
 
         er.setFilename(state.infile + ".struct");
         if (!parse_structures(state.ptStructures)) {
+
             ok = false;
             ok = false;
+            er.report(null, "Error parsing structs.");
         }
 
         er.setFilename(state.infile + ".space");
         if (!parse_space(state.ptSpace)) {
             ok = false;
         }
 
         er.setFilename(state.infile + ".space");
         if (!parse_space(state.ptSpace)) {
             ok = false;
+            er.report(null, "Error parsing sets and relations.");
         }
         }
-        
+
         er.setFilename(state.infile + ".constraints");
         if (!parse_constraints(state.ptConstraints)) {
             ok = false;
         er.setFilename(state.infile + ".constraints");
         if (!parse_constraints(state.ptConstraints)) {
             ok = false;
+            er.report(null, "Error parsing constraints.");
         }
 
         er.setFilename(state.infile + ".model");
         if (!parse_rules(state.ptModel)) {
             ok = false;
         }
 
         er.setFilename(state.infile + ".model");
         if (!parse_rules(state.ptModel)) {
             ok = false;
+            er.report(null, "Error parsing model definition rules.");
         }
 
         return ok;
     }
 
         }
 
         return ok;
     }
 
-    /********************** HELPER FUNCTIONS ************************/ 
+    /********************** HELPER FUNCTIONS ************************/
 
     /**
 
     /**
-     * special case lookup that returns null if no such type exists 
+     * special case lookup that returns null if no such type exists
      */
     private TypeDescriptor lookupType(String typename) {
         return lookupType(typename, false);
      */
     private TypeDescriptor lookupType(String typename) {
         return lookupType(typename, false);
@@ -114,23 +119,23 @@ public class SemanticChecker {
      */
     private TypeDescriptor lookupType(String typename, boolean createmissing) {
         if (stTypes.get(typename) != null) {
      */
     private TypeDescriptor lookupType(String typename, boolean createmissing) {
         if (stTypes.get(typename) != null) {
-            // the type exists, so plug in the descriptor directly 
-            return (TypeDescriptor) stTypes.get(typename);              
+            // the type exists, so plug in the descriptor directly
+            return (TypeDescriptor) stTypes.get(typename);
         } else if (createmissing) {
             return new MissingTypeDescriptor(typename);
         } else {
             return null;
         } else if (createmissing) {
             return new MissingTypeDescriptor(typename);
         } else {
             return null;
-        }       
+        }
     }
 
     /**
     }
 
     /**
-     * reserve a name 
+     * reserve a name
      */
     private VarDescriptor reserveName(ParseNode pn) {
         assert pn != null;
         String varname = pn.getTerminal();
         assert varname != null;
      */
     private VarDescriptor reserveName(ParseNode pn) {
         assert pn != null;
         String varname = pn.getTerminal();
         assert varname != null;
-                
+
         /* do semantic check and if valid, add it to symbol table
            and add it to the quantifier as well */
         if (sts.peek().contains(varname)) {
         /* do semantic check and if valid, add it to symbol table
            and add it to the quantifier as well */
         if (sts.peek().contains(varname)) {
@@ -145,7 +150,7 @@ public class SemanticChecker {
     }
 
     /**
     }
 
     /**
-     * special case lookup that returns null if no such set exists 
+     * special case lookup that returns null if no such set exists
      */
     private SetDescriptor lookupSet(String setname) {
         return lookupSet(setname, false);
      */
     private SetDescriptor lookupSet(String setname) {
         return lookupSet(setname, false);
@@ -157,31 +162,31 @@ public class SemanticChecker {
      */
     private SetDescriptor lookupSet(String setname, boolean createmissing) {
         if (stSets.get(setname) != null) {
      */
     private SetDescriptor lookupSet(String setname, boolean createmissing) {
         if (stSets.get(setname) != null) {
-            // the set exists, so plug in the descriptor directly 
-            return (SetDescriptor) stSets.get(setname);              
+            // the set exists, so plug in the descriptor directly
+            return (SetDescriptor) stSets.get(setname);
         } else if (createmissing) {
             return new MissingSetDescriptor(setname);
         } else {
             return null;
         } else if (createmissing) {
             return new MissingSetDescriptor(setname);
         } else {
             return null;
-        }       
+        }
     }
     }
-    
+
     /**
      * does a look up in the set's symbol table. if the set is
      * not found than a missing set descriptor is returned
      */
     private RelationDescriptor lookupRelation(String relname) {
         if (stRelations.get(relname) != null) {
     /**
      * does a look up in the set's symbol table. if the set is
      * not found than a missing set descriptor is returned
      */
     private RelationDescriptor lookupRelation(String relname) {
         if (stRelations.get(relname) != null) {
-            // the relation exists, so plug in the descriptor directly 
-            return (RelationDescriptor) stRelations.get(relname);              
+            // the relation exists, so plug in the descriptor directly
+            return (RelationDescriptor) stRelations.get(relname);
         } else {
             return null;
         } else {
             return null;
-        }       
+        }
     }
     }
-    
-    
+
+
     private static int count = 0;
     private static int count = 0;
-    private boolean precheck(ParseNode pn, String label) {             
+    private boolean precheck(ParseNode pn, String label) {
        if (pn == null) {
             er.report(pn, "IE: Expected '" + label + "', got null");
             assert false;
        if (pn == null) {
             er.report(pn, "IE: Expected '" + label + "', got null");
             assert false;
@@ -201,7 +206,7 @@ public class SemanticChecker {
        return true;
     }
 
        return true;
     }
 
-    /********************* PARSING FUNCTIONS ************************/ 
+    /********************* PARSING FUNCTIONS ************************/
 
     private boolean parse_rules(ParseNode pn) {
         if (!precheck(pn, "rules")) {
 
     private boolean parse_rules(ParseNode pn) {
         if (!precheck(pn, "rules")) {
@@ -210,19 +215,20 @@ public class SemanticChecker {
 
         boolean ok = true;
         ParseNodeVector rules = pn.getChildren();
 
         boolean ok = true;
         ParseNodeVector rules = pn.getChildren();
-        
+
         for (int i = 0; i < rules.size(); i++) {
             ParseNode rule = rules.elementAt(i);
             if (!parse_rule(rule)) {
         for (int i = 0; i < rules.size(); i++) {
             ParseNode rule = rules.elementAt(i);
             if (!parse_rule(rule)) {
+                er.report(rule, "Error parsing rule");
                 ok = false;
             }
         }
                 ok = false;
             }
         }
-               
-        /* type check */       
+
+        /* type check */
         Iterator ruleiterator = state.vRules.iterator();
         Iterator ruleiterator = state.vRules.iterator();
-        
+
         while (ruleiterator.hasNext()) {
         while (ruleiterator.hasNext()) {
-            Rule rule = (Rule) ruleiterator.next();            
+            Rule rule = (Rule) ruleiterator.next();
             Expr guard = rule.getGuardExpr();
             final SymbolTable rulest = rule.getSymbolTable();
             SemanticAnalyzer sa = new SemanticAnalyzer() {
             Expr guard = rule.getGuardExpr();
             final SymbolTable rulest = rule.getSymbolTable();
             SemanticAnalyzer sa = new SemanticAnalyzer() {
@@ -230,28 +236,29 @@ public class SemanticChecker {
                     public SymbolTable getSymbolTable() { return rulest; }
                 };
             TypeDescriptor guardtype = guard.typecheck(sa);
                     public SymbolTable getSymbolTable() { return rulest; }
                 };
             TypeDescriptor guardtype = guard.typecheck(sa);
-            
+
             if (guardtype == null) {
                 ok = false;
             } else if (guardtype != ReservedTypeDescriptor.INT) {
                 er.report(null, "Type of guard must be 'int' not '" + guardtype.getSymbol() + "'");
                 ok = false;
             }
             if (guardtype == null) {
                 ok = false;
             } else if (guardtype != ReservedTypeDescriptor.INT) {
                 er.report(null, "Type of guard must be 'int' not '" + guardtype.getSymbol() + "'");
                 ok = false;
             }
-            
+
             if (!rule.getInclusion().typecheck(sa)) {
             if (!rule.getInclusion().typecheck(sa)) {
+                er.report(null, "Error typechecking rule:"+rule);
                 ok = false;
                 ok = false;
-            }           
-            
+            }
+
             Iterator quantifiers = rule.quantifiers();
             Iterator quantifiers = rule.quantifiers();
-            
+
             while (quantifiers.hasNext()) {
                 Quantifier q = (Quantifier) quantifiers.next();
             while (quantifiers.hasNext()) {
                 Quantifier q = (Quantifier) quantifiers.next();
-                
+
                 if (q instanceof ForQuantifier && !((ForQuantifier)q).typecheck(sa)) {
                     ok = false;
                 }
                 if (q instanceof ForQuantifier && !((ForQuantifier)q).typecheck(sa)) {
                     ok = false;
                 }
-            }              
-        }        
+            }
+        }
 
         /* do any post checks ?? */
 
 
         /* do any post checks ?? */
 
@@ -265,7 +272,7 @@ public class SemanticChecker {
 
         boolean ok = true;
         Rule rule = new Rule();
 
         boolean ok = true;
         Rule rule = new Rule();
-        
+
         /* get rule type */
         boolean isstatic = pn.getChild("static") != null;
         boolean isdelay = pn.getChild("delay") != null;
         /* get rule type */
         boolean isstatic = pn.getChild("static") != null;
         boolean isdelay = pn.getChild("delay") != null;
@@ -276,11 +283,9 @@ public class SemanticChecker {
         assert sts.empty();
         sts.push(stGlobals);
         sts.push(rule.getSymbolTable());
         assert sts.empty();
         sts.push(stGlobals);
         sts.push(rule.getSymbolTable());
-
         /* optional quantifiers */
         if (pn.getChild("quantifiers") != null) {
             ParseNodeVector quantifiers = pn.getChild("quantifiers").getChildren();
         /* optional quantifiers */
         if (pn.getChild("quantifiers") != null) {
             ParseNodeVector quantifiers = pn.getChild("quantifiers").getChildren();
-            
             for (int i = 0; i < quantifiers.size(); i++) {
                 ParseNode qn = quantifiers.elementAt(i);
                 Quantifier quantifier = parse_quantifier(qn);
             for (int i = 0; i < quantifiers.size(); i++) {
                 ParseNode qn = quantifiers.elementAt(i);
                 Quantifier quantifier = parse_quantifier(qn);
@@ -292,7 +297,7 @@ public class SemanticChecker {
                 }
             }
         }
                 }
             }
         }
-        
+
         /* get guard expr */
         Expr guard = parse_expr(pn.getChild("expr"));
 
         /* get guard expr */
         Expr guard = parse_expr(pn.getChild("expr"));
 
@@ -304,19 +309,19 @@ public class SemanticChecker {
 
         /* inclusion constraint */
         Inclusion inclusion = parse_inclusion(pn.getChild("inclusion"));
 
         /* inclusion constraint */
         Inclusion inclusion = parse_inclusion(pn.getChild("inclusion"));
-        
+
         if (inclusion == null) {
             ok = false;
         } else {
             rule.setInclusion(inclusion);
         }
         if (inclusion == null) {
             ok = false;
         } else {
             rule.setInclusion(inclusion);
         }
-        
+
         /* pop symbol table stack */
         SymbolTable st = sts.pop();
         sts.pop(); /* pop off globals */
 
         /* make sure the stack we pop is our rule s.t. */
         /* pop symbol table stack */
         SymbolTable st = sts.pop();
         sts.pop(); /* pop off globals */
 
         /* make sure the stack we pop is our rule s.t. */
-        assert st == rule.getSymbolTable(); 
+        assert st == rule.getSymbolTable();
         assert sts.empty();
 
         /* add rule to global set */
         assert sts.empty();
 
         /* add rule to global set */
@@ -333,7 +338,7 @@ public class SemanticChecker {
         if (pn.getChild("set") != null) {
             ParseNode set = pn.getChild("set");
             Expr expr = parse_expr(set.getChild("expr"));
         if (pn.getChild("set") != null) {
             ParseNode set = pn.getChild("set");
             Expr expr = parse_expr(set.getChild("expr"));
-            
+
             if (expr == null) {
                 return null;
             }
             if (expr == null) {
                 return null;
             }
@@ -341,7 +346,7 @@ public class SemanticChecker {
             String setname = set.getChild("name").getTerminal();
             assert setname != null;
             SetDescriptor sd = lookupSet(setname);
             String setname = set.getChild("name").getTerminal();
             assert setname != null;
             SetDescriptor sd = lookupSet(setname);
-            
+
             if (sd == null) {
                 er.report(set.getChild("name"), "Undefined set '" + setname + "'");
                 return null;
             if (sd == null) {
                 er.report(set.getChild("name"), "Undefined set '" + setname + "'");
                 return null;
@@ -352,7 +357,7 @@ public class SemanticChecker {
             ParseNode relation = pn.getChild("relation");
             Expr leftexpr = parse_expr(relation.getChild("left").getChild("expr"));
             Expr rightexpr = parse_expr(relation.getChild("right").getChild("expr"));
             ParseNode relation = pn.getChild("relation");
             Expr leftexpr = parse_expr(relation.getChild("left").getChild("expr"));
             Expr rightexpr = parse_expr(relation.getChild("right").getChild("expr"));
-            
+
             if ((leftexpr == null) || (rightexpr == null)) {
                 return null;
             }
             if ((leftexpr == null) || (rightexpr == null)) {
                 return null;
             }
@@ -430,11 +435,11 @@ public class SemanticChecker {
         /* set up symbol table for constraint */
         assert sts.empty();
         sts.push(constraint.getSymbolTable());
         /* set up symbol table for constraint */
         assert sts.empty();
         sts.push(constraint.getSymbolTable());
-        
+
         /* get quantifiers */
         if (pn.getChild("quantifiers") != null) {
             ParseNodeVector quantifiers = pn.getChild("quantifiers").getChildren();
         /* get quantifiers */
         if (pn.getChild("quantifiers") != null) {
             ParseNodeVector quantifiers = pn.getChild("quantifiers").getChildren();
-            
+
             for (int i = 0; i < quantifiers.size(); i++) {
                 ParseNode qn = quantifiers.elementAt(i);
                 assert qn.getLabel().equals("quantifier");
             for (int i = 0; i < quantifiers.size(); i++) {
                 ParseNode qn = quantifiers.elementAt(i);
                 assert qn.getLabel().equals("quantifier");
@@ -457,12 +462,12 @@ public class SemanticChecker {
         } else {
             constraint.setLogicStatement(logicexpr);
         }
         } else {
             constraint.setLogicStatement(logicexpr);
         }
-        
+
         /* pop symbol table stack */
         SymbolTable st = sts.pop();
 
         /* make sure the stack we pop is our constraint s.t. */
         /* pop symbol table stack */
         SymbolTable st = sts.pop();
 
         /* make sure the stack we pop is our constraint s.t. */
-        assert st == constraint.getSymbolTable(); 
+        assert st == constraint.getSymbolTable();
         assert sts.empty();
 
         /* add to vConstraints */
         assert sts.empty();
 
         /* add to vConstraints */
@@ -473,7 +478,7 @@ public class SemanticChecker {
 
     private Quantifier parse_quantifier(ParseNode pn) {
         if (!precheck(pn, "quantifier")) {
 
     private Quantifier parse_quantifier(ParseNode pn) {
         if (!precheck(pn, "quantifier")) {
-            return null;           
+            return null;
         }
 
         if (pn.getChild("forall") != null) { /* forall element in Set */
         }
 
         if (pn.getChild("forall") != null) { /* forall element in Set */
@@ -481,10 +486,10 @@ public class SemanticChecker {
 
             /* get var */
             VarDescriptor vd = reserveName(pn.getChild("var"));
 
             /* get var */
             VarDescriptor vd = reserveName(pn.getChild("var"));
-            
+
             if (vd == null) {
                 return null;
             if (vd == null) {
                 return null;
-            } 
+            }
 
             sq.setVar(vd);
 
 
             sq.setVar(vd);
 
@@ -505,13 +510,13 @@ public class SemanticChecker {
             /* get vars */
             VarDescriptor vd1 = reserveName(pn.getChild("left"));
             VarDescriptor vd2 = reserveName(pn.getChild("right"));
             /* get vars */
             VarDescriptor vd1 = reserveName(pn.getChild("left"));
             VarDescriptor vd2 = reserveName(pn.getChild("right"));
-            
+
             if ((vd1 == null) || (vd2 == null)) {
                 return null;
             }
             if ((vd1 == null) || (vd2 == null)) {
                 return null;
             }
-            
+
             rq.setTuple(vd1, vd2);
             rq.setTuple(vd1, vd2);
-            
+
             /* get relation */
             String relationname = pn.getChild("relation").getTerminal();
             assert relationname != null;
             /* get relation */
             String relationname = pn.getChild("relation").getTerminal();
             assert relationname != null;
@@ -520,7 +525,7 @@ public class SemanticChecker {
             if (rd == null) {
                 return null;
             }
             if (rd == null) {
                 return null;
             }
-            
+
             rq.setRelation(rd);
             vd1.setType(rd.getDomain().getType());
            vd1.setSet(rd.getDomain());
             rq.setRelation(rd);
             vd1.setType(rd.getDomain().getType());
            vd1.setSet(rd.getDomain());
@@ -529,10 +534,10 @@ public class SemanticChecker {
             return rq;
         } else if (pn.getChild("for") != null) { /* for j = x to y */
             ForQuantifier fq = new ForQuantifier();
             return rq;
         } else if (pn.getChild("for") != null) { /* for j = x to y */
             ForQuantifier fq = new ForQuantifier();
-            
+
             /* grab var */
             VarDescriptor vd = reserveName(pn.getChild("var"));
             /* grab var */
             VarDescriptor vd = reserveName(pn.getChild("var"));
-           
+
             if (vd == null) {
                 return null;
             }
             if (vd == null) {
                 return null;
             }
@@ -560,19 +565,19 @@ public class SemanticChecker {
 
     private LogicStatement parse_body(ParseNode pn) {
         if (!precheck(pn, "body")) {
 
     private LogicStatement parse_body(ParseNode pn) {
         if (!precheck(pn, "body")) {
-            return null;           
+            return null;
         }
         }
-        
+
         if (pn.getChild("and") != null) {
             /* body AND body */
             LogicStatement left, right;
             left = parse_body(pn.getChild("and").getChild("left").getChild("body"));
             right = parse_body(pn.getChild("and").getChild("right").getChild("body"));
         if (pn.getChild("and") != null) {
             /* body AND body */
             LogicStatement left, right;
             left = parse_body(pn.getChild("and").getChild("left").getChild("body"));
             right = parse_body(pn.getChild("and").getChild("right").getChild("body"));
-            
+
             if ((left == null) || (right == null)) {
                 return null;
             }
             if ((left == null) || (right == null)) {
                 return null;
             }
-            
+
             // what do we want to call the and/or/not body classes?
             return new LogicStatement(LogicStatement.AND, left, right);
         } else if (pn.getChild("or") != null) {
             // what do we want to call the and/or/not body classes?
             return new LogicStatement(LogicStatement.AND, left, right);
         } else if (pn.getChild("or") != null) {
@@ -580,7 +585,7 @@ public class SemanticChecker {
             LogicStatement left, right;
             left = parse_body(pn.getChild("or").getChild("left").getChild("body"));
             right = parse_body(pn.getChild("or").getChild("right").getChild("body"));
             LogicStatement left, right;
             left = parse_body(pn.getChild("or").getChild("left").getChild("body"));
             right = parse_body(pn.getChild("or").getChild("right").getChild("body"));
-            
+
             if ((left == null) || (right == null)) {
                 return null;
             }
             if ((left == null) || (right == null)) {
                 return null;
             }
@@ -589,17 +594,17 @@ public class SemanticChecker {
         } else if (pn.getChild("not") != null) {
             /* NOT body */
             LogicStatement left = parse_body(pn.getChild("not").getChild("body"));
         } else if (pn.getChild("not") != null) {
             /* NOT body */
             LogicStatement left = parse_body(pn.getChild("not").getChild("body"));
-            
+
             if (left == null) {
                 return null;
             }
             if (left == null) {
                 return null;
             }
-            
+
             return new LogicStatement(LogicStatement.NOT, left);
         } else if (pn.getChild("predicate") != null) {
             return parse_predicate(pn.getChild("predicate"));
         } else {
             throw new IRException();
             return new LogicStatement(LogicStatement.NOT, left);
         } else if (pn.getChild("predicate") != null) {
             return parse_predicate(pn.getChild("predicate"));
         } else {
             throw new IRException();
-        }                        
+        }
     }
 
     private Predicate parse_predicate(ParseNode pn) {
     }
 
     private Predicate parse_predicate(ParseNode pn) {
@@ -609,11 +614,11 @@ public class SemanticChecker {
 
         if (pn.getChild("inclusion") != null) {
             ParseNode in = pn.getChild("inclusion");
 
         if (pn.getChild("inclusion") != null) {
             ParseNode in = pn.getChild("inclusion");
-            
+
             /* Expr */
             Expr expr = parse_expr(in.getChild("expr"));
             /* Expr */
             Expr expr = parse_expr(in.getChild("expr"));
-           
-            if (expr == null) { 
+
+            if (expr == null) {
                 return null;
             }
 
                 return null;
             }
 
@@ -627,7 +632,7 @@ public class SemanticChecker {
             return new InclusionPredicate(expr, setexpr);
         } else if (pn.getChild("expr") != null) {
             Expr expr = parse_expr(pn.getChild("expr"));
             return new InclusionPredicate(expr, setexpr);
         } else if (pn.getChild("expr") != null) {
             Expr expr = parse_expr(pn.getChild("expr"));
-            
+
             if (expr == null) {
                 return null;
             }
             if (expr == null) {
                 return null;
             }
@@ -635,18 +640,18 @@ public class SemanticChecker {
             return new ExprPredicate(expr);
         } else {
             throw new IRException();
             return new ExprPredicate(expr);
         } else {
             throw new IRException();
-        }       
+        }
     }
 
     private SetDescriptor parse_set(ParseNode pn) {
         if (!precheck(pn, "set")) {
             return null;
         }
     }
 
     private SetDescriptor parse_set(ParseNode pn) {
         if (!precheck(pn, "set")) {
             return null;
         }
-    
+
         if (pn.getChild("name") != null) {
             String setname = pn.getChild("name").getTerminal();
             assert setname != null;
         if (pn.getChild("name") != null) {
             String setname = pn.getChild("name").getTerminal();
             assert setname != null;
-                
+
             if (!stSets.contains(setname)) {
                 /* Semantic Error: unknown set */
                 er.report(pn, "Unknown set '" + setname + "' referenced in quantifier");
             if (!stSets.contains(setname)) {
                 /* Semantic Error: unknown set */
                 er.report(pn, "Unknown set '" + setname + "' referenced in quantifier");
@@ -656,12 +661,12 @@ public class SemanticChecker {
                 SetDescriptor sd = (SetDescriptor) stSets.get(setname);
                 assert sd != null;
                 return sd;
                 SetDescriptor sd = (SetDescriptor) stSets.get(setname);
                 assert sd != null;
                 return sd;
-            }            
-        } else if (pn.getChild("listofliterals") != null) {            
+            }
+        } else if (pn.getChild("listofliterals") != null) {
             TokenSetDescriptor tokenset = new TokenSetDescriptor();
             ParseNodeVector token_literals = pn.getChild("listofliterals").getChildren();
             assert token_literals.size() > 0;
             TokenSetDescriptor tokenset = new TokenSetDescriptor();
             ParseNodeVector token_literals = pn.getChild("listofliterals").getChildren();
             assert token_literals.size() > 0;
-            
+
             for (int i = 0; i < token_literals.size(); i++) {
                 ParseNode literal = token_literals.elementAt(i);
                 assert literal.getLabel().equals("literal");
             for (int i = 0; i < token_literals.size(); i++) {
                 ParseNode literal = token_literals.elementAt(i);
                 assert literal.getLabel().equals("literal");
@@ -670,32 +675,32 @@ public class SemanticChecker {
                 if (litexpr == null) {
                     return null;
                 }
                 if (litexpr == null) {
                     return null;
                 }
-                
+
                 if (litexpr instanceof TokenLiteralExpr || litexpr instanceof IntegerLiteralExpr) {
                     tokenset.addLiteral(litexpr);
                 } else {
                     er.report(literal, "Elements of a user-defined set must be of type token or integer");
                     // return null; /* don't think we need to return null */
                 }
                 if (litexpr instanceof TokenLiteralExpr || litexpr instanceof IntegerLiteralExpr) {
                     tokenset.addLiteral(litexpr);
                 } else {
                     er.report(literal, "Elements of a user-defined set must be of type token or integer");
                     // return null; /* don't think we need to return null */
                 }
-            }               
+            }
 
             return tokenset;
         } else {
             throw new IRException(pn.getTerminal());
         }
     }
 
             return tokenset;
         } else {
             throw new IRException(pn.getTerminal());
         }
     }
-    
+
     private boolean parse_space(ParseNode pn) {
         if (!precheck(pn, "space")) {
             return false;
         }
     private boolean parse_space(ParseNode pn) {
         if (!precheck(pn, "space")) {
             return false;
         }
-        
+
         boolean ok = true;
         ParseNodeVector sets = pn.getChildren("setdefinition");
         ParseNodeVector relations = pn.getChildren("relationdefinition");
 
         assert pn.getChildren().size() == (sets.size() + relations.size());
         boolean ok = true;
         ParseNodeVector sets = pn.getChildren("setdefinition");
         ParseNodeVector relations = pn.getChildren("relationdefinition");
 
         assert pn.getChildren().size() == (sets.size() + relations.size());
-        
+
         /* parse sets */
         for (int i = 0; i < sets.size(); i++) {
             if (!parse_setdefinition(sets.elementAt(i))) {
         /* parse sets */
         for (int i = 0; i < sets.size(); i++) {
             if (!parse_setdefinition(sets.elementAt(i))) {
@@ -714,17 +719,17 @@ public class SemanticChecker {
         // for cycles etc.
 
         // #TBD#: typecheck and check for cycles
         // for cycles etc.
 
         // #TBD#: typecheck and check for cycles
-      
+
         /* replace missing with actual */
         Iterator allsets = state.stSets.descriptors();
         /* replace missing with actual */
         Iterator allsets = state.stSets.descriptors();
-        
+
         while (allsets.hasNext()) {
             SetDescriptor sd = (SetDescriptor) allsets.next();
             Vector subsets = sd.getSubsets();
 
             for (int i = 0; i < subsets.size(); i++) {
                 SetDescriptor subset = (SetDescriptor) subsets.elementAt(i);
         while (allsets.hasNext()) {
             SetDescriptor sd = (SetDescriptor) allsets.next();
             Vector subsets = sd.getSubsets();
 
             for (int i = 0; i < subsets.size(); i++) {
                 SetDescriptor subset = (SetDescriptor) subsets.elementAt(i);
-                
+
                 if (subset instanceof MissingSetDescriptor) {
                     SetDescriptor newsubset = lookupSet(subset.getSymbol());
 
                 if (subset instanceof MissingSetDescriptor) {
                     SetDescriptor newsubset = lookupSet(subset.getSymbol());
 
@@ -736,7 +741,7 @@ public class SemanticChecker {
                 }
             }
         }
                 }
             }
         }
-        
+
         return ok;
     }
 
         return ok;
     }
 
@@ -744,37 +749,37 @@ public class SemanticChecker {
         if (!precheck(pn, "setdefinition")) {
             return false;
         }
         if (!precheck(pn, "setdefinition")) {
             return false;
         }
-        
+
         boolean ok = true;
         boolean ok = true;
-        
+
         /* get set name */
         String setname = pn.getChild("name").getTerminal();
         assert (setname != null);
 
         SetDescriptor sd = new SetDescriptor(setname);
         /* get set name */
         String setname = pn.getChild("name").getTerminal();
         assert (setname != null);
 
         SetDescriptor sd = new SetDescriptor(setname);
-        
+
         /* get set type */
         String settype = pn.getChild("type").getTerminal();
         TypeDescriptor type = lookupType(settype);
         if (type == null) {
             er.report(pn, "Undefined type '" + settype + "'");
         /* get set type */
         String settype = pn.getChild("type").getTerminal();
         TypeDescriptor type = lookupType(settype);
         if (type == null) {
             er.report(pn, "Undefined type '" + settype + "'");
-            ok = false; 
+            ok = false;
         } else {
             sd.setType(type);
         }
 
         /* is this a partition? */
         boolean partition = pn.getChild("partition") != null;
         } else {
             sd.setType(type);
         }
 
         /* is this a partition? */
         boolean partition = pn.getChild("partition") != null;
-        sd.isPartition(partition); 
+        sd.isPartition(partition);
 
         /* if set has subsets, add them to set descriptor */
         if (pn.getChild("setlist") != null) {
             ParseNodeVector setlist = pn.getChild("setlist").getChildren();
 
         /* if set has subsets, add them to set descriptor */
         if (pn.getChild("setlist") != null) {
             ParseNodeVector setlist = pn.getChild("setlist").getChildren();
-            
+
             for (int i = 0; i < setlist.size(); i++) {
                 String subsetname = setlist.elementAt(i).getLabel();
                 sd.addSubset(lookupSet(subsetname, CREATE_MISSING));
             for (int i = 0; i < setlist.size(); i++) {
                 String subsetname = setlist.elementAt(i).getLabel();
                 sd.addSubset(lookupSet(subsetname, CREATE_MISSING));
-            }            
+            }
         }
 
         /* add set to symbol table */
         }
 
         /* add set to symbol table */
@@ -814,7 +819,7 @@ public class SemanticChecker {
         String rangesetname = pn.getChild("range").getChild("type").getTerminal();
         assert rangesetname != null;
 
         String rangesetname = pn.getChild("range").getChild("type").getTerminal();
         assert rangesetname != null;
 
-        /* get domain multiplicity */  
+        /* get domain multiplicity */
        String domainmult;
        if (pn.getChild("domain").getChild("domainmult") != null)
            domainmult = pn.getChild("domain").getChild("domainmult").getChild("mult").getTerminal();
        String domainmult;
        if (pn.getChild("domain").getChild("domainmult") != null)
            domainmult = pn.getChild("domain").getChild("domainmult").getChild("mult").getTerminal();
@@ -826,7 +831,7 @@ public class SemanticChecker {
            rangemult = pn.getChild("range").getChild("domainrange").getChild("mult").getTerminal();
         //assert rangemult != null;
 
            rangemult = pn.getChild("range").getChild("domainrange").getChild("mult").getTerminal();
         //assert rangemult != null;
 
-        /* NOTE: it is assumed that the sets have been parsed already so that the 
+        /* NOTE: it is assumed that the sets have been parsed already so that the
            set namespace is fully populated. any missing setdescriptors for the set
            symbol table will be assumed to be errors and reported. */
 
            set namespace is fully populated. any missing setdescriptors for the set
            symbol table will be assumed to be errors and reported. */
 
@@ -863,7 +868,7 @@ public class SemanticChecker {
         if (!precheck(pn, "structures")) {
             return false;
         }
         if (!precheck(pn, "structures")) {
             return false;
         }
-        
+
         boolean ok = true;
         ParseNodeVector structures = pn.getChildren("structure");
 
         boolean ok = true;
         ParseNodeVector structures = pn.getChildren("structure");
 
@@ -881,7 +886,7 @@ public class SemanticChecker {
             }
         }
 
             }
         }
 
-        // ok, all the structures have been parsed, now we gotta type check       
+        // ok, all the structures have been parsed, now we gotta type check
 
         Enumeration types = stTypes.getDescriptors();
         while (types.hasMoreElements()) {
 
         Enumeration types = stTypes.getDescriptors();
         while (types.hasMoreElements()) {
@@ -890,7 +895,7 @@ public class SemanticChecker {
             if (t instanceof ReservedTypeDescriptor) {
                 // we don't need to check reserved types
             } else if (t instanceof StructureTypeDescriptor) {
             if (t instanceof ReservedTypeDescriptor) {
                 // we don't need to check reserved types
             } else if (t instanceof StructureTypeDescriptor) {
-                
+
                 StructureTypeDescriptor type = (StructureTypeDescriptor) t;
                 TypeDescriptor subtype = type.getSuperType();
 
                 StructureTypeDescriptor type = (StructureTypeDescriptor) t;
                 TypeDescriptor subtype = type.getSuperType();
 
@@ -910,7 +915,7 @@ public class SemanticChecker {
                 Iterator fields = type.getFields();
 
                 while (fields.hasNext()) {
                 Iterator fields = type.getFields();
 
                 while (fields.hasNext()) {
-                    FieldDescriptor field = (FieldDescriptor) fields.next();                        
+                    FieldDescriptor field = (FieldDescriptor) fields.next();
                     TypeDescriptor fieldtype = field.getType();
 
                     assert fieldtype != null;
                     TypeDescriptor fieldtype = field.getType();
 
                     assert fieldtype != null;
@@ -921,8 +926,8 @@ public class SemanticChecker {
                         if (newtype == null) {
                             // type never defined
                             // #TBD#: replace new ParseNode with original parsenode
                         if (newtype == null) {
                             // type never defined
                             // #TBD#: replace new ParseNode with original parsenode
-                           
-                           if (!field.getPtr()) { 
+
+                           if (!field.getPtr()) {
                                /* Pointer types don't have to be defined */
                                er.report(null, "Undefined type '" + fieldtype.getSymbol() + "'");
                                ok = false;
                                /* Pointer types don't have to be defined */
                                er.report(null, "Undefined type '" + fieldtype.getSymbol() + "'");
                                ok = false;
@@ -956,7 +961,7 @@ public class SemanticChecker {
                         }
                     }
                 }
                         }
                     }
                 }
-                
+
             } else {
                 throw new IRException("shouldn't be any other typedescriptor classes");
             }
             } else {
                 throw new IRException("shouldn't be any other typedescriptor classes");
             }
@@ -974,13 +979,13 @@ public class SemanticChecker {
             if (t instanceof ReservedTypeDescriptor) {
                 // we don't need to check reserved types
             } else if (t instanceof StructureTypeDescriptor) {
             if (t instanceof ReservedTypeDescriptor) {
                 // we don't need to check reserved types
             } else if (t instanceof StructureTypeDescriptor) {
-                
+
                 StructureTypeDescriptor type = (StructureTypeDescriptor)t;
                 TypeDescriptor subtype = type.getSuperType();
                 Iterator fields = type.getFields();
 
                 while (fields.hasNext()) {
                 StructureTypeDescriptor type = (StructureTypeDescriptor)t;
                 TypeDescriptor subtype = type.getSuperType();
                 Iterator fields = type.getFields();
 
                 while (fields.hasNext()) {
-                    FieldDescriptor field = (FieldDescriptor) fields.next();                        
+                    FieldDescriptor field = (FieldDescriptor) fields.next();
 
                     if (field instanceof ArrayDescriptor) {
                         ArrayDescriptor ad = (ArrayDescriptor) field;
 
                     if (field instanceof ArrayDescriptor) {
                         ArrayDescriptor ad = (ArrayDescriptor) field;
@@ -1010,7 +1015,7 @@ public class SemanticChecker {
                                 public IRErrorReporter getErrorReporter() { return er; }
                                 public SymbolTable getSymbolTable() { return stGlobals; }
                             });
                                 public IRErrorReporter getErrorReporter() { return er; }
                                 public SymbolTable getSymbolTable() { return stGlobals; }
                             });
-                        
+
                         if (indextype != ReservedTypeDescriptor.INT) {
                             er.report(null, "Label '" + type.getSymbol() + "." + label.getSymbol() + "' index must be type 'int' not '" + indextype.getSymbol() + "'");
                             ok = false;
                         if (indextype != ReservedTypeDescriptor.INT) {
                             er.report(null, "Label '" + type.getSymbol() + "." + label.getSymbol() + "' index must be type 'int' not '" + indextype.getSymbol() + "'");
                             ok = false;
@@ -1023,7 +1028,7 @@ public class SemanticChecker {
         }
 
         // #TBD#: need to make sure that no cycles exist in any of the declarations or subtypes
         }
 
         // #TBD#: need to make sure that no cycles exist in any of the declarations or subtypes
-        // subtypes, of course, are not real subtypes, they are merely a way to validate a 
+        // subtypes, of course, are not real subtypes, they are merely a way to validate a
         // cast, i believe
 
         return ok;
         // cast, i believe
 
         return ok;
@@ -1039,10 +1044,10 @@ public class SemanticChecker {
 
         String type = pn.getChild("type").getTerminal();
         assert type != null;
 
         String type = pn.getChild("type").getTerminal();
         assert type != null;
+
         TypeDescriptor td = lookupType(type);
         assert td != null;
         TypeDescriptor td = lookupType(type);
         assert td != null;
-        assert !(td instanceof ReservedTypeDescriptor);
-        
+
         if (stGlobals.contains(name)) {
             /* redefinition of global */
             er.report(pn, "Redefinition of global '" + name + "'");
         if (stGlobals.contains(name)) {
             /* redefinition of global */
             er.report(pn, "Redefinition of global '" + name + "'");
@@ -1061,7 +1066,7 @@ public class SemanticChecker {
         boolean ok = true;
         String typename = pn.getChild("name").getTerminal();
         StructureTypeDescriptor type = new StructureTypeDescriptor(typename);
         boolean ok = true;
         String typename = pn.getChild("name").getTerminal();
         StructureTypeDescriptor type = new StructureTypeDescriptor(typename);
-        
+
         if (pn.getChild("subtype") != null) {
             // has a subtype, lets try to resolve it
             String subtype = pn.getChild("subtype").getTerminal();
         if (pn.getChild("subtype") != null) {
             // has a subtype, lets try to resolve it
             String subtype = pn.getChild("subtype").getTerminal();
@@ -1077,7 +1082,7 @@ public class SemanticChecker {
         } else if (pn.getChild("subclass") != null) {
             // has a subtype, lets try to resolve it
             String subclass = pn.getChild("subclass").getTerminal();
         } else if (pn.getChild("subclass") != null) {
             // has a subtype, lets try to resolve it
             String subclass = pn.getChild("subclass").getTerminal();
-           
+
             if (subclass.equals(typename)) {
                 // Semantic Error: cyclic inheritance
                 er.report(pn, "Cyclic inheritance prohibited");
             if (subclass.equals(typename)) {
                 // Semantic Error: cyclic inheritance
                 er.report(pn, "Cyclic inheritance prohibited");
@@ -1090,9 +1095,9 @@ public class SemanticChecker {
         }
 
         // set the current type so that the recursive parses on the labels
         }
 
         // set the current type so that the recursive parses on the labels
-        // and fields can add themselves automatically to the current type         
+        // and fields can add themselves automatically to the current type
         dCurrentType = type;
         dCurrentType = type;
-        
+
         // parse the labels and fields
         if (!parse_labelsandfields(pn.getChild("lf"))) {
             ok = false;
         // parse the labels and fields
         if (!parse_labelsandfields(pn.getChild("lf"))) {
             ok = false;
@@ -1104,7 +1109,7 @@ public class SemanticChecker {
         } else {
             stTypes.add(type);
         }
         } else {
             stTypes.add(type);
         }
-        
+
         return ok;
     }
 
         return ok;
     }
 
@@ -1114,8 +1119,8 @@ public class SemanticChecker {
         }
 
         boolean ok = true;
         }
 
         boolean ok = true;
-     
-        // check the fields first (need the field names 
+
+        // check the fields first (need the field names
         // to type check the labels)
         if (!parse_fields(pn.getChild("fields"))) {
             ok = false;
         // to type check the labels)
         if (!parse_fields(pn.getChild("fields"))) {
             ok = false;
@@ -1133,17 +1138,17 @@ public class SemanticChecker {
         if (!precheck(pn, "fields")) {
             return false;
         }
         if (!precheck(pn, "fields")) {
             return false;
         }
-        
+
         boolean ok = true;
         boolean ok = true;
-        
+
         /* NOTE: because the order of the fields is important when defining a data structure,
            and because the order is defined by the order of the fields defined in the field
            vector, its important that the parser returns the fields in the correct order */
         /* NOTE: because the order of the fields is important when defining a data structure,
            and because the order is defined by the order of the fields defined in the field
            vector, its important that the parser returns the fields in the correct order */
-        
+
         ParseNodeVector fields = pn.getChildren();
 
         for (int i = 0; i < fields.size(); i++) {
         ParseNodeVector fields = pn.getChildren();
 
         for (int i = 0; i < fields.size(); i++) {
-            ParseNode field = fields.elementAt(i);            
+            ParseNode field = fields.elementAt(i);
             FieldDescriptor fd;
             boolean reserved;
             String name = null;
             FieldDescriptor fd;
             boolean reserved;
             String name = null;
@@ -1155,7 +1160,7 @@ public class SemanticChecker {
                 fd = new ReservedFieldDescriptor();
                 reserved = true;
             } else {
                 fd = new ReservedFieldDescriptor();
                 reserved = true;
             } else {
-                name = field.getChild("name").getTerminal();                
+                name = field.getChild("name").getTerminal();
                 fd = new FieldDescriptor(name);
                 reserved = false;
             }
                 fd = new FieldDescriptor(name);
                 reserved = false;
             }
@@ -1167,7 +1172,7 @@ public class SemanticChecker {
             fd.setType(lookupType(type, CREATE_MISSING));
 
             if (field.getChild("index") != null) {
             fd.setType(lookupType(type, CREATE_MISSING));
 
             if (field.getChild("index") != null) {
-                // field is an array, so create an array descriptor to wrap the 
+                // field is an array, so create an array descriptor to wrap the
                 // field descriptor and then replace the top level field descriptor with
                 // this array descriptor
                 Expr expr = parse_expr(field.getChild("index").getChild("expr"));
                 // field descriptor and then replace the top level field descriptor with
                 // this array descriptor
                 Expr expr = parse_expr(field.getChild("index").getChild("expr"));
@@ -1175,7 +1180,7 @@ public class SemanticChecker {
                     // #ATTN#: do we really want to return an exception here?
                     throw new IRException("invalid index expression");
                 }
                     // #ATTN#: do we really want to return an exception here?
                     throw new IRException("invalid index expression");
                 }
-                ArrayDescriptor ad = new ArrayDescriptor(fd, expr);               
+                ArrayDescriptor ad = new ArrayDescriptor(fd, expr);
                 fd = ad;
             }
 
                 fd = ad;
             }
 
@@ -1183,7 +1188,7 @@ public class SemanticChecker {
             if (reserved == false) {
                 // lets double check that we are redefining a field
                 if (dCurrentType.getField(name) != null) {
             if (reserved == false) {
                 // lets double check that we are redefining a field
                 if (dCurrentType.getField(name) != null) {
-                    // Semantic Error: field redefinition 
+                    // Semantic Error: field redefinition
                     er.report(pn, "Redefinition of field '" + name + "'");
                     ok = false;
                 } else {
                     er.report(pn, "Redefinition of field '" + name + "'");
                     ok = false;
                 } else {
@@ -1193,7 +1198,7 @@ public class SemanticChecker {
                 dCurrentType.addField(fd);
             }
         }
                 dCurrentType.addField(fd);
             }
         }
-        
+
         return ok;
     }
 
         return ok;
     }
 
@@ -1209,10 +1214,10 @@ public class SemanticChecker {
 
         ParseNodeVector labels = pn.getChildren();
 
 
         ParseNodeVector labels = pn.getChildren();
 
-        for (int i = 0; i < labels.size(); i++) {           
+        for (int i = 0; i < labels.size(); i++) {
             ParseNode label = labels.elementAt(i);
             String name = label.getChild("name").getTerminal();
             ParseNode label = labels.elementAt(i);
             String name = label.getChild("name").getTerminal();
-            LabelDescriptor ld = new LabelDescriptor(name); 
+            LabelDescriptor ld = new LabelDescriptor(name);
 
             if (label.getChild("index") != null) {
                 Expr expr = parse_expr(label.getChild("index").getChild("expr"));
 
             if (label.getChild("index") != null) {
                 Expr expr = parse_expr(label.getChild("index").getChild("expr"));
@@ -1220,14 +1225,14 @@ public class SemanticChecker {
                     /* #ATTN#: do we really want to return an exception here? */
                     throw new IRException("Invalid expression");
                 }
                     /* #ATTN#: do we really want to return an exception here? */
                     throw new IRException("Invalid expression");
                 }
-                ld.setIndex(expr);                
-            } 
-            
+                ld.setIndex(expr);
+            }
+
             String type = label.getChild("type").getTerminal();
 
             ld.setType(lookupType(type, CREATE_MISSING));
             String type = label.getChild("type").getTerminal();
 
             ld.setType(lookupType(type, CREATE_MISSING));
-                        
-            String field = label.getChild("field").getTerminal();           
+
+            String field = label.getChild("field").getTerminal();
             FieldDescriptor fd = dCurrentType.getField(field);
 
             if (fd == null) {
             FieldDescriptor fd = dCurrentType.getField(field);
 
             if (fd == null) {
@@ -1244,7 +1249,7 @@ public class SemanticChecker {
                 er.report(pn, "Redefinition of label '" + name + "'");
                 ok = false;
             } else {
                 er.report(pn, "Redefinition of label '" + name + "'");
                 ok = false;
             } else {
-                dCurrentType.addLabel(ld);            
+                dCurrentType.addLabel(ld);
             }
         }
 
             }
         }
 
@@ -1269,18 +1274,18 @@ public class SemanticChecker {
         } else if (pn.getChild("sizeof") != null) {
             return parse_sizeof(pn.getChild("sizeof"));
         } else if (pn.getChild("simple_expr") != null) {
         } else if (pn.getChild("sizeof") != null) {
             return parse_sizeof(pn.getChild("sizeof"));
         } else if (pn.getChild("simple_expr") != null) {
-            return parse_simple_expr(pn.getChild("simple_expr"));        
+            return parse_simple_expr(pn.getChild("simple_expr"));
         } else if (pn.getChild("elementof") != null) {
         } else if (pn.getChild("elementof") != null) {
-            return parse_elementof(pn.getChild("elementof"));        
+            return parse_elementof(pn.getChild("elementof"));
         } else if (pn.getChild("tupleof") != null) {
         } else if (pn.getChild("tupleof") != null) {
-            return parse_tupleof(pn.getChild("tupleof"));        
+            return parse_tupleof(pn.getChild("tupleof"));
         } else if (pn.getChild("isvalid") != null) {
             er.report(pn, "Operation 'isvalid' is currently unsupported.");
             return null;
         } else {
             er.report(pn, "Unknown or invalid expression type '" + pn.getTerminal() + "'");
             return null;
         } else if (pn.getChild("isvalid") != null) {
             er.report(pn, "Operation 'isvalid' is currently unsupported.");
             return null;
         } else {
             er.report(pn, "Unknown or invalid expression type '" + pn.getTerminal() + "'");
             return null;
-        }            
+        }
     }
 
     private Expr parse_elementof(ParseNode pn) {
     }
 
     private Expr parse_elementof(ParseNode pn) {
@@ -1300,7 +1305,7 @@ public class SemanticChecker {
 
         /* get left side expr */
         Expr expr = parse_expr(pn.getChild("expr"));
 
         /* get left side expr */
         Expr expr = parse_expr(pn.getChild("expr"));
-        
+
         if (expr == null) {
             return null;
         }
         if (expr == null) {
             return null;
         }
@@ -1312,7 +1317,7 @@ public class SemanticChecker {
         if (!precheck(pn, "tupleof")) {
             return null;
         }
         if (!precheck(pn, "tupleof")) {
             return null;
         }
-        
+
         /* get relation */
         String relname = pn.getChild("name").getTerminal();
         assert relname != null;
         /* get relation */
         String relname = pn.getChild("name").getTerminal();
         assert relname != null;
@@ -1366,23 +1371,23 @@ public class SemanticChecker {
 
         String relname = pn.getChild("name").getTerminal();
         boolean inverse = pn.getChild("inv") != null;
 
         String relname = pn.getChild("name").getTerminal();
         boolean inverse = pn.getChild("inv") != null;
-        Expr expr = parse_expr(pn.getChild("expr"));        
+        Expr expr = parse_expr(pn.getChild("expr"));
 
         if (expr == null) {
             return null;
         }
 
         if (expr == null) {
             return null;
         }
-                    
+
         RelationDescriptor relation = lookupRelation(relname);
         RelationDescriptor relation = lookupRelation(relname);
-            
+
         if (relation == null) {
             /* Semantic Error: relation not definied" */
             er.report(pn, "Undefined relation '" + relname + "'");
             return null;
         if (relation == null) {
             /* Semantic Error: relation not definied" */
             er.report(pn, "Undefined relation '" + relname + "'");
             return null;
-        }                       
+        }
 
         /* add usage so correct sets are created */
         relation.addUsage(inverse ? RelationDescriptor.INVIMAGE : RelationDescriptor.IMAGE);
 
         /* add usage so correct sets are created */
         relation.addUsage(inverse ? RelationDescriptor.INVIMAGE : RelationDescriptor.IMAGE);
-            
+
         return new RelationExpr(expr, relation, inverse);
     }
 
         return new RelationExpr(expr, relation, inverse);
     }
 
@@ -1393,7 +1398,7 @@ public class SemanticChecker {
 
         /* get setexpr */
         SetExpr setexpr = parse_setexpr(pn.getChild("setexpr"));
 
         /* get setexpr */
         SetExpr setexpr = parse_setexpr(pn.getChild("setexpr"));
-        
+
         if (setexpr == null) {
             return null;
         }
         if (setexpr == null) {
             return null;
         }
@@ -1415,14 +1420,14 @@ public class SemanticChecker {
             /* semantic error: undefined type in cast */
             er.report(pn, "Undefined type '" + typename + "' in cast operator");
             return null;
             /* semantic error: undefined type in cast */
             er.report(pn, "Undefined type '" + typename + "' in cast operator");
             return null;
-        } 
+        }
 
         /* get expr */
         Expr expr = parse_simple_expr(pn.getChild("simple_expr"));
 
         /* get expr */
         Expr expr = parse_simple_expr(pn.getChild("simple_expr"));
-        
+
         if (expr == null) {
             return null;
         if (expr == null) {
             return null;
-        } 
+        }
 
         return new CastExpr(type, expr);
     }
 
         return new CastExpr(type, expr);
     }
@@ -1440,9 +1445,9 @@ public class SemanticChecker {
             SetDescriptor sd = lookupSet(setname);
 
             if (sd == null) {
             SetDescriptor sd = lookupSet(setname);
 
             if (sd == null) {
-                er.report(pn, "Unknown or undefined set '" + setname + "'");             
+                er.report(pn, "Unknown or undefined set '" + setname + "'");
                 return null;
                 return null;
-            } else {                         
+            } else {
                 return new SetExpr(sd);
             }
         } else if (pn.getChild("dot") != null) {
                 return new SetExpr(sd);
             }
         } else if (pn.getChild("dot") != null) {
@@ -1478,14 +1483,14 @@ public class SemanticChecker {
         /* get var */
         String varname = pn.getTerminal();
         assert varname != null;
         /* get var */
         String varname = pn.getTerminal();
         assert varname != null;
-        
+
         /* NOTE: quantifier var's are only found in the constraints and
         /* NOTE: quantifier var's are only found in the constraints and
-           model definitions... therefore we can do a semantic check here 
+           model definitions... therefore we can do a semantic check here
            to make sure that the variables exist in the symbol table */
 
         /* NOTE: its assumed that the symbol table stack is appropriately
            set up with the parent quantifier symbol table */
            to make sure that the variables exist in the symbol table */
 
         /* NOTE: its assumed that the symbol table stack is appropriately
            set up with the parent quantifier symbol table */
-        assert !sts.empty();          
+        assert !sts.empty();
 
         /* do semantic check and if valid, add it to symbol table
            and add it to the quantifier as well */
 
         /* do semantic check and if valid, add it to symbol table
            and add it to the quantifier as well */
@@ -1504,7 +1509,7 @@ public class SemanticChecker {
             return null;
         }
     }
             return null;
         }
     }
-    
+
     private LiteralExpr parse_literal(ParseNode pn) {
         if (!precheck(pn, "literal")) {
             return null;
     private LiteralExpr parse_literal(ParseNode pn) {
         if (!precheck(pn, "literal")) {
             return null;
@@ -1515,8 +1520,8 @@ public class SemanticChecker {
                 return new BooleanLiteralExpr(true);
             } else {
                 return new BooleanLiteralExpr(false);
                 return new BooleanLiteralExpr(true);
             } else {
                 return new BooleanLiteralExpr(false);
-            } 
-        } else if (pn.getChild("decimal") != null) {            
+            }
+        } else if (pn.getChild("decimal") != null) {
             String integer = pn.getChild("decimal").getTerminal();
 
             /* Check for integer literal overflow */
             String integer = pn.getChild("decimal").getTerminal();
 
             /* Check for integer literal overflow */
@@ -1550,7 +1555,7 @@ public class SemanticChecker {
 
     private OpExpr parse_operator(ParseNode pn) {
         if (!precheck(pn, "operator")) {
 
     private OpExpr parse_operator(ParseNode pn) {
         if (!precheck(pn, "operator")) {
-            return null; 
+            return null;
         }
 
         String opname = pn.getChild("op").getTerminal();
         }
 
         String opname = pn.getChild("op").getTerminal();
@@ -1560,15 +1565,15 @@ public class SemanticChecker {
             er.report(pn, "Unsupported operation: " + opname);
             return null;
         }
             er.report(pn, "Unsupported operation: " + opname);
             return null;
         }
-        
+
         Expr left = parse_expr(pn.getChild("left").getChild("expr"));
         Expr right = null;
         Expr left = parse_expr(pn.getChild("left").getChild("expr"));
         Expr right = null;
-        
+
         if (pn.getChild("right") != null) {
             right = parse_expr(pn.getChild("right").getChild("expr"));
         }
 
         if (pn.getChild("right") != null) {
             right = parse_expr(pn.getChild("right").getChild("expr"));
         }
 
-        if (left == null) {           
+        if (left == null) {
             return null;
         }
 
             return null;
         }
 
@@ -1597,14 +1602,13 @@ public class SemanticChecker {
 
         if (pn.getChild("index") != null) {
             index = parse_expr(pn.getChild("index").getChild("expr"));
 
         if (pn.getChild("index") != null) {
             index = parse_expr(pn.getChild("index").getChild("expr"));
-            
+
             if (index == null) {
                 return null;
             }
         }
 
             if (index == null) {
                 return null;
             }
         }
 
-        return new DotExpr(left, field, index);        
+        return new DotExpr(left, field, index);
     }
 
 }
     }
 
 }
-
index 51a5113844a1b3147cc6640c67c7679e623ae5af..7beefc99eb23e036ea207a7481f2e672d2a926e3 100755 (executable)
@@ -3,7 +3,7 @@ import MCC.Compiler;
 import java.util.*;
 
 public class SetInclusion extends Inclusion {
 import java.util.*;
 
 public class SetInclusion extends Inclusion {
-    
+
     Expr elementexpr;
     SetDescriptor set;
 
     Expr elementexpr;
     SetDescriptor set;
 
@@ -59,22 +59,22 @@ public class SetInclusion extends Inclusion {
         String addeditem = (VarDescriptor.makeNew("addeditem")).getSafeSymbol();
         generatedaddeditem = addeditem; // allows access to the result of the set addition later.
 
         String addeditem = (VarDescriptor.makeNew("addeditem")).getSafeSymbol();
         generatedaddeditem = addeditem; // allows access to the result of the set addition later.
 
-        // we set equal to one so that if dostore == false the guard in teh 
-        // metainclusion generation for the subrules and sub quantifiers will go on        
+        // we set equal to one so that if dostore == false the guard in teh
+        // metainclusion generation for the subrules and sub quantifiers will go on
 
 
         if (dostore) {
            /*      if (!Compiler.REPAIR) {
                writer.outputline("int " + addeditem + " = 1;");
 
 
         if (dostore) {
            /*      if (!Compiler.REPAIR) {
                writer.outputline("int " + addeditem + " = 1;");
-               writer.outputline(addeditem + " = " + set.getSafeSymbol() + "_hash->add((int)" + vd.getSafeSymbol() 
+               writer.outputline(addeditem + " = " + set.getSafeSymbol() + "_hash->add((int)" + vd.getSafeSymbol()
                                  +  ", (int)" + vd.getSafeSymbol() + ");");
                                  } else {*/
                Repair.generate_dispatch(writer, set, vd.getSafeSymbol());
                //          }
                                  +  ", (int)" + vd.getSafeSymbol() + ");");
                                  } else {*/
                Repair.generate_dispatch(writer, set, vd.getSafeSymbol());
                //          }
-           
+
             if (SetInclusion.worklist) {
                 writer.outputline("if (" + addeditem + ")");
             if (SetInclusion.worklist) {
                 writer.outputline("if (" + addeditem + ")");
-                writer.startblock(); {                
+                writer.startblock(); {
                     WorkList.generate_dispatch(writer, set, vd.getSafeSymbol());
                 }
                 writer.endblock();
                     WorkList.generate_dispatch(writer, set, vd.getSafeSymbol());
                 }
                 writer.endblock();
@@ -84,8 +84,9 @@ public class SetInclusion extends Inclusion {
 
     public boolean typecheck(SemanticAnalyzer sa) {
         TypeDescriptor td = elementexpr.typecheck(sa);
 
     public boolean typecheck(SemanticAnalyzer sa) {
         TypeDescriptor td = elementexpr.typecheck(sa);
-        
+
         if (td == null) {
         if (td == null) {
+            sa.getErrorReporter().report(null, "No type found for:"+elementexpr);
             return false;
         }
 
             return false;
         }
 
@@ -95,7 +96,7 @@ public class SetInclusion extends Inclusion {
             sa.getErrorReporter().report(null, "Type mismatch: attempting to test for types '" + td.getSymbol() + "' in set of type '" + settype.getSymbol() + "'");
             return false;
         }
             sa.getErrorReporter().report(null, "Type mismatch: attempting to test for types '" + td.getSymbol() + "' in set of type '" + settype.getSymbol() + "'");
             return false;
         }
-        
+
         return true;
     }
 
         return true;
     }
 
index 12a47f364ac74001bac92ae06c00aaf4fdd5b56b..de490b3a19b3f759f8987ec71bbeae788b75a0d6 100755 (executable)
@@ -38,7 +38,7 @@ public class VarExpr extends Expr {
     public VarExpr(VarDescriptor vd) {
        this.vd=vd;
        varname=vd.getSymbol();
     public VarExpr(VarDescriptor vd) {
        this.vd=vd;
        varname=vd.getSymbol();
-        this.td = vd.getType();        
+        this.td = vd.getType();
     }
 
     public String name() {
     }
 
     public String name() {
@@ -85,7 +85,7 @@ public class VarExpr extends Expr {
     public Set getRequiredDescriptors() {
         return new HashSet();
     }
     public Set getRequiredDescriptors() {
         return new HashSet();
     }
-    
+
     public VarDescriptor getVar() {
         return vd;
     }
     public VarDescriptor getVar() {
         return vd;
     }
@@ -103,12 +103,12 @@ public class VarExpr extends Expr {
            Set s=new HashSet();
            s.add(this);
            return s;
            Set s=new HashSet();
            s.add(this);
            return s;
-       } else 
+       } else
            return new HashSet();
     }
 
     public void generate(CodeWriter writer, VarDescriptor dest) {
            return new HashSet();
     }
 
     public void generate(CodeWriter writer, VarDescriptor dest) {
-        // #TBD#: bit of a hack, really should have been type checked properly 
+        // #TBD#: bit of a hack, really should have been type checked properly
         assert vd != null;
         assert vd.getType() != null;
        this.td = vd.getType();
         assert vd != null;
         assert vd.getType() != null;
        this.td = vd.getType();
@@ -121,16 +121,16 @@ public class VarExpr extends Expr {
            return;
        }
 
            return;
        }
 
-        writer.outputline(vd.getType().getGenerateType().getSafeSymbol() + " " + dest.getSafeSymbol() + 
+        writer.outputline(vd.getType().getGenerateType().getSafeSymbol() + " " + dest.getSafeSymbol() +
                           " = (" + vd.getType().getGenerateType().getSafeSymbol() + ") " + vd.getSafeSymbol() + "; //varexpr");
        if (vd.isGlobal() && (DOTYPECHECKS||DOMEMCHECKS) && (td instanceof StructureTypeDescriptor)) {
            VarDescriptor typevar=VarDescriptor.makeNew("typechecks");
            writer.outputline("if ("+dest.getSafeSymbol()+")");
            writer.startblock();
            if (DOTYPECHECKS)
                           " = (" + vd.getType().getGenerateType().getSafeSymbol() + ") " + vd.getSafeSymbol() + "; //varexpr");
        if (vd.isGlobal() && (DOTYPECHECKS||DOMEMCHECKS) && (td instanceof StructureTypeDescriptor)) {
            VarDescriptor typevar=VarDescriptor.makeNew("typechecks");
            writer.outputline("if ("+dest.getSafeSymbol()+")");
            writer.startblock();
            if (DOTYPECHECKS)
-               writer.outputline("bool "+typevar.getSafeSymbol()+"=assertvalidtype(" + dest.getSafeSymbol() + ", " + td.getId() + ");"); 
+               writer.outputline("bool "+typevar.getSafeSymbol()+"=assertvalidtype(" + dest.getSafeSymbol() + ", " + td.getId() + ");");
            else
            else
-               writer.outputline("bool "+typevar.getSafeSymbol()+"=assertvalidmemory(" + dest.getSafeSymbol() + ", " + td.getId() + ");"); 
+               writer.outputline("bool "+typevar.getSafeSymbol()+"=assertvalidmemory(" + dest.getSafeSymbol() + ", " + td.getId() + ");");
            writer.outputline("if (!"+typevar.getSafeSymbol()+")");
            writer.startblock();
            writer.outputline(dest.getSafeSymbol()+"=0;");
            writer.outputline("if (!"+typevar.getSafeSymbol()+")");
            writer.startblock();
            writer.outputline(dest.getSafeSymbol()+"=0;");
@@ -148,17 +148,13 @@ public class VarExpr extends Expr {
     public TypeDescriptor typecheck(SemanticAnalyzer sa) {
         typechecked = true;
         vd = (VarDescriptor) sa.getSymbolTable().get(varname);
     public TypeDescriptor typecheck(SemanticAnalyzer sa) {
         typechecked = true;
         vd = (VarDescriptor) sa.getSymbolTable().get(varname);
-
         if (vd == null) {
             //System.out.println(varname);
             sa.getErrorReporter().report(null, "Undefined variable '" + varname + "'");
             return null;
         }
         if (vd == null) {
             //System.out.println(varname);
             sa.getErrorReporter().report(null, "Undefined variable '" + varname + "'");
             return null;
         }
-        
         assert vd.getType() != null;
         assert vd.getType() != null;
-
         this.td = vd.getType();
         return this.td;
     }
         this.td = vd.getType();
         return this.td;
     }
-    
 }
 }
index a5299e396c7bf706747b6fbe609060658db317d4..1d69d05e08b727c178bf81d89518ad6f5cd0bea2 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
 #!/bin/bash
-FLAG='-O9'
+FLAG='-O0 -g'
 g++ $FLAG -c SimpleHash.cc
 g++ $FLAG -c tmap.cc
 g++ $FLAG -c instrument.cc
 g++ $FLAG -c SimpleHash.cc
 g++ $FLAG -c tmap.cc
 g++ $FLAG -c instrument.cc
index 0ae3eb5765e778e633011f0dae3d82effa106869..92704f68ad41d213e9fa40b4d8cd7b604031cadb 100755 (executable)
@@ -194,6 +194,7 @@ nonterminal ParseNode               label;
 nonterminal    ParseNode               field;
 nonterminal    ParseNode               optptr;
 nonterminal    ParseNode               type;
 nonterminal    ParseNode               field;
 nonterminal    ParseNode               optptr;
 nonterminal    ParseNode               type;
+nonterminal    ParseNode               primtype;
 nonterminal    ParseNode               optindex;
 nonterminal    ParseNode               expr;
 nonterminal    ParseNode               simple_expr;
 nonterminal    ParseNode               optindex;
 nonterminal    ParseNode               expr;
 nonterminal    ParseNode               simple_expr;
@@ -250,10 +251,20 @@ structure ::=
        {:
        debugMessage(PRODSTRING);
        ParseNode global = new ParseNode("global", parser.curLine(4));
        {:
        debugMessage(PRODSTRING);
        ParseNode global = new ParseNode("global", parser.curLine(4));
+       global.addChild("ptr");
        global.addChild("type").addChild(type);
        global.addChild("name").addChild(name);
        RESULT = global;
        :}
        global.addChild("type").addChild(type);
        global.addChild("name").addChild(name);
        RESULT = global;
        :}
+
+       | primtype:type ID:name SEMICOLON
+       {:
+       debugMessage(PRODSTRING);
+       ParseNode global = new ParseNode("global", parser.curLine(4));
+       global.addChild(type);
+       global.addChild("name").addChild(name);
+       RESULT = global;
+       :}
        ;
 
 optsubtype ::= 
        ;
 
 optsubtype ::= 
@@ -594,3 +605,38 @@ type ::=
        RESULT = type;
        :}
        ;
        RESULT = type;
        :}
        ;
+
+primtype ::= 
+     
+       BIT
+       {:
+       debugMessage(PRODSTRING);
+       ParseNode type = new ParseNode("type", parser.curLine(1));
+       type.addChild("bit");
+       RESULT = type;
+       :}
+     
+       | BYTE
+       {:
+       debugMessage(PRODSTRING);
+       ParseNode type = new ParseNode("type", parser.curLine(1));
+       type.addChild("byte");
+       RESULT = type;
+       :}
+     
+       | SHORT
+       {:
+       debugMessage(PRODSTRING);
+       ParseNode type = new ParseNode("type", parser.curLine(1));
+       type.addChild("short");
+       RESULT = type;
+       :}
+     
+       | INT 
+       {:
+       debugMessage(PRODSTRING);
+       ParseNode type = new ParseNode("type", parser.curLine(1));
+       type.addChild("int");
+       RESULT = type;
+       :}
+;
\ No newline at end of file