use of org.jparsec.functors.Tuple5 in project fql by CategoricalData.
the class XSqlToFql method toEInsertValues.
@SuppressWarnings({ "rawtypes", "unchecked" })
private static EInsertValues toEInsertValues(Object decl) {
Tuple5 t = (Tuple5) decl;
String target = t.b.toString();
List<Tuple3> x = (List<Tuple3>) t.d;
List<List<String>> values = new LinkedList<>();
for (Tuple3 y : x) {
List<String> l = (List<String>) y.b;
values.add(l);
}
return new EInsertValues(target, values);
}
use of org.jparsec.functors.Tuple5 in project fql by CategoricalData.
the class CombinatorParser method mapExpRaw.
// TODO: aql reverse order on arguments env
private static Parser<MapExpRaw> mapExpRaw() {
Parser<List<catdata.Pair<LocStr, List<String>>>> fks = Parsers.tuple(token("foreign_keys"), env(ident.sepBy1(token(".")), "->")).map(x -> x.b);
Parser<Tuple5<Token, String, Pair<Token, String>, Token, RawTerm>> lp0 = Parsers.tuple(token("lambda"), ident, Parsers.tuple(token(":"), ident).optional(), token("."), term());
Parser<Tuple5<Token, String, Pair<Token, String>, Token, RawTerm>> lq = ident.sepBy1(token(".")).map(x -> {
// TODO aql
RawTerm term = RawTerm.fold(x, "_x");
return new Tuple5<>(null, "_x", new Pair<>(null, null), null, term);
});
Parser<Tuple5<Token, String, Pair<Token, String>, Token, RawTerm>> lp = Parsers.or(lp0, lq);
Parser<List<catdata.Pair<LocStr, Triple<String, String, RawTerm>>>> envp = env(lp.map(x -> new Triple<>(x.b, x.c == null ? null : x.c.b, x.e)), "->");
Parser<List<catdata.Pair<LocStr, Triple<String, String, RawTerm>>>> atts = Parsers.tuple(token("attributes"), envp).map(x -> x.b);
// List<Pair<LocStr, Triple<String, List<Pair<LocStr, List<String>>>,
// List<Pair<LocStr, Triple<String, String, RawTerm>>>>>> list,
Parser<List<catdata.Pair<LocStr, String>>> ens = Parsers.tuple(token("entities"), env(ident, "->")).map(x -> x.b);
Parser<Tuple3<List<LocStr>, List<catdata.Pair<LocStr, Triple<String, List<catdata.Pair<LocStr, List<String>>>, List<catdata.Pair<LocStr, Triple<String, String, RawTerm>>>>>>, List<catdata.Pair<String, String>>>> pa = Parsers.tuple(imports, Parsers.tuple(token("entity"), locstr.followedBy(token("->")), ident, fks.optional(), atts.optional()).map(x -> new catdata.Pair<>(x.b, new Triple<>(x.c, Util.newIfNull(x.d), Util.newIfNull(x.e)))).many(), options);
Parser<Tuple5<Token, Token, SchExp<?, ?, ?, ?, ?>, SchExp<?, ?, ?, ?, ?>, Token>> l = Parsers.tuple(token("literal"), token(":"), sch_ref.lazy().followedBy(token("->")), sch_ref.lazy(), token("{"));
// List<Pair<LocStr, Triple<String, List<Pair<LocStr, List<String>>>,
// List<Pair<LocStr, Triple<String, String, RawTerm>>>>>> list,
Parser<MapExpRaw> ret = Parsers.tuple(l, pa, token("}")).map(x -> new MapExpRaw(x.a.c, x.a.d, x.b.a, x.b.b, x.b.c));
return ret;
}
Aggregations