Parses the "Pragma" rule. @return array of pragmas or null @throws QueryException query exception
()
| 2134 | * @throws QueryException query exception |
| 2135 | */ |
| 2136 | private Pragma[] pragma() throws QueryException { |
| 2137 | final int p = pos; |
| 2138 | if(!wsConsume("(#") || !consumeWS()) { |
| 2139 | pos = p; |
| 2140 | return null; |
| 2141 | } |
| 2142 | |
| 2143 | final ArrayList<Pragma> el = new ArrayList<>(); |
| 2144 | do { |
| 2145 | final QNm name = eQName(null, QNAME_X); |
| 2146 | int cp = current(); |
| 2147 | if(cp != '#' && !ws(cp)) throw error(PRAGMAINV); |
| 2148 | token.reset(); |
| 2149 | while(cp != '#' || next() != ')') { |
| 2150 | if(cp == 0) throw error(PRAGMAINV); |
| 2151 | token.add(consume()); |
| 2152 | cp = current(); |
| 2153 | } |
| 2154 | |
| 2155 | final byte[] value = token.trim().toArray(); |
| 2156 | if(eq(name.prefix(), DB_PREFIX)) { |
| 2157 | // project-specific declaration |
| 2158 | final String key = string(uc(name.local())); |
| 2159 | final MainOptions mopts = qc.context.options; |
| 2160 | final Option<?> option = mopts.option(key); |
| 2161 | if(option == null) throw error(BASEX_OPTIONSINV_X, mopts.similar(key)); |
| 2162 | el.add(new DBPragma(name, option, value)); |
| 2163 | } else if(eq(name.prefix(), BASEX_PREFIX)) { |
| 2164 | // project-specific declaration |
| 2165 | el.add(new BaseXPragma(name, value)); |
| 2166 | } |
| 2167 | pos += 2; |
| 2168 | } while(wsConsumeWs("(#")); |
| 2169 | return el.toArray(Pragma[]::new); |
| 2170 | } |
| 2171 | |
| 2172 | /** |
| 2173 | * Parses the "ItemMapExpr" rule. |