Search in sources :

Example 16 with Reference

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

the class PPParser method value.

private static Parser<?> value() {
    Reference ref = Parser.newReference();
    Parser<?> p1 = Parsers.tuple(term("inl"), ref.lazy());
    Parser<?> p2 = Parsers.tuple(term("inr"), ref.lazy());
    Parser<?> p3 = Parsers.tuple(term("("), term(")"));
    Parser<?> p4 = Parsers.tuple(term("("), ref.lazy(), term(","), ref.lazy(), term(")"));
    Parser<?> p5 = term("true");
    Parser<?> p6 = term("false");
    Parser<?> p7 = Parsers.tuple(term("{"), ref.lazy().sepBy(term(",")), term("}"));
    Parser<?> xxx = Parsers.tuple(p7, term("->"), p7);
    Parser<?> p8 = Parsers.tuple(term("{"), p4.sepBy(term(",")), term("}"), term(":"), xxx);
    // Parser<?> op = Parsers.tuple(term("opposite"), ref.lazy());
    Parser<?> a = Parsers.or(new Parser[] { string(), p1, p2, p3, p4, p5, p6, p8, p7 });
    ref.set(a);
    return a;
}
Also used : Reference(org.jparsec.Parser.Reference)

Example 17 with Reference

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

the class PPParser method cat.

private static Parser<?> cat() {
    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<?> 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<?> colim = Parsers.tuple(term("colim"), ident());
    Parser<?> kleisli = Parsers.tuple(term("kleisli"), ident(), ident(), ident());
    Parser<?> cokleisli = Parsers.tuple(term("cokleisli"), ident(), ident(), ident());
    Parser<?> union = Parsers.tuple(term("union"), ref.lazy(), ref.lazy());
    Parser<?> a = Parsers.or(colim, term("void"), term("unit"), plusTy, prodTy, expTy, k, v, ident(), catConst(), term("Cat"), term("Set"), kleisli, cokleisli, union);
    ref.set(a);
    return a;
}
Also used : Reference(org.jparsec.Parser.Reference)

Example 18 with Reference

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

the class PPParser method fn.

private static Parser<?> fn() {
    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(";"), ref.lazy()), term(")"));
    Parser<?> app2 = Parsers.tuple(term("apply"), ident(), set());
    Parser<?> app = Parsers.tuple(term("apply"), ident(), term("on"), term("arrow"), ref.lazy());
    Parser a = Parsers.or(term("true"), term("false"), term("and"), term("or"), term("not"), term("implies"), Parsers.tuple(term("tt"), set()), Parsers.tuple(term("ff"), set()), Parsers.tuple(term("iso1"), set(), set()), Parsers.tuple(term("iso2"), set(), set()), Parsers.tuple(term("fst"), set(), set()), Parsers.tuple(term("snd"), set(), set()), Parsers.tuple(term("inl"), set(), set()), Parsers.tuple(term("inr"), set(), set()), Parsers.tuple(term("eval"), set(), set()), Parsers.tuple(term("curry"), ref.lazy()), Parsers.tuple(term("char"), ref.lazy()), Parsers.tuple(term("kernel"), ref.lazy()), Parsers.tuple(term("id"), set()), compTy, plusTy, prodTy, ident(), fnConst(), app, app2);
    ref.set(a);
    return a;
}
Also used : Reference(org.jparsec.Parser.Reference) Parser(org.jparsec.Parser)

Example 19 with Reference

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

the class MplParser method term.

private static Parser<?> term() {
    Reference ref = Parser.newReference();
    Parser<?> prod = Parsers.tuple(term("("), ref.lazy(), term("*"), ref.lazy(), term(")"));
    Parser<?> comp = Parsers.tuple(term("("), ref.lazy(), term(";"), ref.lazy(), term(")"));
    Parser<?> alpha1 = Parsers.tuple(term("alpha1"), type(), type(), type());
    Parser<?> alpha2 = Parsers.tuple(term("alpha2"), type(), type(), type());
    Parser<?> lambda1 = Parsers.tuple(term("lambda1"), type());
    Parser<?> lambda2 = Parsers.tuple(term("lambda2"), type());
    Parser<?> rho1 = Parsers.tuple(term("rho1"), type());
    Parser<?> rho2 = Parsers.tuple(term("rho2"), type());
    Parser<?> id = Parsers.tuple(term("id"), type());
    Parser<?> tr = Parsers.tuple(term("tr"), ref.lazy());
    Parser<?> sym = Parsers.tuple(term("sym"), type(), type());
    // Parser<?> rho = Parsers.tuple(term("("), ref.lazy(), term("*"), ref.lazy(), term(")"));
    Parser<?> a = Parsers.or(sym, tr, id, ident(), prod, comp, alpha1, alpha2, lambda1, lambda2, rho1, rho2);
    ref.set(a);
    return a;
}
Also used : Reference(org.jparsec.Parser.Reference)

Example 20 with Reference

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

the class NraViewer method ty.

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

Aggregations

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