Search in sources :

Example 6 with Module

use of edu.mit.csail.sdg.ast.Module in project org.alloytools.alloy by AlloyTools.

the class SimpleGUI method doShowParseTree.

/**
 * This method displays the parse tree.
 */
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;
}
Also used : Err(edu.mit.csail.sdg.alloy4.Err) A4Options(edu.mit.csail.sdg.translator.A4Options) Module(edu.mit.csail.sdg.ast.Module)

Example 7 with Module

use of edu.mit.csail.sdg.ast.Module in project org.alloytools.alloy by AlloyTools.

the class InternalTest method main2.

/**
 * Displays the amount of memory taken per solution enumeration.
 */
public static void main2(String[] args) throws Exception {
    String filename = "models/examples/algorithms/dijkstra.als";
    Module world = CompUtil.parseEverything_fromFile(A4Reporter.NOP, null, filename);
    A4Options options = new A4Options();
    for (Command command : world.getAllCommands()) {
        A4Solution ans = TranslateAlloyToKodkod.execute_command(A4Reporter.NOP, world.getAllReachableSigs(), command, options);
        while (ans.satisfiable()) {
            String hc = "Answer: " + ans.toString().hashCode();
            System.gc();
            System.gc();
            System.gc();
            Thread.sleep(500);
            System.gc();
            System.gc();
            System.gc();
            Thread.sleep(500);
            long t = Runtime.getRuntime().totalMemory(), f = Runtime.getRuntime().freeMemory(), m = Runtime.getRuntime().maxMemory();
            System.out.println(hc + " total=" + t + " free=" + f + " max=" + m);
            System.out.flush();
            ans = ans.next();
        }
        return;
    }
}
Also used : Command(edu.mit.csail.sdg.ast.Command) A4Options(edu.mit.csail.sdg.translator.A4Options) Module(edu.mit.csail.sdg.ast.Module) A4Solution(edu.mit.csail.sdg.translator.A4Solution)

Example 8 with Module

use of edu.mit.csail.sdg.ast.Module in project org.alloytools.alloy by AlloyTools.

the class AlloyTest method main.

public static void main(String[] args) throws Exception {
    A4Reporter rep = new A4Reporter();
    Module world = CompUtil.parseEverything_fromFile(rep, null, "/home/aleks/mvc.als");
    A4Options options = new A4Options();
    options.solver = A4Options.SatSolver.SAT4J;
    options.skolemDepth = 1;
    for (Command command : world.getAllCommands()) {
        A4Solution ans = null;
        try {
            ans = TranslateAlloyToKodkod.execute_commandFromBook(rep, world.getAllReachableSigs(), command, options);
            System.out.println(ans);
        } catch (Err ex) {
            Logger.getLogger(AlloyTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
Also used : Err(edu.mit.csail.sdg.alloy4.Err) Command(edu.mit.csail.sdg.ast.Command) A4Reporter(edu.mit.csail.sdg.alloy4.A4Reporter) A4Options(edu.mit.csail.sdg.translator.A4Options) Module(edu.mit.csail.sdg.ast.Module) A4Solution(edu.mit.csail.sdg.translator.A4Solution)

Aggregations

Module (edu.mit.csail.sdg.ast.Module)8 A4Options (edu.mit.csail.sdg.translator.A4Options)7 Command (edu.mit.csail.sdg.ast.Command)6 A4Solution (edu.mit.csail.sdg.translator.A4Solution)6 A4Reporter (edu.mit.csail.sdg.alloy4.A4Reporter)3 Err (edu.mit.csail.sdg.alloy4.Err)3 Expr (edu.mit.csail.sdg.ast.Expr)3 ErrorWarning (edu.mit.csail.sdg.alloy4.ErrorWarning)2 XMLNode (edu.mit.csail.sdg.alloy4.XMLNode)2 Decl (edu.mit.csail.sdg.ast.Decl)2 ExprHasName (edu.mit.csail.sdg.ast.ExprHasName)2 Sig (edu.mit.csail.sdg.ast.Sig)2 Pair (edu.mit.csail.sdg.alloy4.Pair)1 VizGUI (edu.mit.csail.sdg.alloy4viz.VizGUI)1 ExprBinary (edu.mit.csail.sdg.ast.ExprBinary)1 ExprUnary (edu.mit.csail.sdg.ast.ExprUnary)1 Func (edu.mit.csail.sdg.ast.Func)1 Field (edu.mit.csail.sdg.ast.Sig.Field)1 PrimSig (edu.mit.csail.sdg.ast.Sig.PrimSig)1 SubsetSig (edu.mit.csail.sdg.ast.Sig.SubsetSig)1