Search in sources :

Example 1 with Parser

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;
}
Also used : Reference(org.jparsec.Parser.Reference) Parser(org.jparsec.Parser)

Example 2 with Parser

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;
}
Also used : Parser(org.jparsec.Parser)

Example 3 with Parser

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;
}
Also used : Parser(org.jparsec.Parser)

Example 4 with Parser

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;
}
Also used : Parser(org.jparsec.Parser)

Example 5 with Parser

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;
}
Also used : Parser(org.jparsec.Parser)

Aggregations

Parser (org.jparsec.Parser)38 Reference (org.jparsec.Parser.Reference)15 InstExpAnonymize (catdata.aql.exp.InstExp.InstExpAnonymize)4 InstExpChase (catdata.aql.exp.InstExp.InstExpChase)4 InstExpCoEval (catdata.aql.exp.InstExp.InstExpCoEval)4 InstExpCoProdFull (catdata.aql.exp.InstExp.InstExpCoProdFull)4 InstExpCod (catdata.aql.exp.InstExp.InstExpCod)4 InstExpDelta (catdata.aql.exp.InstExp.InstExpDelta)4 InstExpDistinct (catdata.aql.exp.InstExp.InstExpDistinct)4 InstExpDom (catdata.aql.exp.InstExp.InstExpDom)4 InstExpEval (catdata.aql.exp.InstExp.InstExpEval)4 InstExpFrozen (catdata.aql.exp.InstExp.InstExpFrozen)4 InstExpPi (catdata.aql.exp.InstExp.InstExpPi)4 InstExpSigma (catdata.aql.exp.InstExp.InstExpSigma)4 InstExpSigmaChase (catdata.aql.exp.InstExp.InstExpSigmaChase)4 InstExpVar (catdata.aql.exp.InstExp.InstExpVar)4 ParseException (catdata.ParseException)3 Program (catdata.Program)3 Quad (catdata.Quad)3 Triple (catdata.Triple)3