From 6fa9e6a51bc7766e45bf0dea92159622d773877e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Gjesdal?= Date: Tue, 17 Nov 2026 22:17:24 +0100 Subject: [PATCH 1/3] GH-1324: ARQCharStream for the ARQ parser The SimpleCharStream that javacc generates grows its buffer by 2048 chars at a time, so reading a long token, such as a large literal, takes quadratic time. javacc's master branch grows the buffer exponentially since this commit, from javacc PR 303: https://github.com/javacc/javacc/commit/3bb3dbff92d29e576441a2ecb6911e7537922900 https://github.com/javacc/javacc/pull/303 It uses bufsize >> 1, which halves the buffer: https://github.com/javacc/javacc/issues/316 Open javacc PR 317 corrects it to bufsize << 1: https://github.com/javacc/javacc/pull/317 Neither is in a javacc release; the latest is 7.0.13. For the ARQ parser only (#ifdef ARQ in main.jj), set the javacc option USER_CHAR_STREAM, so javacc no longer generates SimpleCharStream.java, and add the InputStream and Reader constructors and ReInit operations that javacc leaves out with this option. They create an ARQCharStream. ARQCharStream, in org.apache.jena.sparql.lang.arq, is based on the SimpleCharStream that javacc 7.0.12 generates from this template: https://github.com/javacc/javacc/blob/javacc-7.0.12/src/main/resources/templates/SimpleCharStream.template with these changes: - ExpandBuff doubles the buffer instead of adding 2048 chars, so reading a long token takes linear time. - The buffer grows to at most Integer.MAX_VALUE - 8 chars, the largest array length that is safe on common JVMs. A longer token is a TokenMgrError, which the query and update parsers report as a parse error. A buffer size below 1 is an IllegalArgumentException: such a buffer never grows. - Line and column are no longer stored for every buffered char. They are kept for the start of the token, and the end of the token is calculated when asked for. The buffer uses 2 bytes per char instead of 10. After a lexical error, they are right up to the error, where the parsers stop. - An exception from the Reader, checked or unchecked, is a TokenMgrError. The token manager takes an exception from the char stream as the end of the input, so the rest of the input was silently dropped: an update with a byte that is not valid UTF-8 (MalformedInputException) parsed as an empty or shortened update. Only the end of the input is an IOException, and the Reader, closed at the end of the input, is not read again. - adjustBeginLineColumn is left out: it is not part of CharStream and nothing calls it. ParserARQ and ParserARQUpdate report a failed read as a QueryParseException with the Reader's exception as its cause. An unchecked exception from the Reader, such as a cancellation, is not a parse error: they pass it on unchanged. TestARQCharStream checks that the buffer grows by doubling (8 expansions for a token of 1,000,000 chars after the buffer has wrapped round, where growing by 2048 chars takes 487), that a buffer size of 0 is rejected, that a failing Reader is an error, that an update with invalid UTF-8 is a parse error with the decoder's exception as its cause, that an unchecked exception from the Reader is passed on, that queries ending on a token the lexer reads past still parse, and the line and column of a parse error after a long multi-line literal. It also checks that a failed read of an update, executed in a write transaction as Fuseki does, commits nothing: a transfer whose connection drops after two of its four operations, and 300 operations with a Latin-1 byte after the decoder's first read. On main, both commit part of the update. The grammar script removes CharStream.java before running javacc, so that it is regenerated. The parser is regenerated in the next commit. This commit does not compile on its own: javacc generates the CharStream interface. Co-Authored-By: Claude Opus 5.5 --- jena-arq/Grammar/README | 4 + jena-arq/Grammar/grammar | 4 +- jena-arq/Grammar/main.jj | 22 + .../jena/sparql/lang/arq/ARQCharStream.java | 551 ++++++++++++++++++ .../jena/sparql/lang/arq/ParserARQ.java | 6 +- .../jena/sparql/lang/arq/ParserARQUpdate.java | 6 +- .../jena/sparql/lang/TS_LangSPARQL.java | 3 +- .../jena/sparql/lang/TestARQCharStream.java | 292 ++++++++++ 8 files changed, 884 insertions(+), 4 deletions(-) create mode 100644 jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ARQCharStream.java create mode 100644 jena-arq/src/test/java/org/apache/jena/sparql/lang/TestARQCharStream.java diff --git a/jena-arq/Grammar/README b/jena-arq/Grammar/README index 9398f10db2d..79937701b31 100644 --- a/jena-arq/Grammar/README +++ b/jena-arq/Grammar/README @@ -14,6 +14,10 @@ Note: cpp (the C Preprocessor) must be installed. The grammar script runs cpp over main.jj to produce arq.jj and sparql.jj. +For ARQ, main.jj sets the javacc option USER_CHAR_STREAM: the ARQ parser +reads with ARQCharStream (org.apache.jena.sparql.lang.arq), which is not +generated, instead of a generated SimpleCharStream (GH-1324). + ==== HTML To produce the HTML for the SPARQL Grammar for the W3C spec: diff --git a/jena-arq/Grammar/grammar b/jena-arq/Grammar/grammar index 40efbd2b197..4a1406af970 100755 --- a/jena-arq/Grammar/grammar +++ b/jena-arq/Grammar/grammar @@ -32,7 +32,9 @@ function grammar DIR="../src/main/java/org/apache/jena/sparql/lang/$PKG/javacc" - (cd "$DIR" ; rm -f TokenMgrError.java ParseException.java Token.java JavaCharStream.java ) + ## javacc does not overwrite existing support files, so remove them to have them regenerated. + ## CharStream.java: ARQ only (USER_CHAR_STREAM in main.jj). + (cd "$DIR" ; rm -f TokenMgrError.java ParseException.java Token.java JavaCharStream.java CharStream.java ) echo "---- Process grammar -- $1" javacc -OUTPUT_DIRECTORY=$DIR -JDK_VERSION=1.8 "${FILE}" diff --git a/jena-arq/Grammar/main.jj b/jena-arq/Grammar/main.jj index c8e75a01dc9..18cc79d7311 100644 --- a/jena-arq/Grammar/main.jj +++ b/jena-arq/Grammar/main.jj @@ -60,6 +60,10 @@ options UNICODE_INPUT = true ; STATIC = false ; +#ifdef ARQ +// ARQCharStream (GH-1324): see the parser class below. + USER_CHAR_STREAM = true ; +#endif // DEBUG_PARSER = true ; // DEBUG_TOKEN_MANAGER = true ; } @@ -103,10 +107,28 @@ import org.apache.jena.sparql.modify.request.* ; import org.apache.jena.sparql.core.Quad ; import java.util.List; import java.util.ArrayList; +import org.apache.jena.sparql.lang.arq.ARQCharStream ; #endif public class CLASS extends PARSERBASE +#ifdef ARQ +{ + // USER_CHAR_STREAM leaves out the InputStream and Reader constructors and + // ReInit operations: these are the ones javacc would generate, with ARQCharStream. + public CLASS(java.io.InputStream stream) { this(stream, null); } + public CLASS(java.io.InputStream stream, String encoding) { this(newCharStream(stream, encoding)); } + public CLASS(java.io.Reader stream) { this(new ARQCharStream(stream, 1, 1)); } + public void ReInit(java.io.InputStream stream) { ReInit(stream, null); } + public void ReInit(java.io.InputStream stream, String encoding) { ReInit(newCharStream(stream, encoding)); } + public void ReInit(java.io.Reader stream) { ReInit(new ARQCharStream(stream, 1, 1)); } + private static ARQCharStream newCharStream(java.io.InputStream stream, String encoding) { + try { return new ARQCharStream(stream, encoding, 1, 1); } + catch (java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } + } +} +#else {} +#endif PARSER_END(CLASS) // // Common top for single entry point. diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ARQCharStream.java b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ARQCharStream.java new file mode 100644 index 00000000000..e586408d76d --- /dev/null +++ b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ARQCharStream.java @@ -0,0 +1,551 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.apache.jena.sparql.lang.arq; + +import org.apache.jena.sparql.lang.arq.javacc.CharStream; +import org.apache.jena.sparql.lang.arq.javacc.TokenMgrError; + +// Not generated by javacc: the ARQ grammar (main.jj, #ifdef ARQ) uses option +// USER_CHAR_STREAM, and the ARQParser constructors in main.jj create an ARQCharStream. +// Based on SimpleCharStream.java as generated by javacc 7.0.12 from +// https://github.com/javacc/javacc/blob/javacc-7.0.12/src/main/resources/templates/SimpleCharStream.template +// with these changes: +// Named ARQCharStream, in this package, and "implements CharStream" +// ExpandBuff doubles the buffer size (GH-1324), as in javacc commit +// https://github.com/javacc/javacc/commit/3bb3dbff92d29e576441a2ecb6911e7537922900 +// with the correction from bufsize >> 1 to bufsize << 1 in +// https://github.com/javacc/javacc/pull/317 +// The buffer grows up to MAX_BUFSIZE chars; a longer token is a TokenMgrError. +// The buffer size must be at least 1. +// Line and column are not stored for each char in the buffer. +// They are kept for the start of the current token, and the end of the token is +// calculated when asked for. After a lexical error, they are right up to the +// error: the parsers stop there. +// adjustBeginLineColumn is left out: it is not part of CharStream and is not called. +// getTrackLineColumn and setTrackLineColumn are public, as required by CharStream +// FillBuff turns an exception from the Reader into a TokenMgrError, with the exception +// as its cause, so that only the end of the input is an IOException, and does not +// read the Reader again after the end of the input. The token manager takes an +// exception from the char stream as the end of the input. The stream is not meant +// to be read after a failed read: the parsers stop at the error. + +/** + * The char stream of the ARQ parser: javacc's SimpleCharStream with a buffer that + * doubles when a token does not fit (GH-1324), without unicode escape processing. + */ + +public class ARQCharStream implements CharStream +{ +/** Whether parser is static. */ + public static final boolean staticFlag = false; + int bufsize; + int available; + int tokenBegin; +/** Position in buffer. */ + public int bufpos = -1; + + // Line and column of the char at tokenBegin, and the CR/LF state after it. + protected int column = 0; + protected int line = 1; + + protected boolean prevCharIsCR = false; + protected boolean prevCharIsLF = false; + + // False until the first char is read; line and column are then 0, as javacc's SimpleCharStream. + private boolean tokenStarted = false; + + // Line and column of the char at endBufpos, calculated from those of the char at endTokenBegin. + private char[] endBuffer = null; + private int endTokenBegin; + private int endBufpos; + private int endLine; + private int endColumn; + private boolean endPrevCharIsCR; + private boolean endPrevCharIsLF; + + protected java.io.Reader inputStream; + // True once the Reader has returned the end of the input; it is then closed. + private boolean inputEnded = false; + + protected char[] buffer; + protected int maxNextCharInd = 0; + protected int inBuf = 0; + protected int tabSize = 1; + protected boolean trackLineColumn = true; + + public void setTabSize(int i) { tabSize = i; } + public int getTabSize() { return tabSize; } + + + + // The largest buffer. Some JVMs can't allocate arrays of length close to Integer.MAX_VALUE. + private static final int MAX_BUFSIZE = Integer.MAX_VALUE - 8; + + protected void ExpandBuff(boolean wrapAround) + { + if (bufsize >= MAX_BUFSIZE) + throw new TokenMgrError("Token too long: the limit is " + MAX_BUFSIZE + " chars", TokenMgrError.LEXICAL_ERROR); + int newBufsize = (bufsize > MAX_BUFSIZE / 2) ? MAX_BUFSIZE : bufsize << 1; + char[] newbuffer = new char[newBufsize]; + + try + { + if (wrapAround) + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); + buffer = newbuffer; + + maxNextCharInd = (bufpos += (bufsize - tokenBegin)); + } + else + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + buffer = newbuffer; + + maxNextCharInd = (bufpos -= tokenBegin); + } + } + catch (Throwable t) + { + throw new Error(t.getMessage()); + } + + + bufsize = newBufsize; + available = bufsize; + tokenBegin = 0; + } + + protected void FillBuff() throws java.io.IOException + { + if (maxNextCharInd == available) + { + if (available == bufsize) + { + if (tokenBegin > 2048) + { + bufpos = maxNextCharInd = 0; + available = tokenBegin; + } + else if (tokenBegin < 0) + bufpos = maxNextCharInd = 0; + else + ExpandBuff(false); + } + else if (available > tokenBegin) + available = bufsize; + else if ((tokenBegin - available) < 2048) + ExpandBuff(true); + else + available = tokenBegin; + } + + int i = -1; + if (!inputEnded) + { + try { + i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd); + } + catch (java.io.IOException | RuntimeException ex) + { + // Not the end of the input: the rest of the input would be silently dropped. + TokenMgrError err = new TokenMgrError("Failed to read the input: " + ex, TokenMgrError.LEXICAL_ERROR); + err.initCause(ex); + throw err; + } + } + try { + if (i == -1) + { + if (!inputEnded) + { + inputEnded = true; + inputStream.close(); + } + throw new java.io.IOException(); + } + else + maxNextCharInd += i; + return; + } + catch(java.io.IOException e) { + --bufpos; + backup(0); + if (tokenBegin == -1) + tokenBegin = bufpos; + throw e; + } + } + +/** Start. */ + public char BeginToken() throws java.io.IOException + { + // Move line and column on from the start of the previous token to its last char. + if (tokenStarted) + lineColumnTo(bufpos); + endBuffer = null; + tokenBegin = -1; + char c = readChar(); + tokenBegin = bufpos; + UpdateLineColumn(c); + tokenStarted = true; + + return c; + } + + protected void UpdateLineColumn(char c) + { + column++; + + if (prevCharIsLF) + { + prevCharIsLF = false; + line += (column = 1); + } + else if (prevCharIsCR) + { + prevCharIsCR = false; + if (c == '\n') + { + prevCharIsLF = true; + } + else + line += (column = 1); + } + + switch (c) + { + case '\r' : + prevCharIsCR = true; + break; + case '\n' : + prevCharIsLF = true; + break; + case '\t' : + column--; + column += (tabSize - (column % tabSize)); + break; + default : + break; + } + } + + // Move line, column and the CR/LF state from the char at tokenBegin to the char at pos. + private void lineColumnTo(int pos) + { + if (endBuffer == buffer && endTokenBegin == tokenBegin && endBufpos == pos) + { + line = endLine; + column = endColumn; + prevCharIsCR = endPrevCharIsCR; + prevCharIsLF = endPrevCharIsLF; + return; + } + int i = tokenBegin; + // Chars from tokenBegin to pos, allowing for the buffer wrapping round. + // (pos - tokenBegin + bufsize) would overflow int for buffers over 2^30 chars. + int n = pos - tokenBegin; + if (n < 0) + n += bufsize; + for (; n > 0; n--) + { + if (++i == bufsize) + i = 0; + UpdateLineColumn(buffer[i]); + } + } + + // Calculate the line and column of the char at bufpos. + private void calcEnd() + { + if (endBuffer == buffer && endTokenBegin == tokenBegin && endBufpos == bufpos) + return; + int beginLine = line; + int beginColumn = column; + boolean beginPrevCharIsCR = prevCharIsCR; + boolean beginPrevCharIsLF = prevCharIsLF; + lineColumnTo(bufpos); + endLine = line; + endColumn = column; + endPrevCharIsCR = prevCharIsCR; + endPrevCharIsLF = prevCharIsLF; + endBuffer = buffer; + endTokenBegin = tokenBegin; + endBufpos = bufpos; + line = beginLine; + column = beginColumn; + prevCharIsCR = beginPrevCharIsCR; + prevCharIsLF = beginPrevCharIsLF; + } + +/** Read a character. */ + public char readChar() throws java.io.IOException + { + if (inBuf > 0) + { + --inBuf; + + if (++bufpos == bufsize) + bufpos = 0; + + return buffer[bufpos]; + } + + if (++bufpos >= maxNextCharInd) + FillBuff(); + + return buffer[bufpos]; + } + + /** + * @deprecated + * @see #getEndColumn + */ + @Deprecated + public int getColumn() { + return getEndColumn(); + } + + /** + * @deprecated + * @see #getEndLine + */ + @Deprecated + public int getLine() { + return getEndLine(); + } + + /** Get token end column number. */ + public int getEndColumn() { + if (!tokenStarted) + return 0; + calcEnd(); + return endColumn; + } + + /** Get token end line number. */ + public int getEndLine() { + if (!tokenStarted) + return 0; + calcEnd(); + return endLine; + } + + /** Get token beginning column number. */ + public int getBeginColumn() { + return tokenStarted ? column : 0; + } + + /** Get token beginning line number. */ + public int getBeginLine() { + return tokenStarted ? line : 0; + } + +/** Backup a number of characters. */ + public void backup(int amount) { + + inBuf += amount; + if ((bufpos -= amount) < 0) + bufpos += bufsize; + } + + // A buffer of no chars never grows: readChar would fail, and the token manager + // would take that as the end of the input. + private static void checkBufferSize(int buffersize) + { + if (buffersize < 1) + throw new IllegalArgumentException("Buffer size must be at least 1: " + buffersize); + } + + /** Constructor. */ + public ARQCharStream(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) + { + checkBufferSize(buffersize); + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + available = bufsize = buffersize; + buffer = new char[buffersize]; + } + + /** Constructor. */ + public ARQCharStream(java.io.Reader dstream, int startline, + int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + + /** Constructor. */ + public ARQCharStream(java.io.Reader dstream) + { + this(dstream, 1, 1, 4096); + } + + /** Reinitialise. */ + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) + { + checkBufferSize(buffersize); + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + if (buffer == null || buffersize != buffer.length) + { + available = bufsize = buffersize; + buffer = new char[buffersize]; + } + prevCharIsLF = prevCharIsCR = false; + tokenStarted = false; + endBuffer = null; + inputEnded = false; + tokenBegin = inBuf = maxNextCharInd = 0; + bufpos = -1; + } + + /** Reinitialise. */ + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn) + { + ReInit(dstream, startline, startcolumn, 4096); + } + + /** Reinitialise. */ + public void ReInit(java.io.Reader dstream) + { + ReInit(dstream, 1, 1, 4096); + } + /** Constructor. */ + public ARQCharStream(java.io.InputStream dstream, String encoding, int startline, + int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException + { + this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + + /** Constructor. */ + public ARQCharStream(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) + { + this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); + } + + /** Constructor. */ + public ARQCharStream(java.io.InputStream dstream, String encoding, int startline, + int startcolumn) throws java.io.UnsupportedEncodingException + { + this(dstream, encoding, startline, startcolumn, 4096); + } + + /** Constructor. */ + public ARQCharStream(java.io.InputStream dstream, int startline, + int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + + /** Constructor. */ + public ARQCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException + { + this(dstream, encoding, 1, 1, 4096); + } + + /** Constructor. */ + public ARQCharStream(java.io.InputStream dstream) + { + this(dstream, 1, 1, 4096); + } + + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, String encoding, int startline, + int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException + { + ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) + { + ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); + } + + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException + { + ReInit(dstream, encoding, 1, 1, 4096); + } + + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream) + { + ReInit(dstream, 1, 1, 4096); + } + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, String encoding, int startline, + int startcolumn) throws java.io.UnsupportedEncodingException + { + ReInit(dstream, encoding, startline, startcolumn, 4096); + } + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, int startline, + int startcolumn) + { + ReInit(dstream, startline, startcolumn, 4096); + } + /** Get token literal value. */ + public String GetImage() + { + if (bufpos >= tokenBegin) + return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); + else + return new String(buffer, tokenBegin, bufsize - tokenBegin) + + new String(buffer, 0, bufpos + 1); + } + + /** Get the suffix. */ + public char[] GetSuffix(int len) + { + char[] ret = new char[len]; + + if ((bufpos + 1) >= len) + System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); + else + { + System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, + len - bufpos - 1); + System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); + } + + return ret; + } + + /** Reset buffer when finished. */ + public void Done() + { + buffer = null; + } + + public boolean getTrackLineColumn() { return trackLineColumn; } + public void setTrackLineColumn(boolean tlc) { trackLineColumn = tlc; } +} diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ParserARQ.java b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ParserARQ.java index 7aa082359a0..7e75a07a742 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ParserARQ.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ParserARQ.java @@ -94,11 +94,15 @@ private static void perform(Query query, String string, Action action) { } catch (org.apache.jena.sparql.lang.arq.javacc.ParseException ex) { throw new QueryParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn); } catch (org.apache.jena.sparql.lang.arq.javacc.TokenMgrError tErr) { + // The cause is set when reading the input failed (see ARQCharStream). + // An unchecked exception, such as a cancellation, is not a parse error. + if ( tErr.getCause() instanceof RuntimeException ex ) + throw ex; // Last valid token : not the same as token error message - but this // should not happen int col = parser.token.endColumn; int line = parser.token.endLine; - throw new QueryParseException(tErr.getMessage(), line, col); + throw new QueryParseException(tErr.getMessage(), tErr.getCause(), line, col); } catch (QueryException ex) { diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ParserARQUpdate.java b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ParserARQUpdate.java index c735e44a4c0..18fe431bd6e 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ParserARQUpdate.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ParserARQUpdate.java @@ -45,11 +45,15 @@ protected void executeParse(UpdateSink sink, Prologue prologue, Reader r) { } catch (org.apache.jena.sparql.lang.arq.javacc.ParseException ex) { throw new QueryParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn); } catch (org.apache.jena.sparql.lang.arq.javacc.TokenMgrError tErr) { + // The cause is set when reading the input failed (see ARQCharStream). + // An unchecked exception, such as a cancellation, is not a parse error. + if ( tErr.getCause() instanceof RuntimeException ex ) + throw ex; // Last valid token : not the same as token error message - but this // should not happen int col = parser.token.endColumn; int line = parser.token.endLine; - throw new QueryParseException(tErr.getMessage(), line, col); + throw new QueryParseException(tErr.getMessage(), tErr.getCause(), line, col); } catch (QueryException | UpdateException ex) { throw ex; } catch (Error err) { diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/lang/TS_LangSPARQL.java b/jena-arq/src/test/java/org/apache/jena/sparql/lang/TS_LangSPARQL.java index ebea1f846a8..26fe9854c84 100644 --- a/jena-arq/src/test/java/org/apache/jena/sparql/lang/TS_LangSPARQL.java +++ b/jena-arq/src/test/java/org/apache/jena/sparql/lang/TS_LangSPARQL.java @@ -27,7 +27,8 @@ @Suite @SelectClasses({ TestUnescape.class , - TestVarScope.class + TestVarScope.class , + TestARQCharStream.class }) public class TS_LangSPARQL diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/lang/TestARQCharStream.java b/jena-arq/src/test/java/org/apache/jena/sparql/lang/TestARQCharStream.java new file mode 100644 index 00000000000..27bb65b319d --- /dev/null +++ b/jena-arq/src/test/java/org/apache/jena/sparql/lang/TestARQCharStream.java @@ -0,0 +1,292 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.apache.jena.sparql.lang; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.io.StringReader; +import java.nio.charset.MalformedInputException; +import java.nio.charset.StandardCharsets; + +import org.junit.jupiter.api.Test; + +import org.apache.jena.query.QueryFactory; +import org.apache.jena.query.QueryParseException; +import org.apache.jena.query.Syntax; +import org.apache.jena.sparql.core.DatasetGraph; +import org.apache.jena.sparql.core.DatasetGraphFactory; +import org.apache.jena.sparql.sse.SSE; +import org.apache.jena.system.Txn; +import org.apache.jena.update.UpdateAction; +import org.apache.jena.update.UpdateFactory; +import org.apache.jena.sparql.lang.arq.ARQCharStream; +import org.apache.jena.sparql.lang.arq.javacc.ARQParserConstants; +import org.apache.jena.sparql.lang.arq.javacc.ARQParserTokenManager; + +/** + * Tests of ARQCharStream, the char stream of the ARQ parser (GH-1324). + */ +public class TestARQCharStream { + + /** Counts the times the buffer grows. */ + static class CountingCharStream extends ARQCharStream { + int expansions = 0; + + CountingCharStream(Reader reader) { + super(reader, 1, 1); + } + + @Override + protected void ExpandBuff(boolean wrapAround) { + expansions++; + super.ExpandBuff(wrapAround); + } + } + + @Test + public void bufferGrowsByDoubling() throws IOException { + // The first token moves the start of the second one past 2048 chars, + // so the buffer wraps round before it grows. + String first = "a".repeat(3000); + String second = "b".repeat(1_000_000); + CountingCharStream chars = new CountingCharStream(new StringReader(first + second)); + assertEquals(first, readToken(chars, first.length())); + assertEquals(second, readToken(chars, second.length())); + // Doubling from 4096 chars takes 8 expansions to hold 1,000,000 chars. + // Growing by 2048 chars at a time takes about 490, and the time is quadratic. + assertTrue(chars.expansions <= 10, "Buffer expansions: " + chars.expansions); + } + + // A buffer of no chars never grows, so the token manager would take the input as empty. + @Test + public void bufferSizeZero() { + assertThrows(IllegalArgumentException.class, ()->new ARQCharStream(new StringReader("SELECT ?x"), 1, 1, 0)); + ARQCharStream chars = new ARQCharStream(new StringReader(""), 1, 1); + assertThrows(IllegalArgumentException.class, ()->chars.ReInit(new StringReader("SELECT ?x"), 1, 1, 0)); + } + + private static String readToken(ARQCharStream chars, int length) throws IOException { + chars.BeginToken(); + for ( int i = 1 ; i < length ; i++ ) + chars.readChar(); + return chars.GetImage(); + } + + /** How a reader fails. */ + interface ReadFailure { + void fail() throws IOException; + } + + private static final ReadFailure UNCHECKED = ()->{ throw new IllegalStateException("Read failed"); }; + private static final ReadFailure MALFORMED = ()->{ throw new MalformedInputException(1); }; + + /** A reader that returns the text and then fails. */ + private static Reader failingReader(String text, ReadFailure failure) { + return new Reader() { + private final Reader reader = new StringReader(text); + + @Override + public int read(char[] cbuf, int off, int len) throws IOException { + int n = reader.read(cbuf, off, len); + if ( n == -1 ) + failure.fail(); + return n; + } + + @Override + public void close() {} + }; + } + + // The token manager takes an exception from the char stream as the end of the + // input. A failing reader must be an error instead, or the rest of the input is + // silently dropped. + + @Test + public void readerFailure() { + readerFailure(UNCHECKED); + readerFailure(MALFORMED); + } + + private static void readerFailure(ReadFailure failure) { + ARQParserTokenManager tokens = + new ARQParserTokenManager(new ARQCharStream(failingReader(" ; ", failure), 1, 1)); + assertEquals(ARQParserConstants.IRIref, tokens.getNextToken().kind); + assertEquals(ARQParserConstants.SEMICOLON, tokens.getNextToken().kind); + assertThrows(org.apache.jena.sparql.lang.arq.javacc.TokenMgrError.class, ()->tokens.getNextToken()); + } + + // An unchecked exception from reading the input, such as a cancellation, is not a + // parse error: the parser passes it on unchanged. + @Test + public void readerRuntimeException() { + IllegalStateException failure = new IllegalStateException("Cancelled"); + InputStream input = new InputStream() { + private final InputStream bytes = new ByteArrayInputStream("INSERT DATA { } ; ".getBytes(StandardCharsets.UTF_8)); + + @Override + public int read() throws IOException { + int b = bytes.read(); + if ( b == -1 ) + throw failure; + return b; + } + }; + IllegalStateException ex = assertThrows(IllegalStateException.class, ()->UpdateFactory.read(input, Syntax.syntaxARQ)); + assertSame(failure, ex); + } + + // An update read as bytes, as Fuseki reads update requests, with a byte that is + // not valid UTF-8. The decoder fails with MalformedInputException: that must be a + // parse error, not an empty or shortened update, and keep the exception as its cause. + + @Test + public void malformedInputUpdate() { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + bytes.writeBytes("INSERT DATA { } ; INSERT DATA { \"".getBytes(StandardCharsets.UTF_8)); + bytes.write(0xFF); + bytes.writeBytes("\" }".getBytes(StandardCharsets.UTF_8)); + QueryParseException ex = assertThrows(QueryParseException.class, ()->UpdateFactory.read(new ByteArrayInputStream(bytes.toByteArray()), Syntax.syntaxARQ)); + assertTrue(ex.getCause() instanceof MalformedInputException, "Cause: " + ex.getCause()); + } + + // A failed read of an update request must not commit part of the update. Fuseki + // parses and executes an update in one write transaction (SPARQL_Update.execute), + // and aborts it on an exception, as Txn.executeWrite does. + + private static void executeUpdate(DatasetGraph dsg, InputStream body) { + Txn.executeWrite(dsg, ()->UpdateAction.parseExecute(null, dsg, body, "http://example/", Syntax.syntaxARQ)); + } + + /** The bytes up to cut, then an IOException, as when the client's connection drops. */ + private static InputStream droppedConnection(byte[] bytes, int cut) { + return new InputStream() { + private int pos = 0; + + @Override + public int read() throws IOException { + byte[] b = new byte[1]; + return read(b, 0, 1) == -1 ? -1 : b[0] & 0xFF; + } + + @Override + public int read(byte[] b, int off, int len) throws IOException { + if ( pos >= cut ) + throw new IOException("Early EOF"); + int n = Math.min(len, cut - pos); + System.arraycopy(bytes, pos, b, off, n); + pos += n; + return n; + } + }; + } + + // A transfer of 50 from Alice to Bob; the connection drops after the second operation. + @Test + public void updateConnectionDropped() { + DatasetGraph dsg = DatasetGraphFactory.createTxnMem(); + Txn.executeWrite(dsg, ()->UpdateAction.parseExecute(""" + INSERT DATA { 100 . + 0 } + """, dsg)); + String update = """ + DELETE DATA { 100 } ; + INSERT DATA { 50 } ; + DELETE DATA { 0 } ; + INSERT DATA { 50 } ; + """; + int cut = update.indexOf("DELETE DATA { "); + InputStream body = droppedConnection(update.getBytes(StandardCharsets.UTF_8), cut); + QueryParseException ex = assertThrows(QueryParseException.class, ()->executeUpdate(dsg, body)); + assertTrue(ex.getCause() instanceof IOException, "Cause: " + ex.getCause()); + Txn.executeRead(dsg, ()->{ + assertEquals(2, dsg.getDefaultGraph().size()); + assertTrue(dsg.getDefaultGraph().contains(SSE.parseTriple("( 100)"))); + assertTrue(dsg.getDefaultGraph().contains(SSE.parseTriple("( 0)"))); + }); + } + + // 300 operations of 64 bytes; operation 200 has "Bjørn" in Latin-1 (byte F8), which + // is not valid UTF-8. The decoder reads 8192 bytes at a time, so on main its first + // read ended after operation 127, and those 128 operations were committed. + @Test + public void updateInvalidUTF8() { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + for ( int i = 0 ; i < 300 ; i++ ) { + String op = ( i == 200 ) + ? "INSERT DATA { \"Bjørn\" } ;" + : "INSERT DATA { " + i + " } ;"; + bytes.writeBytes((op + " ".repeat(63 - op.length()) + "\n").getBytes(StandardCharsets.ISO_8859_1)); + } + DatasetGraph dsg = DatasetGraphFactory.createTxnMem(); + QueryParseException ex = assertThrows(QueryParseException.class, ()->executeUpdate(dsg, new ByteArrayInputStream(bytes.toByteArray()))); + assertTrue(ex.getCause() instanceof MalformedInputException, "Cause: " + ex.getCause()); + assertEquals(0, Txn.calculateRead(dsg, ()->dsg.getDefaultGraph().size()).intValue()); + } + + // Queries that end on a token the lexer reads past, with no newline after it. + // The char stream is asked for more input after the end of the input has been reached. + + private static final String[] queriesEndingAtEOF = { + "SELECT * { ?s ?p ?o } LIMIT 10", + "SELECT ?x { } ORDER BY ?x", + "ASK { ?s ?p ?o } # comment" + }; + + @Test + public void endOfInput() { + for ( String q : queriesEndingAtEOF ) + QueryFactory.create(q, Syntax.syntaxARQ); + } + + // Line and column after a multi-line literal that is longer than the initial buffer. + + @Test + public void positionAfterLongLiteral() { + String literalLine = "x".repeat(99) + "\n"; + String query = "SELECT * {\n ?s ?p \"\"\"" + literalLine.repeat(1000) + "\"\"\" .\n ?a ?b ?lastGood ]\n}\n"; + int lastGood = query.indexOf("?lastGood"); + int bad = query.indexOf(']'); + QueryParseException ex = assertThrows(QueryParseException.class, ()->QueryFactory.create(query, Syntax.syntaxARQ)); + // The exception has the position of the last token parsed; the message has the position of the bad token. + assertEquals(lineOf(query, lastGood), ex.getLine()); + assertEquals(columnOf(query, lastGood), ex.getColumn()); + String position = "line " + lineOf(query, bad) + ", column " + columnOf(query, bad); + assertTrue(ex.getMessage().contains(position), "Expected \"" + position + "\" in: " + ex.getMessage()); + } + + private static int lineOf(String text, int index) { + return (int)text.substring(0, index).chars().filter(ch -> ch == '\n').count() + 1; + } + + private static int columnOf(String text, int index) { + return index - text.lastIndexOf('\n', index - 1); + } +} From 30d6fe4e2bcd991f896e04b6348224b9a2221bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Gjesdal?= Date: Tue, 17 Nov 2026 21:47:18 +0100 Subject: [PATCH 2/3] GH-1324: Regenerate the ARQ parser Run jena-arq/Grammar/grammar with javacc 7.0.12 and GNU cpp after the USER_CHAR_STREAM change to main.jj. javacc now generates the CharStream interface for the ARQ parser, which ARQCharStream implements. ARQParser and its token manager use CharStream in place of SimpleCharStream, and the InputStream and Reader constructors come from the parser class in main.jj. The generated SimpleCharStream.java of the ARQ parser is removed. The script also regenerates the SPARQL 1.2 parser, which comes out the same as before. javacc names its lookahead methods after their line in the .jj file, and the lines added to main.jj move the grammar down, so most of the ARQParser.java diff is renamed methods. Co-Authored-By: Claude Opus 5.5 --- jena-arq/Grammar/arq.jj | 18 +- .../sparql/lang/arq/javacc/ARQParser.java | 850 +++++++++--------- .../arq/javacc/ARQParserTokenManager.java | 13 +- .../sparql/lang/arq/javacc/CharStream.java | 140 +++ .../lang/arq/javacc/SimpleCharStream.java | 492 ---------- 5 files changed, 574 insertions(+), 939 deletions(-) create mode 100644 jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/CharStream.java delete mode 100644 jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/SimpleCharStream.java diff --git a/jena-arq/Grammar/arq.jj b/jena-arq/Grammar/arq.jj index 1062221641e..afd92992fef 100644 --- a/jena-arq/Grammar/arq.jj +++ b/jena-arq/Grammar/arq.jj @@ -26,6 +26,8 @@ options JAVA_UNICODE_ESCAPE = false ; UNICODE_INPUT = true ; STATIC = false ; +// ARQCharStream (GH-1324): see the parser class below. + USER_CHAR_STREAM = true ; // DEBUG_PARSER = true ; // DEBUG_TOKEN_MANAGER = true ; } @@ -64,8 +66,22 @@ import org.apache.jena.sparql.modify.request.* ; import org.apache.jena.sparql.core.Quad ; import java.util.List; import java.util.ArrayList; +import org.apache.jena.sparql.lang.arq.ARQCharStream ; public class ARQParser extends org.apache.jena.sparql.lang.arq.ARQParserBase -{} +{ + // USER_CHAR_STREAM leaves out the InputStream and Reader constructors and + // ReInit operations: these are the ones javacc would generate, with ARQCharStream. + public ARQParser(java.io.InputStream stream) { this(stream, null); } + public ARQParser(java.io.InputStream stream, String encoding) { this(newCharStream(stream, encoding)); } + public ARQParser(java.io.Reader stream) { this(new ARQCharStream(stream, 1, 1)); } + public void ReInit(java.io.InputStream stream) { ReInit(stream, null); } + public void ReInit(java.io.InputStream stream, String encoding) { ReInit(newCharStream(stream, encoding)); } + public void ReInit(java.io.Reader stream) { ReInit(new ARQCharStream(stream, 1, 1)); } + private static ARQCharStream newCharStream(java.io.InputStream stream, String encoding) { + try { return new ARQCharStream(stream, encoding, 1, 1); } + catch (java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } + } +} PARSER_END(ARQParser) // // Common top for single entry point. // void Top(): {} diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/ARQParser.java b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/ARQParser.java index 5a9b2361e79..746839371b3 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/ARQParser.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/ARQParser.java @@ -34,9 +34,22 @@ import org.apache.jena.sparql.core.Quad ; import java.util.List; import java.util.ArrayList; +import org.apache.jena.sparql.lang.arq.ARQCharStream ; @SuppressWarnings("all") public class ARQParser extends org.apache.jena.sparql.lang.arq.ARQParserBase implements ARQParserConstants { + // USER_CHAR_STREAM leaves out the InputStream and Reader constructors and + // ReInit operations: these are the ones javacc would generate, with ARQCharStream. + public ARQParser(java.io.InputStream stream) { this(stream, null); } + public ARQParser(java.io.InputStream stream, String encoding) { this(newCharStream(stream, encoding)); } + public ARQParser(java.io.Reader stream) { this(new ARQCharStream(stream, 1, 1)); } + public void ReInit(java.io.InputStream stream) { ReInit(stream, null); } + public void ReInit(java.io.InputStream stream, String encoding) { ReInit(newCharStream(stream, encoding)); } + public void ReInit(java.io.Reader stream) { ReInit(new ARQCharStream(stream, 1, 1)); } + private static ARQCharStream newCharStream(java.io.InputStream stream, String encoding) { + try { return new ARQCharStream(stream, encoding, 1, 1); } + catch (java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } + } // // Common top for single entry point. // void Top(): {} @@ -7732,368 +7745,308 @@ private boolean jj_2_5(int xla) finally { jj_save(4, xla); } } - private boolean jj_3R_BuiltInCall_1909_5_116() - { - if (jj_scan_token(TRIPLE)) return true; - if (jj_scan_token(LPAREN)) return true; - return false; - } - - private boolean jj_3R_BuiltInCall_1907_5_115() - { - if (jj_scan_token(IS_TRIPLE)) return true; - if (jj_scan_token(LPAREN)) return true; - return false; - } - - private boolean jj_3R_BuiltInCall_1906_5_114() - { - if (jj_3R_NotExistsFunc_1964_4_132()) return true; - return false; - } - - private boolean jj_3R_BuiltInCall_1905_5_113() - { - if (jj_3R_ExistsFunc_1958_4_131()) return true; - return false; - } - - private boolean jj_3R_BuiltInCall_1904_5_112() - { - if (jj_3R_RegexExpression_1923_5_130()) return true; - return false; - } - - private boolean jj_3R_BuiltInCall_1901_5_111() - { - if (jj_scan_token(HAS_LANGDIR)) return true; - if (jj_scan_token(LPAREN)) return true; - return false; - } - - private boolean jj_3R_BuiltInCall_1899_5_110() - { - if (jj_scan_token(HAS_LANG)) return true; - if (jj_scan_token(LPAREN)) return true; - return false; - } - - private boolean jj_3R_BuiltInCall_1897_5_109() - { - if (jj_scan_token(IS_NUMERIC)) return true; - if (jj_scan_token(LPAREN)) return true; - return false; - } - - private boolean jj_3R_BuiltInCall_1895_5_108() - { - if (jj_scan_token(IS_LITERAL)) return true; - if (jj_scan_token(LPAREN)) return true; - return false; - } - - private boolean jj_3R_BuiltInCall_1893_5_107() + private boolean jj_3R_BuiltInCall_1909_5_107() { if (jj_scan_token(IS_BLANK)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1891_5_106() + private boolean jj_3R_BuiltInCall_1907_5_106() { if (jj_scan_token(IS_URI)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_TripleTerm_1506_5_180() + private boolean jj_3R_BuiltInCall_1905_5_105() { - if (jj_scan_token(L_TRIPLE)) return true; + if (jj_scan_token(IS_IRI)) return true; + if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1889_5_105() + private boolean jj_3R_TripleTerm_1522_5_180() { - if (jj_scan_token(IS_IRI)) return true; - if (jj_scan_token(LPAREN)) return true; + if (jj_scan_token(L_TRIPLE)) return true; return false; } - private boolean jj_3R_BuiltInCall_1887_5_104() + private boolean jj_3R_BuiltInCall_1903_5_104() { if (jj_scan_token(SAME_VALUE)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1885_5_103() + private boolean jj_3R_BuiltInCall_1901_5_103() { if (jj_scan_token(SAME_TERM)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1883_5_102() + private boolean jj_3R_BuiltInCall_1899_5_102() { if (jj_scan_token(STRDT)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1879_5_101() + private boolean jj_3R_BuiltInCall_1895_5_101() { if (jj_scan_token(STRLANGDIR)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1877_5_100() + private boolean jj_3R_BuiltInCall_1893_5_100() { if (jj_scan_token(STRLANG)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1873_5_99() + private boolean jj_3R_BuiltInCall_1889_5_99() { if (jj_scan_token(IF)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1865_5_98() + private boolean jj_3R_BuiltInCall_1881_5_98() { if (jj_scan_token(CALL)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_ReifiedTripleBlock_713_3_138() + private boolean jj_3R_ReifiedTripleBlock_729_3_138() { - if (jj_3R_ReifiedTriple_1465_3_171()) return true; + if (jj_3R_ReifiedTriple_1481_3_171()) return true; return false; } - private boolean jj_3R_BuiltInCall_1860_5_97() + private boolean jj_3R_BuiltInCall_1876_5_97() { if (jj_scan_token(COALESCE)) return true; - if (jj_3R_ExpressionList_1020_3_127()) return true; + if (jj_3R_ExpressionList_1036_3_127()) return true; return false; } - private boolean jj_3R_BuiltInCall_1859_5_96() + private boolean jj_3R_BuiltInCall_1875_5_96() { if (jj_scan_token(EBV)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1857_5_95() + private boolean jj_3R_BuiltInCall_1873_5_95() { if (jj_scan_token(VERSION)) return true; if (jj_scan_token(NIL)) return true; return false; } - private boolean jj_3R_BuiltInCall_1855_5_94() + private boolean jj_3R_BuiltInCall_1871_5_94() { if (jj_scan_token(SHA512)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1854_5_93() + private boolean jj_3R_BuiltInCall_1870_5_93() { if (jj_scan_token(SHA384)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1853_5_92() + private boolean jj_3R_BuiltInCall_1869_5_92() { if (jj_scan_token(SHA256)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1852_5_91() + private boolean jj_3R_BuiltInCall_1868_5_91() { if (jj_scan_token(SHA1)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1851_5_90() + private boolean jj_3R_BuiltInCall_1867_5_90() { if (jj_scan_token(MD5)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1850_5_89() + private boolean jj_3R_BuiltInCall_1866_5_89() { if (jj_scan_token(STRUUID)) return true; if (jj_scan_token(NIL)) return true; return false; } - private boolean jj_3R_BuiltInCall_1849_5_88() + private boolean jj_3R_BuiltInCall_1865_5_88() { if (jj_scan_token(UUID)) return true; if (jj_scan_token(NIL)) return true; return false; } - private boolean jj_3R_BuiltInCall_1848_5_87() + private boolean jj_3R_BuiltInCall_1864_5_87() { if (jj_scan_token(NOW)) return true; if (jj_scan_token(NIL)) return true; return false; } - private boolean jj_3R_ReifiedTriple_1465_3_171() + private boolean jj_3R_ReifiedTriple_1481_3_171() { if (jj_scan_token(LT2)) return true; return false; } - private boolean jj_3R_BuiltInCall_1844_5_86() + private boolean jj_3R_BuiltInCall_1860_5_86() { if (jj_scan_token(ADJUST)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1843_5_85() + private boolean jj_3R_BuiltInCall_1859_5_85() { if (jj_scan_token(TZ)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_VarOrTerm_1459_5_168() + private boolean jj_3R_VarOrTerm_1475_5_168() { - if (jj_3R_TripleTerm_1506_5_180()) return true; + if (jj_3R_TripleTerm_1522_5_180()) return true; return false; } - private boolean jj_3R_BuiltInCall_1842_5_84() + private boolean jj_3R_BuiltInCall_1858_5_84() { if (jj_scan_token(TIMEZONE)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_VarOrTerm_1458_5_167() + private boolean jj_3R_VarOrTerm_1474_5_167() { if (jj_scan_token(NIL)) return true; return false; } - private boolean jj_3R_BuiltInCall_1841_5_83() + private boolean jj_3R_BuiltInCall_1857_5_83() { if (jj_scan_token(SECONDS)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1840_5_82() + private boolean jj_3R_BuiltInCall_1856_5_82() { if (jj_scan_token(MINUTES)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_VarOrTerm_1456_5_166() + private boolean jj_3R_VarOrTerm_1472_5_166() { - if (jj_3R_BlankNode_2158_3_179()) return true; + if (jj_3R_BlankNode_2174_3_179()) return true; return false; } - private boolean jj_3R_BuiltInCall_1839_5_81() + private boolean jj_3R_BuiltInCall_1855_5_81() { if (jj_scan_token(HOURS)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_VarOrTerm_1455_5_165() + private boolean jj_3R_VarOrTerm_1471_5_165() { - if (jj_3R_BooleanLiteral_2125_3_178()) return true; + if (jj_3R_BooleanLiteral_2141_3_178()) return true; return false; } - private boolean jj_3R_BuiltInCall_1838_5_80() + private boolean jj_3R_BuiltInCall_1854_5_80() { if (jj_scan_token(DAY)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_VarOrTerm_1454_5_164() + private boolean jj_3R_VarOrTerm_1470_5_164() { - if (jj_3R_NumericLiteral_2098_3_177()) return true; + if (jj_3R_NumericLiteral_2114_3_177()) return true; return false; } - private boolean jj_3R_BuiltInCall_1837_5_79() + private boolean jj_3R_BuiltInCall_1853_5_79() { if (jj_scan_token(MONTH)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_VarOrTerm_1453_5_163() + private boolean jj_3R_VarOrTerm_1469_5_163() { - if (jj_3R_RDFLiteral_2085_3_176()) return true; + if (jj_3R_RDFLiteral_2101_3_176()) return true; return false; } - private boolean jj_3R_BuiltInCall_1836_5_78() + private boolean jj_3R_BuiltInCall_1852_5_78() { if (jj_scan_token(YEAR)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_VarOrTerm_1452_5_162() + private boolean jj_3R_VarOrTerm_1468_5_162() { - if (jj_3R_iri_2143_3_172()) return true; + if (jj_3R_iri_2159_3_172()) return true; return false; } - private boolean jj_3R_VarOrTerm_1451_5_161() + private boolean jj_3R_VarOrTerm_1467_5_161() { - if (jj_3R_Var_1598_5_175()) return true; + if (jj_3R_Var_1614_5_175()) return true; return false; } - private boolean jj_3R_BuiltInCall_1834_5_77() + private boolean jj_3R_BuiltInCall_1850_5_77() { if (jj_scan_token(STRAFTER)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_VarOrTerm_1451_3_136() + private boolean jj_3R_VarOrTerm_1467_3_136() { Token xsp; xsp = jj_scanpos; - if (jj_3R_VarOrTerm_1451_5_161()) { + if (jj_3R_VarOrTerm_1467_5_161()) { jj_scanpos = xsp; - if (jj_3R_VarOrTerm_1452_5_162()) { + if (jj_3R_VarOrTerm_1468_5_162()) { jj_scanpos = xsp; - if (jj_3R_VarOrTerm_1453_5_163()) { + if (jj_3R_VarOrTerm_1469_5_163()) { jj_scanpos = xsp; - if (jj_3R_VarOrTerm_1454_5_164()) { + if (jj_3R_VarOrTerm_1470_5_164()) { jj_scanpos = xsp; - if (jj_3R_VarOrTerm_1455_5_165()) { + if (jj_3R_VarOrTerm_1471_5_165()) { jj_scanpos = xsp; - if (jj_3R_VarOrTerm_1456_5_166()) { + if (jj_3R_VarOrTerm_1472_5_166()) { jj_scanpos = xsp; - if (jj_3R_VarOrTerm_1458_5_167()) { + if (jj_3R_VarOrTerm_1474_5_167()) { jj_scanpos = xsp; - if (jj_3R_VarOrTerm_1459_5_168()) return true; + if (jj_3R_VarOrTerm_1475_5_168()) return true; } } } @@ -8104,149 +8057,149 @@ private boolean jj_3R_VarOrTerm_1451_3_136() return false; } - private boolean jj_3R_BuiltInCall_1832_5_76() + private boolean jj_3R_BuiltInCall_1848_5_76() { if (jj_scan_token(STRBEFORE)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1830_5_75() + private boolean jj_3R_BuiltInCall_1846_5_75() { if (jj_scan_token(STRENDS)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1828_5_74() + private boolean jj_3R_BuiltInCall_1844_5_74() { if (jj_scan_token(STRSTARTS)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1826_5_73() + private boolean jj_3R_BuiltInCall_1842_5_73() { if (jj_scan_token(CONTAINS)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_TriplesSameSubject_1061_3_123() + private boolean jj_3R_TriplesSameSubject_1077_3_123() { - if (jj_3R_ReifiedTripleBlock_713_3_138()) return true; + if (jj_3R_ReifiedTripleBlock_729_3_138()) return true; return false; } - private boolean jj_3R_BuiltInCall_1825_5_72() + private boolean jj_3R_BuiltInCall_1841_5_72() { if (jj_scan_token(ENCODE_FOR_URI)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1824_5_71() + private boolean jj_3R_BuiltInCall_1840_5_71() { if (jj_scan_token(LCASE)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1823_5_70() + private boolean jj_3R_BuiltInCall_1839_5_70() { if (jj_scan_token(UCASE)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1822_5_69() + private boolean jj_3R_BuiltInCall_1838_5_69() { - if (jj_3R_StrReplaceExpression_1947_3_129()) return true; + if (jj_3R_StrReplaceExpression_1963_3_129()) return true; return false; } - private boolean jj_3R_BuiltInCall_1821_5_68() + private boolean jj_3R_BuiltInCall_1837_5_68() { if (jj_scan_token(STRLEN)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_TriplesSameSubject_1056_3_122() + private boolean jj_3R_TriplesSameSubject_1072_3_122() { - if (jj_3R_TriplesNode_1301_4_137()) return true; + if (jj_3R_TriplesNode_1317_4_137()) return true; return false; } - private boolean jj_3R_BuiltInCall_1820_5_67() + private boolean jj_3R_BuiltInCall_1836_5_67() { - if (jj_3R_SubstringExpression_1935_5_128()) return true; + if (jj_3R_SubstringExpression_1951_5_128()) return true; return false; } - private boolean jj_3R_BuiltInCall_1819_5_66() + private boolean jj_3R_BuiltInCall_1835_5_66() { if (jj_scan_token(CONCAT)) return true; - if (jj_3R_ExpressionList_1020_3_127()) return true; + if (jj_3R_ExpressionList_1036_3_127()) return true; return false; } - private boolean jj_3R_BuiltInCall_1818_5_65() + private boolean jj_3R_BuiltInCall_1834_5_65() { if (jj_scan_token(IDIV)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1817_5_64() + private boolean jj_3R_BuiltInCall_1833_5_64() { if (jj_scan_token(MOD)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_TriplesSameSubject_1052_3_48() + private boolean jj_3R_TriplesSameSubject_1068_3_48() { Token xsp; xsp = jj_scanpos; - if (jj_3R_TriplesSameSubject_1052_3_121()) { + if (jj_3R_TriplesSameSubject_1068_3_121()) { jj_scanpos = xsp; - if (jj_3R_TriplesSameSubject_1056_3_122()) { + if (jj_3R_TriplesSameSubject_1072_3_122()) { jj_scanpos = xsp; - if (jj_3R_TriplesSameSubject_1061_3_123()) return true; + if (jj_3R_TriplesSameSubject_1077_3_123()) return true; } } return false; } - private boolean jj_3R_TriplesSameSubject_1052_3_121() + private boolean jj_3R_TriplesSameSubject_1068_3_121() { - if (jj_3R_VarOrTerm_1451_3_136()) return true; + if (jj_3R_VarOrTerm_1467_3_136()) return true; return false; } - private boolean jj_3R_BuiltInCall_1816_5_63() + private boolean jj_3R_BuiltInCall_1832_5_63() { if (jj_scan_token(ROUND)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1815_5_62() + private boolean jj_3R_BuiltInCall_1831_5_62() { if (jj_scan_token(FLOOR)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1814_5_61() + private boolean jj_3R_BuiltInCall_1830_5_61() { if (jj_scan_token(CEIL)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1813_5_60() + private boolean jj_3R_BuiltInCall_1829_5_60() { if (jj_scan_token(ABS)) return true; if (jj_scan_token(LPAREN)) return true; @@ -8256,43 +8209,43 @@ private boolean jj_3R_BuiltInCall_1813_5_60() private boolean jj_3_4() { if (jj_scan_token(DOT)) return true; - if (jj_3R_TriplesSameSubject_1052_3_48()) return true; + if (jj_3R_TriplesSameSubject_1068_3_48()) return true; return false; } - private boolean jj_3R_BuiltInCall_1812_5_59() + private boolean jj_3R_BuiltInCall_1828_5_59() { if (jj_scan_token(RAND)) return true; if (jj_scan_token(NIL)) return true; return false; } - private boolean jj_3R_BuiltInCall_1810_7_126() + private boolean jj_3R_BuiltInCall_1826_7_126() { if (jj_scan_token(NIL)) return true; return false; } - private boolean jj_3R_BuiltInCall_1807_7_125() + private boolean jj_3R_BuiltInCall_1823_7_125() { if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_GroupGraphPattern_661_3_157() + private boolean jj_3R_GroupGraphPattern_677_3_157() { if (jj_scan_token(LBRACE)) return true; return false; } - private boolean jj_3R_BuiltInCall_1806_5_58() + private boolean jj_3R_BuiltInCall_1822_5_58() { if (jj_scan_token(BNODE)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_BuiltInCall_1807_7_125()) { + if (jj_3R_BuiltInCall_1823_7_125()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1810_7_126()) return true; + if (jj_3R_BuiltInCall_1826_7_126()) return true; } return false; } @@ -8300,234 +8253,234 @@ private boolean jj_3R_BuiltInCall_1806_5_58() private boolean jj_3_3() { if (jj_scan_token(DOT)) return true; - if (jj_3R_TriplesSameSubject_1052_3_48()) return true; + if (jj_3R_TriplesSameSubject_1068_3_48()) return true; return false; } - private boolean jj_3R_BuiltInCall_1804_5_57() + private boolean jj_3R_BuiltInCall_1820_5_57() { if (jj_scan_token(URI)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1802_5_56() + private boolean jj_3R_BuiltInCall_1818_5_56() { if (jj_scan_token(IRI)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1797_5_55() + private boolean jj_3R_BuiltInCall_1813_5_55() { if (jj_scan_token(BOUND)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1795_5_54() + private boolean jj_3R_BuiltInCall_1811_5_54() { if (jj_scan_token(DTYPE)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1793_5_53() + private boolean jj_3R_BuiltInCall_1809_5_53() { if (jj_scan_token(LANGDIR)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1790_5_52() + private boolean jj_3R_BuiltInCall_1806_5_52() { if (jj_scan_token(LANGMATCHES)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_ExpressionList_1023_5_156() + private boolean jj_3R_ExpressionList_1039_5_156() { if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1788_5_51() + private boolean jj_3R_BuiltInCall_1804_5_51() { if (jj_scan_token(LANG)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1786_5_50() + private boolean jj_3R_BuiltInCall_1802_5_50() { if (jj_scan_token(STR)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_ExpressionList_1020_3_127() + private boolean jj_3R_ExpressionList_1036_3_127() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(196)) { jj_scanpos = xsp; - if (jj_3R_ExpressionList_1023_5_156()) return true; + if (jj_3R_ExpressionList_1039_5_156()) return true; } return false; } - private boolean jj_3R_BuiltInCall_1784_5_49() + private boolean jj_3R_BuiltInCall_1800_5_49() { - if (jj_3R_Aggregate_1976_3_124()) return true; + if (jj_3R_Aggregate_1992_3_124()) return true; return false; } - private boolean jj_3R_BuiltInCall_1784_5_46() + private boolean jj_3R_BuiltInCall_1800_5_46() { Token xsp; xsp = jj_scanpos; - if (jj_3R_BuiltInCall_1784_5_49()) { + if (jj_3R_BuiltInCall_1800_5_49()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1786_5_50()) { + if (jj_3R_BuiltInCall_1802_5_50()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1788_5_51()) { + if (jj_3R_BuiltInCall_1804_5_51()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1790_5_52()) { + if (jj_3R_BuiltInCall_1806_5_52()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1793_5_53()) { + if (jj_3R_BuiltInCall_1809_5_53()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1795_5_54()) { + if (jj_3R_BuiltInCall_1811_5_54()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1797_5_55()) { + if (jj_3R_BuiltInCall_1813_5_55()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1802_5_56()) { + if (jj_3R_BuiltInCall_1818_5_56()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1804_5_57()) { + if (jj_3R_BuiltInCall_1820_5_57()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1806_5_58()) { + if (jj_3R_BuiltInCall_1822_5_58()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1812_5_59()) { + if (jj_3R_BuiltInCall_1828_5_59()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1813_5_60()) { + if (jj_3R_BuiltInCall_1829_5_60()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1814_5_61()) { + if (jj_3R_BuiltInCall_1830_5_61()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1815_5_62()) { + if (jj_3R_BuiltInCall_1831_5_62()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1816_5_63()) { + if (jj_3R_BuiltInCall_1832_5_63()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1817_5_64()) { + if (jj_3R_BuiltInCall_1833_5_64()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1818_5_65()) { + if (jj_3R_BuiltInCall_1834_5_65()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1819_5_66()) { + if (jj_3R_BuiltInCall_1835_5_66()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1820_5_67()) { + if (jj_3R_BuiltInCall_1836_5_67()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1821_5_68()) { + if (jj_3R_BuiltInCall_1837_5_68()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1822_5_69()) { + if (jj_3R_BuiltInCall_1838_5_69()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1823_5_70()) { + if (jj_3R_BuiltInCall_1839_5_70()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1824_5_71()) { + if (jj_3R_BuiltInCall_1840_5_71()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1825_5_72()) { + if (jj_3R_BuiltInCall_1841_5_72()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1826_5_73()) { + if (jj_3R_BuiltInCall_1842_5_73()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1828_5_74()) { + if (jj_3R_BuiltInCall_1844_5_74()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1830_5_75()) { + if (jj_3R_BuiltInCall_1846_5_75()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1832_5_76()) { + if (jj_3R_BuiltInCall_1848_5_76()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1834_5_77()) { + if (jj_3R_BuiltInCall_1850_5_77()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1836_5_78()) { + if (jj_3R_BuiltInCall_1852_5_78()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1837_5_79()) { + if (jj_3R_BuiltInCall_1853_5_79()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1838_5_80()) { + if (jj_3R_BuiltInCall_1854_5_80()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1839_5_81()) { + if (jj_3R_BuiltInCall_1855_5_81()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1840_5_82()) { + if (jj_3R_BuiltInCall_1856_5_82()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1841_5_83()) { + if (jj_3R_BuiltInCall_1857_5_83()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1842_5_84()) { + if (jj_3R_BuiltInCall_1858_5_84()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1843_5_85()) { + if (jj_3R_BuiltInCall_1859_5_85()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1844_5_86()) { + if (jj_3R_BuiltInCall_1860_5_86()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1848_5_87()) { + if (jj_3R_BuiltInCall_1864_5_87()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1849_5_88()) { + if (jj_3R_BuiltInCall_1865_5_88()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1850_5_89()) { + if (jj_3R_BuiltInCall_1866_5_89()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1851_5_90()) { + if (jj_3R_BuiltInCall_1867_5_90()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1852_5_91()) { + if (jj_3R_BuiltInCall_1868_5_91()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1853_5_92()) { + if (jj_3R_BuiltInCall_1869_5_92()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1854_5_93()) { + if (jj_3R_BuiltInCall_1870_5_93()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1855_5_94()) { + if (jj_3R_BuiltInCall_1871_5_94()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1857_5_95()) { + if (jj_3R_BuiltInCall_1873_5_95()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1859_5_96()) { + if (jj_3R_BuiltInCall_1875_5_96()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1860_5_97()) { + if (jj_3R_BuiltInCall_1876_5_97()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1865_5_98()) { + if (jj_3R_BuiltInCall_1881_5_98()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1873_5_99()) { + if (jj_3R_BuiltInCall_1889_5_99()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1877_5_100()) { + if (jj_3R_BuiltInCall_1893_5_100()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1879_5_101()) { + if (jj_3R_BuiltInCall_1895_5_101()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1883_5_102()) { + if (jj_3R_BuiltInCall_1899_5_102()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1885_5_103()) { + if (jj_3R_BuiltInCall_1901_5_103()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1887_5_104()) { + if (jj_3R_BuiltInCall_1903_5_104()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1889_5_105()) { + if (jj_3R_BuiltInCall_1905_5_105()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1891_5_106()) { + if (jj_3R_BuiltInCall_1907_5_106()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1893_5_107()) { + if (jj_3R_BuiltInCall_1909_5_107()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1895_5_108()) { + if (jj_3R_BuiltInCall_1911_5_108()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1897_5_109()) { + if (jj_3R_BuiltInCall_1913_5_109()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1899_5_110()) { + if (jj_3R_BuiltInCall_1915_5_110()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1901_5_111()) { + if (jj_3R_BuiltInCall_1917_5_111()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1904_5_112()) { + if (jj_3R_BuiltInCall_1920_5_112()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1905_5_113()) { + if (jj_3R_BuiltInCall_1921_5_113()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1906_5_114()) { + if (jj_3R_BuiltInCall_1922_5_114()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1907_5_115()) { + if (jj_3R_BuiltInCall_1923_5_115()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1909_5_116()) { + if (jj_3R_BuiltInCall_1925_5_116()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1913_5_117()) { + if (jj_3R_BuiltInCall_1929_5_117()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1915_5_118()) { + if (jj_3R_BuiltInCall_1931_5_118()) { jj_scanpos = xsp; - if (jj_3R_BuiltInCall_1917_5_119()) return true; + if (jj_3R_BuiltInCall_1933_5_119()) return true; } } } @@ -8601,457 +8554,457 @@ private boolean jj_3R_BuiltInCall_1784_5_46() return false; } - private boolean jj_3R_IRIREF_2168_3_173() + private boolean jj_3R_IRIREF_2184_3_173() { if (jj_scan_token(IRIref)) return true; return false; } - private boolean jj_3R_BlankNode_2162_3_194() + private boolean jj_3R_BlankNode_2178_3_194() { if (jj_scan_token(ANON)) return true; return false; } - private boolean jj_3R_BlankNode_2158_3_193() + private boolean jj_3R_BlankNode_2174_3_193() { if (jj_scan_token(BLANK_NODE_LABEL)) return true; return false; } - private boolean jj_3R_BlankNode_2158_3_179() + private boolean jj_3R_BlankNode_2174_3_179() { Token xsp; xsp = jj_scanpos; - if (jj_3R_BlankNode_2158_3_193()) { + if (jj_3R_BlankNode_2174_3_193()) { jj_scanpos = xsp; - if (jj_3R_BlankNode_2162_3_194()) return true; + if (jj_3R_BlankNode_2178_3_194()) return true; } return false; } - private boolean jj_3R_PrefixedName_2152_5_204() + private boolean jj_3R_PrefixedName_2168_5_204() { if (jj_scan_token(PNAME_NS)) return true; return false; } - private boolean jj_3R_PrefixedName_2149_5_203() + private boolean jj_3R_PrefixedName_2165_5_203() { if (jj_scan_token(PNAME_LN)) return true; return false; } - private boolean jj_3R_PrefixedName_2149_3_195() + private boolean jj_3R_PrefixedName_2165_3_195() { Token xsp; xsp = jj_scanpos; - if (jj_3R_PrefixedName_2149_5_203()) { + if (jj_3R_PrefixedName_2165_5_203()) { jj_scanpos = xsp; - if (jj_3R_PrefixedName_2152_5_204()) return true; + if (jj_3R_PrefixedName_2168_5_204()) return true; } return false; } - private boolean jj_3R_iri_2145_3_184() + private boolean jj_3R_iri_2161_3_184() { - if (jj_3R_PrefixedName_2149_3_195()) return true; + if (jj_3R_PrefixedName_2165_3_195()) return true; return false; } - private boolean jj_3R_iri_2143_3_172() + private boolean jj_3R_iri_2159_3_172() { Token xsp; xsp = jj_scanpos; - if (jj_3R_iri_2143_3_183()) { + if (jj_3R_iri_2159_3_183()) { jj_scanpos = xsp; - if (jj_3R_iri_2145_3_184()) return true; + if (jj_3R_iri_2161_3_184()) return true; } return false; } - private boolean jj_3R_iri_2143_3_183() + private boolean jj_3R_iri_2159_3_183() { - if (jj_3R_IRIREF_2168_3_173()) return true; + if (jj_3R_IRIREF_2184_3_173()) return true; return false; } - private boolean jj_3R_String_2134_5_199() + private boolean jj_3R_String_2150_5_199() { if (jj_scan_token(STRING_LITERAL_LONG2)) return true; return false; } - private boolean jj_3R_String_2133_5_198() + private boolean jj_3R_String_2149_5_198() { if (jj_scan_token(STRING_LITERAL_LONG1)) return true; return false; } - private boolean jj_3R_String_2132_5_197() + private boolean jj_3R_String_2148_5_197() { if (jj_scan_token(STRING_LITERAL2)) return true; return false; } - private boolean jj_3R_String_2131_5_196() + private boolean jj_3R_String_2147_5_196() { if (jj_scan_token(STRING_LITERAL1)) return true; return false; } - private boolean jj_3R_String_2131_3_187() + private boolean jj_3R_String_2147_3_187() { Token xsp; xsp = jj_scanpos; - if (jj_3R_String_2131_5_196()) { + if (jj_3R_String_2147_5_196()) { jj_scanpos = xsp; - if (jj_3R_String_2132_5_197()) { + if (jj_3R_String_2148_5_197()) { jj_scanpos = xsp; - if (jj_3R_String_2133_5_198()) { + if (jj_3R_String_2149_5_198()) { jj_scanpos = xsp; - if (jj_3R_String_2134_5_199()) return true; + if (jj_3R_String_2150_5_199()) return true; } } } return false; } - private boolean jj_3R_BooleanLiteral_2127_3_192() + private boolean jj_3R_BooleanLiteral_2143_3_192() { if (jj_scan_token(FALSE)) return true; return false; } - private boolean jj_3R_BooleanLiteral_2125_3_191() + private boolean jj_3R_BooleanLiteral_2141_3_191() { if (jj_scan_token(TRUE)) return true; return false; } - private boolean jj_3R_BooleanLiteral_2125_3_178() + private boolean jj_3R_BooleanLiteral_2141_3_178() { Token xsp; xsp = jj_scanpos; - if (jj_3R_BooleanLiteral_2125_3_191()) { + if (jj_3R_BooleanLiteral_2141_3_191()) { jj_scanpos = xsp; - if (jj_3R_BooleanLiteral_2127_3_192()) return true; + if (jj_3R_BooleanLiteral_2143_3_192()) return true; } return false; } - private boolean jj_3R_NumericLiteralNegative_2121_3_213() + private boolean jj_3R_NumericLiteralNegative_2137_3_213() { if (jj_scan_token(DOUBLE_NEGATIVE)) return true; return false; } - private boolean jj_3R_NumericLiteralNegative_2120_3_212() + private boolean jj_3R_NumericLiteralNegative_2136_3_212() { if (jj_scan_token(DECIMAL_NEGATIVE)) return true; return false; } - private boolean jj_3R_NumericLiteralNegative_2119_3_211() + private boolean jj_3R_NumericLiteralNegative_2135_3_211() { if (jj_scan_token(INTEGER_NEGATIVE)) return true; return false; } - private boolean jj_3R_NumericLiteralNegative_2119_3_202() + private boolean jj_3R_NumericLiteralNegative_2135_3_202() { Token xsp; xsp = jj_scanpos; - if (jj_3R_NumericLiteralNegative_2119_3_211()) { + if (jj_3R_NumericLiteralNegative_2135_3_211()) { jj_scanpos = xsp; - if (jj_3R_NumericLiteralNegative_2120_3_212()) { + if (jj_3R_NumericLiteralNegative_2136_3_212()) { jj_scanpos = xsp; - if (jj_3R_NumericLiteralNegative_2121_3_213()) return true; + if (jj_3R_NumericLiteralNegative_2137_3_213()) return true; } } return false; } - private boolean jj_3R_NumericLiteralPositive_2115_3_210() + private boolean jj_3R_NumericLiteralPositive_2131_3_210() { if (jj_scan_token(DOUBLE_POSITIVE)) return true; return false; } - private boolean jj_3R_NumericLiteralPositive_2114_3_209() + private boolean jj_3R_NumericLiteralPositive_2130_3_209() { if (jj_scan_token(DECIMAL_POSITIVE)) return true; return false; } - private boolean jj_3R_NumericLiteralPositive_2113_3_208() + private boolean jj_3R_NumericLiteralPositive_2129_3_208() { if (jj_scan_token(INTEGER_POSITIVE)) return true; return false; } - private boolean jj_3R_NumericLiteralPositive_2113_3_201() + private boolean jj_3R_NumericLiteralPositive_2129_3_201() { Token xsp; xsp = jj_scanpos; - if (jj_3R_NumericLiteralPositive_2113_3_208()) { + if (jj_3R_NumericLiteralPositive_2129_3_208()) { jj_scanpos = xsp; - if (jj_3R_NumericLiteralPositive_2114_3_209()) { + if (jj_3R_NumericLiteralPositive_2130_3_209()) { jj_scanpos = xsp; - if (jj_3R_NumericLiteralPositive_2115_3_210()) return true; + if (jj_3R_NumericLiteralPositive_2131_3_210()) return true; } } return false; } - private boolean jj_3R_NumericLiteralUnsigned_2109_3_207() + private boolean jj_3R_NumericLiteralUnsigned_2125_3_207() { if (jj_scan_token(DOUBLE)) return true; return false; } - private boolean jj_3R_NumericLiteralUnsigned_2108_3_206() + private boolean jj_3R_NumericLiteralUnsigned_2124_3_206() { if (jj_scan_token(DECIMAL)) return true; return false; } - private boolean jj_3R_NumericLiteralUnsigned_2107_3_205() + private boolean jj_3R_NumericLiteralUnsigned_2123_3_205() { if (jj_scan_token(INTEGER)) return true; return false; } - private boolean jj_3R_NumericLiteralUnsigned_2107_3_200() + private boolean jj_3R_NumericLiteralUnsigned_2123_3_200() { Token xsp; xsp = jj_scanpos; - if (jj_3R_NumericLiteralUnsigned_2107_3_205()) { + if (jj_3R_NumericLiteralUnsigned_2123_3_205()) { jj_scanpos = xsp; - if (jj_3R_NumericLiteralUnsigned_2108_3_206()) { + if (jj_3R_NumericLiteralUnsigned_2124_3_206()) { jj_scanpos = xsp; - if (jj_3R_NumericLiteralUnsigned_2109_3_207()) return true; + if (jj_3R_NumericLiteralUnsigned_2125_3_207()) return true; } } return false; } - private boolean jj_3R_NumericLiteral_2101_5_190() + private boolean jj_3R_NumericLiteral_2117_5_190() { - if (jj_3R_NumericLiteralNegative_2119_3_202()) return true; + if (jj_3R_NumericLiteralNegative_2135_3_202()) return true; return false; } - private boolean jj_3R_NumericLiteral_2100_5_189() + private boolean jj_3R_NumericLiteral_2116_5_189() { - if (jj_3R_NumericLiteralPositive_2113_3_201()) return true; + if (jj_3R_NumericLiteralPositive_2129_3_201()) return true; return false; } - private boolean jj_3R_NumericLiteral_2099_5_188() + private boolean jj_3R_NumericLiteral_2115_5_188() { - if (jj_3R_NumericLiteralUnsigned_2107_3_200()) return true; + if (jj_3R_NumericLiteralUnsigned_2123_3_200()) return true; return false; } - private boolean jj_3R_NumericLiteral_2098_3_177() + private boolean jj_3R_NumericLiteral_2114_3_177() { Token xsp; xsp = jj_scanpos; - if (jj_3R_NumericLiteral_2099_5_188()) { + if (jj_3R_NumericLiteral_2115_5_188()) { jj_scanpos = xsp; - if (jj_3R_NumericLiteral_2100_5_189()) { + if (jj_3R_NumericLiteral_2116_5_189()) { jj_scanpos = xsp; - if (jj_3R_NumericLiteral_2101_5_190()) return true; + if (jj_3R_NumericLiteral_2117_5_190()) return true; } } return false; } - private boolean jj_3R_Collection_1331_3_181() + private boolean jj_3R_Collection_1347_3_181() { if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_RDFLiteral_2085_3_176() + private boolean jj_3R_RDFLiteral_2101_3_176() { - if (jj_3R_String_2131_3_187()) return true; + if (jj_3R_String_2147_3_187()) return true; return false; } private boolean jj_3_1() { - if (jj_3R_BuiltInCall_1784_5_46()) return true; + if (jj_3R_BuiltInCall_1800_5_46()) return true; return false; } - private boolean jj_3R_BlankNodePropertyList_1307_3_182() + private boolean jj_3R_BlankNodePropertyList_1323_3_182() { if (jj_scan_token(LBRACKET)) return true; return false; } - private boolean jj_3R_TriplesNode_1303_4_170() + private boolean jj_3R_TriplesNode_1319_4_170() { - if (jj_3R_BlankNodePropertyList_1307_3_182()) return true; + if (jj_3R_BlankNodePropertyList_1323_3_182()) return true; return false; } - private boolean jj_3R_TriplesNode_1301_4_137() + private boolean jj_3R_TriplesNode_1317_4_137() { Token xsp; xsp = jj_scanpos; - if (jj_3R_TriplesNode_1301_4_169()) { + if (jj_3R_TriplesNode_1317_4_169()) { jj_scanpos = xsp; - if (jj_3R_TriplesNode_1303_4_170()) return true; + if (jj_3R_TriplesNode_1319_4_170()) return true; } return false; } - private boolean jj_3R_TriplesNode_1301_4_169() + private boolean jj_3R_TriplesNode_1317_4_169() { - if (jj_3R_Collection_1331_3_181()) return true; + if (jj_3R_Collection_1347_3_181()) return true; return false; } - private boolean jj_3R_Prologue_106_33_135() + private boolean jj_3R_Prologue_122_33_135() { - if (jj_3R_VersionDecl_121_5_160()) return true; + if (jj_3R_VersionDecl_137_5_160()) return true; return false; } - private boolean jj_3R_Aggregate_2045_5_155() + private boolean jj_3R_Aggregate_2061_5_155() { if (jj_scan_token(AGG)) return true; - if (jj_3R_iri_2143_3_172()) return true; + if (jj_3R_iri_2159_3_172()) return true; return false; } - private boolean jj_3R_VersionSpecifier_127_7_186() + private boolean jj_3R_VersionSpecifier_143_7_186() { if (jj_scan_token(STRING_LITERAL2)) return true; return false; } - private boolean jj_3R_VersionSpecifier_126_7_185() + private boolean jj_3R_VersionSpecifier_142_7_185() { if (jj_scan_token(STRING_LITERAL1)) return true; return false; } - private boolean jj_3R_VersionSpecifier_126_5_174() + private boolean jj_3R_VersionSpecifier_142_5_174() { Token xsp; xsp = jj_scanpos; - if (jj_3R_VersionSpecifier_126_7_185()) { + if (jj_3R_VersionSpecifier_142_7_185()) { jj_scanpos = xsp; - if (jj_3R_VersionSpecifier_127_7_186()) return true; + if (jj_3R_VersionSpecifier_143_7_186()) return true; } return false; } - private boolean jj_3R_VersionDecl_121_5_160() + private boolean jj_3R_VersionDecl_137_5_160() { if (jj_scan_token(VERSION)) return true; - if (jj_3R_VersionSpecifier_126_5_174()) return true; + if (jj_3R_VersionSpecifier_142_5_174()) return true; return false; } - private boolean jj_3R_Prologue_106_18_134() + private boolean jj_3R_Prologue_122_18_134() { - if (jj_3R_PrefixDecl_115_5_159()) return true; + if (jj_3R_PrefixDecl_131_5_159()) return true; return false; } - private boolean jj_3R_PrefixDecl_115_5_159() + private boolean jj_3R_PrefixDecl_131_5_159() { if (jj_scan_token(PREFIX)) return true; if (jj_scan_token(PNAME_NS)) return true; - if (jj_3R_IRIREF_2168_3_173()) return true; + if (jj_3R_IRIREF_2184_3_173()) return true; return false; } - private boolean jj_3R_Aggregate_2024_5_154() + private boolean jj_3R_Aggregate_2040_5_154() { if (jj_scan_token(FOLD)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BaseDecl_110_3_158() + private boolean jj_3R_BaseDecl_126_3_158() { if (jj_scan_token(BASE)) return true; - if (jj_3R_IRIREF_2168_3_173()) return true; + if (jj_3R_IRIREF_2184_3_173()) return true; return false; } - private boolean jj_3R_Aggregate_2022_5_153() + private boolean jj_3R_Aggregate_2038_5_153() { if (jj_scan_token(VAR_POP)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_Prologue_106_5_120() + private boolean jj_3R_Prologue_122_5_120() { Token xsp; xsp = jj_scanpos; - if (jj_3R_Prologue_106_5_133()) { + if (jj_3R_Prologue_122_5_133()) { jj_scanpos = xsp; - if (jj_3R_Prologue_106_18_134()) { + if (jj_3R_Prologue_122_18_134()) { jj_scanpos = xsp; - if (jj_3R_Prologue_106_33_135()) return true; + if (jj_3R_Prologue_122_33_135()) return true; } } return false; } - private boolean jj_3R_Prologue_106_5_133() + private boolean jj_3R_Prologue_122_5_133() { - if (jj_3R_BaseDecl_110_3_158()) return true; + if (jj_3R_BaseDecl_126_3_158()) return true; return false; } - private boolean jj_3R_Aggregate_2020_5_152() + private boolean jj_3R_Aggregate_2036_5_152() { if (jj_scan_token(VAR_SAMP)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_Prologue_106_3_47() + private boolean jj_3R_Prologue_122_3_47() { Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_Prologue_106_5_120()) { jj_scanpos = xsp; break; } + if (jj_3R_Prologue_122_5_120()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_Aggregate_2018_5_151() + private boolean jj_3R_Aggregate_2034_5_151() { if (jj_scan_token(VARIANCE)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_Aggregate_2016_5_150() + private boolean jj_3R_Aggregate_2032_5_150() { if (jj_scan_token(STDEV_POP)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_Aggregate_2014_5_149() + private boolean jj_3R_Aggregate_2030_5_149() { if (jj_scan_token(STDEV_SAMP)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_Aggregate_2012_5_148() + private boolean jj_3R_Aggregate_2028_5_148() { if (jj_scan_token(STDEV)) return true; if (jj_scan_token(LPAREN)) return true; @@ -9065,63 +9018,63 @@ private boolean jj_3_5() return false; } - private boolean jj_3R_Aggregate_1998_5_147() + private boolean jj_3R_Aggregate_2014_5_147() { if (jj_scan_token(GROUP_CONCAT)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_Aggregate_1996_5_146() + private boolean jj_3R_Aggregate_2012_5_146() { if (jj_scan_token(SAMPLE)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_Aggregate_1994_5_145() + private boolean jj_3R_Aggregate_2010_5_145() { if (jj_scan_token(MODE)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_Aggregate_1992_5_144() + private boolean jj_3R_Aggregate_2008_5_144() { if (jj_scan_token(MEDIAN)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_Aggregate_1990_5_143() + private boolean jj_3R_Aggregate_2006_5_143() { if (jj_scan_token(AVG)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_Aggregate_1988_5_142() + private boolean jj_3R_Aggregate_2004_5_142() { if (jj_scan_token(MAX)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_Aggregate_1986_5_141() + private boolean jj_3R_Aggregate_2002_5_141() { if (jj_scan_token(MIN)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_Aggregate_1984_5_140() + private boolean jj_3R_Aggregate_2000_5_140() { if (jj_scan_token(SUM)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_Var_1598_5_175() + private boolean jj_3R_Var_1614_5_175() { Token xsp; xsp = jj_scanpos; @@ -9132,50 +9085,50 @@ private boolean jj_3R_Var_1598_5_175() return false; } - private boolean jj_3R_Aggregate_1977_5_139() + private boolean jj_3R_Aggregate_1993_5_139() { if (jj_scan_token(COUNT)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_Aggregate_1976_3_124() + private boolean jj_3R_Aggregate_1992_3_124() { Token xsp; xsp = jj_scanpos; - if (jj_3R_Aggregate_1977_5_139()) { + if (jj_3R_Aggregate_1993_5_139()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_1984_5_140()) { + if (jj_3R_Aggregate_2000_5_140()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_1986_5_141()) { + if (jj_3R_Aggregate_2002_5_141()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_1988_5_142()) { + if (jj_3R_Aggregate_2004_5_142()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_1990_5_143()) { + if (jj_3R_Aggregate_2006_5_143()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_1992_5_144()) { + if (jj_3R_Aggregate_2008_5_144()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_1994_5_145()) { + if (jj_3R_Aggregate_2010_5_145()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_1996_5_146()) { + if (jj_3R_Aggregate_2012_5_146()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_1998_5_147()) { + if (jj_3R_Aggregate_2014_5_147()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_2012_5_148()) { + if (jj_3R_Aggregate_2028_5_148()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_2014_5_149()) { + if (jj_3R_Aggregate_2030_5_149()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_2016_5_150()) { + if (jj_3R_Aggregate_2032_5_150()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_2018_5_151()) { + if (jj_3R_Aggregate_2034_5_151()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_2020_5_152()) { + if (jj_3R_Aggregate_2036_5_152()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_2022_5_153()) { + if (jj_3R_Aggregate_2038_5_153()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_2024_5_154()) { + if (jj_3R_Aggregate_2040_5_154()) { jj_scanpos = xsp; - if (jj_3R_Aggregate_2045_5_155()) return true; + if (jj_3R_Aggregate_2061_5_155()) return true; } } } @@ -9198,7 +9151,7 @@ private boolean jj_3R_Aggregate_1976_3_124() private boolean jj_3_2() { if (jj_scan_token(SEMICOLON)) return true; - if (jj_3R_Prologue_106_3_47()) return true; + if (jj_3R_Prologue_122_3_47()) return true; Token xsp; xsp = jj_scanpos; if (jj_scan_token(157)) { @@ -9244,65 +9197,124 @@ private boolean jj_3_2() return false; } - private boolean jj_3R_NotExistsFunc_1964_4_132() + private boolean jj_3R_NotExistsFunc_1980_4_132() { if (jj_scan_token(NOT)) return true; if (jj_scan_token(EXISTS)) return true; return false; } - private boolean jj_3R_ExistsFunc_1958_4_131() + private boolean jj_3R_ExistsFunc_1974_4_131() { if (jj_scan_token(EXISTS)) return true; - if (jj_3R_GroupGraphPattern_661_3_157()) return true; + if (jj_3R_GroupGraphPattern_677_3_157()) return true; return false; } - private boolean jj_3R_StrReplaceExpression_1947_3_129() + private boolean jj_3R_StrReplaceExpression_1963_3_129() { if (jj_scan_token(REPLACE)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_SubstringExpression_1935_5_128() + private boolean jj_3R_SubstringExpression_1951_5_128() { if (jj_scan_token(SUBSTR)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_RegexExpression_1923_5_130() + private boolean jj_3R_RegexExpression_1939_5_130() { if (jj_scan_token(REGEX)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1917_5_119() + private boolean jj_3R_BuiltInCall_1933_5_119() { if (jj_scan_token(OBJECT)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1915_5_118() + private boolean jj_3R_BuiltInCall_1931_5_118() { if (jj_scan_token(PREDICATE)) return true; if (jj_scan_token(LPAREN)) return true; return false; } - private boolean jj_3R_BuiltInCall_1913_5_117() + private boolean jj_3R_BuiltInCall_1929_5_117() { if (jj_scan_token(SUBJECT)) return true; if (jj_scan_token(LPAREN)) return true; return false; } + private boolean jj_3R_BuiltInCall_1925_5_116() + { + if (jj_scan_token(TRIPLE)) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + private boolean jj_3R_BuiltInCall_1923_5_115() + { + if (jj_scan_token(IS_TRIPLE)) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + private boolean jj_3R_BuiltInCall_1922_5_114() + { + if (jj_3R_NotExistsFunc_1980_4_132()) return true; + return false; + } + + private boolean jj_3R_BuiltInCall_1921_5_113() + { + if (jj_3R_ExistsFunc_1974_4_131()) return true; + return false; + } + + private boolean jj_3R_BuiltInCall_1920_5_112() + { + if (jj_3R_RegexExpression_1939_5_130()) return true; + return false; + } + + private boolean jj_3R_BuiltInCall_1917_5_111() + { + if (jj_scan_token(HAS_LANGDIR)) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + private boolean jj_3R_BuiltInCall_1915_5_110() + { + if (jj_scan_token(HAS_LANG)) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + private boolean jj_3R_BuiltInCall_1913_5_109() + { + if (jj_scan_token(IS_NUMERIC)) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + + private boolean jj_3R_BuiltInCall_1911_5_108() + { + if (jj_scan_token(IS_LITERAL)) return true; + if (jj_scan_token(LPAREN)) return true; + return false; + } + /** Generated Token Manager. */ public ARQParserTokenManager token_source; - SimpleCharStream jj_input_stream; /** Current token. */ public Token token; /** Next token. */ @@ -9358,14 +9370,9 @@ private static void jj_la1_init_7() { private boolean jj_rescan = false; private int jj_gc = 0; - /** Constructor with InputStream. */ - public ARQParser(java.io.InputStream stream) { - this(stream, null); - } - /** Constructor with InputStream and supplied encoding */ - public ARQParser(java.io.InputStream stream, String encoding) { - try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } - token_source = new ARQParserTokenManager(jj_input_stream); + /** Constructor with user supplied CharStream. */ + public ARQParser(CharStream stream) { + token_source = new ARQParserTokenManager(stream); token = new Token(); jj_ntk = -1; jj_gen = 0; @@ -9374,43 +9381,8 @@ public ARQParser(java.io.InputStream stream, String encoding) { } /** Reinitialise. */ - public void ReInit(java.io.InputStream stream) { - ReInit(stream, null); - } - /** Reinitialise. */ - public void ReInit(java.io.InputStream stream, String encoding) { - try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } - token_source.ReInit(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 213; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); - } - - /** Constructor. */ - public ARQParser(java.io.Reader stream) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new ARQParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 213; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader stream) { - if (jj_input_stream == null) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - } else { - jj_input_stream.ReInit(stream, 1, 1); - } - if (token_source == null) { - token_source = new ARQParserTokenManager(jj_input_stream); - } - - token_source.ReInit(jj_input_stream); + public void ReInit(CharStream stream) { + token_source.ReInit(stream); token = new Token(); jj_ntk = -1; jj_gen = 0; @@ -9676,4 +9648,4 @@ static final class JJCalls { JJCalls next; } - } +} diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/ARQParserTokenManager.java b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/ARQParserTokenManager.java index 8fcc5cd3f93..6f5daa11612 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/ARQParserTokenManager.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/ARQParserTokenManager.java @@ -34,6 +34,7 @@ import org.apache.jena.sparql.core.Quad ; import java.util.List; import java.util.ArrayList; +import org.apache.jena.sparql.lang.arq.ARQCharStream ; /** Token Manager. */ @SuppressWarnings ("unused") @@ -5057,23 +5058,21 @@ private void jjCheckNAddStates(int start, int end) } /** Constructor. */ - public ARQParserTokenManager(SimpleCharStream stream){ + public ARQParserTokenManager(CharStream stream){ - if (SimpleCharStream.staticFlag) - throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); input_stream = stream; } /** Constructor. */ - public ARQParserTokenManager (SimpleCharStream stream, int lexState){ + public ARQParserTokenManager (CharStream stream, int lexState){ ReInit(stream); SwitchTo(lexState); } /** Reinitialise parser. */ - public void ReInit(SimpleCharStream stream) + public void ReInit(CharStream stream) { @@ -5094,7 +5093,7 @@ private void ReInitRounds() } /** Reinitialise parser. */ - public void ReInit(SimpleCharStream stream, int lexState) + public void ReInit(CharStream stream, int lexState) { ReInit(stream); @@ -5141,7 +5140,7 @@ public void SwitchTo(int lexState) static final long[] jjtoMore = { 0x0L, 0x0L, 0x0L, 0x0L, }; - protected SimpleCharStream input_stream; + protected CharStream input_stream; private final int[] jjrounds = new int[296]; private final int[] jjstateSet = new int[2 * 296]; diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/CharStream.java b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/CharStream.java new file mode 100644 index 00000000000..88e3070e936 --- /dev/null +++ b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/CharStream.java @@ -0,0 +1,140 @@ +/* Generated By:JavaCC: Do not edit this line. CharStream.java Version 7.0 */ +/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.apache.jena.sparql.lang.arq.javacc ; + +/** + * This interface describes a character stream that maintains line and + * column number positions of the characters. It also has the capability + * to backup the stream to some extent. An implementation of this + * interface is used in the TokenManager implementation generated by + * JavaCCParser. + * + * All the methods except backup can be implemented in any fashion. backup + * needs to be implemented correctly for the correct operation of the lexer. + * Rest of the methods are all used to get information like line number, + * column number and the String that constitutes a token and are not used + * by the lexer. Hence their implementation won't affect the generated lexer's + * operation. + */ + +public +interface CharStream { + + /** + * Returns the next character from the selected input. The method + * of selecting the input is the responsibility of the class + * implementing this interface. Can throw any java.io.IOException. + */ + char readChar() throws java.io.IOException; + + /** + * Returns the column position of the character last read. + * @deprecated + * @see #getEndColumn + */ + @Deprecated + int getColumn(); + + /** + * Returns the line number of the character last read. + * @deprecated + * @see #getEndLine + */ + @Deprecated + int getLine(); + + /** + * Returns the column number of the last character for current token (being + * matched after the last call to BeginTOken). + */ + int getEndColumn(); + + /** + * Returns the line number of the last character for current token (being + * matched after the last call to BeginTOken). + */ + int getEndLine(); + + /** + * Returns the column number of the first character for current token (being + * matched after the last call to BeginTOken). + */ + int getBeginColumn(); + + /** + * Returns the line number of the first character for current token (being + * matched after the last call to BeginTOken). + */ + int getBeginLine(); + + /** + * Backs up the input stream by amount steps. Lexer calls this method if it + * had already read some characters, but could not use them to match a + * (longer) token. So, they will be used again as the prefix of the next + * token and it is the implementation's responsibility to do this right. + */ + void backup(int amount); + + /** + * Returns the next character that marks the beginning of the next token. + * All characters must remain in the buffer between two successive calls + * to this method to implement backup correctly. + */ + char BeginToken() throws java.io.IOException; + + /** + * Returns a string made up of characters from the marked token beginning + * to the current buffer position. Implementations have the choice of returning + * anything that they want to. For example, for efficiency, one might decide + * to just return null, which is a valid implementation. + */ + String GetImage(); + + /** + * Returns an array of characters that make up the suffix of length 'len' for + * the currently matched token. This is used to build up the matched string + * for use in actions in the case of MORE. A simple and inefficient + * implementation of this is as follows : + * + * { + * String t = GetImage(); + * return t.substring(t.length() - len, t.length()).toCharArray(); + * } + */ + char[] GetSuffix(int len); + + /** + * The lexer calls this function to indicate that it is done with the stream + * and hence implementations can free any resources held by this class. + * Again, the body of this function can be just empty and it will not + * affect the lexer's operation. + */ + void Done(); + + + void setTabSize(int i); + int getTabSize(); + boolean getTrackLineColumn(); + void setTrackLineColumn(boolean trackLineColumn); +} +/* JavaCC - OriginalChecksum=2e47f2ea31a1dae631142dbc38dc0a48 (do not edit this line) */ diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/SimpleCharStream.java b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/SimpleCharStream.java deleted file mode 100644 index 9d5c53d3e85..00000000000 --- a/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/javacc/SimpleCharStream.java +++ /dev/null @@ -1,492 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 7.0 */ -/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.apache.jena.sparql.lang.arq.javacc ; - -/** - * An implementation of interface CharStream, where the stream is assumed to - * contain only ASCII characters (without unicode processing). - */ - -public class SimpleCharStream -{ -/** Whether parser is static. */ - public static final boolean staticFlag = false; - int bufsize; - int available; - int tokenBegin; -/** Position in buffer. */ - public int bufpos = -1; - protected int bufline[]; - protected int bufcolumn[]; - - protected int column = 0; - protected int line = 1; - - protected boolean prevCharIsCR = false; - protected boolean prevCharIsLF = false; - - protected java.io.Reader inputStream; - - protected char[] buffer; - protected int maxNextCharInd = 0; - protected int inBuf = 0; - protected int tabSize = 1; - protected boolean trackLineColumn = true; - - public void setTabSize(int i) { tabSize = i; } - public int getTabSize() { return tabSize; } - - - - protected void ExpandBuff(boolean wrapAround) - { - char[] newbuffer = new char[bufsize + 2048]; - int newbufline[] = new int[bufsize + 2048]; - int newbufcolumn[] = new int[bufsize + 2048]; - - try - { - if (wrapAround) - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos += (bufsize - tokenBegin)); - } - else - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos -= tokenBegin); - } - } - catch (Throwable t) - { - throw new Error(t.getMessage()); - } - - - bufsize += 2048; - available = bufsize; - tokenBegin = 0; - } - - protected void FillBuff() throws java.io.IOException - { - if (maxNextCharInd == available) - { - if (available == bufsize) - { - if (tokenBegin > 2048) - { - bufpos = maxNextCharInd = 0; - available = tokenBegin; - } - else if (tokenBegin < 0) - bufpos = maxNextCharInd = 0; - else - ExpandBuff(false); - } - else if (available > tokenBegin) - available = bufsize; - else if ((tokenBegin - available) < 2048) - ExpandBuff(true); - else - available = tokenBegin; - } - - int i; - try { - if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) - { - inputStream.close(); - throw new java.io.IOException(); - } - else - maxNextCharInd += i; - return; - } - catch(java.io.IOException e) { - --bufpos; - backup(0); - if (tokenBegin == -1) - tokenBegin = bufpos; - throw e; - } - } - -/** Start. */ - public char BeginToken() throws java.io.IOException - { - tokenBegin = -1; - char c = readChar(); - tokenBegin = bufpos; - - return c; - } - - protected void UpdateLineColumn(char c) - { - column++; - - if (prevCharIsLF) - { - prevCharIsLF = false; - line += (column = 1); - } - else if (prevCharIsCR) - { - prevCharIsCR = false; - if (c == '\n') - { - prevCharIsLF = true; - } - else - line += (column = 1); - } - - switch (c) - { - case '\r' : - prevCharIsCR = true; - break; - case '\n' : - prevCharIsLF = true; - break; - case '\t' : - column--; - column += (tabSize - (column % tabSize)); - break; - default : - break; - } - - bufline[bufpos] = line; - bufcolumn[bufpos] = column; - } - -/** Read a character. */ - public char readChar() throws java.io.IOException - { - if (inBuf > 0) - { - --inBuf; - - if (++bufpos == bufsize) - bufpos = 0; - - return buffer[bufpos]; - } - - if (++bufpos >= maxNextCharInd) - FillBuff(); - - char c = buffer[bufpos]; - - UpdateLineColumn(c); - return c; - } - - /** - * @deprecated - * @see #getEndColumn - */ - @Deprecated - public int getColumn() { - return bufcolumn[bufpos]; - } - - /** - * @deprecated - * @see #getEndLine - */ - @Deprecated - public int getLine() { - return bufline[bufpos]; - } - - /** Get token end column number. */ - public int getEndColumn() { - return bufcolumn[bufpos]; - } - - /** Get token end line number. */ - public int getEndLine() { - return bufline[bufpos]; - } - - /** Get token beginning column number. */ - public int getBeginColumn() { - return bufcolumn[tokenBegin]; - } - - /** Get token beginning line number. */ - public int getBeginLine() { - return bufline[tokenBegin]; - } - -/** Backup a number of characters. */ - public void backup(int amount) { - - inBuf += amount; - if ((bufpos -= amount) < 0) - bufpos += bufsize; - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream) - { - this(dstream, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - if (buffer == null || buffersize != buffer.length) - { - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - prevCharIsLF = prevCharIsCR = false; - tokenBegin = inBuf = maxNextCharInd = 0; - bufpos = -1; - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn) - { - ReInit(dstream, startline, startcolumn, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream) - { - ReInit(dstream, 1, 1, 4096); - } - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException - { - this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) - { - this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException - { - this(dstream, encoding, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException - { - this(dstream, encoding, 1, 1, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream) - { - this(dstream, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException - { - ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) - { - ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException - { - ReInit(dstream, encoding, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream) - { - ReInit(dstream, 1, 1, 4096); - } - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException - { - ReInit(dstream, encoding, startline, startcolumn, 4096); - } - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn) - { - ReInit(dstream, startline, startcolumn, 4096); - } - /** Get token literal value. */ - public String GetImage() - { - if (bufpos >= tokenBegin) - return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); - else - return new String(buffer, tokenBegin, bufsize - tokenBegin) + - new String(buffer, 0, bufpos + 1); - } - - /** Get the suffix. */ - public char[] GetSuffix(int len) - { - char[] ret = new char[len]; - - if ((bufpos + 1) >= len) - System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); - else - { - System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, - len - bufpos - 1); - System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); - } - - return ret; - } - - /** Reset buffer when finished. */ - public void Done() - { - buffer = null; - bufline = null; - bufcolumn = null; - } - - /** - * Method to adjust line and column numbers for the start of a token. - */ - public void adjustBeginLineColumn(int newLine, int newCol) - { - int start = tokenBegin; - int len; - - if (bufpos >= tokenBegin) - { - len = bufpos - tokenBegin + inBuf + 1; - } - else - { - len = bufsize - tokenBegin + bufpos + 1 + inBuf; - } - - int i = 0, j = 0, k = 0; - int nextColDiff = 0, columnDiff = 0; - - while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) - { - bufline[j] = newLine; - nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; - bufcolumn[j] = newCol + columnDiff; - columnDiff = nextColDiff; - i++; - } - - if (i < len) - { - bufline[j] = newLine++; - bufcolumn[j] = newCol + columnDiff; - - while (i++ < len) - { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) - bufline[j] = newLine++; - else - bufline[j] = newLine; - } - } - - line = bufline[j]; - column = bufcolumn[j]; - } - boolean getTrackLineColumn() { return trackLineColumn; } - void setTrackLineColumn(boolean tlc) { trackLineColumn = tlc; } -} -/* JavaCC - OriginalChecksum=634b64954287d690165240ef69bf7568 (do not edit this line) */ From 316f19f7f6ced1973a7aabc466c9027fab13a828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Gjesdal?= Date: Tue, 17 Nov 2026 21:47:35 +0100 Subject: [PATCH 3/3] GH-1324: JMH benchmark for parsing a query with a large literal TestParseLargeLiteral parses a query with one literal of 1, 2, 10, 100 and 250MB with the ARQ parser. The literal is WKT polygon coordinates: in the issue, a SERVICE request with a geometry literal of about 100MB stalled in the parser. The same queries are parsed with Jena 5.6.0 up to 100MB. Its SimpleCharStream grows the buffer by 2048 chars at a time, so the parse time grows with the square of the literal's length: one parse of 100MB takes about a quarter of an hour. Jena 5.6.0 runs separately, with fewer iterations and a 30 minute timeout per iteration. With the buffer doubling, the time grows linearly. Co-Authored-By: Claude Opus 5.5 --- .../sparql/lang/TestParseLargeLiteral.java | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 jena-benchmarks/jena-benchmarks-jmh/src/test/java/org/apache/jena/sparql/lang/TestParseLargeLiteral.java diff --git a/jena-benchmarks/jena-benchmarks-jmh/src/test/java/org/apache/jena/sparql/lang/TestParseLargeLiteral.java b/jena-benchmarks/jena-benchmarks-jmh/src/test/java/org/apache/jena/sparql/lang/TestParseLargeLiteral.java new file mode 100644 index 00000000000..45a95a3b688 --- /dev/null +++ b/jena-benchmarks/jena-benchmarks-jmh/src/test/java/org/apache/jena/sparql/lang/TestParseLargeLiteral.java @@ -0,0 +1,133 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.apache.jena.sparql.lang; + +import java.util.concurrent.TimeUnit; + +import org.apache.jena.jmh.JmhDefaultOptions; +import org.apache.jena.query.Query; +import org.apache.jena.query.QueryFactory; +import org.apache.jena.query.Syntax; +import org.apache.jena.sys.JenaSystem; + +import org.junit.Assert; +import org.junit.Test; + +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.options.TimeValue; + +/** + * Parse a query with one large literal, as in GH-1324: a SERVICE request with a + * geometry literal of about 100MB stalled in the parser. The ARQ parser reads with + * ARQCharStream, which doubles its buffer. + *

+ * The javacc-generated SimpleCharStream of Jena 5.6.0 grows its buffer by 2048 chars + * at a time, so the time to read a token grows with the square of its length. It is + * run up to 100MB, in a separate run with fewer iterations and a longer timeout: one + * parse of 100MB takes about a quarter of an hour. + */ +public class TestParseLargeLiteral { + + static { + JenaSystem.init(); + org.apache.shadedJena560.sys.JenaSystem.init(); + } + + private static final int MB = 1024 * 1024; + + @State(Scope.Benchmark) + public static class QueryCurrent { + @Param({"1", "2", "10", "100", "250"}) + public int param0_literalSizeMB; + + String queryString; + + @Setup(Level.Trial) + public void setup() { + queryString = queryWithLiteral(param0_literalSizeMB * MB); + } + } + + @State(Scope.Benchmark) + public static class QueryJena560 { + @Param({"1", "2", "10", "100"}) + public int param0_literalSizeMBJena560; + + String queryString; + + @Setup(Level.Trial) + public void setup() { + queryString = queryWithLiteral(param0_literalSizeMBJena560 * MB); + } + } + + /** + * A query with a literal of {@code literalLength} chars, made of WKT polygon + * coordinates. + */ + static String queryWithLiteral(int literalLength) { + StringBuilder sb = new StringBuilder(literalLength + 32); + sb.append("SELECT * { ?s ?p \""); + int start = sb.length(); + sb.append("POLYGON(("); + while ( sb.length() - start < literalLength ) + sb.append("10.123456 59.123456, "); + sb.setLength(start + literalLength - 2); + sb.append("))"); + sb.append("\" }"); + return sb.toString(); + } + + @Benchmark + public Query parseQuery(QueryCurrent state) { + return QueryFactory.create(state.queryString, Syntax.syntaxARQ); + } + + @Benchmark + public org.apache.shadedJena560.query.Query parseQueryJena560(QueryJena560 state) { + return org.apache.shadedJena560.query.QueryFactory.create(state.queryString, + org.apache.shadedJena560.query.Syntax.syntaxARQ); + } + + @Test + public void benchmark() throws Exception { + var opt = JmhDefaultOptions.getDefaults(this.getClass()) + .exclude("\\.parseQueryJena560$") + .timeUnit(TimeUnit.MILLISECONDS) + .warmupIterations(2) + .measurementIterations(4) + .build(); + var results = new Runner(opt).run(); + Assert.assertNotNull(results); + + var optJena560 = JmhDefaultOptions.getDefaults(this.getClass()) + .exclude("\\.parseQuery$") + .timeUnit(TimeUnit.MILLISECONDS) + .warmupIterations(1) + .measurementIterations(2) + .timeout(TimeValue.minutes(30)) + .build(); + var resultsJena560 = new Runner(optJena560).run(); + Assert.assertNotNull(resultsJena560); + } +}