use of org.jparsec.Parser 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 in project fql by CategoricalData.
the class OplParser method block2.
private static Parser<?> block2() {
Parser<?> fromAs = Parsers.tuple(ident(), Parsers.tuple(term("as"), ident()).optional());
Parser<?> from = Parsers.tuple(term("from"), fromAs.sepBy(term(",")));
Parser<?> where = Parsers.tuple(term("where"), Parsers.tuple(oplTerm(), term("="), oplTerm()).sepBy(term("and")));
Parser<?> zzz = Parsers.tuple(term("("), Parsers.tuple(oplTerm(), term("as"), ident()).sepBy(term(",")), term(")"));
Parser<?> retAs = Parsers.tuple(Parsers.or(zzz, oplTerm()), term("as"), ident());
Parser<?> ret = Parsers.tuple(term("select"), retAs.sepBy(term(",")));
Parser p = Parsers.tuple(ret, from, where.optional());
return p;
}
use of org.jparsec.Parser in project fql by CategoricalData.
the class OplParser method oplImpl.
private static Parser<?> oplImpl() {
Parser<?> p1 = Parsers.tuple(ident(), term(":"), ident());
Parser<?> z = Parsers.longest(p1, ident());
Parser<?> p = z.sepBy(term(","));
Parser<?> q = Parsers.tuple(oplTerm(), term("="), oplTerm()).sepBy(term(","));
Parser<?> zz = Parsers.tuple(q, term("->"), q);
Parser a = Parsers.tuple(term("forall"), p, term("."));
Parser retX = Parsers.tuple(a.optional(), zz);
return retX;
}
use of org.jparsec.Parser in project fql by CategoricalData.
the class OplParser method oplEq.
private static Parser<?> oplEq() {
Parser<?> p1 = Parsers.tuple(ident(), term(":"), ident());
Parser<?> z = Parsers.longest(p1, ident());
Parser<?> p = z.sepBy(term(","));
Parser<?> q = Parsers.tuple(oplTerm(), term("="), oplTerm());
Parser a = Parsers.tuple(term("forall"), p, term("."));
Parser retX = Parsers.tuple(a.optional(), q);
return retX;
}
use of org.jparsec.Parser in project fql by CategoricalData.
the class OplParser method agg.
private static Parser<?> agg() {
Parser p1 = Parsers.tuple(ident(), term(":"), ident()).sepBy(term(",")).between(term("for"), term(";"));
Parser p2 = Parsers.tuple(oplTerm(), term("="), oplTerm()).sepBy(term(",")).between(term("where"), term(";"));
Parser p3 = Parsers.tuple(term("return"), oplTerm());
Parser p0 = Parsers.tuple(term("agg"), ident(), ident(), term("{"));
Parser p = Parsers.tuple(p0, p1, p2, p3, term("}"));
return p;
}
Aggregations