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

Method pragma

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

Parses the "Pragma" rule. @return array of pragmas or null @throws QueryException query exception

()

Source from the content-addressed store, hash-verified

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.

Callers 2

extensionMethod · 0.95
ftPrimaryMethod · 0.95

Calls 15

wsConsumeMethod · 0.95
consumeWSMethod · 0.95
eQNameMethod · 0.95
errorMethod · 0.95
prefixMethod · 0.95
localMethod · 0.95
wsConsumeWsMethod · 0.95
ucMethod · 0.80
resetMethod · 0.65
nextMethod · 0.65
addMethod · 0.65
eqMethod · 0.65

Tested by

no test coverage detected