use of org.jparsec.Parser in project fql by CategoricalData.
the class CfgToOpl method program.
@SuppressWarnings({ "unchecked", "rawtypes" })
private static Parser program() {
Parser q = string().many().sepBy(term("|"));
Parser p = Parsers.tuple(ident(), term("::="), q).sepBy(term(","));
return p;
}
use of org.jparsec.Parser in project fql by CategoricalData.
the class XParser method poly.
private static Parser<?> poly(Reference ref) {
Parser p = Parsers.tuple(ident(), term("="), block(), term(":"), ident());
Parser p2 = p.sepBy(term(",")).between(term("{"), term("}")).between(term("polynomial"), term(":"));
return Parsers.tuple(p2, ref.lazy(), term("->"), ref.lazy());
}
use of org.jparsec.Parser in project fql by CategoricalData.
the class XParser method block.
/*{ from a1:A, a2:A;
where a1.att2=a2.f.att1;
attributes att3 = a2.att2,
att4 = a2.att2;
edges e1 = {b2=a1.f, b3=a1.f} : q2,
e2 = { ... } : q3;
} */
private static Parser<?> block() {
Parser p1 = Parsers.tuple(ident(), term(":"), ident()).sepBy(term(",")).between(term("for"), term(";"));
Parser p2 = Parsers.tuple(ident().sepBy1(term(".")), term("="), ident().sepBy1(term("."))).sepBy(term(",")).between(term("where"), term(";"));
Parser p3 = Parsers.tuple(ident(), term("="), ident().sepBy1(term("."))).sepBy(term(",")).between(term("attributes"), term(";"));
Parser q = Parsers.tuple(ident(), term("="), ident().sepBy1(term("."))).sepBy(term(",")).between(term("{"), term("}"));
Parser a = Parsers.tuple(ident(), term("="), q, term(":"), ident());
Parser p4 = a.sepBy(term(",")).between(term("edges"), term(";"));
Parser p = Parsers.tuple(p1, p2, p3, p4);
return p.between(term("{"), term("}"));
}
use of org.jparsec.Parser in project fql by CategoricalData.
the class XParser method transform.
private static Parser<?> transform(Reference ref) {
Parser p = Parsers.tuple(ident(), term(":"), ident());
Parser<?> node = Parsers.tuple(p.or(ident()), term("->"), path());
Parser<?> xxx = section("variables", node);
Parser<?> constant = Parsers.tuple(Parsers.between(term("homomorphism").followedBy(term("{")), xxx, term("}")), term(":"), ref.lazy(), term("->"), ref.lazy());
return constant;
}
use of org.jparsec.Parser in project fql by CategoricalData.
the class XParser method FLOWER.
private static Parser<?> FLOWER(Reference self) {
Parser<?> from0 = Parsers.tuple(ident(), term("as"), ident()).sepBy(term(","));
Parser<?> from = Parsers.tuple(term("from"), from0, term(";"));
Parser<?> where = Parsers.tuple(term("where"), where(), term(";"));
Parser<?> select0 = Parsers.tuple(path(), term("as"), ident()).sepBy(term(","));
Parser<?> select = Parsers.tuple(term("select"), select0, term(";"));
Parser p = Parsers.tuple(select, from, where);
Parser ret = Parsers.tuple(term("FLOWER"), p.between(term("{"), term("}")), self.lazy());
return ret;
}
Aggregations