Search in sources :

Example 1 with Unknown

use of catdata.fql.decl.SigExp.Unknown 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

Pair (catdata.Pair)1 FullQueryExp (catdata.fql.decl.FullQueryExp)1 Var (catdata.fql.decl.FullQueryExp.Var)1 InstExp (catdata.fql.decl.InstExp)1 Exp (catdata.fql.decl.InstExp.Exp)1 One (catdata.fql.decl.InstExp.One)1 Plus (catdata.fql.decl.InstExp.Plus)1 Times (catdata.fql.decl.InstExp.Times)1 Zero (catdata.fql.decl.InstExp.Zero)1 MapExp (catdata.fql.decl.MapExp)1 QueryExp (catdata.fql.decl.QueryExp)1 SigExp (catdata.fql.decl.SigExp)1 Union (catdata.fql.decl.SigExp.Union)1 Unknown (catdata.fql.decl.SigExp.Unknown)1 TransExp (catdata.fql.decl.TransExp)1 Token (org.jparsec.Token)1 Tuple3 (org.jparsec.functors.Tuple3)1