Search in sources :

Example 1 with Token

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

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

the class CombinatorParser method graphExpRaw.

private static Parser<GraphExpRaw> graphExpRaw() {
    Parser<List<LocStr>> nodes = Parsers.tuple(token("nodes"), locstr.many()).map(x -> x.b);
    Parser<Pair<Token, List<Tuple5<List<LocStr>, Token, String, Token, String>>>> edges = Parsers.tuple(token("edges"), Parsers.tuple(locstr.many1(), token(":"), ident, token("->"), ident).many());
    Parser<List<catdata.Pair<LocStr, catdata.Pair<String, String>>>> edges0 = edges.map(x -> {
        List<catdata.Pair<LocStr, catdata.Pair<String, String>>> ret = new LinkedList<>();
        for (Tuple5<List<LocStr>, Token, String, Token, String> a : x.b) {
            for (LocStr b : a.a) {
                ret.add(new catdata.Pair<>(b, new catdata.Pair<>(a.c, a.e)));
            }
        }
        return ret;
    });
    Parser<Tuple3<List<LocStr>, List<LocStr>, List<catdata.Pair<LocStr, catdata.Pair<String, String>>>>> pa = Parsers.tuple(imports, nodes.optional(), edges0.optional());
    Parser<GraphExpRaw> ret = pa.map(x -> new GraphExpRaw(Util.newIfNull(x.b), Util.newIfNull(x.c), x.a));
    return ret.between(token("literal").followedBy(token("{")), token("}"));
}
Also used : Token(org.jparsec.Token) LinkedList(java.util.LinkedList) GraphExpRaw(catdata.aql.exp.GraphExp.GraphExpRaw) Tuple5(org.jparsec.functors.Tuple5) Tuple3(org.jparsec.functors.Tuple3) List(java.util.List) LinkedList(java.util.LinkedList) Pair(org.jparsec.functors.Pair)

Example 3 with Token

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

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

the class CombinatorParser method schExpRaw.

private static Parser<SchExpRaw> schExpRaw() {
    Parser<List<LocStr>> entities = Parsers.tuple(token("entities"), locstr.many()).map(x -> x.b);
    Parser<Pair<Token, List<Tuple5<List<LocStr>, Token, String, Token, String>>>> fks = Parsers.tuple(token("foreign_keys"), Parsers.tuple(locstr.many1(), token(":"), ident, token("->"), ident).many());
    Parser<List<catdata.Pair<LocStr, catdata.Pair<String, String>>>> fks0 = fks.map(x -> {
        List<catdata.Pair<LocStr, catdata.Pair<String, String>>> ret = new LinkedList<>();
        for (Tuple5<List<LocStr>, Token, String, Token, String> a : x.b) {
            for (LocStr b : a.a) {
                ret.add(new catdata.Pair<>(b, new catdata.Pair<>(a.c, a.e)));
            }
        }
        return ret;
    });
    Parser<Pair<Token, List<Tuple5<List<LocStr>, Token, String, Token, String>>>> atts = Parsers.tuple(token("attributes"), Parsers.tuple(locstr.many1(), token(":"), ident, token("->"), ident).many());
    Parser<List<catdata.Pair<LocStr, catdata.Pair<String, String>>>> atts0 = atts.map(x -> {
        List<catdata.Pair<LocStr, catdata.Pair<String, String>>> ret = new LinkedList<>();
        for (Tuple5<List<LocStr>, Token, String, Token, String> a : x.b) {
            for (LocStr b : a.a) {
                ret.add(new catdata.Pair<>(b, new catdata.Pair<>(a.c, a.e)));
            }
        }
        return ret;
    });
    Parser<catdata.Pair<Integer, catdata.Pair<List<String>, List<String>>>> p_eq = Parsers.tuple(Parsers.INDEX, Parsers.tuple(ident.sepBy(token(".")), token("="), ident.sepBy(token(".")))).map(x -> new catdata.Pair<>(x.a, new catdata.Pair<>(x.b.a, x.b.c)));
    Parser<Pair<Token, List<catdata.Pair<Integer, catdata.Pair<List<String>, List<String>>>>>> p_eqs = Parsers.tuple(token("path_equations"), p_eq.many());
    Parser<List<catdata.Pair<Integer, catdata.Pair<List<String>, List<String>>>>> p_eqs0 = p_eqs.map(x -> x.b);
    Parser<catdata.Pair<Integer, Quad<String, String, RawTerm, RawTerm>>> o_eq_from_p_eq = p_eq.map(x -> new catdata.Pair<>(x.first, new Quad<>("_x", null, RawTerm.fold(x.second.first, "_x"), RawTerm.fold(x.second.second, "_x"))));
    Parser<catdata.Pair<Integer, Quad<String, String, RawTerm, RawTerm>>> o_eq_old = Parsers.tuple(Parsers.INDEX, Parsers.tuple(token("forall"), ident, Parsers.tuple(token(":"), ident).optional().followedBy(token(".")), term().followedBy(token("=")), term())).map(x -> new catdata.Pair<>(x.a, new Quad<>(x.b.b, x.b.c == null ? null : x.b.c.b, x.b.d, x.b.e)));
    Parser<catdata.Pair<Integer, Quad<String, String, RawTerm, RawTerm>>> o_eq = Parsers.or(o_eq_old, o_eq_from_p_eq);
    Parser<Pair<Token, List<catdata.Pair<Integer, Quad<String, String, RawTerm, RawTerm>>>>> o_eqs = Parsers.tuple(token("observation_equations"), o_eq.many());
    Parser<List<catdata.Pair<Integer, Quad<String, String, RawTerm, RawTerm>>>> o_eqs0 = o_eqs.map(x -> x.b);
    Parser<Tuple4<List<LocStr>, List<LocStr>, List<catdata.Pair<LocStr, catdata.Pair<String, String>>>, List<catdata.Pair<Integer, catdata.Pair<List<String>, List<String>>>>>> pa = Parsers.tuple(imports, entities.optional(), fks0.optional(), p_eqs0.optional());
    Parser<Tuple3<List<catdata.Pair<LocStr, catdata.Pair<String, String>>>, List<catdata.Pair<Integer, Quad<String, String, RawTerm, RawTerm>>>, List<catdata.Pair<String, String>>>> pb = Parsers.tuple(atts0.optional(), o_eqs0.optional(), options);
    Parser<Tuple4<Token, Token, TyExp<?, ?>, Token>> l = Parsers.tuple(token("literal"), token(":"), ty_ref.lazy(), // .map(x -> x.c);
    token("{"));
    // needs tyexp
    Parser<SchExpRaw> ret = Parsers.tuple(l, pa, pb, token("}")).map(x -> new SchExpRaw((TyExp<Ty, Sym>) x.a.c, x.b.a, Util.newIfNull(x.b.b), Util.newIfNull(x.b.c), Util.newIfNull(x.b.d), Util.newIfNull(x.c.a), Util.newIfNull(x.c.b), x.c.c));
    return ret;
}
Also used : Quad(catdata.Quad) Token(org.jparsec.Token) List(java.util.List) LinkedList(java.util.LinkedList) Pair(org.jparsec.functors.Pair) RawTerm(catdata.aql.RawTerm) LinkedList(java.util.LinkedList) Tuple4(org.jparsec.functors.Tuple4) Tuple5(org.jparsec.functors.Tuple5) Tuple3(org.jparsec.functors.Tuple3) ColimSchExpRaw(catdata.aql.exp.ColimSchExp.ColimSchExpRaw)

Example 5 with Token

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

the class FQLParser method toSchema.

@SuppressWarnings({ "rawtypes", "unchecked" })
private static SigExp toSchema(Object o) {
    try {
        Tuple3<?, ?, ?> t = (Tuple3<?, ?, ?>) o;
        Token z = (Token) t.b;
        String y = z.toString();
        switch(y) {
            case "+":
                return new SigExp.Plus(toSchema(t.a), toSchema(t.c));
            case "*":
                return new SigExp.Times(toSchema(t.a), toSchema(t.c));
            case "^":
                return new SigExp.Exp(toSchema(t.a), toSchema(t.c));
            case "union":
                return new Union(toSchema(t.a), toSchema(t.c));
            default:
                break;
        }
    } catch (RuntimeException cce) {
    }
    try {
        org.jparsec.functors.Pair p = (org.jparsec.functors.Pair) o;
        if (p.a.toString().equals("unit")) {
            return new SigExp.One(new HashSet<>((Collection<String>) p.b));
        } else if (p.a.toString().equals("opposite")) {
            return new SigExp.Opposite(toSchema(p.b));
        }
    } catch (RuntimeException cce) {
    }
    try {
        if (o.toString().equals("void")) {
            return new SigExp.Zero();
        } else if (o.toString().equals("?")) {
            return new Unknown("?" + unknown_idx++);
        }
        throw new RuntimeException();
    } catch (RuntimeException cce) {
    }
    try {
        return toSchemaConst(o);
    } catch (RuntimeException cce) {
    }
    return new SigExp.Var(o.toString());
}
Also used : Zero(catdata.fql.decl.InstExp.Zero) Var(catdata.fql.decl.FullQueryExp.Var) One(catdata.fql.decl.InstExp.One) Token(org.jparsec.Token) Union(catdata.fql.decl.SigExp.Union) Unknown(catdata.fql.decl.SigExp.Unknown) SigExp(catdata.fql.decl.SigExp) Tuple3(org.jparsec.functors.Tuple3) Times(catdata.fql.decl.InstExp.Times) Plus(catdata.fql.decl.InstExp.Plus) FullQueryExp(catdata.fql.decl.FullQueryExp) Exp(catdata.fql.decl.InstExp.Exp) MapExp(catdata.fql.decl.MapExp) TransExp(catdata.fql.decl.TransExp) QueryExp(catdata.fql.decl.QueryExp) SigExp(catdata.fql.decl.SigExp) InstExp(catdata.fql.decl.InstExp) Pair(catdata.Pair)

Aggregations

Token (org.jparsec.Token)7 Tuple3 (org.jparsec.functors.Tuple3)7 Tuple4 (org.jparsec.functors.Tuple4)5 Quad (catdata.Quad)4 RawTerm (catdata.aql.RawTerm)4 ColimSchExpRaw (catdata.aql.exp.ColimSchExp.ColimSchExpRaw)4 GraphExpRaw (catdata.aql.exp.GraphExp.GraphExpRaw)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4 Pair (org.jparsec.functors.Pair)4 Tuple5 (org.jparsec.functors.Tuple5)4 ParseException (catdata.ParseException)3 Program (catdata.Program)3 Triple (catdata.Triple)3 Util (catdata.Util)3 AqlOptions (catdata.aql.AqlOptions)3 ColimSchExpQuotient (catdata.aql.exp.ColimSchExp.ColimSchExpQuotient)3 ColimSchExpVar (catdata.aql.exp.ColimSchExp.ColimSchExpVar)3 ColimSchExpWrap (catdata.aql.exp.ColimSchExp.ColimSchExpWrap)3 EdsExpVar (catdata.aql.exp.EdsExp.EdsExpVar)3