Some modifications to allow to print the name of the file when a syntax error is...
[repair.git] / Repair / RepairCompiler / MCC / Compiler.java
index ebda670ebd356603137db75373233fba87bd4b85..0395872829aaed67cb77ea53643fbdc6b86e716b 100755 (executable)
@@ -17,7 +17,8 @@ import MCC.IR.*;
  */
 
 public class Compiler {
-    public static boolean REPAIR=true;
+    /* Set this flag to false to turn repairs off */
+    public static boolean REPAIR=false;
     
     public static void main(String[] args) {
         State state = null;
@@ -55,12 +56,11 @@ public class Compiler {
            success = semantics(state) || error(state, "Semantic analysis failed, not attempting variable initialization.");
 
 
+           Termination termination=null;
+           /* Check partition constraints */
+           (new ImplicitSchema(state)).update();
+           termination=new Termination(state);
 
-           if (REPAIR) {
-               /* Check partition constraints */
-               (new ImplicitSchema(state)).update();
-               Termination t=new Termination(state);
-           }
             state.printall();
             (new DependencyBuilder(state)).calculate();
             
@@ -85,16 +85,25 @@ public class Compiler {
             
             try {
                 FileOutputStream gcode = new FileOutputStream(cli.infile + ".cc");
-                FileOutputStream gcode2 = new FileOutputStream(cli.infile + "_aux.cc");
-                FileOutputStream gcode3 = new FileOutputStream(cli.infile + "_aux.h");
+
 
                 // do model optimizations
                 //(new Optimizer(state)).optimize();
 
-                //NaiveGenerator ng = new NaiveGenerator(state);
-                //ng.generate(gcode);
-                RepairGenerator wg = new RepairGenerator(state);
-                wg.generate(gcode,gcode2,gcode3, cli.infile + "_aux.h");
+
+
+               FileOutputStream gcode2 = new FileOutputStream(cli.infile + "_aux.cc");
+               FileOutputStream gcode3 = new FileOutputStream(cli.infile + "_aux.h");
+               RepairGenerator wg = new RepairGenerator(state,termination);
+               wg.generate(gcode,gcode2,gcode3, cli.infile + "_aux.h");
+               gcode2.close();
+               gcode3.close();
+               /*              } else {
+                   WorklistGenerator ng = new WorklistGenerator(state);
+                   SetInclusion.worklist=true;
+                   RelationInclusion.worklist=true;
+                   ng.generate(gcode);
+                   }*/
                 gcode.close();
             } catch (Exception e) {
                 e.printStackTrace();
@@ -257,6 +266,7 @@ public class Compiler {
             LineCount.reset();
             FileInputStream infile = new FileInputStream(state.infile + ".model");
             MDLParser parser = new MDLParser(new Lexer(infile));
+           parser.filename = state.infile + ".model";
             CUP$MDLParser$actions.debug = state.verbose > 1 ;
             state.ptModel = (ParseNode) parser.parse().value;
         } catch (FileNotFoundException fnfe) {
@@ -280,8 +290,8 @@ public class Compiler {
             System.err.println("Unable to open file: " + state.infile + ".space");
             System.exit(-1);
        } catch (Exception e) {
-           //      System.out.println(e);
-           //      e.printStackTrace();
+           System.out.println(e);
+           e.printStackTrace();
            return false;
        }