Search in sources :

Example 1 with FqlTokenizer

use of catdata.fql.parse.FqlTokenizer in project fql by CategoricalData.

the class Chase method run.

private static Pair<String, String> run(String eds, String inst, KIND kind) throws Exception {
    Partial<List<EmbeddedDependency>> xxx = eds_p.parse(new FqlTokenizer(eds));
    List<EmbeddedDependency> eds0 = xxx.value;
    if (!xxx.tokens.toString().trim().isEmpty()) {
        throw new FQLException("Unconsumed input: " + xxx.tokens);
    }
    Partial<List<Pair<String, List<Pair<String, String>>>>> yyy = inst_p.parse(new FqlTokenizer(inst));
    Map<String, Set<Pair<Object, Object>>> inst0 = conv(yyy.value);
    if (!yyy.tokens.toString().trim().isEmpty()) {
        throw new FQLException("Unconsumed input: " + yyy.tokens);
    }
    Pair<List<Triple<List<String>, List<Triple<String, String, String>>, List<Triple<String, String, String>>>>, List<Triple<List<String>, List<Triple<String, String, String>>, List<Pair<String, String>>>>> zzz = split(eds0);
    if (inst0.isEmpty()) {
        return new Pair<>(printNicely3(zzz), "");
    }
    Map<String, Set<Pair<Object, Object>>> res = chase(new HashSet<>(), zzz, inst0, kind);
    return new Pair<>(printNicely3(zzz), printNicely(res));
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) FqlTokenizer(catdata.fql.parse.FqlTokenizer) EmbeddedDependency(catdata.fql.sql.EmbeddedDependency) Pair(catdata.Pair)

Example 2 with FqlTokenizer

use of catdata.fql.parse.FqlTokenizer in project fql by CategoricalData.

the class Path method parsePath.

// private static List<String> convert(
// List<Pair<Pair<String, String>, String>> l) {
// List<String> ret = new LinkedList<>();
// for (Pair<Pair<String, String>, String> x : l) {
// ret.add(x.second);
// }
// return ret;
// }
public static Path parsePath(Signature a, String s) throws FQLException {
    try {
        Tokens t = new FqlTokenizer(s);
        PathParser pp = new PathParser();
        Partial<List<String>> r = pp.parse(t);
        if (!r.tokens.toString().trim().isEmpty()) {
            throw new FQLException("Invalid path: " + s);
        }
        return new Path(a, r.value);
    } catch (Exception e) {
        throw new FQLException("Invalid path: " + s);
    }
}
Also used : FQLException(catdata.fql.FQLException) PathParser(catdata.fql.parse.PathParser) FqlTokenizer(catdata.fql.parse.FqlTokenizer) List(java.util.List) LinkedList(java.util.LinkedList) FQLException(catdata.fql.FQLException) Tokens(catdata.fql.parse.Tokens)

Aggregations

FqlTokenizer (catdata.fql.parse.FqlTokenizer)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Pair (catdata.Pair)1 FQLException (catdata.fql.FQLException)1 PathParser (catdata.fql.parse.PathParser)1 Tokens (catdata.fql.parse.Tokens)1 EmbeddedDependency (catdata.fql.sql.EmbeddedDependency)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1