MCPcopy Create free account
hub / github.com/BaseXdb/basex / arrow

Method arrow

basex-core/src/main/java/org/basex/query/QueryParser.java:2010–2059  ·  view source on GitHub ↗

Parses the "ArrowExpr" rule. @return query expression or null @throws QueryException query exception

()

Source from the content-addressed store, hash-verified

2008 * @throws QueryException query exception
2009 */
2010 private Expr arrow() throws QueryException {
2011 Expr expr = unary();
2012 if(expr != null) {
2013 while(true) {
2014 final boolean mapping = wsConsume("=!>");
2015 if(!mapping && !consume("=>")) break;
2016
2017 QNm name = null;
2018 Expr ex;
2019 skipWs();
2020 if(current('$')) {
2021 ex = varRef();
2022 } else if(current('(')) {
2023 ex = parenthesized();
2024 } else {
2025 ex = mapConstructor();
2026 if(ex == null) ex = arrayConstructor();
2027 if(ex == null) ex = functionItem();
2028 if(ex == null) {
2029 final int p = pos;
2030 name = eQName(null, ARROWSPEC_X);
2031 if(reserved(name, p)) throw error(RESERVED_X, name.local());
2032 }
2033 }
2034 final InputInfo ii = info();
2035 final Expr arg;
2036 For fr = null;
2037 int s = 0;
2038 if(mapping) {
2039 s = localVars.openScope();
2040 fr = new For(localVars.add(new Var(new QNm("item"), null, qc, ii)), expr);
2041 arg = new VarRef(ii, fr.var);
2042 } else {
2043 arg = expr;
2044 }
2045 final FuncBuilder fb = argumentList(ex == null, arg);
2046 if(ex != null) {
2047 expr = Functions.dynamic(ex, fb);
2048 } else {
2049 final QNm funcName = name;
2050 expr = qc.functions.newRef(() -> Functions.get(funcName, fb, qc));
2051 }
2052 if(mapping) {
2053 expr = new GFLWOR(ii, fr, expr);
2054 localVars.closeScope(s);
2055 }
2056 }
2057 }
2058 return expr;
2059 }
2060
2061 /**
2062 * Parses the "UnaryExpr" rule.

Callers 1

pipelineMethod · 0.95

Calls 15

unaryMethod · 0.95
wsConsumeMethod · 0.95
skipWsMethod · 0.95
varRefMethod · 0.95
parenthesizedMethod · 0.95
mapConstructorMethod · 0.95
arrayConstructorMethod · 0.95
functionItemMethod · 0.95
eQNameMethod · 0.95
reservedMethod · 0.95
errorMethod · 0.95
localMethod · 0.95

Tested by

no test coverage detected