Search in sources :

Example 6 with Reference

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

the class MplParser method type.

private static Parser<?> type() {
    Reference ref = Parser.newReference();
    Parser<?> prod = Parsers.tuple(term("("), ref.lazy(), term("*"), ref.lazy(), term(")"));
    Parser<?> a = Parsers.or(new Parser[] { term("I"), ident(), prod });
    ref.set(a);
    return a;
}
Also used : Reference(org.jparsec.Parser.Reference)

Example 7 with Reference

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

the class NraViewer method inst.

private static Parser<?> inst() {
    Reference ref = Parser.newReference();
    Parser rcd = Parsers.tuple(term("("), Parsers.tuple(ident(), term(":"), ref.lazy()).sepBy(term(",")), term(")"));
    Parser set = Parsers.tuple(term("{"), rcd.sepBy(term(",")), term("}"));
    Parser p = Parsers.or(string(), rcd, set);
    ref.set(p);
    return p;
}
Also used : Reference(org.jparsec.Parser.Reference) Parser(org.jparsec.Parser)

Example 8 with Reference

use of org.jparsec.Parser.Reference 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 9 with Reference

use of org.jparsec.Parser.Reference 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 10 with Reference

use of org.jparsec.Parser.Reference 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)

Aggregations

Reference (org.jparsec.Parser.Reference)21 Parser (org.jparsec.Parser)12