Search in sources :

Example 6 with Parser

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

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

the class CombinatorParser method instExpCoProd.

@SuppressWarnings({ "rawtypes", "unchecked" })
private static Parser<InstExpCoProdSigma> instExpCoProd() {
    Parser<catdata.Pair<MapExp, InstExp>> p = Parsers.tuple(map_ref.lazy(), inst_ref.lazy()).map(x -> new catdata.Pair<>(x.a, x.b));
    Parser<InstExpCoProdSigma> ret = Parsers.tuple(token("coproduct_sigma"), p.many(), token(":"), sch_ref.lazy(), options.between(token("{"), token("}")).optional()).map(x -> new InstExpCoProdSigma(x.b, x.d, Util.newIfNull(x.e)));
    // 
    Parser<InstExpCoProdSigma> ret2 = Parsers.tuple(token("union"), inst_ref.lazy().sepBy(token("+")), token(":"), sch_ref.lazy(), options.between(token("{"), token("}")).optional()).map(x -> new InstExpCoProdSigma(x.b.stream().map(y -> new catdata.Pair<>(new MapExpId(x.d), y)).collect(Collectors.toList()), x.d, Util.newIfNull(x.e)));
    return Parsers.or(ret, ret2);
}
Also used : InstExpCoProdSigma(catdata.aql.exp.InstExp.InstExpCoProdSigma) AqlOptions(catdata.aql.AqlOptions) PragmaExpProc(catdata.aql.exp.PragmaExp.PragmaExpProc) Scanners(org.jparsec.Scanners) InstExpDelta(catdata.aql.exp.InstExp.InstExpDelta) GraphExpVar(catdata.aql.exp.GraphExp.GraphExpVar) GraphExpRaw(catdata.aql.exp.GraphExp.GraphExpRaw) StringLiteral(org.jparsec.Terminals.StringLiteral) EdsExpVar(catdata.aql.exp.EdsExp.EdsExpVar) SchExpInst(catdata.aql.exp.SchExp.SchExpInst) Pair(org.jparsec.functors.Pair) TransExpSigmaDeltaCounit(catdata.aql.exp.TransExp.TransExpSigmaDeltaCounit) QueryExpCompose(catdata.aql.exp.QueryExp.QueryExpCompose) PragmaExpConsistent(catdata.aql.exp.PragmaExp.PragmaExpConsistent) ParseException(catdata.ParseException) Quad(catdata.Quad) PragmaExpSql(catdata.aql.exp.PragmaExp.PragmaExpSql) SchExpVar(catdata.aql.exp.SchExp.SchExpVar) Parser(org.jparsec.Parser) InstExpColim(catdata.aql.exp.InstExp.InstExpColim) QueryExpDeltaCoEval(catdata.aql.exp.QueryExp.QueryExpDeltaCoEval) IntegerLiteral(org.jparsec.Terminals.IntegerLiteral) Program(catdata.Program) Triple(catdata.Triple) PragmaExpJs(catdata.aql.exp.PragmaExp.PragmaExpJs) PragmaExpCheck(catdata.aql.exp.PragmaExp.PragmaExpCheck) Ty(catdata.aql.exp.TyExpRaw.Ty) Terminals(org.jparsec.Terminals) PragmaExpMatch(catdata.aql.exp.PragmaExp.PragmaExpMatch) MapExpVar(catdata.aql.exp.MapExp.MapExpVar) TransExpDistinct(catdata.aql.exp.TransExp.TransExpDistinct) TyExpEmpty(catdata.aql.exp.TyExp.TyExpEmpty) TransExpVar(catdata.aql.exp.TransExp.TransExpVar) ColimSchExpQuotient(catdata.aql.exp.ColimSchExp.ColimSchExpQuotient) Token(org.jparsec.Token) PragmaExpToCsvInst(catdata.aql.exp.PragmaExp.PragmaExpToCsvInst) MapExpComp(catdata.aql.exp.MapExp.MapExpComp) InstExpCoEq(catdata.aql.exp.InstExp.InstExpCoEq) InstExpCod(catdata.aql.exp.InstExp.InstExpCod) InstExpCoProdFull(catdata.aql.exp.InstExp.InstExpCoProdFull) Att(catdata.aql.exp.SchExpRaw.Att) TransExpCoEvalEvalCoUnit(catdata.aql.exp.TransExp.TransExpCoEvalEvalCoUnit) TransExpDelta(catdata.aql.exp.TransExp.TransExpDelta) SchExpEmpty(catdata.aql.exp.SchExp.SchExpEmpty) ParserException(org.jparsec.error.ParserException) PragmaExpToJdbcTrans(catdata.aql.exp.PragmaExp.PragmaExpToJdbcTrans) Trans(catdata.aql.exp.QueryExpRaw.Trans) SchExpCod(catdata.aql.exp.SchExp.SchExpCod) InstExpChase(catdata.aql.exp.InstExp.InstExpChase) PragmaExpToJdbcQuery(catdata.aql.exp.PragmaExp.PragmaExpToJdbcQuery) InstExpFrozen(catdata.aql.exp.InstExp.InstExpFrozen) Sym(catdata.aql.exp.TyExpRaw.Sym) Tuple3(org.jparsec.functors.Tuple3) PragmaExpVar(catdata.aql.exp.PragmaExp.PragmaExpVar) Tuple4(org.jparsec.functors.Tuple4) Tuple5(org.jparsec.functors.Tuple5) InstExpAnonymize(catdata.aql.exp.InstExp.InstExpAnonymize) InstExpSigma(catdata.aql.exp.InstExp.InstExpSigma) TransExpEval(catdata.aql.exp.TransExp.TransExpEval) InstExpCoProdSigma(catdata.aql.exp.InstExp.InstExpCoProdSigma) InstExpVar(catdata.aql.exp.InstExp.InstExpVar) PreBlock(catdata.aql.exp.QueryExpRaw.PreBlock) TransExpSigmaDeltaUnit(catdata.aql.exp.TransExp.TransExpSigmaDeltaUnit) EdExpRaw(catdata.aql.exp.EdsExpRaw.EdExpRaw) Collectors(java.util.stream.Collectors) List(java.util.List) InstExpDom(catdata.aql.exp.InstExp.InstExpDom) Parsers(org.jparsec.Parsers) InstExpCoEval(catdata.aql.exp.InstExp.InstExpCoEval) TransExpSigma(catdata.aql.exp.TransExp.TransExpSigma) TransExpId(catdata.aql.exp.TransExp.TransExpId) MapExpId(catdata.aql.exp.MapExp.MapExpId) RawTerm(catdata.aql.RawTerm) En(catdata.aql.exp.SchExpRaw.En) InstExpSigmaChase(catdata.aql.exp.InstExp.InstExpSigmaChase) HashMap(java.util.HashMap) QueryExpDeltaEval(catdata.aql.exp.QueryExp.QueryExpDeltaEval) InstExpPi(catdata.aql.exp.InstExp.InstExpPi) ColimSchExpVar(catdata.aql.exp.ColimSchExp.ColimSchExpVar) ColimSchExpRaw(catdata.aql.exp.ColimSchExp.ColimSchExpRaw) PragmaExpLoadJars(catdata.aql.exp.PragmaExp.PragmaExpLoadJars) LinkedList(java.util.LinkedList) PragmaExpToCsvTrans(catdata.aql.exp.PragmaExp.PragmaExpToCsvTrans) Fk(catdata.aql.exp.SchExpRaw.Fk) TyExpSch(catdata.aql.exp.TyExp.TyExpSch) Reference(org.jparsec.Parser.Reference) ColimSchExpWrap(catdata.aql.exp.ColimSchExp.ColimSchExpWrap) Util(catdata.Util) QueryExpId(catdata.aql.exp.QueryExp.QueryExpId) QueryExpVar(catdata.aql.exp.QueryExp.QueryExpVar) InstExpEval(catdata.aql.exp.InstExp.InstExpEval) TransExpCoEval(catdata.aql.exp.TransExp.TransExpCoEval) TyExpVar(catdata.aql.exp.TyExp.TyExpVar) Identifier(org.jparsec.Terminals.Identifier) InstExpDistinct(catdata.aql.exp.InstExp.InstExpDistinct) PragmaExpToJdbcInst(catdata.aql.exp.PragmaExp.PragmaExpToJdbcInst) TransExpCoEvalEvalUnit(catdata.aql.exp.TransExp.TransExpCoEvalEvalUnit) Collections(java.util.Collections) InstExpEmpty(catdata.aql.exp.InstExp.InstExpEmpty) MapExpId(catdata.aql.exp.MapExp.MapExpId) Pair(org.jparsec.functors.Pair)

Example 8 with Parser

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

the class CombinatorParser method edExpRaw.

private static Parser<EdExpRaw> edExpRaw() {
    Parser<List<catdata.Pair<LocStr, String>>> as = Parsers.tuple(token("forall"), env(ident, ":")).map(x -> x.b).optional();
    Parser<catdata.Pair<List<catdata.Pair<LocStr, String>>, Boolean>> es = Parsers.tuple(token("exists"), token("unique").optional(), env(ident, ":")).map(x -> new catdata.Pair<>(x.c, x.b != null)).optional();
    Parser<catdata.Pair<Integer, catdata.Pair<RawTerm, RawTerm>>> eq = Parsers.tuple(Parsers.INDEX, Parsers.tuple(term(), token("="), term()).map(x -> new catdata.Pair<>(x.a, x.c))).map(x -> new catdata.Pair<>(x.a, x.b));
    Parser<List<catdata.Pair<Integer, catdata.Pair<RawTerm, RawTerm>>>> eqs = Parsers.tuple(token("where"), eq.many()).map(x -> x.b).optional();
    Parser<EdExpRaw> ret = Parsers.tuple(as, eqs, token("->"), es, eqs).map(x -> new EdExpRaw(Util.newIfNull(x.a), Util.newIfNull(x.b), x.d == null ? new LinkedList<>() : x.d.first, Util.newIfNull(x.e), x.d == null ? false : x.d.second));
    return ret;
}
Also used : AqlOptions(catdata.aql.AqlOptions) PragmaExpProc(catdata.aql.exp.PragmaExp.PragmaExpProc) Scanners(org.jparsec.Scanners) InstExpDelta(catdata.aql.exp.InstExp.InstExpDelta) GraphExpVar(catdata.aql.exp.GraphExp.GraphExpVar) GraphExpRaw(catdata.aql.exp.GraphExp.GraphExpRaw) StringLiteral(org.jparsec.Terminals.StringLiteral) EdsExpVar(catdata.aql.exp.EdsExp.EdsExpVar) SchExpInst(catdata.aql.exp.SchExp.SchExpInst) Pair(org.jparsec.functors.Pair) TransExpSigmaDeltaCounit(catdata.aql.exp.TransExp.TransExpSigmaDeltaCounit) QueryExpCompose(catdata.aql.exp.QueryExp.QueryExpCompose) PragmaExpConsistent(catdata.aql.exp.PragmaExp.PragmaExpConsistent) ParseException(catdata.ParseException) Quad(catdata.Quad) PragmaExpSql(catdata.aql.exp.PragmaExp.PragmaExpSql) SchExpVar(catdata.aql.exp.SchExp.SchExpVar) Parser(org.jparsec.Parser) InstExpColim(catdata.aql.exp.InstExp.InstExpColim) QueryExpDeltaCoEval(catdata.aql.exp.QueryExp.QueryExpDeltaCoEval) IntegerLiteral(org.jparsec.Terminals.IntegerLiteral) Program(catdata.Program) Triple(catdata.Triple) PragmaExpJs(catdata.aql.exp.PragmaExp.PragmaExpJs) PragmaExpCheck(catdata.aql.exp.PragmaExp.PragmaExpCheck) Ty(catdata.aql.exp.TyExpRaw.Ty) Terminals(org.jparsec.Terminals) PragmaExpMatch(catdata.aql.exp.PragmaExp.PragmaExpMatch) MapExpVar(catdata.aql.exp.MapExp.MapExpVar) TransExpDistinct(catdata.aql.exp.TransExp.TransExpDistinct) TyExpEmpty(catdata.aql.exp.TyExp.TyExpEmpty) TransExpVar(catdata.aql.exp.TransExp.TransExpVar) ColimSchExpQuotient(catdata.aql.exp.ColimSchExp.ColimSchExpQuotient) Token(org.jparsec.Token) PragmaExpToCsvInst(catdata.aql.exp.PragmaExp.PragmaExpToCsvInst) MapExpComp(catdata.aql.exp.MapExp.MapExpComp) InstExpCoEq(catdata.aql.exp.InstExp.InstExpCoEq) InstExpCod(catdata.aql.exp.InstExp.InstExpCod) InstExpCoProdFull(catdata.aql.exp.InstExp.InstExpCoProdFull) Att(catdata.aql.exp.SchExpRaw.Att) TransExpCoEvalEvalCoUnit(catdata.aql.exp.TransExp.TransExpCoEvalEvalCoUnit) TransExpDelta(catdata.aql.exp.TransExp.TransExpDelta) SchExpEmpty(catdata.aql.exp.SchExp.SchExpEmpty) ParserException(org.jparsec.error.ParserException) PragmaExpToJdbcTrans(catdata.aql.exp.PragmaExp.PragmaExpToJdbcTrans) Trans(catdata.aql.exp.QueryExpRaw.Trans) SchExpCod(catdata.aql.exp.SchExp.SchExpCod) InstExpChase(catdata.aql.exp.InstExp.InstExpChase) PragmaExpToJdbcQuery(catdata.aql.exp.PragmaExp.PragmaExpToJdbcQuery) InstExpFrozen(catdata.aql.exp.InstExp.InstExpFrozen) Sym(catdata.aql.exp.TyExpRaw.Sym) Tuple3(org.jparsec.functors.Tuple3) PragmaExpVar(catdata.aql.exp.PragmaExp.PragmaExpVar) Tuple4(org.jparsec.functors.Tuple4) Tuple5(org.jparsec.functors.Tuple5) InstExpAnonymize(catdata.aql.exp.InstExp.InstExpAnonymize) InstExpSigma(catdata.aql.exp.InstExp.InstExpSigma) TransExpEval(catdata.aql.exp.TransExp.TransExpEval) InstExpCoProdSigma(catdata.aql.exp.InstExp.InstExpCoProdSigma) InstExpVar(catdata.aql.exp.InstExp.InstExpVar) PreBlock(catdata.aql.exp.QueryExpRaw.PreBlock) TransExpSigmaDeltaUnit(catdata.aql.exp.TransExp.TransExpSigmaDeltaUnit) EdExpRaw(catdata.aql.exp.EdsExpRaw.EdExpRaw) Collectors(java.util.stream.Collectors) List(java.util.List) InstExpDom(catdata.aql.exp.InstExp.InstExpDom) Parsers(org.jparsec.Parsers) InstExpCoEval(catdata.aql.exp.InstExp.InstExpCoEval) TransExpSigma(catdata.aql.exp.TransExp.TransExpSigma) TransExpId(catdata.aql.exp.TransExp.TransExpId) MapExpId(catdata.aql.exp.MapExp.MapExpId) RawTerm(catdata.aql.RawTerm) En(catdata.aql.exp.SchExpRaw.En) InstExpSigmaChase(catdata.aql.exp.InstExp.InstExpSigmaChase) HashMap(java.util.HashMap) QueryExpDeltaEval(catdata.aql.exp.QueryExp.QueryExpDeltaEval) InstExpPi(catdata.aql.exp.InstExp.InstExpPi) ColimSchExpVar(catdata.aql.exp.ColimSchExp.ColimSchExpVar) ColimSchExpRaw(catdata.aql.exp.ColimSchExp.ColimSchExpRaw) PragmaExpLoadJars(catdata.aql.exp.PragmaExp.PragmaExpLoadJars) LinkedList(java.util.LinkedList) PragmaExpToCsvTrans(catdata.aql.exp.PragmaExp.PragmaExpToCsvTrans) Fk(catdata.aql.exp.SchExpRaw.Fk) TyExpSch(catdata.aql.exp.TyExp.TyExpSch) Reference(org.jparsec.Parser.Reference) ColimSchExpWrap(catdata.aql.exp.ColimSchExp.ColimSchExpWrap) Util(catdata.Util) QueryExpId(catdata.aql.exp.QueryExp.QueryExpId) QueryExpVar(catdata.aql.exp.QueryExp.QueryExpVar) InstExpEval(catdata.aql.exp.InstExp.InstExpEval) TransExpCoEval(catdata.aql.exp.TransExp.TransExpCoEval) TyExpVar(catdata.aql.exp.TyExp.TyExpVar) Identifier(org.jparsec.Terminals.Identifier) InstExpDistinct(catdata.aql.exp.InstExp.InstExpDistinct) PragmaExpToJdbcInst(catdata.aql.exp.PragmaExp.PragmaExpToJdbcInst) TransExpCoEvalEvalUnit(catdata.aql.exp.TransExp.TransExpCoEvalEvalUnit) Collections(java.util.Collections) InstExpEmpty(catdata.aql.exp.InstExp.InstExpEmpty) EdExpRaw(catdata.aql.exp.EdsExpRaw.EdExpRaw) RawTerm(catdata.aql.RawTerm) List(java.util.List) LinkedList(java.util.LinkedList) Pair(org.jparsec.functors.Pair)

Example 9 with Parser

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

the class XParser method instance.

/*	public static final Parser<?> query(Reference ref) {
		Parser<?> xxx = ref.lazy().between(term("pi"), term(";"));
		Parser<?> yyy = ref.lazy().between(term("delta"), term(";"));
		Parser<?> zzz = ref.lazy().between(term("sigma"), term(";"));
		Parser p = Parsers.tuple(xxx, yyy, zzz);
		
		Parser<?> ret = Parsers.tuple(term("query"), p.between(term("{"), term("}")));
		return ret;
	} */
private static Parser<?> instance(Reference ref) {
    Parser<?> node = Parsers.tuple(ident().many1(), term(":"), ident());
    Parser<?> p3 = Parsers.tuple(path(), term("="), path());
    Parser<?> xxx = Parsers.tuple(section("variables", node), section("equations", p3));
    Parser kkk = ((Parser) term("INSTANCE")).or(term("instance"));
    Parser<?> constant = Parsers.tuple(kkk, xxx.between(term("{"), term("}")), term(":"), ref.lazy());
    return constant;
}
Also used : Parser(org.jparsec.Parser)

Example 10 with Parser

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

the class XParser method decl.

private static Parser<?> decl() {
    // Parser e = Parsers.or(new Parser[] { exp(), type(), fn(), constx(), assume() });
    Parser p0 = Parsers.tuple(Parsers.tuple(ident(), term(":"), ident()).between(term("("), term(")")), term("="), exp());
    Parser p1 = Parsers.tuple(ident(), term("="), exp());
    Parser p3 = Parsers.tuple(ident().many1(), term(":"), Parsers.tuple(ident(), term("->"), ident()));
    Parser p4 = Parsers.tuple(ident().many1(), term(":"), term("type"));
    Parser p5 = Parsers.tuple(ident(), term(":"), Parsers.tuple(path(), term("="), path()));
    Parser p2 = Parsers.tuple(ident().many1(), term(":"), ident());
    return Parsers.or(new Parser[] { p0, p1, p3, p4, p5, p2 });
// return Parsers.tuple(ident(), Parsers.or(term("="), term(":")), e);
}
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