This is an automated email from the ASF dual-hosted git repository. andy pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/jena.git
commit 022c21497dba7100cd9567b20dfb904464b9e804 Author: Andy Seaborne <[email protected]> AuthorDate: Sat Jan 24 15:02:43 2026 +0000 Make argument order of emitTriple consistent --- jena-arq/Grammar/Turtle/turtle.jj | 8 +- .../org/apache/jena/riot/lang/LangParserBase.java | 13 +- .../lang/turtlejcc/LangTurtleJCCParserBase.java | 8 +- .../riot/lang/turtlejcc/javacc/TurtleJavacc.java | 8 +- .../jena/ttl_test/turtle/TurtleParserBase.java | 401 +++++++++++---------- .../ttl_test/turtle/javacc/JavaCharStream.java | 17 +- .../ttl_test/turtle/javacc/ParseException.java | 17 +- .../apache/jena/ttl_test/turtle/javacc/Token.java | 17 +- .../jena/ttl_test/turtle/javacc/TokenMgrError.java | 17 +- .../jena/ttl_test/turtle/javacc/TurtleParser.java | 29 +- .../turtle/javacc/TurtleParserConstants.java | 15 +- .../turtle/javacc/TurtleParserTokenManager.java | 15 +- jena-core/testing/ttl_test/turtle-test.jj | 44 +-- 13 files changed, 316 insertions(+), 293 deletions(-) diff --git a/jena-arq/Grammar/Turtle/turtle.jj b/jena-arq/Grammar/Turtle/turtle.jj index 2a7945fb1c..c84622c0dd 100644 --- a/jena-arq/Grammar/Turtle/turtle.jj +++ b/jena-arq/Grammar/Turtle/turtle.jj @@ -151,11 +151,11 @@ void PredicateObjectList(Node s) : { Node p = null ; } void ObjectList(Node s, Node p): { Node o ; } { o = Object() - { emitTriple(token.beginLine, token.beginColumn, s, p, o) ; } + { emitTriple(s, p, o, token.beginLine, token.beginColumn) ; } Annotation(s, p, o) ( <COMMA> o = Object() - { emitTriple(token.beginLine, token.beginColumn, s, p, o) ; } + { emitTriple(s, p, o, token.beginLine, token.beginColumn) ; } Annotation(s, p, o) )* } @@ -365,7 +365,7 @@ Node ReifiedTriple() : { Node reifId = null ; Token tok ; Node s; Node p ; Node p = Verb() o = ReifiedTripleObject() ( reifId = Reifier())? - { reifId = emitTripleReifier(tok.beginLine, tok.beginColumn, reifId, s, p, o); } + { reifId = emitTripleReifier(reifId, s, p, o, tok.beginLine, tok.beginColumn); } <GT2> { return reifId ; } } @@ -425,7 +425,7 @@ void Annotation(Node s, Node p, Node o) : { Node reifId = null; } { ( reifId = Reifier() - { reifId = emitTripleReifier(token.beginLine, token.beginColumn, reifId, s, p, o) ; } + { reifId = emitTripleReifier(reifId, s, p, o, token.beginLine, token.beginColumn) ; } { setReifierId(reifId); } | { reifId = getOrAllocReifierId(s, p, o, token.beginLine, token.beginColumn); } diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangParserBase.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangParserBase.java index e57613ef28..a732bc4598 100644 --- a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangParserBase.java +++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangParserBase.java @@ -58,7 +58,7 @@ public class LangParserBase { protected final Node nRDFpredicate = RDF.Nodes.predicate ; protected final Node nRDFobject = RDF.Nodes.object ; - protected final Node nRDFreifies = RDF.Nodes.reifies; + protected final Node nRDFreifies = RDF.Nodes.reifies; protected StreamRDF stream; protected ParserProfile profile; @@ -206,11 +206,22 @@ public class LangParserBase { stream.version(version); } + @Deprecated(forRemoval = true) protected void emitTriple(int line, int column, Node s, Node p, Node o) { + emitTriple(s, p, o, line, column); + } + + protected void emitTriple(Node s, Node p, Node o, int line, int column) { stream.triple(Triple.create(s, p, o)); } + + @Deprecated(forRemoval = true) protected Node emitTripleReifier(int line, int column, Node reifierId, Node s, Node p, Node o) { + return emitTripleReifier(reifierId, s, p, o, line, column); + } + + protected Node emitTripleReifier(Node reifierId, Node s, Node p, Node o, int line, int column) { Node tripleTerm = createTripleTerm(s, p, o, line, column); if ( reifierId == null ) reifierId = createBNode(line, column); diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/turtlejcc/LangTurtleJCCParserBase.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/turtlejcc/LangTurtleJCCParserBase.java index 07a76288c9..3c5f7a3864 100644 --- a/jena-arq/src/main/java/org/apache/jena/riot/lang/turtlejcc/LangTurtleJCCParserBase.java +++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/turtlejcc/LangTurtleJCCParserBase.java @@ -230,11 +230,11 @@ public class LangTurtleJCCParserBase { output.version(version); } - protected void emitTriple(int line, int column, Node s, Node p, Node o) { + protected void emitTriple(Node s, Node p, Node o, int line, int column) { output.triple(Triple.create(s, p, o)); } - protected Node emitTripleReifier(int line, int column, Node reifierId, Node s, Node p, Node o) { + protected Node emitTripleReifier(Node reifierId, Node s, Node p, Node o, int line, int column) { Node tripleTerm = createTripleTerm(s, p, o, line, column); if ( reifierId == null ) reifierId = createBNode(line, column); @@ -253,7 +253,7 @@ public class LangTurtleJCCParserBase { if ( annotationReifierId != null ) return annotationReifierId; Node reifierId = createBNode(line, column); - emitTripleReifier(line, column, reifierId, s, p, o); + emitTripleReifier(reifierId, s, p, o, line, column); return reifierId; } @@ -270,6 +270,6 @@ public class LangTurtleJCCParserBase { } protected void listStart(int line, int column) {}; - protected void listTriple(int line, int column, Node s, Node p , Node o) { emitTriple(line, column, s, p, o); } + protected void listTriple(int line, int column, Node s, Node p , Node o) { emitTriple(s, p, o, line, column); } protected void listFinish(int line, int column) {}; } diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/turtlejcc/javacc/TurtleJavacc.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/turtlejcc/javacc/TurtleJavacc.java index 891328b2e8..f735481ef4 100644 --- a/jena-arq/src/main/java/org/apache/jena/riot/lang/turtlejcc/javacc/TurtleJavacc.java +++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/turtlejcc/javacc/TurtleJavacc.java @@ -275,7 +275,7 @@ declareVersion(verStr, t.beginLine, t.beginColumn); final public void ObjectList(Node s, Node p) throws ParseException {Node o ; o = Object(); -emitTriple(token.beginLine, token.beginColumn, s, p, o) ; +emitTriple(s, p, o, token.beginLine, token.beginColumn) ; Annotation(s, p, o); label_3: while (true) { @@ -290,7 +290,7 @@ emitTriple(token.beginLine, token.beginColumn, s, p, o) ; } jj_consume_token(COMMA); o = Object(); -emitTriple(token.beginLine, token.beginColumn, s, p, o) ; +emitTriple(s, p, o, token.beginLine, token.beginColumn) ; Annotation(s, p, o); } } @@ -786,7 +786,7 @@ if ( n == null ) n = createBNode(t.beginLine, t.beginColumn) ; jj_la1[29] = jj_gen; ; } -reifId = emitTripleReifier(tok.beginLine, tok.beginColumn, reifId, s, p, o); +reifId = emitTripleReifier(reifId, s, p, o, tok.beginLine, tok.beginColumn); jj_consume_token(GT2); {if ("" != null) return reifId ;} throw new Error("Missing return statement in function"); @@ -955,7 +955,7 @@ o = createURI(iri, token.beginLine, token.beginColumn) ; switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case TILDE:{ reifId = Reifier(); -reifId = emitTripleReifier(token.beginLine, token.beginColumn, reifId, s, p, o) ; +reifId = emitTripleReifier(reifId, s, p, o, token.beginLine, token.beginColumn) ; setReifierId(reifId); break; } diff --git a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/TurtleParserBase.java b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/TurtleParserBase.java index 4ef7219920..53a477b76b 100644 --- a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/TurtleParserBase.java +++ b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/TurtleParserBase.java @@ -34,27 +34,26 @@ import org.apache.jena.shared.PrefixMapping; import org.apache.jena.shared.impl.PrefixMappingImpl; import org.apache.jena.vocabulary.RDF; -public class TurtleParserBase -{ +public class TurtleParserBase { // Should be the same as ARQ ParserBase and Prologues. - protected final Node XSD_TRUE = NodeFactory.createLiteral("true", null, XSDDatatype.XSDboolean); - protected final Node XSD_FALSE = NodeFactory.createLiteral("false", null, XSDDatatype.XSDboolean); + protected final Node XSD_TRUE = NodeFactory.createLiteral("true", null, XSDDatatype.XSDboolean); + protected final Node XSD_FALSE = NodeFactory.createLiteral("false", null, XSDDatatype.XSDboolean); - protected final Node nRDFtype = RDF.type.asNode(); + protected final Node nRDFtype = RDF.type.asNode(); - protected final Node nRDFnil = RDF.nil.asNode(); - protected final Node nRDFfirst = RDF.first.asNode(); - protected final Node nRDFrest = RDF.rest.asNode(); + protected final Node nRDFnil = RDF.nil.asNode(); + protected final Node nRDFfirst = RDF.first.asNode(); + protected final Node nRDFrest = RDF.rest.asNode(); - protected final Node nRDFsubject = RDF.subject.asNode(); - protected final Node nRDFpredicate = RDF.predicate.asNode(); - protected final Node nRDFobject = RDF.object.asNode(); + protected final Node nRDFsubject = RDF.subject.asNode(); + protected final Node nRDFpredicate = RDF.predicate.asNode(); + protected final Node nRDFobject = RDF.object.asNode(); - protected final String SWAP_NS = "http://www.w3.org/2000/10/swap/"; - protected final String SWAP_LOG_NS = "http://www.w3.org/2000/10/swap/log#"; - protected final Node nLogImplies = NodeFactory.createURI(SWAP_LOG_NS+"implies"); + protected final String SWAP_NS = "http://www.w3.org/2000/10/swap/"; + protected final String SWAP_LOG_NS = "http://www.w3.org/2000/10/swap/log#"; + protected final Node nLogImplies = NodeFactory.createURI(SWAP_LOG_NS + "implies"); - protected final Node nOwlSameAs = NodeFactory.createURI("http://www.w3.org/2002/07/owl#sameAs"); + protected final Node nOwlSameAs = NodeFactory.createURI("http://www.w3.org/2002/07/owl#sameAs"); protected boolean strictTurtle = true; protected boolean skolomizedBNodes = true; @@ -64,92 +63,86 @@ public class TurtleParserBase public TurtleParserBase() {} - protected String getBaseURI() { return resolver.getBaseURI(); } - public void setBaseURI(String u) - { + protected String getBaseURI() { + return resolver.getBaseURI(); + } + + public void setBaseURI(String u) { resolver = IRIxResolver.create(u).build(); } - protected void setBase(String iriStr , int line, int column) - { + protected void setBase(String iriStr, int line, int column) { // Already resolved. setBaseURI(iriStr); } - public PrefixMapping getPrefixMapping() { return prefixMapping; } + public PrefixMapping getPrefixMapping() { + return prefixMapping; + } // label => bNode for construct templates patterns LabelToNodeMap bNodeLabels = new LabelToNodeMap(); TurtleEventHandler handler = null; - public void setEventHandler(TurtleEventHandler h) { handler = h; } + public void setEventHandler(TurtleEventHandler h) { + handler = h; + } - protected void emitTriple(int line, int col, Triple triple) - { + protected void emitTriple(Triple triple, int line, int col) { handler.triple(line, col, triple); } - protected void startFormula(int line, int col) - { handler.startFormula(line, col); } + protected void startFormula(int line, int col) { + handler.startFormula(line, col); + } - protected void endFormula(int line, int col) - {handler.endFormula(line, col); } + protected void endFormula(int line, int col) { + handler.endFormula(line, col); + } - protected void setPrefix(int line, int col, String prefix, String uri) - { + protected void setPrefix(int line, int col, String prefix, String uri) { prefixMapping.setNsPrefix(prefix, uri); handler.prefix(line, col, prefix, uri); } - protected int makePositiveInteger(String lexicalForm) - { + protected int makePositiveInteger(String lexicalForm) { if ( lexicalForm == null ) return -1; - return Integer.parseInt(lexicalForm); } - protected Node createLiteralInteger(String lexicalForm) - { + protected Node createLiteralInteger(String lexicalForm) { return NodeFactory.createLiteral(lexicalForm, null, XSDDatatype.XSDinteger); } - protected Node createLiteralDouble(String lexicalForm) - { + protected Node createLiteralDouble(String lexicalForm) { return NodeFactory.createLiteral(lexicalForm, null, XSDDatatype.XSDdouble); } - protected Node createLiteralDecimal(String lexicalForm) - { + protected Node createLiteralDecimal(String lexicalForm) { return NodeFactory.createLiteral(lexicalForm, null, XSDDatatype.XSDdecimal); } - protected Node createLiteral(String lexicalForm, String langTag, Node datatype) - { - String uri = (datatype==null) ? null : datatype.getURI(); - return createLiteral(lexicalForm, langTag, uri); + protected Node createLiteral(String lexicalForm, String langTag, Node datatype) { + String uri = (datatype == null) ? null : datatype.getURI(); + return createLiteral(lexicalForm, langTag, uri); } - protected Node createLiteral(String lexicalForm, String langTag, String datatypeURI) - { + protected Node createLiteral(String lexicalForm, String langTag, String datatypeURI) { Node n = null; // Can't have type and lang tag. - if ( datatypeURI != null) - { + if ( datatypeURI != null ) { RDFDatatype dType = TypeMapper.getInstance().getSafeTypeByName(datatypeURI); n = NodeFactory.createLiteral(lexicalForm, null, dType); - } - else + } else n = NodeFactory.createLiteral(lexicalForm, langTag, null); return n; } - protected long integerValue(String s) - { + protected long integerValue(String s) { if ( s.startsWith("+") ) s = s.substring(1); - if ( s.startsWith("0x") ) - { + if ( s.startsWith("0x") ) { // Hex s = s.substring(2); return Long.parseLong(s, 16); @@ -157,37 +150,31 @@ public class TurtleParserBase return Long.parseLong(s); } - protected double doubleValue(String s) - { + protected double doubleValue(String s) { if ( s.startsWith("+") ) s = s.substring(1); double valDouble = Double.parseDouble(s); return valDouble; } - protected String stripQuotes(String s) - { - return s.substring(1,s.length()-1) ; + protected String stripQuotes(String s) { + return s.substring(1, s.length() - 1); } - protected String stripQuotes3(String s) - { - return s.substring(3,s.length()-3) ; + protected String stripQuotes3(String s) { + return s.substring(3, s.length() - 3); } - protected String stripChars(String s, int n) - { - return s.substring(n, s.length()) ; + protected String stripChars(String s, int n) { + return s.substring(n, s.length()); } - protected String resolveQuotedIRI(String iriStr ,int line, int column) - { + protected String resolveQuotedIRI(String iriStr, int line, int column) { iriStr = stripQuotes(iriStr); return resolveIRI(iriStr, line, column); } - protected String resolveIRI(String iriStr , int line, int column) - { + protected String resolveIRI(String iriStr, int line, int column) { if ( isBNodeIRI(iriStr) ) return iriStr; @@ -205,28 +192,25 @@ public class TurtleParserBase } } - protected String resolvePName(String qname, int line, int column) - { + protected String resolvePName(String qname, int line, int column) { String s = myExpandPrefix(prefixMapping, qname); if ( s == null ) - throwParseException("Unresolved prefixed name: "+qname, line, column); + throwParseException("Unresolved prefixed name: " + qname, line, column); return s; } - private static String myExpandPrefix(PrefixMapping prefixMapping, String qname) - { + private static String myExpandPrefix(PrefixMapping prefixMapping, String qname) { String s = prefixMapping.expandPrefix(qname); if ( s == null ) return null; - if ( s.equals(qname) ) - { + if ( s.equals(qname) ) { // The contract of expandPrefix is to return the original name if // there is no prefix but what s the expanded and original form are // actually the same character string ? - int colon = qname.indexOf( ':' ); - if (colon < 0) + int colon = qname.indexOf(':'); + if ( colon < 0 ) return null; - String prefix = qname.substring( 0, colon ); + String prefix = qname.substring(0, colon); if ( prefixMapping.getNsPrefixURI(prefix) != null ) // The original and resolved forms are the same. return s; @@ -237,27 +221,28 @@ public class TurtleParserBase final static String bNodeLabelStart = "_:"; - protected Node createListNode() { return createBNode(); } + protected Node createListNode() { + return createBNode(); + } // Unlabelled bNode. - protected Node createBNode() { return bNodeLabels.allocNode(); } + protected Node createBNode() { + return bNodeLabels.allocNode(); + } - // Labelled bNode. - protected Node createBNode(String label, int line, int column) - { + // Labelled bNode. + protected Node createBNode(String label, int line, int column) { return bNodeLabels.asNode(label); } - protected Node createVariable(String s, int line, int column) - { + + protected Node createVariable(String s, int line, int column) { s = s.substring(1); // Drop the marker return NodeFactory.createVariable(s); } - protected Node createNode(String iri) - { + protected Node createNode(String iri) { // Is it a bNode label? i.e. <_:xyz> - if ( isBNodeIRI(iri) ) - { + if ( isBNodeIRI(iri) ) { String s = iri.substring(bNodeLabelStart.length()); Node n = NodeFactory.createBlankNode(s); return n; @@ -265,146 +250,130 @@ public class TurtleParserBase return NodeFactory.createURI(iri); } - protected boolean isBNodeIRI(String iri) - { + protected boolean isBNodeIRI(String iri) { return skolomizedBNodes && iri.startsWith(bNodeLabelStart); } - - -// protected Node createNodeFromURI(String s, int line, int column) -// { -// s = stripQuotes(s); -// String uriStr = s; // Mutated -// -// try { -// uriStr = resolver.resolve(uriStr); -// } catch (JenaURIException ex) -// { -// throw new TurtleParseException(exMsg(ex.getMessage(), line, column)); -// } -// return Node.createURI(uriStr); -// } - - protected void throwParseException(String s , int line, int column) - { + protected void throwParseException(String s, int line, int column) { throw new TurtleParseException(exMsg(s, line, column)); } - protected String fixupPrefix(String prefix, int line, int column) - { + protected String fixupPrefix(String prefix, int line, int column) { if ( prefix.endsWith(":") ) - prefix = prefix.substring(0, prefix.length()-1); + prefix = prefix.substring(0, prefix.length() - 1); return prefix; } // Utilities to remove escapes // Testing interface - public static String unescapeStr(String s) - { return unescape(s, '\\', false, 1, 1); } - -// public static String unescapeCodePoint(String s) -// { return unescape(s, '\\', true, 1, 1); } -// -// protected String unescapeCodePoint(String s, int line, int column) -// { return unescape(s, '\\', true, line, column); } - + public static String unescapeStr(String s) { + return unescape(s, '\\', false, 1, 1); + } - protected String unescapeStr(String s, int line, int column) - { return unescape(s, '\\', false, line, column); } + protected String unescapeStr(String s, int line, int column) { + return unescape(s, '\\', false, line, column); + } // Worker function - private static String unescape(String s, char escape, boolean pointCodeOnly, int line, int column) - { + private static String unescape(String s, char escape, boolean pointCodeOnly, int line, int column) { int i = s.indexOf(escape); if ( i == -1 ) return s; // Dump the initial part straight into the string buffer - StringBuilder sb = new StringBuilder(s.substring(0,i)); + StringBuilder sb = new StringBuilder(s.substring(0, i)); int len = s.length(); - for (; i < len; i++ ) - { + for ( ; i < len ; i++ ) { char ch = s.charAt(i); // Keep line and column numbers. - switch (ch) - { - case '\n': - case '\r': + switch (ch) { + case '\n' : + case '\r' : line++; column = 1; break; - default: + default : column++; break; } - if ( ch != escape ) - { + if ( ch != escape ) { sb.append(ch); continue; } // Escape - if ( i >= len-1 ) + if ( i >= len - 1 ) throw new TurtleParseException(exMsg("Illegal escape at end of string", line, column)); - char ch2 = s.charAt(i+1); - column = column+1; + char ch2 = s.charAt(i + 1); + column = column + 1; i = i + 1; // \\u and \\U - if ( ch2 == 'u' ) - { + if ( ch2 == 'u' ) { // i points to the \ so i+6 is next character - if ( i+4 >= len ) + if ( i + 4 >= len ) throw new TurtleParseException(exMsg("\\u escape too short", line, column)); - int x = hex(s, i+1, 4, line, column); + int x = hex(s, i + 1, 4, line, column); sb.append((char)x); // Jump 1 2 3 4 -- already skipped \ and u - i = i+4; - column = column+4; + i = i + 4; + column = column + 4; continue; } - if ( ch2 == 'U' ) - { + if ( ch2 == 'U' ) { // i points to the \ so i+6 is next character - if ( i+8 >= len ) + if ( i + 8 >= len ) throw new TurtleParseException(exMsg("\\U escape too short", line, column)); - int x = hex(s, i+1, 8, line, column); + int x = hex(s, i + 1, 8, line, column); sb.append((char)x); // Jump 1 2 3 4 5 6 7 8 -- already skipped \ and u - i = i+8; - column = column+8; + i = i + 8; + column = column + 8; continue; } // Are we doing just point code escapes? // If so, \X-anything else is legal as a literal "\" and "X" - if ( pointCodeOnly ) - { + if ( pointCodeOnly ) { sb.append('\\'); sb.append(ch2); i = i + 1; continue; } - // Not just codepoints. Must be a legal escape. + // Not just codepoints. Must be a legal escape. char ch3 = 0; - switch (ch2) - { - case 'n': ch3 = '\n'; break; - case 't': ch3 = '\t'; break; - case 'r': ch3 = '\r'; break; - case 'b': ch3 = '\b'; break; - case 'f': ch3 = '\f'; break; - case '\'': ch3 = '\''; break; - case '\"': ch3 = '\"'; break; - case '\\': ch3 = '\\'; break; - default: - throw new TurtleParseException(exMsg("Unknown escape: \\"+ch2, line, column)); + switch (ch2) { + case 'n' : + ch3 = '\n'; + break; + case 't' : + ch3 = '\t'; + break; + case 'r' : + ch3 = '\r'; + break; + case 'b' : + ch3 = '\b'; + break; + case 'f' : + ch3 = '\f'; + break; + case '\'' : + ch3 = '\''; + break; + case '\"' : + ch3 = '\"'; + break; + case '\\' : + ch3 = '\\'; + break; + default : + throw new TurtleParseException(exMsg("Unknown escape: \\" + ch2, line, column)); } sb.append(ch3); } @@ -412,46 +381,80 @@ public class TurtleParserBase } // Line and column that started the escape - static private int hex(String s, int i, int len, int line, int column) - { -// if ( i+len >= s.length() ) -// { + static private int hex(String s, int i, int len, int line, int column) { +// if ( i+len >= s.length() ) +// { // -// } +// } int x = 0; - for ( int j = i; j < i+len; j++ ) - { - char ch = s.charAt(j); - column++; - int k = 0 ; - switch (ch) - { - case '0': k = 0; break; - case '1': k = 1; break; - case '2': k = 2; break; - case '3': k = 3; break; - case '4': k = 4; break; - case '5': k = 5; break; - case '6': k = 6; break; - case '7': k = 7; break; - case '8': k = 8; break; - case '9': k = 9; break; - case 'A': case 'a': k = 10; break; - case 'B': case 'b': k = 11; break; - case 'C': case 'c': k = 12; break; - case 'D': case 'd': k = 13; break; - case 'E': case 'e': k = 14; break; - case 'F': case 'f': k = 15; break; - default: - throw new TurtleParseException(exMsg("Illegal hex escape: "+ch, line, column)); - } - x = (x<<4)+k; + for ( int j = i ; j < i + len ; j++ ) { + char ch = s.charAt(j); + column++; + int k = 0; + switch (ch) { + case '0' : + k = 0; + break; + case '1' : + k = 1; + break; + case '2' : + k = 2; + break; + case '3' : + k = 3; + break; + case '4' : + k = 4; + break; + case '5' : + k = 5; + break; + case '6' : + k = 6; + break; + case '7' : + k = 7; + break; + case '8' : + k = 8; + break; + case '9' : + k = 9; + break; + case 'A' : + case 'a' : + k = 10; + break; + case 'B' : + case 'b' : + k = 11; + break; + case 'C' : + case 'c' : + k = 12; + break; + case 'D' : + case 'd' : + k = 13; + break; + case 'E' : + case 'e' : + k = 14; + break; + case 'F' : + case 'f' : + k = 15; + break; + default : + throw new TurtleParseException(exMsg("Illegal hex escape: " + ch, line, column)); + } + x = (x << 4) + k; } return x; } - protected static String exMsg(String msg, int line, int column) - { + protected static String exMsg(String msg, int line, int column) { return "Line " + line + ", column " + column + ": " + msg; } } diff --git a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/JavaCharStream.java b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/JavaCharStream.java index 0e8963bafb..9d6a09e02f 100644 --- a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/JavaCharStream.java +++ b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/JavaCharStream.java @@ -9,15 +9,16 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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 + * SPDX-License-Identifier: Apache-2.0 */ package org.apache.jena.ttl_test.turtle.javacc; @@ -781,4 +782,4 @@ public void adjustBeginLineColumn(int newLine, int newCol) void setTrackLineColumn(boolean tlc) { trackLineColumn = tlc; } } -/* JavaCC - OriginalChecksum=23caaa453750482178ac43d0df92264c (do not edit this line) */ +/* JavaCC - OriginalChecksum=a115f76bc92235c3e95356a7afd571d2 (do not edit this line) */ diff --git a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/ParseException.java b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/ParseException.java index 3ab3b52cbf..75bed03c14 100644 --- a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/ParseException.java +++ b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/ParseException.java @@ -9,15 +9,16 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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 + * SPDX-License-Identifier: Apache-2.0 */ package org.apache.jena.ttl_test.turtle.javacc; @@ -212,4 +213,4 @@ public class ParseException extends Exception { } } -/* JavaCC - OriginalChecksum=8531b94f7a8788ef0992d1be052c4c81 (do not edit this line) */ +/* JavaCC - OriginalChecksum=f1cf3a22ee1de40527493c7728b3f5bd (do not edit this line) */ diff --git a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/Token.java b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/Token.java index 21e5b21d2e..793f754e0a 100644 --- a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/Token.java +++ b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/Token.java @@ -9,15 +9,16 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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 + * SPDX-License-Identifier: Apache-2.0 */ package org.apache.jena.ttl_test.turtle.javacc; @@ -149,4 +150,4 @@ public class Token implements java.io.Serializable { } } -/* JavaCC - OriginalChecksum=29726366ad9146239bfd04cc538097ad (do not edit this line) */ +/* JavaCC - OriginalChecksum=ba213cb31abfcf519049aeb52c4990f6 (do not edit this line) */ diff --git a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TokenMgrError.java b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TokenMgrError.java index 1a93af4ae6..d2dfb26c42 100644 --- a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TokenMgrError.java +++ b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TokenMgrError.java @@ -9,15 +9,16 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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 + * SPDX-License-Identifier: Apache-2.0 */ package org.apache.jena.ttl_test.turtle.javacc; @@ -166,4 +167,4 @@ public class TokenMgrError extends Error this(LexicalErr(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } -/* JavaCC - OriginalChecksum=2f932b2c32fcdab48fe89a8299c0d2bd (do not edit this line) */ +/* JavaCC - OriginalChecksum=350436db9a57f9dd26f1a8e840e0495e (do not edit this line) */ diff --git a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TurtleParser.java b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TurtleParser.java index 54a12f98fc..edd8b5d2a0 100644 --- a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TurtleParser.java +++ b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TurtleParser.java @@ -9,15 +9,16 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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 + * SPDX-License-Identifier: Apache-2.0 */ package org.apache.jena.ttl_test.turtle.javacc; @@ -247,7 +248,7 @@ void TriplesSameSubject() throws ParseException {Node s ; final public void Object(Node s, Node p) throws ParseException {Node o ; o = GraphNode(); Triple t = Triple.create(s,p,o) ; - emitTriple(token.beginLine, token.beginColumn, t) ; + emitTriple(t, token.beginLine, token.beginColumn) ; } final public Node Verb() throws ParseException {Node p ; String iri ; @@ -334,11 +335,11 @@ Node cell = createBNode() ; if ( listHead == nRDFnil ) listHead = cell ; if ( lastCell != null ) - emitTriple(token.beginLine, token.beginColumn, - Triple.create(lastCell, nRDFrest, cell)) ; + emitTriple(Triple.create(lastCell, nRDFrest, cell), + token.beginLine, token.beginColumn); n = GraphNode(); -emitTriple(token.beginLine, token.beginColumn, - Triple.create(cell, nRDFfirst, n)) ; +emitTriple(Triple.create(cell, nRDFfirst, n), + token.beginLine, token.beginColumn); lastCell = cell ; switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case TRUE: @@ -370,8 +371,8 @@ emitTriple(token.beginLine, token.beginColumn, } jj_consume_token(RPAREN); if ( lastCell != null ) - emitTriple(token.beginLine, token.beginColumn, - Triple.create(lastCell, nRDFrest, nRDFnil)) ; + emitTriple(Triple.create(lastCell, nRDFrest, nRDFnil), + token.beginLine, token.beginColumn); {if ("" != null) return listHead ;} throw new Error("Missing return statement in function"); } diff --git a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TurtleParserConstants.java b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TurtleParserConstants.java index b33a39a193..1bf7a1a445 100644 --- a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TurtleParserConstants.java +++ b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TurtleParserConstants.java @@ -8,15 +8,16 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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 + * SPDX-License-Identifier: Apache-2.0 */ package org.apache.jena.ttl_test.turtle.javacc; diff --git a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TurtleParserTokenManager.java b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TurtleParserTokenManager.java index ecdbc535d9..7e7ec96586 100644 --- a/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TurtleParserTokenManager.java +++ b/jena-core/src/test/java/org/apache/jena/ttl_test/turtle/javacc/TurtleParserTokenManager.java @@ -9,15 +9,16 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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 + * SPDX-License-Identifier: Apache-2.0 */ package org.apache.jena.ttl_test.turtle.javacc; diff --git a/jena-core/testing/ttl_test/turtle-test.jj b/jena-core/testing/ttl_test/turtle-test.jj index 6cfd4bca68..9a1c4f6c5a 100644 --- a/jena-core/testing/ttl_test/turtle-test.jj +++ b/jena-core/testing/ttl_test/turtle-test.jj @@ -7,15 +7,16 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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 + * SPDX-License-Identifier: Apache-2.0 */ // Turtle for Jena testing @@ -43,15 +44,16 @@ PARSER_BEGIN(TurtleParser) * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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 + * SPDX-License-Identifier: Apache-2.0 */ package org.apache.jena.ttl_test.turtle.javacc; @@ -136,7 +138,7 @@ void Object(Node s, Node p): { Node o ; } { o = GraphNode() { Triple t = Triple.create(s,p,o) ; - emitTriple(token.beginLine, token.beginColumn, t) ; } + emitTriple(t, token.beginLine, token.beginColumn) ; } } Node Verb() : { Node p ; String iri ;} @@ -193,21 +195,21 @@ Node Collection() : if ( listHead == nRDFnil ) listHead = cell ; if ( lastCell != null ) - emitTriple(token.beginLine, token.beginColumn, - Triple.create(lastCell, nRDFrest, cell)) ; + emitTriple(Triple.create(lastCell, nRDFrest, cell), + token.beginLine, token.beginColumn); } n = GraphNode() { - emitTriple(token.beginLine, token.beginColumn, - Triple.create(cell, nRDFfirst, n)) ; + emitTriple(Triple.create(cell, nRDFfirst, n), + token.beginLine, token.beginColumn); lastCell = cell ; } ) + // Not * here - "()" is handled separately. <RPAREN> { if ( lastCell != null ) - emitTriple(token.beginLine, token.beginColumn, - Triple.create(lastCell, nRDFrest, nRDFnil)) ; + emitTriple(Triple.create(lastCell, nRDFrest, nRDFnil), + token.beginLine, token.beginColumn); return listHead ; } }
