Package edu.mit.csail.sdg.alloy4compiler.ast

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Module


      }
    };

    System.out.println("=========== Parsing+Typechecking " + theory
        + " =============");
    Module world;
    try {
      world = CompUtil.parseEverything_fromFile(rep, null, theory);
      // Choose some default options for how you want to execute the
      // commands
      A4Options options = new A4Options();
      options.solver = A4Options.SatSolver.SAT4J;

      for (Command command : world.getAllCommands()) {
        // Execute the command
        System.out.println("============ Command " + command
            + ": ============");
        A4Solution ans = TranslateAlloyToKodkod.execute_command(rep,
            world.getAllReachableSigs(), command, options);
        // Print the outcome
        // System.out.println(ans);
        int cont = 1;
        long tempoAntes = System.currentTimeMillis();
View Full Code Here


        private void cb(Object... objs) throws Exception { out.callback(objs); }
        public void run(WorkerCallback out) throws Exception {
            this.out = out;
            cb("S2", "Enumerating...\n");
            A4Solution sol;
            Module mod;
            synchronized(SimpleReporter.class) {
                if (latestMetamodelXML!=null && latestMetamodelXML.equals(filename))
                   {cb("pop", "You cannot enumerate a metamodel.\n"); return;}
                if (latestKodkodXML==null || !latestKodkodXML.equals(filename))
                   {cb("pop", "You can only enumerate the solutions of the most-recently-solved command."); return;}
View Full Code Here

        public SimpleTask1() { }
        public void cb(WorkerCallback out, Object... objs) throws IOException { out.callback(objs); }
        public void run(WorkerCallback out) throws Exception {
            cb(out, "S2", "Starting the solver...\n\n");
            final SimpleReporter rep = new SimpleReporter(out, options.recordKodkod);
            final Module world = CompUtil.parseEverything_fromFile(rep, map, options.originalFilename, resolutionMode);
            final List<Sig> sigs = world.getAllReachableSigs();
            final ConstList<Command> cmds = world.getAllCommands();
            cb(out, "warnings", bundleWarningNonFatal);
            if (rep.warn>0 && !bundleWarningNonFatal) return;
            List<String> result = new ArrayList<String>(cmds.size());
            if (bundleIndex==-2) {
                final String outf=tempdir+File.separatorChar+"m.xml";
                cb(out, "S2", "Generating the metamodel...\n");
                PrintWriter of = new PrintWriter(outf, "UTF-8");
                Util.encodeXMLs(of, "\n<alloy builddate=\"", Version.buildDate(), "\">\n\n");
                A4SolutionWriter.writeMetamodel(ConstList.make(sigs), options.originalFilename, of);
                Util.encodeXMLs(of, "\n</alloy>");
                Util.close(of);
                if ("yes".equals(System.getProperty("debug"))) validate(outf);
                cb(out, "metamodel", outf);
                synchronized(SimpleReporter.class) { latestMetamodelXML=outf; }
            } else for(int i=0; i<cmds.size(); i++) if (bundleIndex<0 || i==bundleIndex) {
                synchronized(SimpleReporter.class) { latestModule=world; latestKodkodSRC=ConstMap.make(map); }
                final String tempXML=tempdir+File.separatorChar+i+".cnf.xml";
                final String tempCNF=tempdir+File.separatorChar+i+".cnf";
                final Command cmd=cmds.get(i);
                rep.tempfile=tempCNF;
                cb(out, "bold", "Executing \""+cmd+"\"\n");
                A4Solution ai=TranslateAlloyToKodkod.execute_commandFromBook(rep, world.getAllReachableSigs(), cmd, options);
                if (ai==null) result.add(null);
                else if (ai.satisfiable()) result.add(tempXML);
                else if (ai.highLevelCore().a.size()>0) result.add(tempCNF+".core");
                else result.add("");
            }
            (new File(tempdir)).delete(); // In case it was UNSAT, or canceled...
            if (result.size()>1) {
                rep.cb("bold", "" + result.size() + " commands were executed. The results are:\n");
                for(int i=0; i<result.size(); i++) {
                    Command r=world.getAllCommands().get(i);
                    if (result.get(i)==null) { rep.cb("", "   #"+(i+1)+": Unknown.\n"); continue; }
                    if (result.get(i).endsWith(".xml")) {
                        rep.cb("", "   #"+(i+1)+": ");
                        rep.cb("link", r.check?"Counterexample found. ":"Instance found. ", "XML: "+result.get(i));
                        rep.cb("", r.label+(r.check?" is invalid":" is consistent"));
View Full Code Here

    private Runner doShowParseTree() {
        if (wrap) return wrapMe();
        doRefreshRun();
        OurUtil.enableAll(runmenu);
        if (commands!=null) {
            Module world = null;
            try {
                int resolutionMode = (Version.experimental && ImplicitThis.get()) ? 2 : 1;
                A4Options opt = new A4Options();
                opt.tempDirectory = alloyHome() + fs + "tmp";
                opt.solverDirectory = alloyHome() + fs + "binary";
                opt.originalFilename = Util.canon(text.get().getFilename());
                world = CompUtil.parseEverything_fromFile(A4Reporter.NOP, text.takeSnapshot(), opt.originalFilename, resolutionMode);
            } catch(Err er) {
                text.shade(er.pos);
                log.logRed(er.toString()+"\n\n");
                return null;
            }
            world.showAsTree(this);
        }
        return null;
    }
View Full Code Here

        for(String filename:args) {

            // Parse+typecheck the model
            System.out.println("=========== Parsing+Typechecking "+filename+" =============");
            Module world = CompUtil.parseEverything_fromFile(rep, null, filename);

            // Choose some default options for how you want to execute the commands
            A4Options options = new A4Options();
            options.solver = A4Options.SatSolver.SAT4J;

            for (Command command: world.getAllCommands()) {
                // Execute the command
                System.out.println("============ Command "+command+": ============");
                A4Solution ans = TranslateAlloyToKodkod.execute_command(rep, world.getAllReachableSigs(), command, options);
                // Print the outcome
                System.out.println(ans);
                // If satisfiable...
                if (ans.satisfiable()) {
                    // You can query "ans" to find out the values of each set or type.
View Full Code Here

TOP

Related Classes of edu.mit.csail.sdg.alloy4compiler.ast.Module

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.