Search in sources :

Example 1 with PathParser

use of catdata.fql.parse.PathParser 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

FQLException (catdata.fql.FQLException)1 FqlTokenizer (catdata.fql.parse.FqlTokenizer)1 PathParser (catdata.fql.parse.PathParser)1 Tokens (catdata.fql.parse.Tokens)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1