Parses the "ArrowExpr" rule. @return query expression or null @throws QueryException query exception
()
| 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. |
no test coverage detected