Small changes to allow:
[repair.git] / Repair / RepairCompiler / MCC / IR / SemanticChecker.java
index 2e54c87778d1ba03de910a10e0581ec949217d66..af4aa96f735965afc163e8f8476aea5e86be3ff8 100755 (executable)
@@ -381,6 +381,7 @@ public class SemanticChecker {
         if (!precheck(pn, "constraints")) {
             return false;
         }
+        //System.out.println(pn.PPrint(2,true));
 
         boolean ok = true;
         ParseNodeVector constraints = pn.getChildren();
@@ -594,7 +595,6 @@ public class SemanticChecker {
         } else if (pn.getChild("not") != null) {
             /* NOT body */
             LogicStatement left = parse_body(pn.getChild("not").getChild("body"));
-
             if (left == null) {
                 return null;
             }
@@ -1099,7 +1099,7 @@ public class SemanticChecker {
         dCurrentType = type;
 
         // parse the labels and fields
-        if (!parse_labelsandfields(pn.getChild("lf"))) {
+        if (pn.getChild("lf")!=null && !parse_labelsandfields(pn.getChild("lf"))) {
             ok = false;
         }
 
@@ -1265,6 +1265,8 @@ public class SemanticChecker {
             // we've got a variable reference... we'll have to scope check it later
             // when we are completely done... there are also some issues of cyclic definitions
             return new VarExpr(pn.getChild("var").getTerminal());
+        } else if (pn.getChild("sumexpr") != null) {
+            return parse_sum(pn.getChild("sumexpr"));
         } else if (pn.getChild("literal") != null) {
             return parse_literal(pn.getChild("literal"));
         } else if (pn.getChild("operator") != null) {
@@ -1406,6 +1408,25 @@ public class SemanticChecker {
         return new SizeofExpr(setexpr);
     }
 
+    private SumExpr parse_sum(ParseNode pn) {
+        if (!precheck(pn, "sumexpr")) {
+            return null;
+        }
+        String setname = pn.getChild("dot").getChild("set").getTerminal();
+        assert setname != null;
+        SetDescriptor sd = lookupSet(setname);
+
+        if (sd == null) {
+            er.report(pn, "Unknown or undefined set '" + setname + "'");
+            return null;
+        }
+
+        RelationDescriptor rd = lookupRelation(pn.getChild("dot").getChild("relation").getTerminal());
+        rd.addUsage(RelationDescriptor.IMAGE);
+
+        return new SumExpr(sd,rd);
+    }
+
     private CastExpr parse_cast(ParseNode pn) {
         if (!precheck(pn, "cast")) {
             return null;