use of org.jparsec.Parser.Reference in project fql by CategoricalData.
the class PPParser method set.
private static Parser<?> set() {
Reference ref = Parser.newReference();
Parser<?> app = Parsers.tuple(term("apply"), ident(), term("on"), term("object"), ref.lazy());
Parser<?> union = Parsers.between(term("("), Parsers.tuple(ref.lazy(), term("union"), ref.lazy()), term(")"));
Parser<?> isect = Parsers.between(term("("), Parsers.tuple(ref.lazy(), term("intersect"), ref.lazy()), term(")"));
Parser<?> plusTy = Parsers.between(term("("), Parsers.tuple(ref.lazy(), term("+"), ref.lazy()), term(")"));
Parser<?> prodTy = Parsers.between(term("("), Parsers.tuple(ref.lazy(), term("*"), ref.lazy()), term(")"));
Parser<?> expTy = Parsers.between(term("("), Parsers.tuple(ref.lazy(), term("^"), ref.lazy()), term(")"));
Parser<?> k = Parsers.tuple(term("cod"), ident());
Parser<?> v = Parsers.tuple(term("dom"), ident());
Parser<?> u = Parsers.tuple(term("range"), ident());
Parser<?> a = Parsers.or(union, isect, term("void"), term("unit"), term("prop"), plusTy, prodTy, expTy, k, v, u, ident(), setConst(), IntegerLiteral.PARSER, app);
ref.set(a);
return a;
}
use of org.jparsec.Parser.Reference in project fql by CategoricalData.
the class PPParser method ftr.
private static Parser<?> ftr() {
Reference ref = Parser.newReference();
Parser plusTy = Parsers.between(term("("), Parsers.tuple(ref.lazy(), term("+"), ref.lazy()), term(")"));
Parser expTy = Parsers.between(term("("), Parsers.tuple(ref.lazy(), term("^"), ref.lazy()), term(")"));
Parser prodTy = Parsers.between(term("("), Parsers.tuple(ref.lazy(), term("*"), ref.lazy()), term(")"));
Parser compTy = Parsers.between(term("("), Parsers.tuple(ref.lazy(), term(";"), ref.lazy()), term(")"));
// //
Parser<?> node = Parsers.tuple(ident(), term("->"), cat());
Parser<?> arrow = Parsers.tuple(ident(), term("->"), ref.lazy());
Parser<?> xxx = Parsers.tuple(section("objects", node), section("arrows", arrow));
Parser<?> constant = Parsers.tuple(Parsers.between(term("{"), xxx, term("}")), term(":"), cat(), term("->"), term("Cat"));
// //
// //
Parser<?> node2 = Parsers.tuple(ident(), term("->"), ref.lazy());
Parser<?> arrow2 = Parsers.tuple(ident(), term("->"), ident());
Parser<?> xxx2 = Parsers.tuple(section("objects", node2), section("arrows", arrow2));
Parser t1 = Parsers.between(term("("), Parsers.tuple(term("Set"), term("^"), cat()), term(")"));
Parser t2 = Parsers.between(term("("), Parsers.tuple(term("Cat"), term("^"), cat()), term(")"));
Parser<?> constant2 = Parsers.tuple(Parsers.between(term("{"), xxx2, term("}")), term(":"), cat(), term("->"), t1.or(t2));
// //
Parser catTerm = term("Cat");
Parser setTerm = term("Set");
Parser a = Parsers.or(Parsers.tuple(term("unit"), cat(), catTerm.or(setTerm)), Parsers.tuple(term("void"), cat(), catTerm.or(setTerm)), Parsers.tuple(term("tt"), cat()), Parsers.tuple(term("ff"), cat()), Parsers.tuple(term("dom"), ident()), Parsers.tuple(term("cod"), ident()), Parsers.tuple(term("iso1"), cat(), cat()), Parsers.tuple(term("iso2"), cat(), cat()), Parsers.tuple(term("fst"), cat(), cat()), Parsers.tuple(term("snd"), cat(), cat()), Parsers.tuple(term("inl"), cat(), cat()), Parsers.tuple(term("inr"), cat(), cat()), Parsers.tuple(term("eval"), cat(), cat()), Parsers.tuple(term("curry"), ref.lazy()), Parsers.tuple(term("uncurry"), ref.lazy()), Parsers.tuple(term("delta"), ref.lazy()), Parsers.tuple(term("sigma"), ref.lazy()), Parsers.tuple(term("pi"), ref.lazy()), Parsers.tuple(term("pivot"), ref.lazy()), Parsers.tuple(term("unpivot"), ref.lazy()), Parsers.tuple(term("pushout"), ident(), ident()), Parsers.tuple(term("apply"), ref.lazy(), term("on"), term("object"), ref.lazy()), Parsers.tuple(term("id"), cat()), Parsers.tuple(term("prop"), cat()), compTy, plusTy, prodTy, expTy, ident(), instanceConst(), constant, setsetConst(), constant2, mappingConst());
ref.set(a);
return a;
}
use of org.jparsec.Parser.Reference in project fql by CategoricalData.
the class OplParser method exp.
private static Parser<?> exp() {
Reference ref = Parser.newReference();
Parser<?> theory = theory();
Parser<?> model = model();
Parser<?> trans = trans();
Parser<?> trans_pres = trans_pres();
Parser<?> eval = Parsers.tuple(term("eval"), ident(), oplTerm());
Parser<?> java = java();
Parser<?> mapping = mapping();
Parser<?> delta = Parsers.tuple(term("delta"), ident(), ident());
Parser<?> sigma = Parsers.tuple(term("sigma"), ident(), ident());
Parser<?> presentation = presentation();
Parser<?> sat = Parsers.tuple(term("saturate"), ident());
Parser<?> DELTA = Parsers.tuple(term("DELTA"), ident());
Parser<?> ubersat = Parsers.tuple(term("SATURATE"), ident(), ident());
Parser<?> unsat = Parsers.tuple(term("unsaturate"), ident());
Parser<?> flower = flower();
Parser<?> schema = schema();
Parser<?> projE = Parsers.tuple(term("entities"), ident());
Parser<?> projA = Parsers.tuple(term("attributes"), ident());
Parser<?> projT = Parsers.tuple(term("types"), ident());
Parser<?> projEA = Parsers.tuple(term("entitiesAndAttributes"), ident());
Parser<?> inst = Parsers.tuple(term("instance"), ident(), ident(), ident());
Parser<?> query = query();
Parser<?> idQ = Parsers.tuple(term("id"), ident());
Parser<?> ID = Parsers.tuple(term("ID"), ident());
Parser<?> apply = Parsers.tuple(term("apply"), ident(), ident());
Parser<?> SCHEMA = SCHEMA();
Parser<?> INST = INSTANCE();
Parser<?> pushout = Parsers.tuple(term("pushout"), ident(), ident());
Parser<?> pushoutSch = Parsers.tuple(term("PUSHOUT"), ident(), ident());
Parser<?> pushoutBen = Parsers.tuple(term("pushoutBen"), ident(), ident());
Parser<?> pivot = Parsers.tuple(term("pivot"), ident());
Parser<?> union = Parsers.tuple(term("union"), ident(), term("{"), ident().many(), term("}"));
Parser<?> pragma = pragma();
Parser<?> colim = Parsers.tuple(term("colimit"), ident(), ident());
Parser<?> sql = sql();
Parser<?> model2 = model2();
Parser<?> graph = graph();
Parser<?> distinct = Parsers.tuple(term("distinct"), ident());
Parser<?> chase = Parsers.tuple(term("chase"), ident(), Parsers.tuple(term("with"), term("{"), ident().sepBy(term(",")), term("}")), term("max"), IntegerLiteral.PARSER);
Parser<?> arith = Parsers.tuple(term("arith"), NUMBER);
Parser<?> a = Parsers.or(arith, distinct, graph, model2, sql, chase, ID, colim, pragma, union, pushoutBen, pushoutSch, pivot, DELTA, pushout, INST, SCHEMA, apply, idQ, query, projEA, inst, schema, projE, projA, projT, flower, ubersat, sigma, sat, unsat, presentation, delta, mapping, theory, model, eval, trans, trans_pres, java);
ref.set(a);
return a;
}
use of org.jparsec.Parser.Reference in project fql by CategoricalData.
the class OplParser method oplTerm.
private static Parser<?> oplTerm() {
Reference ref = Parser.newReference();
Parser<?> app = Parsers.tuple(string(), term("("), ref.lazy().sepBy(term(",")), term(")"));
Parser<?> app2 = Parsers.tuple(term("("), ref.lazy(), string(), ref.lazy(), term(")"));
Parser<?> a = Parsers.or(new Parser[] { app, app2, string().sepBy1(term(".")) });
ref.set(a);
return a;
}
use of org.jparsec.Parser.Reference in project fql by CategoricalData.
the class MplParser method exp.
private static Parser<?> exp() {
Reference ref = Parser.newReference();
Parser<?> eval = Parsers.tuple(term("eval"), ident(), term());
Parser<?> a = Parsers.or(new Parser[] { theory(), eval });
ref.set(a);
return a;
}