Search in sources :

Example 1 with AqlEnv

use of catdata.aql.exp.AqlEnv in project fql by CategoricalData.

the class AqlCmdLine method main.

public static void main(String[] args) {
    try (FileReader r = new FileReader(args[0])) {
        String str = Util.readFile(r);
        Program<Exp<?>> prog = AqlParser.getParser().parseProgram(str);
        String[] t = new String[1];
        AqlMultiDriver driver = new AqlMultiDriver(prog, t, null);
        driver.start();
        AqlEnv last_env = driver.env;
        if (last_env.exn != null) {
            throw last_env.exn;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : AqlEnv(catdata.aql.exp.AqlEnv) FileReader(java.io.FileReader) Exp(catdata.aql.exp.Exp) AqlMultiDriver(catdata.aql.exp.AqlMultiDriver)

Example 2 with AqlEnv

use of catdata.aql.exp.AqlEnv in project fql by CategoricalData.

the class AqlTester method runMany.

private static Ctx<String, Throwable> runMany(Ctx<String, String> progs) {
    Ctx<String, Throwable> result = new Ctx<>();
    for (String k : progs.keySet()) {
        try {
            System.out.println(k);
            Program<Exp<?>> prog = AqlParser.getParser().parseProgram(progs.get(k));
            String[] toUpdate = new String[] { "" };
            AqlMultiDriver driver = new AqlMultiDriver(prog, toUpdate, null);
            // blocks
            driver.start();
            AqlEnv env = driver.env;
            if (env.exn != null) {
                result.put(k, env.exn);
            }
        } catch (Throwable ex) {
            ex.printStackTrace();
            result.put(k, ex);
        }
    }
    return result;
}
Also used : AqlEnv(catdata.aql.exp.AqlEnv) Ctx(catdata.Ctx) Exp(catdata.aql.exp.Exp) AqlMultiDriver(catdata.aql.exp.AqlMultiDriver)

Example 3 with AqlEnv

use of catdata.aql.exp.AqlEnv in project fql by CategoricalData.

the class CodyCmdLine method main.

// args[0] = input AQL program
// args[1] = directory for tptp output
public static void main(String[] args) {
    try (FileReader r = new FileReader(args[0])) {
        String str = Util.readFile(r);
        Program<Exp<?>> prog = AqlParser.getParser().parseProgram(str);
        // poll for driver status
        String[] t = new String[1];
        AqlMultiDriver driver = new AqlMultiDriver(prog, t, null);
        // blocks
        driver.start();
        AqlEnv env = driver.env;
        if (env.exn != null) {
            throw env.exn;
        }
        File dir = new File(args[1]);
        dir.mkdirs();
        for (String k : env.defs.tys.keySet()) {
            TypeSide<?, ?> ts = env.defs.tys.get(k);
            File f = new File(dir, k + ".tptp");
            // maedmax is unsound with empty sorts, but true here proceeds anyway
            String s = ts.collage().toKB().tptp(true);
            Util.writeFile(s, f.getAbsolutePath());
        }
        for (String k : env.defs.insts.keySet()) {
            Instance ts = env.defs.insts.get(k);
            File f = new File(dir, k + ".tptp");
            // maedmax is unsound with empty sorts, but true here proceeds anyway
            String s = ts.collage().toKB().tptp(true);
            Util.writeFile(s, f.getAbsolutePath());
        }
        for (String k : env.defs.schs.keySet()) {
            Schema ts = env.defs.schs.get(k);
            File f = new File(dir, k + ".tptp");
            // maedmax is unsound with empty sorts, but true here proceeds anyway
            String s = ts.collage().toKB().tptp(true);
            Util.writeFile(s, f.getAbsolutePath());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : AqlEnv(catdata.aql.exp.AqlEnv) FileReader(java.io.FileReader) Exp(catdata.aql.exp.Exp) AqlMultiDriver(catdata.aql.exp.AqlMultiDriver) File(java.io.File)

Aggregations

AqlEnv (catdata.aql.exp.AqlEnv)3 AqlMultiDriver (catdata.aql.exp.AqlMultiDriver)3 Exp (catdata.aql.exp.Exp)3 FileReader (java.io.FileReader)2 Ctx (catdata.Ctx)1 File (java.io.File)1