Search in sources :

Example 11 with Parser

use of org.jparsec.Parser in project fql by CategoricalData.

the class XParser method exp.

private static Parser<?> exp() {
    Reference ref = Parser.newReference();
    Parser<?> sigma = Parsers.tuple(term("sigma"), ref.lazy(), ref.lazy());
    Parser<?> delta = Parsers.tuple(term("delta"), ref.lazy(), ref.lazy());
    Parser<?> pi = Parsers.tuple(term("pi"), ref.lazy(), ref.lazy());
    Parser<?> rel = Parsers.tuple(term("relationalize"), ref.lazy());
    Parser<?> coprod = Parsers.tuple(term("("), ref.lazy(), term("+"), ref.lazy(), term(")"));
    Parser<?> inl = Parsers.tuple(term("inl"), ref.lazy(), ref.lazy());
    Parser<?> inr = Parsers.tuple(term("inr"), ref.lazy(), ref.lazy());
    Parser<?> match = Parsers.tuple(term("case"), ref.lazy(), ref.lazy());
    Parser<?> zero = Parsers.tuple(term("void"), ref.lazy());
    Parser<?> ff = Parsers.tuple(term("ff"), ref.lazy());
    Parser<?> prod = Parsers.tuple(term("("), ref.lazy(), term("*"), ref.lazy(), term(")"));
    Parser<?> fst = Parsers.tuple(term("fst"), ref.lazy(), ref.lazy());
    Parser<?> snd = Parsers.tuple(term("snd"), ref.lazy(), ref.lazy());
    Parser<?> pair = Parsers.tuple(term("pair"), ref.lazy(), ref.lazy());
    Parser<?> unit = Parsers.tuple(term("unit"), ref.lazy());
    Parser<?> tt = Parsers.tuple(term("tt"), ref.lazy());
    Parser<?> ret = Parsers.tuple(term("return"), term("sigma"), term("delta"), ref.lazy(), ref.lazy());
    Parser<?> counit = Parsers.tuple(term("coreturn"), term("sigma"), term("delta"), ref.lazy(), ref.lazy());
    Parser<?> unit1 = Parsers.tuple(term("return"), term("delta"), term("pi"), ref.lazy(), ref.lazy());
    Parser<?> counit1 = Parsers.tuple(term("coreturn"), term("delta"), term("pi"), ref.lazy(), ref.lazy());
    Parser<?> flower = flower(ref);
    Parser<?> FLOWER = FLOWER(ref);
    Parser id1 = Parsers.tuple(term("id"), ref.lazy());
    Parser id2 = Parsers.tuple(term("ID"), ref.lazy());
    Parser<?> comp = Parsers.tuple(term("("), ref.lazy(), term(";"), ref.lazy(), term(")"));
    // Parser<?> query = query(ref);
    Parser<?> apply = Parsers.tuple(term("apply"), ref.lazy(), ref.lazy());
    Parser<?> iter = Parsers.tuple(term("iterate"), IntegerLiteral.PARSER, ref.lazy(), ref.lazy());
    Parser<?> hom = Parsers.tuple(term("hom"), ref.lazy(), ref.lazy());
    Parser<?> uberpi = Parsers.tuple(term("uberpi"), ref.lazy());
    Parser<?> labels = Parsers.tuple(term("labels"), ref.lazy());
    Parser<?> glabels = Parsers.tuple(term("grothlabels"), ref.lazy());
    Parser<?> idpoly = Parsers.tuple(term("idpoly"), ref.lazy());
    Parser<?> coapply = Parsers.tuple(term("coapply"), ref.lazy(), ref.lazy());
    Parser<?> pushout = Parsers.tuple(term("pushout"), ref.lazy(), ref.lazy());
    Parser<?> soed = soed();
    Parser<?> supersoed = superSoed();
    Parser<?> a = Parsers.or(supersoed, soed, pushout, coapply, glabels, idpoly, labels, uberpi, hom, poly(ref), id1, id2, comp, apply, iter, FLOWER, flower, prod, fst, snd, pair, unit, tt, zero, ff, coprod, inl, inr, match, rel, pi, ret, counit, unit1, counit1, ident(), schema(), mapping(ref), instance(ref), transform(ref), sigma, delta);
    ref.set(a);
    return a;
}
Also used : Reference(org.jparsec.Parser.Reference) Parser(org.jparsec.Parser)

Example 12 with Parser

use of org.jparsec.Parser in project fql by CategoricalData.

the class XParser method flower.

private static Parser<?> flower(Reference self) {
    Parser<?> from0 = Parsers.tuple(ident(), term("as"), ident()).sepBy(term(","));
    Parser<?> from = Parsers.tuple(term("from"), from0, term(";"));
    Parser<?> where0 = Parsers.tuple(path(), term("="), path()).sepBy(term(","));
    Parser<?> where = Parsers.tuple(term("where"), where0, term(";"));
    Parser<?> select0 = Parsers.tuple(path(), term("as"), ident()).sepBy(term(","));
    Parser<?> select = Parsers.tuple(term("select"), select0, term(";"));
    Parser p = Parsers.tuple(select, from, where);
    Parser ret = Parsers.tuple(term("flower"), p.between(term("{"), term("}")), self.lazy());
    return ret;
}
Also used : Parser(org.jparsec.Parser)

Example 13 with Parser

use of org.jparsec.Parser in project fql by CategoricalData.

the class FQLParser method query.

@SuppressWarnings({ "rawtypes", "unchecked" })
private static Parser<?> query() {
    Reference ref = Parser.newReference();
    Parser p1 = Parsers.tuple(term("delta"), mapping());
    Parser p2 = Parsers.tuple(term("pi"), mapping());
    Parser p3 = Parsers.tuple(term("sigma"), mapping());
    Parser comp = Parsers.tuple(term("("), ref.lazy(), term("then"), ref.lazy(), term(")"));
    // Parser zzz = Parsers.tuple(ident(), term(","), ident());
    // Parser yyy = Parsers.between(term("("), zzz, term(")"));
    // Parser xxx = Parsers
    // .between(term("{"), yyy.sepBy(term(",")), term("}"));
    // Parser mtch = Parsers.tuple(term("match"), xxx, schema(), schema(),
    // Terminals.StringLiteral.PARSER);
    Parser ret = Parsers.or(Parsers.tuple(p1, p2, p3), comp, ident());
    ref.set(ret);
    return ret;
}
Also used : Reference(org.jparsec.Parser.Reference) Parser(org.jparsec.Parser)

Example 14 with Parser

use of org.jparsec.Parser in project fql by CategoricalData.

the class FQLParser method mapping.

@SuppressWarnings({ "rawtypes", "unchecked" })
private static Parser<?> mapping() {
    Reference ref = Parser.newReference();
    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 compTy = Parsers.between(term("("), Parsers.tuple(ref.lazy(), term("then"), ref.lazy()), term(")"));
    Parser<?> xxx = ident().sepBy(term(",")).between(term("{"), term("}"));
    Parser a = Parsers.or(Parsers.tuple(term("unit"), xxx, schema()), Parsers.tuple(term("void"), schema()), Parsers.tuple(term("iso1"), schema(), schema()), Parsers.tuple(term("iso2"), schema(), schema()), Parsers.tuple(term("fst"), schema(), schema()), Parsers.tuple(term("snd"), schema(), schema()), Parsers.tuple(term("inl"), schema(), schema()), Parsers.tuple(term("inr"), schema(), schema()), Parsers.tuple(term("eval"), schema(), schema()), Parsers.tuple(term("opposite"), ref.lazy()), Parsers.tuple(term("curry"), ref.lazy()), // Parsers.tuple(term("eq"), schema()),
    Parsers.tuple(term("id"), schema()), Parsers.tuple(term("subschema"), schema(), schema()), // Parsers.tuple(term("dist2"), schema(), schema(), schema()),
    compTy, plusTy, prodTy, ident(), mappingConst());
    ref.set(a);
    return a;
}
Also used : Reference(org.jparsec.Parser.Reference) Parser(org.jparsec.Parser)

Example 15 with Parser

use of org.jparsec.Parser in project fql by CategoricalData.

the class FQLParser method instance.

@SuppressWarnings({ "rawtypes", "unchecked" })
private static Parser<?> instance() {
    Reference ref = Parser.newReference();
    Parser plusTy = Parsers.between(term("("), Parsers.tuple(ident(), term("+"), ident()), term(")"));
    Parser prodTy = Parsers.between(term("("), Parsers.tuple(ident(), term("*"), ident()), term(")"));
    Parser expTy = Parsers.between(term("("), Parsers.tuple(ident(), term("^"), ident()), term(")"));
    Parser<?> external = Parsers.tuple(term("external"), ident(), schema());
    Parser<?> delta = Parsers.tuple(term("delta"), mapping(), ident());
    Parser<?> sigma = Parsers.tuple(term("sigma"), mapping(), ident());
    Parser<?> pi = Parsers.tuple(term("pi"), mapping(), ident());
    Parser<?> SIGMA = Parsers.tuple(term("SIGMA"), mapping(), ident());
    Parser<?> relationalize = Parsers.tuple(term("relationalize"), ident());
    Parser<?> eval = Parsers.tuple(term("eval"), query(), ident());
    Parser<?> fullEval = Parsers.tuple(term("EVAL"), fullQuery(), ident());
    Parser<?> step = Parsers.tuple(term("step"), mapping(), mapping(), ident());
    Parser a = Parsers.or(Parsers.tuple(term("kernel"), ident()), Parsers.tuple(term("prop"), schema()), Parsers.tuple(term("void"), schema()), Parsers.tuple(term("unit"), schema()), plusTy, prodTy, expTy, /* ident(), */
    instanceConst(), delta, sigma, pi, SIGMA, external, relationalize, eval, fullEval, step);
    ref.set(a);
    return a;
}
Also used : Reference(org.jparsec.Parser.Reference) 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