You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2025/04/11 07:36:56 UTC
(jena) 01/06: RDF 1.2 and SPARQL 1.2; SEMIJOIN and ANTIJOIN
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 90da0a3f372d7f557eabfac3ccd5b8dc7c2c6cca
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Mon Dec 9 22:10:27 2024 +0000
RDF 1.2 and SPARQL 1.2; SEMIJOIN and ANTIJOIN
---
jena-arq/Grammar/.gitignore | 4 +-
jena-arq/Grammar/RDF-Protobuf/binary-rdf.proto | 3 +-
jena-arq/Grammar/RDF-Thrift/BinaryRDF.thrift | 2 +
jena-arq/Grammar/RDF-Thrift/gen-thrift | 14 +-
jena-arq/Grammar/README | 31 +
jena-arq/Grammar/Turtle/turtle.jj | 181 +-
jena-arq/Grammar/arq.jj | 330 ++-
jena-arq/Grammar/grammar | 1 +
jena-arq/Grammar/jj2bnf | 302 ++
jena-arq/Grammar/main.jj | 492 +++-
jena-arq/Grammar/sparql2bnf | 7 +
jena-arq/Grammar/sparql2html | 16 +-
jena-arq/Grammar/sparql_12.jj | 309 +-
jena-arq/Grammar/sparql_12.txt | 486 ----
jena-arq/Grammar/sse/grammar-sse | 19 +-
jena-arq/Grammar/sse/jj2html | 469 ---
jena-arq/Grammar/sse/sse.jj | 179 +-
jena-arq/Grammar/sse/tokens.inc | 203 --
jena-arq/Grammar/tokens.txt | 30 +-
.../jena/query/ParameterizedSparqlString.java | 73 +-
.../java/org/apache/jena/riot/lang/LangEngine.java | 20 +-
.../java/org/apache/jena/riot/lang/LangNQuads.java | 35 +-
.../java/org/apache/jena/riot/lang/LangNTuple.java | 66 +-
.../java/org/apache/jena/riot/lang/LangTriG.java | 70 +-
.../java/org/apache/jena/riot/lang/LangTurtle.java | 2 +-
.../org/apache/jena/riot/lang/LangTurtleBase.java | 347 ++-
.../java/org/apache/jena/riot/lang/ReaderTriX.java | 56 +-
.../jena/riot/lang/extra/LangParserBase.java | 34 +-
.../jena/riot/lang/extra/javacc/TurtleJavacc.java | 445 ++-
.../lang/extra/javacc/TurtleJavaccConstants.java | 66 +-
.../extra/javacc/TurtleJavaccTokenManager.java | 595 ++--
.../org/apache/jena/riot/out/NodeFormatter.java | 3 +
.../apache/jena/riot/out/NodeFormatterBase.java | 10 +-
.../org/apache/jena/riot/out/NodeFormatterNT.java | 9 +
.../jena/riot/protobuf/Binding2Protobuf.java | 34 +-
.../jena/riot/protobuf/Protobuf2Binding.java | 58 +-
.../apache/jena/riot/protobuf/ProtobufConvert.java | 305 +-
.../org/apache/jena/riot/protobuf/ProtobufRDF.java | 6 +-
.../jena/riot/protobuf/RiotProtobufException.java | 10 +-
.../jena/riot/protobuf/WriterDatasetProtobuf.java | 28 +-
.../jena/riot/protobuf/WriterGraphProtobuf.java | 36 +-
.../org/apache/jena/riot/protobuf/wire/PB_RDF.java | 351 ++-
.../apache/jena/riot/rowset/rw/JSONResultsKW.java | 1 +
.../jena/riot/rowset/rw/RowSetReaderJSON_V1.java | 2 +-
.../jena/riot/rowset/rw/RowSetReaderXML.java | 8 +-
.../jena/riot/rowset/rw/RowSetWriterJSON.java | 20 +-
.../jena/riot/rowset/rw/RowSetWriterXML.java | 14 +-
.../rowset/rw/rs_json/RowSetJSONStreaming.java | 46 +-
.../java/org/apache/jena/riot/system/Checker.java | 51 +-
.../org/apache/jena/riot/system/FactoryRDF.java | 2 +
.../org/apache/jena/riot/system/FactoryRDFStd.java | 5 +
.../org/apache/jena/riot/system/ParserProfile.java | 21 +-
.../apache/jena/riot/system/ParserProfileStd.java | 44 +-
.../jena/riot/system/ParserProfileWrapper.java | 13 +-
.../apache/jena/riot/thrift/Binding2Thrift.java | 96 +-
.../apache/jena/riot/thrift/IteratorThriftRDF.java | 40 +-
.../jena/riot/thrift/RiotThriftException.java | 10 +-
.../jena/riot/thrift/StreamRowTRDFPrinter.java | 62 +-
.../java/org/apache/jena/riot/thrift/TRDF.java | 94 +-
.../org/apache/jena/riot/thrift/Thift2Binding.java | 108 +-
.../org/apache/jena/riot/thrift/ThriftConvert.java | 19 +-
.../org/apache/jena/riot/thrift/ThriftRDF.java | 76 +-
.../jena/riot/thrift/VisitorStreamRowTRDF.java | 12 +-
.../jena/riot/thrift/WriterDatasetThrift.java | 34 +-
.../apache/jena/riot/thrift/WriterGraphThrift.java | 40 +-
.../apache/jena/riot/thrift/wire/RDF_Literal.java | 119 +-
.../org/apache/jena/riot/tokens/TokenizerText.java | 4 +-
.../apache/jena/riot/writer/StreamWriterTriX.java | 2 +-
.../org/apache/jena/riot/writer/TurtleShell.java | 8 +-
.../java/org/apache/jena/sparql/ARQConstants.java | 3 +
.../jena/sparql/algebra/AlgebraGenerator.java | 19 +
.../org/apache/jena/sparql/algebra/OpAsQuery.java | 29 +-
.../org/apache/jena/sparql/algebra/OpVisitor.java | 73 +-
.../apache/jena/sparql/algebra/OpVisitorBase.java | 8 +-
.../jena/sparql/algebra/OpVisitorByType.java | 15 +-
.../org/apache/jena/sparql/algebra/Transform.java | 77 +-
.../apache/jena/sparql/algebra/TransformCopy.java | 10 +-
.../jena/sparql/algebra/TransformSingle.java | 7 +-
.../jena/sparql/algebra/TransformWrapper.java | 82 +-
.../algebra/op/{OpDiff.java => OpAntiJoin.java} | 12 +-
.../algebra/op/{OpDiff.java => OpSemiJoin.java} | 12 +-
.../sparql/algebra/walker/OpVisitorByType.java | 34 +-
.../algebra/walker/OpVisitorByTypeAndExpr.java | 15 +-
.../org/apache/jena/sparql/core/Substitute.java | 6 +-
.../java/org/apache/jena/sparql/engine/Rename.java | 8 +-
.../apache/jena/sparql/engine/ResultSetStream.java | 4 +-
.../engine/iterator/QueryIter2LoopOnLeft.java | 72 +-
.../engine/iterator/QueryIterAddTripleTerm.java | 2 +-
.../jena/sparql/engine/iterator/QueryIterDiff.java | 55 -
.../sparql/engine/iterator/QueryIterHalfJoin.java | 72 +
.../jena/sparql/engine/main/ExecutionDispatch.java | 22 +-
.../jena/sparql/engine/main/JoinClassifier.java | 6 +-
.../apache/jena/sparql/engine/main/OpExecutor.java | 22 +-
.../apache/jena/sparql/engine/main/VarFinder.java | 18 +-
.../jena/sparql/engine/main/solver/RX_PG.java | 8 +-
.../jena/sparql/engine/main/solver/SolverLib.java | 12 +-
.../jena/sparql/engine/main/solver/SolverRX3.java | 2 +-
.../jena/sparql/engine/main/solver/SolverRX4.java | 4 +-
.../engine/main/solver/StageMatchTriple.java | 5 +-
.../apache/jena/sparql/engine/ref/Evaluator.java | 6 +-
.../jena/sparql/engine/ref/EvaluatorDispatch.java | 25 +-
.../jena/sparql/engine/ref/EvaluatorSimple.java | 60 +
.../org/apache/jena/sparql/engine/ref/RefEval.java | 60 +
.../apache/jena/sparql/engine/ref/TableJoin.java | 5 +-
.../apache/jena/sparql/exec/ResultSetAdapter.java | 4 +-
.../expr/{E_TripleFn.java => E_HasLang.java} | 24 +-
.../expr/{E_IsNumeric.java => E_HasLangDir.java} | 20 +-
.../org/apache/jena/sparql/expr/E_IsNumeric.java | 20 +-
.../org/apache/jena/sparql/expr/E_IsTriple.java | 4 +-
.../java/org/apache/jena/sparql/expr/E_Lang.java | 6 +-
.../sparql/expr/{E_Lang.java => E_LangDir.java} | 24 +-
.../org/apache/jena/sparql/expr/E_StrLang.java | 21 +-
.../expr/{E_TripleFn.java => E_StrLangDir.java} | 19 +-
.../org/apache/jena/sparql/expr/E_TripleFn.java | 4 +-
.../apache/jena/sparql/expr/E_TripleObject.java | 4 +-
.../apache/jena/sparql/expr/E_TriplePredicate.java | 4 +-
.../apache/jena/sparql/expr/E_TripleSubject.java | 4 +-
.../org/apache/jena/sparql/expr/ExprFunction3.java | 2 +-
.../java/org/apache/jena/sparql/expr/ExprLib.java | 2 +-
.../apache/jena/sparql/expr/ExprTripleTerm.java | 6 +-
.../java/org/apache/jena/sparql/expr/ExprVars.java | 2 +-
.../org/apache/jena/sparql/expr/NodeValue.java | 22 +-
.../org/apache/jena/sparql/expr/NodeValueCmp.java | 4 +-
.../org/apache/jena/sparql/expr/ValueSpace.java | 47 +-
.../jena/sparql/expr/nodevalue/NodeFunctions.java | 88 +-
.../jena/sparql/expr/nodevalue/NodeValueLang.java | 27 +-
.../{NodeValueLang.java => NodeValueLangDir.java} | 57 +-
.../sparql/expr/nodevalue/NodeValueVisitor.java | 1 +
.../jena/sparql/function/FunctionEnvBase.java | 7 +-
.../function/library/triple/IsTripleTerm.java | 2 +-
.../function/library/triple/TripleObject.java | 2 +-
.../function/library/triple/TriplePredicate.java | 2 +-
.../function/library/triple/TripleSubject.java | 2 +-
.../sparql/function/library/triple/TripleTerm.java | 2 +-
...ddedTripleFunctions.java => TripleTermOps.java} | 8 +-
.../org/apache/jena/sparql/graph/NodeConst.java | 18 +-
.../apache/jena/sparql/lang/QueryParserBase.java | 246 +-
.../org/apache/jena/sparql/lang/arq/ARQParser.java | 2715 +++++++++++-------
.../apache/jena/sparql/lang/arq/ARQParserBase.java | 6 +-
.../jena/sparql/lang/arq/ARQParserConstants.java | 406 +--
.../sparql/lang/arq/ARQParserTokenManager.java | 3001 ++++++++++----------
.../sparql/lang/sparql_10/SPARQLParser10Base.java | 22 +-
.../sparql/lang/sparql_11/SPARQLParser11Base.java | 22 +-
.../jena/sparql/lang/sparql_12/SPARQLParser12.java | 1023 +++++--
...QLParser11Base.java => SPARQLParser12Base.java} | 6 +-
.../lang/sparql_12/SPARQLParser12Constants.java | 300 +-
.../lang/sparql_12/SPARQLParser12TokenManager.java | 2316 +++++++--------
.../jena/sparql/resultset/ResultSetCompare.java | 2 +-
.../apache/jena/sparql/resultset/ResultSetMem.java | 29 +-
.../jena/sparql/serializer/FormatterBase.java | 66 +-
.../jena/sparql/serializer/FormatterElement.java | 18 +
.../java/org/apache/jena/sparql/sse/ItemLift.java | 58 +-
.../org/apache/jena/sparql/sse/ItemWriter.java | 14 +-
.../main/java/org/apache/jena/sparql/sse/Tags.java | 18 +-
.../jena/sparql/sse/builders/BuilderExpr.java | 317 ++-
.../apache/jena/sparql/sse/builders/BuilderOp.java | 87 +-
.../jena/sparql/sse/lang/ParseHandlerLink.java | 1 -
.../jena/sparql/sse/lang/ParseHandlerPlain.java | 2 +-
.../apache/jena/sparql/sse/lang/ParserSSEBase.java | 1 -
.../sparql/sse/lang/parser/ParseException.java | 20 +-
.../sparql/sse/lang/parser/SSE_ParserCore.java | 54 +-
.../sse/lang/parser/SSE_ParserCoreConstants.java | 30 +-
.../lang/parser/SSE_ParserCoreTokenManager.java | 487 ++--
.../sparql/sse/lang/parser/SimpleCharStream.java | 20 +-
.../apache/jena/sparql/sse/lang/parser/Token.java | 20 +-
.../jena/sparql/sse/lang/parser/TokenMgrError.java | 23 +-
.../apache/jena/sparql/sse/writers/WriterOp.java | 15 +-
.../org/apache/jena/sparql/syntax/Element.java | 52 +-
.../{ElementLateral.java => ElementAntiJoin.java} | 33 +-
.../apache/jena/sparql/syntax/ElementLateral.java | 1 -
.../{ElementLateral.java => ElementSemiJoin.java} | 33 +-
.../apache/jena/sparql/syntax/ElementVisitor.java | 38 +-
.../jena/sparql/syntax/ElementVisitorBase.java | 6 +
.../apache/jena/sparql/syntax/ElementWalker.java | 18 +
.../org/apache/jena/sparql/syntax/PatternVars.java | 137 +-
.../jena/sparql/syntax/PatternVarsVisitor.java | 102 -
.../ApplyElementTransformVisitor.java | 14 +
.../syntax/syntaxtransform/ElementTransform.java | 4 +-
.../syntaxtransform/ElementTransformCopyBase.java | 14 +
.../syntaxtransform/ElementTransformIdentity.java | 4 +
.../java/org/apache/jena/sparql/util/FmtUtils.java | 44 +-
.../java/org/apache/jena/sparql/util/IsoAlg.java | 8 +-
.../org/apache/jena/sparql/util/ModelUtils.java | 4 +-
.../java/org/apache/jena/sparql/util/NodeCmp.java | 6 +-
.../apache/jena/sparql/util/NodeFactoryExtra.java | 20 +-
.../org/apache/jena/sparql/util/NodeUtils.java | 105 +-
.../apache/jena/sparql/util/ResultSetUtils.java | 46 +-
.../java/org/apache/jena/sparql/util/VarUtils.java | 2 +-
.../jena/sparql/vocabulary/TestManifestX.java | 2 -
.../jena/sparql/vocabulary/TestManifest_12.java | 23 +-
.../src/main/java/org/apache/jena/system/G.java | 22 +-
.../main/java/org/apache/jena/system/RDFStar.java | 18 +-
.../java/org/apache/jena/arq/ARQTestSuite.java | 6 +-
.../java/org/apache/jena/arq/junit/LibTest.java | 42 +
.../apache/jena/arq/junit/sparql/SparqlTests.java | 8 +
.../arq/junit/sparql/tests/QuerySyntaxTest.java | 8 +-
.../jena/arq/junit/sparql/tests/SparqlTestLib.java | 2 +-
.../jena/query/TestParameterizedSparqlString.java | 22 +
.../apache/jena/rdf12/AbstratTestSPARQL12Eval.java | 101 +
.../org/apache/jena/rdf12/LibTestSPARQL12.java | 71 +
.../Scripts_RDFStar.java => rdf12/TEST.java} | 16 +-
.../TS_RDF_Star.java => rdf12/TS_RDF12.java} | 30 +-
.../org/apache/jena/rdf12/TestRDF12LangSyntax.java | 358 +++
.../org/apache/jena/rdf12/TestSPARQL12Eval.java | 22 +-
.../TestSPARQL12Results.java} | 5 +-
.../org/apache/jena/rdf12/TestSPARQL12Syntax.java | 219 ++
.../basic/TS_RDFStar_Basic.java} | 11 +-
.../basic}/TestNQuadsStarParse.java | 22 +-
.../basic}/TestNTriplesStarParse.java | 19 +-
.../jena/rdf12/basic/TestSPARQLStarParse.java | 143 +
.../basic}/TestTrigStarParse.java | 25 +-
.../basic}/TestTurtleStarParse.java | 15 +-
.../apache/jena/rdf_star/TestSPARQLStarParse.java | 139 -
.../org/apache/jena/riot/Scripts_AltTurtle.java | 9 +-
.../org/apache/jena/riot/lang/TestLangTrig.java | 52 +-
.../org/apache/jena/riot/lang/TestTriXBad.java | 11 +-
.../jena/riot/protobuf/TestProtobufResultSet.java | 8 +-
.../jena/riot/protobuf/TestProtobufTerm.java | 294 +-
.../jena/riot/resultset/TestResultSetIO.java | 18 +-
.../apache/jena/riot/thrift/TestThriftTerm.java | 323 ++-
.../{Scripts_TIM.java => Scripts_DatasetMap.java} | 15 +-
...cripts_TIM.java => Scripts_DatasetMapLink.java} | 13 +-
.../java/org/apache/jena/sparql/Scripts_TIM.java | 5 +-
.../test/java/org/apache/jena/sparql/TC_ARQ.java | 6 +-
.../sparql/algebra/optimize/TestVarRename.java | 454 +--
.../apache/jena/sparql/expr/TestExpressions.java | 24 +-
.../apache/jena/sparql/expr/TestExpressions2.java | 8 +-
.../apache/jena/sparql/expr/TestNodeFunctions.java | 35 +-
.../org/apache/jena/sparql/expr/TestNodeValue.java | 17 +-
.../org/apache/jena/sparql/expr/TestOrdering.java | 26 +-
.../apache/jena/sparql/expr/TestSortOrdering.java | 26 +-
...PARQL_TIM.java => RunnerSPARQL_DatasetMap.java} | 7 +-
...L_TIM.java => RunnerSPARQL_DatasetMapLink.java} | 9 +-
.../apache/jena/sparql/junit/RunnerSPARQL_TIM.java | 5 +-
.../jena/sparql/resultset/TestResultSet.java | 203 +-
.../org/apache/jena/sparql/sse/TestSSE_Basic.java | 38 +-
.../apache/jena/sparql/util/TestIsoMatcher.java | 49 +-
.../apache/jena/system/TestRDFStarTranslation.java | 60 +-
jena-arq/testing/RIOT/Lang/TriX/trix-ns-1.nq | 3 +-
jena-arq/testing/RIOT/Lang/TriX/trix-ns-1.trix | 13 +-
jena-arq/testing/RIOT/Lang/TriX/trix-ns-2.nq | 3 +-
jena-arq/testing/RIOT/Lang/TriX/trix-ns-2.trix | 24 +-
jena-arq/testing/RIOT/Lang/TriX/trix-star-1.nq | 3 +-
jena-arq/testing/RIOT/Lang/TriX/trix-star-1.trix | 13 +-
jena-arq/testing/RIOT/Lang/TriX/trix-star-2.nq | 5 +-
jena-arq/testing/RIOT/Lang/TriX/trix-star-2.trix | 52 +-
.../RIOT/Lang/TriX/trix-star-bad-emb-2.trix | 17 -
.../RIOT/Lang/TriX/trix-star-bad-emb-nested-1.trix | 20 -
.../RIOT/Lang/TriX/trix-star-bad-emb-nested-3.trix | 19 -
...ted-1.trix => trix-star-bad-triple-term-1.trix} | 0
...ted-2.trix => trix-star-bad-triple-term-2.trix} | 0
...emb-1.trix => trix-star-bad-triple-term-3.trix} | 9 +-
...ted-2.trix => trix-star-bad-triple-term-4.trix} | 12 +-
jena-arq/testing/rdf-star-cg/manifest.ttl | 33 -
.../testing/rdf-star-cg/nt/syntax/manifest.ttl | 112 -
.../nt/syntax/ntriples-star-bad-syntax-1.nt | 1 -
.../nt/syntax/ntriples-star-bad-syntax-2.nt | 1 -
.../nt/syntax/ntriples-star-bad-syntax-3.nt | 1 -
.../nt/syntax/ntriples-star-bad-syntax-4.nt | 1 -
.../rdf-star-cg/nt/syntax/ntriples-star-bnode-1.nt | 2 -
.../rdf-star-cg/nt/syntax/ntriples-star-bnode-2.nt | 2 -
.../nt/syntax/ntriples-star-nested-1.nt | 3 -
.../nt/syntax/ntriples-star-nested-2.nt | 3 -
.../nt/syntax/ntriples-star-syntax-1.nt | 1 -
.../nt/syntax/ntriples-star-syntax-2.nt | 1 -
.../nt/syntax/ntriples-star-syntax-3.nt | 1 -
.../nt/syntax/ntriples-star-syntax-4.nt | 1 -
.../nt/syntax/ntriples-star-syntax-5.nt | 1 -
.../testing/rdf-star-cg/sparql/eval/data-0.ttl | 14 -
.../testing/rdf-star-cg/sparql/eval/data-2.ttl | 16 -
.../testing/rdf-star-cg/sparql/eval/data-3.ttl | 4 -
.../testing/rdf-star-cg/sparql/eval/data-4.trig | 13 -
.../testing/rdf-star-cg/sparql/eval/data-5.ttl | 10 -
.../testing/rdf-star-cg/sparql/eval/data-6.trig | 4 -
.../testing/rdf-star-cg/sparql/eval/data-7.ttl | 24 -
.../rdf-star-cg/sparql/eval/data-order-kind.ttl | 18 -
.../testing/rdf-star-cg/sparql/eval/data-order.ttl | 26 -
jena-arq/testing/rdf-star-cg/sparql/eval/empty.nq | 0
.../testing/rdf-star-cg/sparql/eval/manifest.ttl | 366 ---
.../rdf-star-cg/sparql/eval/sparql-star-basic-2.rq | 5 -
.../sparql/eval/sparql-star-basic-2.srj | 12 -
.../rdf-star-cg/sparql/eval/sparql-star-basic-3.rq | 5 -
.../sparql/eval/sparql-star-basic-3.srj | 13 -
.../rdf-star-cg/sparql/eval/sparql-star-basic-4.rq | 5 -
.../sparql/eval/sparql-star-basic-4.srj | 12 -
.../rdf-star-cg/sparql/eval/sparql-star-basic-5.rq | 5 -
.../sparql/eval/sparql-star-basic-5.srj | 12 -
.../rdf-star-cg/sparql/eval/sparql-star-basic-6.rq | 5 -
.../sparql/eval/sparql-star-basic-6.srj | 9 -
.../sparql/eval/sparql-star-construct-1.rq | 5 -
.../sparql/eval/sparql-star-construct-1.ttl | 3 -
.../sparql/eval/sparql-star-construct-2.rq | 5 -
.../sparql/eval/sparql-star-construct-2.ttl | 3 -
.../sparql/eval/sparql-star-construct-3.rq | 7 -
.../sparql/eval/sparql-star-construct-3.ttl | 8 -
.../sparql/eval/sparql-star-construct-4.rq | 7 -
.../sparql/eval/sparql-star-construct-4.ttl | 5 -
.../sparql/eval/sparql-star-construct-5.rq | 5 -
.../sparql/eval/sparql-star-construct-5.ttl | 5 -
.../rdf-star-cg/sparql/eval/sparql-star-expr-01.rq | 10 -
.../sparql/eval/sparql-star-expr-01.ttl | 14 -
.../rdf-star-cg/sparql/eval/sparql-star-expr-02.rq | 13 -
.../sparql/eval/sparql-star-expr-02.srj | 18 -
.../sparql/eval/sparql-star-graphs-1.rq | 6 -
.../sparql/eval/sparql-star-graphs-1.srj | 14 -
.../sparql/eval/sparql-star-graphs-2.rq | 6 -
.../sparql/eval/sparql-star-graphs-2.srj | 17 -
.../rdf-star-cg/sparql/eval/sparql-star-op-1.rq | 7 -
.../rdf-star-cg/sparql/eval/sparql-star-op-1.srj | 46 -
.../rdf-star-cg/sparql/eval/sparql-star-op-2.rq | 8 -
.../rdf-star-cg/sparql/eval/sparql-star-op-2.srj | 79 -
.../rdf-star-cg/sparql/eval/sparql-star-op-3.rq | 8 -
.../rdf-star-cg/sparql/eval/sparql-star-op-3.srj | 27 -
.../rdf-star-cg/sparql/eval/sparql-star-op-4.rq | 8 -
.../rdf-star-cg/sparql/eval/sparql-star-op-4.srj | 136 -
.../sparql/eval/sparql-star-order-1.srj | 31 -
.../sparql/eval/sparql-star-order-2.srj | 154 -
.../sparql/eval/sparql-star-order-by.rq | 69 -
.../sparql/eval/sparql-star-pattern-01.rq | 6 -
.../sparql/eval/sparql-star-pattern-01.srj | 18 -
.../sparql/eval/sparql-star-pattern-02.rq | 6 -
.../sparql/eval/sparql-star-pattern-02.srj | 18 -
.../sparql/eval/sparql-star-pattern-03.rq | 7 -
.../sparql/eval/sparql-star-pattern-03.srj | 20 -
.../sparql/eval/sparql-star-pattern-04.rq | 6 -
.../sparql/eval/sparql-star-pattern-04.srj | 9 -
.../sparql/eval/sparql-star-pattern-05.rq | 6 -
.../sparql/eval/sparql-star-pattern-05.srj | 14 -
.../sparql/eval/sparql-star-pattern-06.rq | 6 -
.../sparql/eval/sparql-star-pattern-06.srj | 11 -
.../sparql/eval/sparql-star-pattern-07.rq | 6 -
.../sparql/eval/sparql-star-pattern-07.srj | 13 -
.../sparql/eval/sparql-star-pattern-08.rq | 7 -
.../sparql/eval/sparql-star-pattern-08.srj | 18 -
.../sparql/eval/sparql-star-pattern-09.rq | 7 -
.../sparql/eval/sparql-star-pattern-09.srj | 18 -
.../sparql/eval/sparql-star-results-1.rq | 5 -
.../sparql/eval/sparql-star-results-1.srj | 106 -
.../sparql/eval/sparql-star-results-1.srx | 177 --
.../sparql/eval/sparql-star-update-1.ru | 7 -
.../sparql/eval/sparql-star-update-2.ru | 7 -
.../sparql/eval/sparql-star-update-3.ru | 7 -
.../rdf-star-cg/sparql/eval/update-result-1.trig | 7 -
.../rdf-star-cg/sparql/eval/update-result-2.trig | 6 -
.../rdf-star-cg/sparql/eval/update-result-3.trig | 2 -
.../testing/rdf-star-cg/sparql/syntax/manifest.ttl | 433 ---
.../sparql/syntax/sparql-star-annotation-01.rq | 5 -
.../sparql/syntax/sparql-star-annotation-02.rq | 12 -
.../sparql/syntax/sparql-star-annotation-03.rq | 6 -
.../sparql/syntax/sparql-star-annotation-04.rq | 6 -
.../sparql/syntax/sparql-star-annotation-05.rq | 6 -
.../sparql/syntax/sparql-star-annotation-06.rq | 5 -
.../sparql/syntax/sparql-star-annotation-07.rq | 5 -
.../sparql/syntax/sparql-star-annotation-08.rq | 6 -
.../sparql/syntax/sparql-star-annotation-09.rq | 5 -
.../sparql/syntax/sparql-star-syntax-bad-01.rq | 5 -
.../sparql/syntax/sparql-star-syntax-bad-02.rq | 5 -
.../sparql/syntax/sparql-star-syntax-bad-03.rq | 5 -
.../sparql/syntax/sparql-star-syntax-bad-04.rq | 5 -
.../sparql/syntax/sparql-star-syntax-bad-05.rq | 5 -
.../sparql/syntax/sparql-star-syntax-bad-06.rq | 5 -
.../sparql/syntax/sparql-star-syntax-bad-07.rq | 5 -
.../sparql/syntax/sparql-star-syntax-bad-08.rq | 5 -
.../sparql/syntax/sparql-star-syntax-bad-09.rq | 5 -
.../sparql/syntax/sparql-star-syntax-bad-10.rq | 5 -
.../sparql/syntax/sparql-star-syntax-bad-11.rq | 6 -
.../sparql/syntax/sparql-star-syntax-bad-12.rq | 6 -
.../sparql/syntax/sparql-star-syntax-bad-ann-1.rq | 6 -
.../sparql/syntax/sparql-star-syntax-bad-ann-2.rq | 6 -
.../syntax/sparql-star-syntax-bad-ann-path-1.rq | 5 -
.../syntax/sparql-star-syntax-bad-ann-path-2.rq | 5 -
.../syntax/sparql-star-syntax-bad-ann-path-3.rq | 5 -
.../syntax/sparql-star-syntax-bad-ann-path-4.rq | 5 -
.../syntax/sparql-star-syntax-bad-ann-path-5.rq | 5 -
.../syntax/sparql-star-syntax-bad-ann-path-6.rq | 7 -
.../syntax/sparql-star-syntax-bad-ann-path-7.rq | 5 -
.../syntax/sparql-star-syntax-bad-update-1.ru | 5 -
.../syntax/sparql-star-syntax-bad-update-2.ru | 5 -
.../syntax/sparql-star-syntax-bad-update-3.ru | 5 -
.../syntax/sparql-star-syntax-bad-update-4.ru | 5 -
.../sparql/syntax/sparql-star-syntax-basic-01.rq | 5 -
.../sparql/syntax/sparql-star-syntax-basic-02.rq | 5 -
.../sparql/syntax/sparql-star-syntax-basic-03.rq | 5 -
.../sparql/syntax/sparql-star-syntax-basic-04.rq | 5 -
.../sparql/syntax/sparql-star-syntax-basic-05.rq | 10 -
.../sparql/syntax/sparql-star-syntax-basic-06.rq | 4 -
.../sparql/syntax/sparql-star-syntax-basic-07.rq | 6 -
.../sparql/syntax/sparql-star-syntax-bnode-01.rq | 5 -
.../sparql/syntax/sparql-star-syntax-bnode-02.rq | 5 -
.../sparql/syntax/sparql-star-syntax-bnode-03.rq | 5 -
.../sparql/syntax/sparql-star-syntax-compound.rq | 10 -
.../sparql/syntax/sparql-star-syntax-expr-01.rq | 6 -
.../sparql/syntax/sparql-star-syntax-expr-02.rq | 6 -
.../sparql/syntax/sparql-star-syntax-expr-03.rq | 6 -
.../sparql/syntax/sparql-star-syntax-expr-04.rq | 6 -
.../sparql/syntax/sparql-star-syntax-expr-05.rq | 9 -
.../sparql/syntax/sparql-star-syntax-expr-06.rq | 10 -
.../sparql/syntax/sparql-star-syntax-inside-01.rq | 5 -
.../sparql/syntax/sparql-star-syntax-inside-02.rq | 5 -
.../sparql/syntax/sparql-star-syntax-nested-01.rq | 6 -
.../sparql/syntax/sparql-star-syntax-nested-02.rq | 6 -
.../sparql/syntax/sparql-star-syntax-update-1.ru | 5 -
.../sparql/syntax/sparql-star-syntax-update-2.ru | 5 -
.../sparql/syntax/sparql-star-syntax-update-3.ru | 8 -
.../sparql/syntax/sparql-star-syntax-update-4.ru | 8 -
.../sparql/syntax/sparql-star-syntax-update-5.ru | 7 -
.../sparql/syntax/sparql-star-syntax-update-6.ru | 7 -
.../sparql/syntax/sparql-star-syntax-update-7.ru | 7 -
.../sparql/syntax/sparql-star-syntax-update-8.ru | 11 -
.../testing/rdf-star-cg/trig/eval/manifest.ttl | 112 -
.../rdf-star-cg/trig/eval/trig-star-eval-01.nq | 1 -
.../rdf-star-cg/trig/eval/trig-star-eval-01.trig | 3 -
.../rdf-star-cg/trig/eval/trig-star-eval-02.nq | 1 -
.../rdf-star-cg/trig/eval/trig-star-eval-02.trig | 3 -
.../trig/eval/trig-star-eval-annotation-1.nq | 2 -
.../trig/eval/trig-star-eval-annotation-1.trig | 3 -
.../trig/eval/trig-star-eval-annotation-2.nq | 7 -
.../trig/eval/trig-star-eval-annotation-2.trig | 12 -
.../trig/eval/trig-star-eval-annotation-3.nq | 6 -
.../trig/eval/trig-star-eval-annotation-3.trig | 7 -
.../trig/eval/trig-star-eval-annotation-4.nq | 3 -
.../trig/eval/trig-star-eval-annotation-4.trig | 3 -
.../trig/eval/trig-star-eval-annotation-5.nq | 3 -
.../trig/eval/trig-star-eval-annotation-5.trig | 4 -
.../trig/eval/trig-star-eval-bnode-1.nq | 2 -
.../trig/eval/trig-star-eval-bnode-1.trig | 6 -
.../trig/eval/trig-star-eval-bnode-2.nq | 2 -
.../trig/eval/trig-star-eval-bnode-2.trig | 6 -
.../eval/trig-star-eval-quoted-annotation-1.nq | 2 -
.../eval/trig-star-eval-quoted-annotation-1.trig | 3 -
.../eval/trig-star-eval-quoted-annotation-2.nq | 2 -
.../eval/trig-star-eval-quoted-annotation-2.trig | 3 -
.../eval/trig-star-eval-quoted-annotation-3.nq | 2 -
.../eval/trig-star-eval-quoted-annotation-3.trig | 3 -
.../testing/rdf-star-cg/trig/syntax/manifest.ttl | 175 --
.../trig/syntax/trig-star-annotation-1.trig | 3 -
.../trig/syntax/trig-star-annotation-2.trig | 12 -
.../trig/syntax/trig-star-syntax-bad-01.trig | 6 -
.../trig/syntax/trig-star-syntax-bad-02.trig | 6 -
.../trig/syntax/trig-star-syntax-bad-03.trig | 6 -
.../trig/syntax/trig-star-syntax-bad-04.trig | 6 -
.../trig/syntax/trig-star-syntax-bad-05.trig | 5 -
.../trig/syntax/trig-star-syntax-bad-06.trig | 5 -
.../trig/syntax/trig-star-syntax-bad-07.trig | 4 -
.../trig/syntax/trig-star-syntax-bad-08.trig | 3 -
.../trig/syntax/trig-star-syntax-bad-ann-1.trig | 4 -
.../trig/syntax/trig-star-syntax-bad-ann-2.trig | 3 -
.../trig/syntax/trig-star-syntax-basic-01.trig | 6 -
.../trig/syntax/trig-star-syntax-basic-02.trig | 6 -
.../trig/syntax/trig-star-syntax-bnode-01.trig | 6 -
.../trig/syntax/trig-star-syntax-bnode-02.trig | 6 -
.../trig/syntax/trig-star-syntax-bnode-03.trig | 3 -
.../trig/syntax/trig-star-syntax-compound.trig | 12 -
.../trig/syntax/trig-star-syntax-inside-01.trig | 6 -
.../trig/syntax/trig-star-syntax-inside-02.trig | 7 -
.../trig/syntax/trig-star-syntax-nested-01.trig | 9 -
.../trig/syntax/trig-star-syntax-nested-02.trig | 7 -
.../testing/rdf-star-cg/turtle/eval/manifest.ttl | 113 -
.../rdf-star-cg/turtle/eval/turtle-star-eval-01.nt | 1 -
.../rdf-star-cg/turtle/eval/turtle-star-eval-02.nt | 1 -
.../turtle/eval/turtle-star-eval-02.ttl | 3 -
.../turtle/eval/turtle-star-eval-annotation-1.nt | 2 -
.../turtle/eval/turtle-star-eval-annotation-1.ttl | 3 -
.../turtle/eval/turtle-star-eval-annotation-2.nt | 7 -
.../turtle/eval/turtle-star-eval-annotation-2.ttl | 10 -
.../turtle/eval/turtle-star-eval-annotation-3.nt | 6 -
.../turtle/eval/turtle-star-eval-annotation-3.ttl | 5 -
.../turtle/eval/turtle-star-eval-annotation-4.nt | 3 -
.../turtle/eval/turtle-star-eval-annotation-4.ttl | 3 -
.../turtle/eval/turtle-star-eval-annotation-5.nt | 3 -
.../turtle/eval/turtle-star-eval-annotation-5.ttl | 4 -
.../turtle/eval/turtle-star-eval-bnode-1.nt | 2 -
.../turtle/eval/turtle-star-eval-bnode-1.ttl | 4 -
.../turtle/eval/turtle-star-eval-bnode-2.nt | 2 -
.../turtle/eval/turtle-star-eval-bnode-2.ttl | 4 -
.../eval/turtle-star-eval-quoted-annotation-1.nt | 2 -
.../eval/turtle-star-eval-quoted-annotation-1.ttl | 3 -
.../eval/turtle-star-eval-quoted-annotation-2.nt | 2 -
.../eval/turtle-star-eval-quoted-annotation-2.ttl | 3 -
.../eval/turtle-star-eval-quoted-annotation-3.nt | 2 -
.../eval/turtle-star-eval-quoted-annotation-3.ttl | 3 -
.../testing/rdf-star-cg/turtle/syntax/manifest.ttl | 268 --
.../turtle/syntax/nt-ttl-star-bad-syntax-1.ttl | 1 -
.../turtle/syntax/nt-ttl-star-bad-syntax-2.ttl | 1 -
.../turtle/syntax/nt-ttl-star-bad-syntax-3.ttl | 1 -
.../turtle/syntax/nt-ttl-star-bad-syntax-4.ttl | 1 -
.../turtle/syntax/nt-ttl-star-bnode-1.ttl | 2 -
.../turtle/syntax/nt-ttl-star-bnode-2.ttl | 2 -
.../turtle/syntax/nt-ttl-star-nested-1.ttl | 3 -
.../turtle/syntax/nt-ttl-star-nested-2.ttl | 3 -
.../turtle/syntax/nt-ttl-star-syntax-1.ttl | 1 -
.../turtle/syntax/nt-ttl-star-syntax-2.ttl | 1 -
.../turtle/syntax/nt-ttl-star-syntax-3.ttl | 1 -
.../turtle/syntax/nt-ttl-star-syntax-4.ttl | 1 -
.../turtle/syntax/nt-ttl-star-syntax-5.ttl | 1 -
.../turtle/syntax/turtle-star-annotation-1.ttl | 3 -
.../turtle/syntax/turtle-star-annotation-2.ttl | 10 -
.../turtle/syntax/turtle-star-syntax-bad-01.ttl | 4 -
.../turtle/syntax/turtle-star-syntax-bad-02.ttl | 4 -
.../turtle/syntax/turtle-star-syntax-bad-03.ttl | 4 -
.../turtle/syntax/turtle-star-syntax-bad-04.ttl | 4 -
.../turtle/syntax/turtle-star-syntax-bad-05.ttl | 3 -
.../turtle/syntax/turtle-star-syntax-bad-06.ttl | 4 -
.../turtle/syntax/turtle-star-syntax-bad-07.ttl | 3 -
.../turtle/syntax/turtle-star-syntax-bad-08.ttl | 3 -
.../turtle/syntax/turtle-star-syntax-bad-ann-1.ttl | 6 -
.../turtle/syntax/turtle-star-syntax-bad-ann-2.ttl | 3 -
.../turtle/syntax/turtle-star-syntax-basic-01.ttl | 4 -
.../turtle/syntax/turtle-star-syntax-basic-02.ttl | 4 -
.../turtle/syntax/turtle-star-syntax-bnode-01.ttl | 4 -
.../turtle/syntax/turtle-star-syntax-bnode-02.ttl | 4 -
.../turtle/syntax/turtle-star-syntax-bnode-03.ttl | 3 -
.../turtle/syntax/turtle-star-syntax-compound.ttl | 11 -
.../turtle/syntax/turtle-star-syntax-inside-01.ttl | 4 -
.../turtle/syntax/turtle-star-syntax-inside-02.ttl | 5 -
.../turtle/syntax/turtle-star-syntax-nested-01.ttl | 7 -
.../turtle/syntax/turtle-star-syntax-nested-02.ttl | 5 -
.../testing/rdf12-wg/Syntax-SPARQL_12/manifest.ttl | 43 +
.../Syntax-SPARQL_12/syntax-sparql12-01.rq} | 3 +-
.../Syntax-SPARQL_12/syntax-sparql12-02.rq} | 3 +-
jena-arq/testing/rdf12-wg/gen-sparql-12.sh | 20 +
jena-arq/testing/rdf12-wg/syn-func12.sh | 272 ++
jena-arq/testing/rdf12-wg/syn-sparql_12.sh | 137 +
.../java/org/apache/jena/atlas/io/PeekReader.java | 1 +
.../jena/atlas/iterator/IteratorBlockingQueue.java | 59 +-
.../apache/jena/atlas/iterator/IteratorConcat.java | 4 +-
.../apache/jena/atlas/iterator/IteratorCons.java | 9 +-
.../jena/atlas/iterator/IteratorInteger.java | 63 -
.../apache/jena/atlas/iterator/NullIterator.java | 2 +
.../jena/atlas/iterator/SingletonIterator.java | 35 +-
jena-cmds/src/main/java/riotcmd/utf8.java | 1 -
.../jena/datatypes/xsd/impl/RDFDirLangString.java | 2 +-
.../jena/datatypes/xsd/impl/RDFLangString.java | 2 +-
.../java/org/apache/jena/enhanced/EnhNode.java | 4 +-
.../src/main/java/org/apache/jena/graph/Node.java | 22 +-
.../java/org/apache/jena/graph/NodeFactory.java | 75 +-
.../java/org/apache/jena/graph/Node_Literal.java | 6 +-
.../java/org/apache/jena/graph/Node_Triple.java | 6 +-
.../java/org/apache/jena/graph/TextDirection.java | 31 +-
.../org/apache/jena/graph/impl/LiteralLabel.java | 30 +-
.../jena/graph/impl/LiteralLabelFactory.java | 4 +-
.../java/org/apache/jena/rdf/model/Literal.java | 10 +-
.../main/java/org/apache/jena/rdf/model/Model.java | 12 +-
.../java/org/apache/jena/rdf/model/ModelCon.java | 95 +-
.../java/org/apache/jena/rdf/model/Resource.java | 1 -
.../apache/jena/rdf/model/impl/LiteralImpl.java | 4 +-
.../org/apache/jena/rdf/model/impl/ModelCom.java | 44 +-
.../apache/jena/rdf/model/impl/ResourceImpl.java | 4 +-
.../java/org/apache/jena/rdf/model/impl/Util.java | 10 +-
.../jena/rdfxml/xmloutput/impl/RDFXML_Basic.java | 4 +
.../jena/rdfxml/xmloutput/impl/Unparser.java | 7 +-
.../org/apache/jena/util/PrefixMappingUtils.java | 4 +-
.../main/java/org/apache/jena/vocabulary/RDF.java | 15 +-
.../java/org/apache/jena/graph/test/TestNode.java | 2 +-
.../apache/jena/graph/test/TestNodeEdgeCases.java | 2 +-
.../org/apache/jena/graph/test/TestNodeExtras.java | 37 +-
.../jena/graph/test/TestRDFStringLiterals.java | 65 +-
.../arq/querybuilder/handlers/WhereHandler.java | 16 +-
.../rewriters/BuildElementVisitor.java | 20 +-
.../querybuilder/rewriters/ElementRewriter.java | 12 +
.../arq/querybuilder/rewriters/ExprRewriter.java | 4 +-
.../querybuilder/rewriters/NodeValueRewriter.java | 19 +-
.../arq/querybuilder/rewriters/OpRewriter.java | 21 +-
.../updatebuilder/QuadIteratorBuilder.java | 11 +
.../updatebuilder/WhereQuadHolder.java | 12 +-
.../jena/arq/querybuilder/ConvertersTest.java | 2 +-
.../jena/arq/querybuilder/ExprFactoryTest.java | 2 +-
.../jena/arq/querybuilder/WhereValidator.java | 16 +
.../arq/querybuilder/clauses/ValuesClauseTest.java | 2 +-
.../permissions/model/impl/SecuredLiteralImpl.java | 4 +-
.../permissions/model/impl/SecuredModelImpl.java | 66 +-
.../permissions/query/rewriter/OpRewriter.java | 30 +-
.../rdfpatch/binary/RDFChangesWriterBinary.java | 2 +-
.../jena/rdfpatch/binary/RDFPatchReaderBinary.java | 2 +-
.../jena/rdfpatch/text/RDFPatchReaderText.java | 12 +-
.../apache/jena/rdfpatch/text/TokenWriterText.java | 109 -
.../apache/jena/rdfpatch/AbstractTestPatchIO.java | 4 +-
jena-rdfpatch/testing/files/syntax-bad-1.rdfp | 5 -
.../java/org/apache/jena/tdb1/lib/DumpOps.java | 212 +-
.../org/apache/jena/tdb1/solver/BindingTDB.java | 17 +-
.../java/org/apache/jena/tdb1/store/NodeType.java | 2 +-
.../jena/tdb1/store/nodetable/DecoderSSE.java | 8 +-
.../jena/tdb1/store/nodetable/NodeTableInline.java | 57 +-
.../apache/jena/tdb1/store/nodetable/NodecSSE.java | 4 +-
.../java/org/apache/jena/tdb1/Scripts_TDB1.java | 5 +-
.../org/apache/jena/tdb1/store/TestQuadFilter.java | 14 +-
.../store/nodetable/AbstractTestNodeTable.java | 7 +-
.../jena/tdb1/store/nodetable/TestNodec.java | 2 +-
.../java/org/apache/jena/tdb2/lib/DumpOps.java | 169 ++
.../java/org/apache/jena/tdb2/lib/NodeLib.java | 2 +-
.../jena/tdb2/store/nodetable/NodeTableOps.java | 3 -
.../java/org/apache/jena/tdb2/Scripts_TDB2.java | 5 +-
.../org/apache/jena/tdb2/store/TestQuadFilter.java | 19 +-
.../store/nodetable/AbstractTestNodeTable.java | 6 +-
.../apache/jena/query/text/TextIndexLucene.java | 4 +-
595 files changed, 15141 insertions(+), 14107 deletions(-)
diff --git a/jena-arq/Grammar/.gitignore b/jena-arq/Grammar/.gitignore
index d1648fbab9..a786afe999 100644
--- a/jena-arq/Grammar/.gitignore
+++ b/jena-arq/Grammar/.gitignore
@@ -9,5 +9,7 @@ Y12.html
sparql-grammar.html
# Grammar in BNF text
sparql.bnf
-# Grammar in HTML as a standalone web page.
+## BNF
+sparql.bnf
+## Grammar in HTML as a standalone web page.
sparql-html.html
diff --git a/jena-arq/Grammar/RDF-Protobuf/binary-rdf.proto b/jena-arq/Grammar/RDF-Protobuf/binary-rdf.proto
index 96cb29a503..76bc9121ea 100644
--- a/jena-arq/Grammar/RDF-Protobuf/binary-rdf.proto
+++ b/jena-arq/Grammar/RDF-Protobuf/binary-rdf.proto
@@ -55,7 +55,8 @@ message RDF_Literal {
string lex = 1 ;
oneof literalKind {
bool simple = 9 ;
- string langtag = 2 ;
+ string langtag = 2 ; // Language tag only literal
+ string langdir = 5 ; // Language tag and base direction separated by "--"
string datatype = 3 ;
RDF_PrefixName dtPrefix = 4 ;
}
diff --git a/jena-arq/Grammar/RDF-Thrift/BinaryRDF.thrift b/jena-arq/Grammar/RDF-Thrift/BinaryRDF.thrift
index 460b72e09b..60b6e7d088 100644
--- a/jena-arq/Grammar/RDF-Thrift/BinaryRDF.thrift
+++ b/jena-arq/Grammar/RDF-Thrift/BinaryRDF.thrift
@@ -44,8 +44,10 @@ struct RDF_BNode {
// union with additional values.
struct RDF_Literal {
+// Keep this numbering.
1: required string lex ;
2: optional string langtag ;
+5: optional string baseDirection ;
3: optional string datatype ; // Either 3 or 4 but UNION is heavy.
4: optional RDF_PrefixName dtPrefix ; // datatype as prefix name
}
diff --git a/jena-arq/Grammar/RDF-Thrift/gen-thrift b/jena-arq/Grammar/RDF-Thrift/gen-thrift
index fff4df6690..87daf52ca8 100755
--- a/jena-arq/Grammar/RDF-Thrift/gen-thrift
+++ b/jena-arq/Grammar/RDF-Thrift/gen-thrift
@@ -1,11 +1,11 @@
#!/bin/bash
## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
-if [ "$#" != 1 ]
-then
- echo "Usage: $(basename $0) FILE" 2>&1
- exit 1
-fi
+## if [ "$#" != 1 ]
+## then
+## echo "Usage: $(basename $0) FILE" 2>&1
+## exit 1
+## fi
# Find the namespace
PKG=../../src/main/java/org/apache/jena/riot/thrift/wire
@@ -16,7 +16,9 @@ rm -f "$PKG"/*.java
## undated: suppress the date at @Generated annotations
## suppress: suppress @Generated annotations entirely
-thrift -r -out ../../src/main/java -gen 'java:generated_annotations=suppress' "$@"
+THRIFT="${1:-BinaryRDF.thrift}"
+
+thrift -r -out ../../src/main/java -gen 'java:generated_annotations=suppress' "$THRIFT"
for f in "$PKG"/*.java
do
diff --git a/jena-arq/Grammar/README b/jena-arq/Grammar/README
new file mode 100644
index 0000000000..65c77d522a
--- /dev/null
+++ b/jena-arq/Grammar/README
@@ -0,0 +1,31 @@
+==== SPARQL Parser
+
+Run
+
+ grammar
+
+This produces the code for the current version SPARQL
+and the ARQ (SPARQL with extensions) parsers.
+
+==
+
+To produce the HTML for the SPARQL Grammar for the W3C spec:
+produce the SPARQL 1.2 specific file
+
+ grammar
+
+which also generates Java code and can be used for checking.
+
+Then run
+
+ sparql2html
+
+The output is in sparql-grammar.html.
+
+This replaces the table between "<!-- GRAMMAR -->" in the specific HTML.
+
+Running
+
+ sparql2bnf
+
+produces a text BNF form.
diff --git a/jena-arq/Grammar/Turtle/turtle.jj b/jena-arq/Grammar/Turtle/turtle.jj
index 57296a15ed..ca1c11e4ae 100644
--- a/jena-arq/Grammar/Turtle/turtle.jj
+++ b/jena-arq/Grammar/Turtle/turtle.jj
@@ -80,9 +80,9 @@ void Statement() : {}
{
Directive()
| DirectiveOld()
-// | (TriplesSameSubject() (<DOT> | <EOF> ) )
+// | (Triples() (<DOT> | <EOF> ) )
// Strict
- | (TriplesSameSubject() <DOT> )
+ | (Triples() <DOT> )
}
// Turtle [3] directive
@@ -106,17 +106,15 @@ void DirectiveOld() : { Token t ; String iri ; }
{ setBase(iri, t.beginLine, t.beginColumn) ; }
}
-// Turtle [6] triples
-void TriplesSameSubject() : { Node s ; }
+void Triples() : { Node n; }
{
- s = Subject()
- PredicateObjectList(s)
+ n = Subject() PredicateObjectList(n)
|
- s = BlankNodePropertyList()
- ( PredicateObjectList(s) )?
+ n = BlankNodePropertyList() ( PredicateObjectList(n) )?
+|
+ n = ReifiedTriple() ( PredicateObjectList(n) )?
}
-// Turtle [7] predicateObjectList
void PredicateObjectList(Node s) : { Node p = null ; }
{
p = Verb()
@@ -124,7 +122,6 @@ void PredicateObjectList(Node s) : { Node p = null ; }
(<SEMICOLON> (p = Verb() ObjectList(s, p))? )*
}
-// Turtle [8] objectList
void ObjectList(Node s, Node p): { Node o ; }
{
o = Object()
@@ -137,17 +134,6 @@ void ObjectList(Node s, Node p): { Node o ; }
)*
}
-// RDF-star Annotation Syntax
-void Annotation(Node s, Node p, Node o) : {}
-{
- (
- <L_ANN>
- { Node x = createQuotedTriple(s, p, o, token.beginLine, token.beginColumn); }
- PredicateObjectList(x)
- <R_ANN>
- )?
-}
-
// Turtle [9] verb
Node Verb() : { Node p ; }
{
@@ -163,13 +149,10 @@ Node Subject() : { Node s; String iri ; }
s = BlankNode()
|
s = Collection()
- |
- s = QuotedTriple()
)
{ return s ; }
}
-
// Turtle [11] predicate
Node Predicate() : { String iri;}
{
@@ -185,43 +168,12 @@ Node Object(): { Node o ; String iri; }
| o = Collection()
| o = BlankNodePropertyList()
| o = Literal()
- | o = QuotedTriple()
+ | o = TripleTerm()
+ | o = ReifiedTriple()
)
{ return o; }
}
-Node QuotedTripleSubject(): { Node o ; String iri; }
-{
- ( iri = iri() { o = createURI(iri, token.beginLine, token.beginColumn) ; }
- | o = BlankNode()
- | o = QuotedTriple()
- )
- { return o; }
-}
-
-Node QuotedTripleObject(): { Node o ; String iri; }
-{
- ( iri = iri() { o = createURI(iri, token.beginLine, token.beginColumn) ; }
- | o = BlankNode()
- | o = Literal()
- | o = QuotedTriple()
- )
- { return o ; }
-}
-
-// The syntax for RDF-star <<>>
-Node QuotedTriple() : { Node s , p , o ; Token t ; }
-{
- t = <LT2>
- s = QuotedTripleSubject()
- p = Verb()
- o = QuotedTripleObject()
- <GT2>
- { Node n = createQuotedTriple(s, p, o, t.beginLine, t.beginColumn);
- return n;
- }
-}
-
// Turtle [13] literal
Node Literal() : { Node n ;}
{
@@ -302,7 +254,7 @@ Node RDFLiteral() : { Token t ; String lex = null ; }
String LangTag() : { Token t ; }
{
// Enumerate the directives here because they look like language tags.
- ( t = <LANGTAG> | t = AnyDirective() )
+ ( t = <LANG_DIR> | t = AnyDirective() )
{ String lang = stripChars(t.image, 1) ; return lang ; }
}
@@ -369,6 +321,106 @@ String IRIREF() : { Token t ; }
{ return resolveQuotedIRI(t.image, t.beginLine, t.beginColumn) ; }
}
+Node Reifier() : { Node n = null; String iriStr; Token t; }
+{
+ t = <TILDE>
+ (
+ iriStr = iri() { n = createURI(iriStr, token.beginLine, token.beginColumn) ; }
+ | n = BlankNode()
+ )?
+ { if ( n == null ) n = createBNode(t.beginLine, t.beginColumn) ; }
+ { return n ; }
+}
+
+Node ReifiedTriple() : { Node reifId = null ; Token tok ; Node s; Node p ; Node o ; }
+{
+ tok = <LT2>
+ s = ReifiedTripleSubject()
+ p = Verb()
+ o = ReifiedTripleObject()
+ ( reifId = Reifier())?
+ { reifId = emitTripleReifier(tok.beginLine, tok.beginColumn, reifId, s, p, o); }
+ <GT2>
+ { return reifId ; }
+}
+
+// rtSubject
+Node ReifiedTripleSubject() : { Node s; String iri; } {
+ ( iri = iri() { s = createURI(iri, token.beginLine, token.beginColumn) ; }
+ | s = BlankNode()
+ | s = ReifiedTriple()
+ )
+ { return s; }
+}
+
+// rtObject
+Node ReifiedTripleObject() : { Node o; String iri; } {
+ ( iri = iri() { o = createURI(iri, token.beginLine, token.beginColumn) ; }
+ | o = BlankNode()
+ | o = Literal()
+ | o = TripleTerm()
+ | o = ReifiedTriple()
+ )
+ { return o; }
+}
+
+Node TripleTerm() : { Node n = null ; Token openToken ; String iri ; Node s , p , o ; }
+{
+ <L_TRIPLE>
+ s = TripleTermSubject()
+ p = Verb()
+ o = TripleTermObject()
+ <R_TRIPLE>
+ { return createTripleTerm(s, p, o, token.beginLine, token.beginColumn) ; }
+}
+
+// ttSubject
+Node TripleTermSubject(): { Node o ; String iri; }
+{
+ ( iri = iri() { o = createURI(iri, token.beginLine, token.beginColumn) ; }
+ | o = BlankNode()
+ )
+ { return o; }
+}
+
+// ttObject
+Node TripleTermObject(): { Node o ; String iri; }
+{
+ ( iri = iri() { o = createURI(iri, token.beginLine, token.beginColumn) ; }
+ | o = BlankNode()
+ | o = Literal()
+ | o = TripleTerm()
+ )
+ { return o ; }
+}
+
+// RDF-star Annotation Syntax
+void Annotation(Node s, Node p, Node o) : { Node reifId = null; }
+{
+ (
+ reifId = Reifier()
+ { reifId = emitTripleReifier(token.beginLine, token.beginColumn, reifId, s, p, o) ; }
+ { setReifierId(reifId); }
+ |
+ { reifId = getOrAllocReifierId(s, p, o, token.beginLine, token.beginColumn); }
+ { clearReifierId(); }
+ AnnotationBlock(reifId)
+ ) *
+}
+
+void AnnotationBlock( Node reifId ) : {}
+{
+ <L_ANN>
+ PredicateObjectList(reifId)
+ <R_ANN>
+// (
+// <L_ANN>
+// { Node x = createQuotedTriple(s, p, o, token.beginLine, token.beginColumn); }
+// PredicateObjectList(x)
+// <R_ANN>
+// )?
+}
+
// ------------------------------------------
// Tokens
@@ -457,18 +509,23 @@ TOKEN :
| < SEMICOLON: ";" >
| < COMMA: "," >
| < DOT: "." >
+
+| < DATATYPE: "^^">
+| < AT: "@">
+
+| < L_TRIPLE: "<<(" >
+| < R_TRIPLE: ")>>" >
| < LT2: "<<" >
| < GT2: ">>" >
| < L_ANN: "{|" >
| < R_ANN: "|}" >
-
-| < DATATYPE: "^^">
-| < AT: "@">
+| < TILDE: "~" >
+| < VBAR: "|" >
| <PNAME_NS: (<PN_PREFIX>)? ":" >
| <PNAME_LN: <PNAME_NS> <PN_LOCAL> >
| <BLANK_NODE_LABEL: "_:" (<PN_CHARS_U> | ["0"-"9"]) ((<PN_CHARS>|".")* <PN_CHARS>)? >
-| <LANGTAG: <AT> (<A2Z>)+("-" (<A2ZN>)+)* >
+| <LANG_DIR: <AT> (<A2Z>)+("-" (<A2ZN>)+)* ( "--" (<A2Z>)* )? >
| <#A2Z: ["a"-"z","A"-"Z"]>
| <#A2ZN: ["a"-"z","A"-"Z","0"-"9"]>
diff --git a/jena-arq/Grammar/arq.jj b/jena-arq/Grammar/arq.jj
index 9bba04ac77..fcab512796 100644
--- a/jena-arq/Grammar/arq.jj
+++ b/jena-arq/Grammar/arq.jj
@@ -628,6 +628,18 @@ Element TriplesBlock(ElementPathBlock acc) : { }
( <DOT> (TriplesBlock(acc))? )?
{ return acc ; }
}
+Node ReifiedTripleBlock(TripleCollector acc) : { Node reifId ; }
+{
+ reifId = ReifiedTriple(acc)
+ PropertyList(reifId, acc)
+ { return reifId ; }
+}
+Node ReifiedTripleBlockPath(TripleCollector acc) : { Node reifId ; }
+{
+ reifId = ReifiedTriple(acc)
+ PropertyListPath(reifId, acc)
+ { return reifId ; }
+}
Element GraphPatternNotTriples() : { Element el = null ; }
{
(
@@ -636,6 +648,10 @@ Element GraphPatternNotTriples() : { Element el = null ; }
el = OptionalGraphPattern()
|
el = LateralGraphPattern()
+ |
+ el = SemiJoinGraphPattern()
+ |
+ el = AntiJoinGraphPattern()
|
el = MinusGraphPattern()
|
@@ -667,6 +683,14 @@ Element LateralGraphPattern() : { Element el ; }
{ <LATERAL> el = GroupGraphPattern()
{ return new ElementLateral(el) ; }
}
+Element SemiJoinGraphPattern() : { Element el ; }
+{ <SEMIJOIN> el = GroupGraphPattern()
+ { return new ElementSemiJoin(el) ; }
+}
+Element AntiJoinGraphPattern() : { Element el ; }
+{ <ANTIJOIN> el = GroupGraphPattern()
+ { return new ElementAntiJoin(el) ; }
+}
Element GraphGraphPattern() : { Element el ; Node n ;}
{
<GRAPH> n = VarOrIri() el = GroupGraphPattern()
@@ -756,7 +780,20 @@ Node DataBlockValue() : { Node n ; String iri ; }
| n = NumericLiteral() { return n ; }
| n = BooleanLiteral() { return n ; }
| <UNDEF> { return null ; }
-| n = QuotedTripleData() { return n ; }
+| n = TripleTermData() { return n ; }
+}
+Node Reifier() : { Token tok = null ; Node reifId = null ; }
+{
+ tok = <TILDE>
+ (reifId = VarOrReifierId() )?
+ { return reifId; }
+}
+Node VarOrReifierId() : { Node n = null; String iri = null; }
+{
+ ( n = Var() { return n; }
+ | iri = iri() { return createNode(iri) ; }
+ | n = BlankNode() { return n ; }
+ )
}
Element Assignment() : { Var v ; Expr expr ; }
{
@@ -833,7 +870,7 @@ Expr FunctionCall() : { String fname ; Args a ; }
{
if ( AggregateRegistry.isRegistered(fname) ) {
if ( ! getAllowAggregatesInExpressions() )
- throwParseException("Aggregate expression not legal at this point : "+fname, -1, -1) ;
+ throwParseException("Aggregate expression not legal at this point : "+fname, token.beginLine, token.beginColumn) ;
Aggregator agg = AggregatorFactory.createCustom(fname, a) ;
Expr exprAgg = getQuery().allocAggregate(agg) ;
return exprAgg ;
@@ -898,6 +935,8 @@ void TriplesSameSubject(TripleCollector acc) : { Node s ; }
s = TriplesNode(tempAcc)
PropertyList(s, tempAcc)
{ insert(acc, tempAcc) ; }
+|
+ ReifiedTripleBlock(acc)
}
void PropertyList(Node s, TripleCollector acc) : { }
{
@@ -941,6 +980,8 @@ void TriplesSameSubjectPath(TripleCollector acc) : { Node s ; }
s = TriplesNodePath(tempAcc)
PropertyListPath(s, tempAcc)
{ insert(acc, tempAcc) ; }
+|
+ ReifiedTripleBlockPath(acc)
}
void PropertyListPath(Node s, TripleCollector acc) : { }
{
@@ -1059,6 +1100,11 @@ Path PathMod(Path p) : { long i1 ; long i2 ; }
)
)
}
+long Integer() : {Token t ;}
+{
+ t = <INTEGER>
+ { return integerValue(t.image) ; }
+}
Path PathPrimary() : { String str ; Path p ; Node n ; }
{
(
@@ -1109,16 +1155,11 @@ P_Path0 PathOneInPropertySet() : { String str ; Node n ; }
)
)
}
-long Integer() : {Token t ;}
-{
- t = <INTEGER>
- { return integerValue(t.image) ; }
-}
Node TriplesNode(TripleCollectorMark acc) : { Node n ; }
{
- n = Collection(acc) { return n ; }
+ n = Collection(acc) { return n ; }
|
- n = BlankNodePropertyList(acc) { return n ; }
+ n = BlankNodePropertyList(acc) { return n ; }
}
Node BlankNodePropertyList(TripleCollector acc) : { Token t ; }
{
@@ -1130,9 +1171,9 @@ Node BlankNodePropertyList(TripleCollector acc) : { Token t ; }
}
Node TriplesNodePath(TripleCollectorMark acc) : { Node n ; }
{
- n = CollectionPath(acc) { return n ; }
+ n = CollectionPath(acc) { return n ; }
|
- n = BlankNodePropertyListPath(acc) { return n ; }
+ n = BlankNodePropertyListPath(acc) { return n ; }
}
Node BlankNodePropertyListPath(TripleCollector acc) : { Token t ; }
{
@@ -1190,80 +1231,177 @@ Node CollectionPath(TripleCollectorMark acc) :
insert(acc, lastCell, nRDFrest, nRDFnil) ;
return listHead ; }
}
-void AnnotationPath(TripleCollector acc, Node s, Node p, Path path, Node o) : {}
+void AnnotationPath(TripleCollector acc, Node s, Node p, Path path, Node o) : { Node reifId = null ; }
{
(
- <L_ANN>
- { Node pAnn = preConditionAnnotation(s, p, path, o, token.beginLine, token.beginColumn) ;
- Node x = createQuotedTriple(s, pAnn, o, token.beginLine, token.beginColumn);
- }
- PropertyListPathNotEmpty(x, acc)
- <R_ANN>
- )?
+ { p = preConditionReifier(s, p, path, o, token.beginLine, token.beginColumn); }
+ reifId = Reifier()
+ { reifId = insertTripleReifier(acc, reifId, s, p, o, token.beginLine, token.beginColumn) ; }
+ { setReifierId(reifId); }
+ |
+ {
+ p = preConditionReifier(s, p, path, o, token.beginLine, token.beginColumn);
+ reifId = getOrAllocReifierId(acc, s, p, o, token.beginLine, token.beginColumn);
+ }
+ { clearReifierId(); }
+ AnnotationBlockPath(acc, reifId)
+ )*
+ { clearReifierId(); }
+}
+void AnnotationBlockPath(TripleCollector acc, Node reifId) : { }
+{
+ <L_ANN>
+ PropertyListPathNotEmpty(reifId, acc)
+ <R_ANN>
}
-void Annotation(TripleCollector acc, Node s, Node p, Path path, Node o) : { }
+void Annotation(TripleCollector acc, Node s, Node p, Path path, Node o) : { Node reifId = null ; }
{
(
- <L_ANN>
- { Node pAnn = preConditionAnnotation(s, p, path, o, token.beginLine, token.beginColumn) ;
- Node x = createQuotedTriple(s, p, o, token.beginLine, token.beginColumn);
- }
- PropertyListNotEmpty(x, acc)
- <R_ANN>
- )?
+ { p = preConditionReifier(s, p, path, o, token.beginLine, token.beginColumn); }
+ reifId = Reifier()
+ { reifId = insertTripleReifier(acc, reifId, s, p, o, token.beginLine, token.beginColumn) ; }
+ { setReifierId(reifId); }
+ |
+ {
+ p = preConditionReifier(s, p, path, o, token.beginLine, token.beginColumn);
+ reifId = getOrAllocReifierId(acc, s, p, o, token.beginLine, token.beginColumn);
+ }
+ { clearReifierId(); }
+ AnnotationBlock(acc, reifId)
+ )*
+}
+void AnnotationBlock(TripleCollector acc, Node reifId) : { }
+{
+ <L_ANN>
+ PropertyListNotEmpty(reifId, acc)
+ <R_ANN>
}
Node GraphNode(TripleCollectorMark acc) : { Node n ; }
{
- n = VarOrTerm() { return n ; }
+ n = VarOrTerm() { return n ; }
|
- n = TriplesNode(acc) { return n ; }
+ n = TriplesNode(acc) { return n ; }
+ |
+ n = ReifiedTriple(acc) { return n ; }
}
Node GraphNodePath(TripleCollectorMark acc) : { Node n ; }
{
n = VarOrTerm() { return n ; }
- |
+|
n = TriplesNodePath(acc) { return n ; }
+|
+ n = ReifiedTriple(acc) { return n ; }
}
Node VarOrTerm() : { Node n = null ; String iri ; }
{
( n = Var()
| iri = iri() { return createNode(iri) ; }
- | n = RDFLiteral() { return n ; }
- | n = NumericLiteral() { return n ; }
- | n = BooleanLiteral() { return n ; }
- | n = BlankNode() { return n ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = BlankNode()
| <NIL> { return nRDFnil ; }
- | n = QuotedTriple()
-)
- { return n ; }
+ | n = TripleTerm() { return n; }
+ )
+ { return n; }
}
-Node QuotedTriple() : { Node n = null ; Token t ; Node s , p , o ; }
+Node ReifiedTriple(TripleCollector acc) : { Node reifId = null ; Token tok ; Node s; Node p ; Node o ; }
{
- t = <LT2>
- s = VarOrTerm()
+ tok = <LT2>
+ s = ReifiedTripleSubject(acc)
p = Verb()
- o = VarOrTerm()
- { n = createQuotedTriple(s, p, o, t.beginLine, t.beginColumn); }
+ o = ReifiedTripleObject(acc)
+ (reifId = Reifier())?
+ { reifId = insertTripleReifier(acc, reifId, s, p, o, tok.beginLine, tok.beginColumn) ; }
<GT2>
+ { return reifId; }
+}
+Node ReifiedTripleSubject(TripleCollector acc) : { Node s; String iri; }
+{
+ ( s = Var()
+ | iri = iri() { s = createNode(iri) ; }
+ | s = RDFLiteral()
+ | s = NumericLiteral()
+ | s = BooleanLiteral()
+ | s = BlankNode()
+ | s = ReifiedTriple(acc)
+ )
+ { return s; }
+}
+Node ReifiedTripleObject(TripleCollector acc) : { Node o; String iri; }
+{
+ ( o = Var()
+ | iri = iri() { o = createNode(iri) ; }
+ | o = RDFLiteral()
+ | o = NumericLiteral()
+ | o = BooleanLiteral()
+ | o = BlankNode()
+ | o = ReifiedTriple(acc)
+ | o = TripleTerm()
+ )
+ { return o; }
+}
+Node TripleTerm() : { Node n = null ; Token openToken ; String iri ; Node s , p , o ; }
+{
+ openToken = <L_TRIPLE>
+ s = TripleTermSubject()
+ p = Verb()
+ o = TripleTermObject()
+ { n = createTripleTerm(s, p, o, openToken.beginLine, openToken.beginColumn); }
+ <R_TRIPLE>
+ { return n ; }
+}
+Node TripleTermSubject() : { Node n; String iri; }
+{
+ ( n = Var()
+ | iri = iri() { n = createNode(iri) ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = BlankNode()
+ )
{ return n; }
}
-Node QuotedTripleData() : { Node n = null ; Token t ; String iri ; Node s , p , o ; }
+Node TripleTermObject() : { Node n; String iri; }
{
- t = <LT2>
- ( s = DataValueTerm() )
- ( iri = iri() { p = createNode(iri) ; } | <KW_A> { p = nRDFtype ; } )
- ( o = DataValueTerm() )
- { n = createQuotedTriple(s, p, o, t.beginLine, t.beginColumn); }
- <GT2>
+ ( n = Var()
+ | iri = iri() { n = createNode(iri) ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = BlankNode()
+ | n = TripleTerm() { return n; }
+ )
{ return n; }
}
-Node DataValueTerm() : { Node n = null ; String iri ; Node s , p , o ; }
+Node TripleTermData() : { Node n = null ; Token openToken ; String iri ; Node s , p , o ; }
{
- iri = iri() { return createNode(iri) ; }
-| n = RDFLiteral() { return n ; }
-| n = NumericLiteral() { return n ; }
-| n = BooleanLiteral() { return n ; }
-| n = QuotedTripleData() { return n ; }
+ openToken = <L_TRIPLE>
+ s = TripleTermDataSubject()
+ ( iri = iri() { p = createNode(iri) ; } | <KW_A> { p = nRDFtype ; } )
+ o = TripleTermDataObject()
+ { n = createTripleTerm(s, p, o, openToken.beginLine, openToken.beginColumn); }
+ <R_TRIPLE>
+ { return n ; }
+}
+Node TripleTermDataSubject() : { Node n = null; String iri; }
+{
+ ( iri = iri() { n = createNode(iri) ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ )
+ { return n; }
+}
+Node TripleTermDataObject() : { Node n = null; String iri; }
+{
+ ( iri = iri() { n = createNode(iri) ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = TripleTermData()
+ )
+ { return n; }
}
Node VarOrIri() : {Node n = null ; String iri ; }
{
@@ -1401,27 +1539,38 @@ Expr PrimaryExpression() : { Expr expr ; Node n ; }
| n = NumericLiteral() { return asExpr(n) ; }
| n = BooleanLiteral() { return asExpr(n) ; }
| n = Var() { return asExpr(n) ; }
- | n = ExprQuotedTriple() { return asExpr(n) ; }
+ | n = ExprTripleTerm() { return asExpr(n) ; }
)
}
-Node ExprVarOrTerm() : { Node n; String s;}
+Node ExprTripleTerm() : { Token t ; Node s,p,o,n; }
+{
+ t = <L_TRIPLE>
+ s = ExprTripleTermSubject()
+ p = Verb()
+ o = ExprTripleTermObject()
+ { n = createTripleTerm(s, p, o, t.beginLine, t.beginColumn); }
+ <R_TRIPLE>
+ { return n; }
+}
+Node ExprTripleTermSubject() : { Node n; String iri; }
{
- ( s = iri() { n = createNode(s); }
+ ( iri = iri() { n = createNode(iri); }
| n = RDFLiteral()
| n = NumericLiteral()
| n = BooleanLiteral()
| n = Var()
- | n = ExprQuotedTriple()
)
{ return n; }
}
-Node ExprQuotedTriple() : { Token t ; Node s,p,o,n; }
-{ t = <LT2>
- s = ExprVarOrTerm()
- p = Verb()
- o = ExprVarOrTerm()
- { n = createQuotedTriple(s, p, o, t.beginLine, t.beginColumn); }
- <GT2>
+Node ExprTripleTermObject() : { Node n; String iri; }
+{
+ ( iri = iri() { n = createNode(iri); }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = Var()
+ | n = ExprTripleTerm()
+ )
{ return n; }
}
Expr BrackettedExpression() : { Expr expr ; }
@@ -1441,6 +1590,8 @@ Expr BuiltInCall() : { Expr expr ;
| <LANGMATCHES>
<LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <RPAREN>
{ return new E_LangMatches(expr1, expr2) ; }
+ | <LANGDIR> <LPAREN> expr = Expression() <RPAREN>
+ { return new E_LangDir(expr) ; }
| <DTYPE> <LPAREN> expr = Expression() <RPAREN>
{ return new E_Datatype(expr) ; }
| <BOUND> <LPAREN> gn = Var() <RPAREN>
@@ -1514,6 +1665,10 @@ Expr BuiltInCall() : { Expr expr ;
{ return new E_Conditional(expr, expr1, expr2) ; }
| <STRLANG> <LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <RPAREN>
{ return new E_StrLang(expr1, expr2) ; }
+ | <STRLANGDIR> <LPAREN> expr1 = Expression() <COMMA>
+ expr2 = Expression() <COMMA>
+ expr3 = Expression() <RPAREN>
+ { return new E_StrLangDir(expr1, expr2, expr3) ; }
| <STRDT> <LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <RPAREN>
{ return new E_StrDatatype(expr1, expr2) ; }
| <SAME_TERM> <LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <RPAREN>
@@ -1528,13 +1683,19 @@ Expr BuiltInCall() : { Expr expr ;
{ return new E_IsLiteral(expr) ; }
| <IS_NUMERIC> <LPAREN> expr = Expression() <RPAREN>
{ return new E_IsNumeric(expr) ; }
+ | <HAS_LANG> <LPAREN> expr = Expression() <RPAREN>
+ { return new E_HasLang(expr) ; }
+ | <HAS_LANGDIR> <LPAREN> expr = Expression() <RPAREN>
+ { return new E_HasLangDir(expr) ; }
|
expr = RegexExpression() { return expr ; }
| expr = ExistsFunc() { return expr ; }
| expr = NotExistsFunc() { return expr ; }
-| <IS_TRIPLE> <LPAREN> expr = Expression() <RPAREN>
+ | <IS_TRIPLE> <LPAREN> expr = Expression() <RPAREN>
{ return new E_IsTriple(expr) ; }
- | <TRIPLE> <LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <COMMA> expr3 = Expression() <RPAREN>
+ | <TRIPLE> <LPAREN> expr1 = Expression() <COMMA>
+ expr2 = Expression() <COMMA>
+ expr3 = Expression() <RPAREN>
{ return new E_TripleFn(expr1, expr2, expr3) ; }
| <SUBJECT> <LPAREN> expr = Expression() <RPAREN>
{ return new E_TripleSubject(expr) ; }
@@ -1689,7 +1850,7 @@ Expr iriOrFunction() : { String iri ; Args a = null ; }
return asExpr(createNode(iri)) ;
if ( AggregateRegistry.isRegistered(iri) ) {
if ( ! getAllowAggregatesInExpressions() )
- throwParseException("Aggregate expression not legal at this point : "+iri, -1, -1) ;
+ throwParseException("Aggregate expression not legal at this point : "+iri, token.beginLine, token.beginColumn) ;
Aggregator agg = AggregatorFactory.createCustom(iri, a) ;
Expr exprAgg = getQuery().allocAggregate(agg) ;
return exprAgg ;
@@ -1697,16 +1858,17 @@ Expr iriOrFunction() : { String iri ; Args a = null ; }
return new E_Function(iri, a) ;
}
}
-Node RDFLiteral() : { Token t ; String lex = null ; }
+Node RDFLiteral() : { Token t ; String lex = null ; String uri = null ; }
{
lex = String()
- { String lang = null ; String uri = null ; }
(
- ( t = <LANGTAG> { lang = stripChars(t.image, 1) ; } )
+ t = <LANG_DIR>
+ { return createLiteralLang(lex, t.image, token.beginLine, token.beginColumn); }
|
- ( <DATATYPE> uri = iri() )
+ <DATATYPE> uri = iri()
+ { return createLiteralDT(lex, uri, token.beginLine, token.beginColumn); }
)?
- { return createLiteral(lex, lang, uri) ; }
+ { return createLiteralString(lex, token.beginLine, token.beginColumn) ; }
}
Node NumericLiteral() : { Node n ; }
{
@@ -1802,7 +1964,7 @@ TOKEN:
| <BLANK_NODE_LABEL: "_:" (<PN_CHARS_U> | ["0"-"9"]) ((<PN_CHARS>|".")* <PN_CHARS>)? >
| <VAR1: "?" <VARNAME> >
| <VAR2: "$" <VARNAME> >
-| <LANGTAG: <AT> (<A2Z>)+("-" (<A2ZN>)+)* >
+| <LANG_DIR: <AT> (<A2Z>)+("-" (<A2ZN>)+)* ( "--" (<A2Z>)* )? >
| <#A2Z: ["a"-"z","A"-"Z"]>
| <#A2ZN: ["a"-"z","A"-"Z","0"-"9"]>
}
@@ -1837,7 +1999,9 @@ TOKEN [IGNORE_CASE] :
| < BIND: "bind" >
| < SERVICE: "service" >
| < LET: "LET" >
-| < LATERAL: "LATERAL" >
+| < LATERAL: "lateral" >
+| < SEMIJOIN: "semijoin" >
+| < ANTIJOIN: "antijoin" >
| < UNFOLD: "unfold" >
| < TRIPLE: "TRIPLE" >
| < IS_TRIPLE: "isTRIPLE" >
@@ -1881,15 +2045,19 @@ TOKEN [IGNORE_CASE] :
| < SHORTEST: "shortest" >
| < STR: "str" >
| < STRLANG: "strlang" >
+| < STRLANGDIR: "strlangdir" >
| < STRDT: "strdt" >
| < DTYPE: "datatype" >
| < LANG: "lang" >
| < LANGMATCHES: "langmatches" >
+| < LANGDIR: "langdir" >
| < IS_URI: "isURI" >
| < IS_IRI: "isIRI" >
| < IS_BLANK: "isBlank" >
| < IS_LITERAL: "isLiteral" >
| < IS_NUMERIC: "isNumeric" >
+| < HAS_LANG: "hasLang" >
+| < HAS_LANGDIR: "hasLangDir" >
| < REGEX: "regex" >
| < SAME_TERM: "sameTerm" >
| < RAND: "RAND" >
@@ -2014,12 +2182,14 @@ TOKEN :
| < LT: "<" >
| < LE: "<=" >
| < GE: ">=" >
-| < GT2: ">>" >
+| < L_TRIPLE: "<<(" >
+| < R_TRIPLE: ")>>" >
| < LT2: "<<" >
-| <L_ANN: "{|" >
-| <R_ANN: "|}" >
-| < BANG: "!" >
+| < GT2: ">>" >
+| < L_ANN: "{|" >
+| < R_ANN: "|}" >
| < TILDE: "~" >
+| < BANG: "!" >
| < COLON: ":" >
| < SC_OR: "||" >
| < SC_AND: "&&" >
diff --git a/jena-arq/Grammar/grammar b/jena-arq/Grammar/grammar
index 08e07f7783..92696e0d1d 100755
--- a/jena-arq/Grammar/grammar
+++ b/jena-arq/Grammar/grammar
@@ -42,6 +42,7 @@ function grammar
## echo "---- Create HTML"
## jjdoc -OUTPUT_FILE=${FILE%%.jj}.html "${FILE}"
+
echo "---- Create text form"
jjdoc -TEXT=true -OUTPUT_FILE=${FILE%%.jj}.txt "${FILE}"
diff --git a/jena-arq/Grammar/jj2bnf b/jena-arq/Grammar/jj2bnf
new file mode 100755
index 0000000000..0403e6e7dc
--- /dev/null
+++ b/jena-arq/Grammar/jj2bnf
@@ -0,0 +1,302 @@
+#!/usr/bin/perl
+## 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
+##
+## http://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.
+
+## TODO (2024)
+## [ ] Why does ruleBodyStr have a newline?
+
+## Consider rewriting, preserving the inlining.
+## Parse lines (and continuation lines). Fixup.
+
+# Grammar into BNF text
+# Reads in sparql.txt and the tokens.txt file
+
+if ( $#ARGV != 1 )
+{
+ print STDERR "Usage: grammar.txt tokens.txt\n" ;
+ exit 1 ;
+}
+
+$/ = undef ;
+# Just table or full page.
+
+$grammarFile = $ARGV[0] ;
+$tokensFile = $ARGV[1] ;
+
+$grammar = &readFile($grammarFile) ;
+$tokens = &readFile($tokensFile) ;
+
+$grammar =~ s!DOCUMENT START!! ;
+# $grammar =~ s!NON-TERMINALS!! ;
+$grammar =~ s!DOCUMENT END!! ;
+$grammar =~ s!TOKENS.*NON-TERMINALS!!s ;
+
+$grammar =~ s!//.*!!g ;
+$grammar =~ s!\r!!g ;
+
+# remove leading whitespace
+$grammar =~ s!^[\n\s]*!\n! ;
+
+# Merge alts
+$grammar =~ s!\n\s*\|!\ |!g ;
+
+$tokens =~ s!//.*!!g ;
+$tokens =~ s!\r!!g ;
+
+
+## Grammar
+
+@g = split(/\n\s*/, $grammar) ;
+
+@rules = () ;
+%ruleMap = () ;
+%tokenMap = () ;
+%inline = () ;
+
+# Grammar rules
+# Direct from "jjdoc -TEXT=true"
+
+for $g (@g) {
+ ($rulename, $rulebody) = split(/:=/,$g) ;
+
+ $rulename =~ s!^\s*!! ;
+ $rulename =~ s!\s*$!! ;
+
+ $rulebody =~ s!^\s*!! ;
+ $rulebody =~ s!\s*$!! ;
+
+ # Remove outer brackets
+# $rulebody =~ s!^\((.*)\)$!$1! ;
+
+ next if $rulename eq '' ;
+
+ push @rules, $rulename ;
+ warn "Duplicate rule (grammar): $rulename\n" if defined($ruleMap{$rulename}) ;
+ $ruleMap{$rulename} = $rulebody ;
+
+## print "----------\n" ;
+## print $rulename,"\n" ;
+## print $rulebody,"\n" ;
+}
+
+# Tokens
+# Produced by "jj2tokens"
+# Hand edited to indicate the inlines
+
+$tokens =~ s/\n+/\n/g ;
+$tokens =~ s/^\n// ;
+
+@t = split(/\n(?=\<|\[)/, $tokens) ;
+
+for $t (@t) {
+ ($tokenname,$tokenbody) = split(/::=/, $t) ;
+ $tokenname =~ s!^\s*!! ;
+ $tokenname =~ s!\s*$!! ;
+ $tokenname =~ s/#// ;
+
+ $tokenbody =~ s!^\s*!! ;
+ $tokenbody =~ s!\s*$!! ;
+
+ # Inline?
+ if ( $tokenname =~ /^\[\<\w*\>\]/ ) {
+ warn "Duplicate inline (token): $tokenname\n" if defined($inline{$tokenname}) ;
+ $tokenname =~ s/^\[//g ;
+ $tokenname =~ s/\]$//g ;
+ $tokenbody =~ s/"/'/g ; # '" -- But not literal " -- how?
+ $tokenbody =~ s/\<\>\'\{\}/\<\>\"\{\}/ ; # '" IRI fixup
+ $inline{$tokenname} = $tokenbody ;
+
+ #print "INLINE: ",$tokenname," => ",$tokenbody,"\n" ;
+ } else {
+ ## Remove < > aroudn a token name.
+ my $inlinePlain = $tokenname ;
+ $inlinePlain =~ s%^<%%;
+ $inlinePlain =~ s%>$%%;
+ $inline{$tokenname} = $inlinePlain ;
+ push @rules, $tokenname ;
+ warn "Duplicate rule (token): $tokenname\n" if defined($tokenMap{$tokenname}) ;
+ $ruleMap{$tokenname} = $tokenbody ;
+ }
+}
+
+$ruleNum = 0 ;
+
+for $r (@rules) {
+ $DEBUG = 0 ;
+ $ruleNum++ ;
+ $rulename = $r ;
+ $rulebody = $ruleMap{$rulename} ;
+
+ if ( $DEBUG ) {
+ print STDERR "\n" ;
+ print STDERR "Rule: $rulename\n" ;
+ print STDERR "Body: $rulebody\n" ;
+ }
+
+ $ruleBodyStr = $rulebody ;
+## # Escape HTML chars before adding markup.
+# $ruleBodyStr = esc($ruleBodyStr) ;
+
+ # Inlines
+ for $k (keys %inline) {
+## $s = esc($inline{$k}) ;
+## $k = esc($k) ;
+## # Assumes escaped <> round tokens.
+## $k = quotemeta $k ;
+## $ruleBodyStr =~ s/$k/$s/g ;
+
+ $s = $inline{$k};
+ $ruleBodyStr =~ s/$k/$s/g ;
+ }
+
+ if ( $DEBUG ) {
+ print STDERR "After inlining\n" ;
+ print STDERR $ruleBodyStr,"\n" ; ;
+ }
+
+ # Add hrefs - issue if one is a substring of another \W helps.
+
+ #exit if $ruleNum > 2 ;
+
+ ##$ruleId = sane("r".$rulename) ;
+
+ if($rulename eq 'IRIREF') {
+ print "\n";
+ print "\@terminals\n";
+ print "\n" ;
+ }
+ ## First part of output.
+ ## $rlabel = '[' . $ruleNum . ']' ;
+
+ $rn = $rulename;
+ $rn =~ s!^<!!;
+ $rn =~ s!>$!!;
+ ## Second part of output
+
+ ## Third part of the output.
+ $ruleBodyStr = fixupRule($rulename, $ruleBodyStr) ;
+
+ ##Why no NL needed?
+ ## printf "%-5s %-25s ::= %s\n", $rlabel, $rn, $ruleBodyStr ;
+ printf "%-25s ::= %s\n", $rn, $ruleBodyStr ;
+
+# $rule{$rulename, $rulebody) ;
+# print $rulename , "\n" ;
+}
+
+sub readFile {
+ my $f = $_[0] ;
+ open(F, "$f") || die "$f: $!";
+ my $s = <F> ;
+ return $s ;
+}
+
+sub esc {
+ my $s = $_[0] ;
+ $s =~ s/&/&/g ;
+ $s =~ s/</</g ;
+ $s =~ s/>/>/g ;
+ return $s ;
+}
+
+sub sane {
+ my $a = $_[0] ;
+ $a =~ s/\W//g ;
+ return $a ;
+}
+
+sub fixupRule {
+ my $head = $_[0] ;
+ my $body = $_[1] ;
+
+ # Remove unnecessary ()
+ $body =~ s/\(\s*([^()| ]*) \)/$1/g ;
+
+ # Remove outer matching () where there are no inner ()
+ $body =~ s/^\(\s+([^\(]*)\s+\)$/$1/ ;
+
+ # There aren't any of these
+## $body =~ s!\(\s+(\S*)\s+\)!$1!g ;
+
+ # Remove <> around tokens.
+ $body =~ s/<(\w+)>/$1/g ;
+
+ # Specials
+ # Split long bodies
+ if ( $head eq "CallExpression" ||
+ $head eq "UnaryExpression" ||
+ $head eq "<PN_CHARS_BASE>" ||
+ $head eq "PatternElement" ||
+ $head eq "BuiltInCall" ||
+ $head eq "Aggregate" )
+ {
+ ## Except BNODE, STRLEN etc
+ ## [138] RegexExpression ::= 'REGEX' '(' Expression ',' Expression ( ',' Expression )? ')'
+ ## [139] SubstringExpression ::= 'SUBSTR' '(' Expression ',' Expression ( ',' Expression )? ')'
+ ## [140] StrReplaceExpression ::= 'REPLACE' '(' Expression ',' Expression ',' Expression ( ',' Expression )? ')'
+ ## [141] ExistsFunc ::= 'EXISTS' GroupGraphPattern
+ ## [142] NotExistsFunc ::= 'NOT' 'EXISTS' GroupGraphPattern
+ ## | 'BNODE' ( '(' Expression ')' | <NIL> )
+
+ print STDERR "A:",$body,"\n" if $p ;
+
+ ## Fix up for BNODE that uses "|" - put in marker.
+ $body =~ s%'BNODE' \( '\(' Expression '\)' \| \<NIL\> \)%XXX-BNODE-XXX%;
+
+ ## | followed by <NIL>
+ $body =~ s%\|\s*%\n | %g ;
+
+ ## Replace marker
+ $body =~ s%XXX-BNODE-XXX%'BNODE' \( '(' Expression ')' \| \<NIL\> \)%;
+ }
+
+ if ( $head eq "Aggregate" )
+ {
+ # Strip outer ()
+ $body =~ s/^\(\s*(.*)\s*\)$/$1/ ;
+ $body =~ s/^\s+// ;
+ }
+
+ # These failed the outer () test because they have nested () in them
+ if ( $head eq "QueryPattern" ||
+ $head eq "OrderCondition" )
+ {
+ # Remove outer ()
+ $body =~ s/^\((.*)\)$/$1/ ;
+ }
+
+ ## Split?
+## if ( $head eq "Query" )
+## {
+## }
+
+ #Rules where an outer () is unnecessary.
+ if ( $head eq "GroupCondition" ||
+ $head eq "LimitOffsetClauses" ||
+ $head eq "GraphOrDefault" ||
+ $head eq "ArgList" ||
+ $head eq "ExpressionList" ||
+ $head eq "PathPrimary" ||
+ $head eq "PathMod" ||
+ $head eq "PathPrimary" ||
+ $head eq "PathNegatedPropertySet" ||
+ $head eq "PathOneInPropertySet")
+ {
+ $body =~ s/^\(\s*(.*)\s*\)$/$1/ ;
+ }
+
+ return $body ;
+}
diff --git a/jena-arq/Grammar/main.jj b/jena-arq/Grammar/main.jj
index c2e017982b..19e2e62285 100644
--- a/jena-arq/Grammar/main.jj
+++ b/jena-arq/Grammar/main.jj
@@ -216,10 +216,6 @@ void SelectClause() : { Var v ; Expr expr ; Node n ; }
| n = NumericLiteral() { getQuery().addResultVar((Var)null, NodeValue.makeNode(n)) ; }
| n = BooleanLiteral() { getQuery().addResultVar((Var)null, NodeValue.makeNode(n)) ; }
)
- // @@ PROBLEMS: expr = FunctionCall()
- // <uri>(?x)
- // looks like a function call and also a "<uri> ( ?v )"
- //| expr = FunctionCall() { getQuery().addResultVar((Var)null, expr) ; }
|
#endif
// Expressions with ()
@@ -893,21 +889,35 @@ Element TriplesBlock(ElementPathBlock acc) : { }
{ return acc ; }
}
+Node ReifiedTripleBlock(TripleCollector acc) : { Node reifId ; }
+{
+ reifId = ReifiedTriple(acc)
+ PropertyList(reifId, acc) // Maybe empty
+ { return reifId ; }
+}
+
+Node ReifiedTripleBlockPath(TripleCollector acc) : { Node reifId ; }
+{
+ reifId = ReifiedTriple(acc)
+ PropertyListPath(reifId, acc) // Maybe empty
+ { return reifId ; }
+}
+
// -----
Element GraphPatternNotTriples() : { Element el = null ; }
{
(
-// el = GroupGraphPattern()
-// |
-// el = UnionGraphPattern()
-// |
el = GroupOrUnionGraphPattern()
|
el = OptionalGraphPattern()
#ifdef ARQ
|
el = LateralGraphPattern()
+ |
+ el = SemiJoinGraphPattern()
+ |
+ el = AntiJoinGraphPattern()
#endif
|
el = MinusGraphPattern()
@@ -947,6 +957,16 @@ Element LateralGraphPattern() : { Element el ; }
{ <LATERAL> el = GroupGraphPattern()
{ return new ElementLateral(el) ; }
}
+
+Element SemiJoinGraphPattern() : { Element el ; }
+{ <SEMIJOIN> el = GroupGraphPattern()
+ { return new ElementSemiJoin(el) ; }
+}
+
+Element AntiJoinGraphPattern() : { Element el ; }
+{ <ANTIJOIN> el = GroupGraphPattern()
+ { return new ElementAntiJoin(el) ; }
+}
#endif
Element GraphGraphPattern() : { Element el ; Node n ;}
@@ -1045,8 +1065,49 @@ Node DataBlockValue() : { Node n ; String iri ; }
| n = NumericLiteral() { return n ; }
| n = BooleanLiteral() { return n ; }
| <UNDEF> { return null ; }
-| n = QuotedTripleData() { return n ; }
+| n = TripleTermData() { return n ; }
+
+}
+
+// ---- Reifier, various cases.
+// May return null.
+
+Node Reifier() : { Token tok = null ; Node reifId = null ; }
+{
+ tok = <TILDE>
+ (reifId = VarOrReifierId() )?
+ { return reifId; }
+}
+
+// // No variables.
+// Node ReifierData() : { Token tok = null ; Node reifId = null ; }
+// {
+// tok = <TILDE>
+// (reifId = ReifierId() )?
+// { return reifId; }
+// }
+//
+// Node ReifierId() : { Node n = null ; String iri ; }
+// {
+// // No variable
+// ( iri = iri() { return createNode(iri) ; }
+// | n = BlankNode() { return n ; }
+// )
+// }
+//
+// Node VarOrReifierId() : { Node n = null; }
+// {
+// ( n = Var() { return n; }
+// | n = ReifierId() { return n; }
+// )
+// }
+Node VarOrReifierId() : { Node n = null; String iri = null; }
+{
+ ( n = Var() { return n; }
+ | iri = iri() { return createNode(iri) ; }
+ | n = BlankNode() { return n ; }
+ )
}
#ifdef ARQ
@@ -1151,7 +1212,7 @@ Expr FunctionCall() : { String fname ; Args a ; }
if ( AggregateRegistry.isRegistered(fname) ) {
// aggregates
if ( ! getAllowAggregatesInExpressions() )
- throwParseException("Aggregate expression not legal at this point : "+fname, -1, -1) ;
+ throwParseException("Aggregate expression not legal at this point : "+fname, token.beginLine, token.beginColumn) ;
Aggregator agg = AggregatorFactory.createCustom(fname, a) ;
Expr exprAgg = getQuery().allocAggregate(agg) ;
return exprAgg ;
@@ -1194,8 +1255,6 @@ ExprList ExpressionList() : { Expr expr = null ; ExprList exprList = new ExprLis
{ return exprList ; }
}
-
-
// -------- Construct patterns
#ifdef ARQ
Template ConstructTemplate() : { QuadAcc acc = new QuadAcc() ;
@@ -1250,6 +1309,8 @@ void TriplesSameSubject(TripleCollector acc) : { Node s ; }
s = TriplesNode(tempAcc)
PropertyList(s, tempAcc)
{ insert(acc, tempAcc) ; }
+|
+ ReifiedTripleBlock(acc)
}
void PropertyList(Node s, TripleCollector acc) : { }
@@ -1288,7 +1349,7 @@ void Object(Node s, Node p, Path path, TripleCollector acc): { Node o ; }
{
{ ElementPathBlock tempAcc = new ElementPathBlock() ; int mark = tempAcc.mark() ; }
o = GraphNode(tempAcc)
- { insert(tempAcc, mark, s, p, path, o) ; insert(acc, tempAcc) ; }
+ { insert(tempAcc, mark, s, p, path, o) ; insert(acc, tempAcc) ; }
Annotation(acc, s, p, path, o)
}
@@ -1305,6 +1366,8 @@ void TriplesSameSubjectPath(TripleCollector acc) : { Node s ; }
s = TriplesNodePath(tempAcc)
PropertyListPath(s, tempAcc)
{ insert(acc, tempAcc) ; }
+|
+ ReifiedTripleBlockPath(acc)
}
void PropertyListPath(Node s, TripleCollector acc) : { }
@@ -1327,12 +1390,8 @@ void PropertyListPathNotEmpty(Node s, TripleCollector acc) :
| p = VerbSimple()
)
ObjectListPath(s, p, path, acc)
- )?
+ )?
)*
-#if 0
- |
- Reification(s, acc)
-#endif
}
Path VerbPath() : {Node p ; Path path ; }
@@ -1348,7 +1407,7 @@ Node VerbSimple() : { Node p ; }
{ return p ; }
}
-void ObjectListPath(Node s, Node p, Path path, TripleCollector acc): { Node o ; }
+void ObjectListPath(Node s, Node p, Path path, TripleCollector acc): { Node o ; }
{
ObjectPath(s, p, path, acc)
( <COMMA> ObjectPath(s, p, path, acc) )*
@@ -1460,6 +1519,16 @@ Path PathMod(Path p) : { long i1 ; long i2 ; }
)
}
+#ifdef ARQ
+long Integer() : {Token t ;}
+{
+ t = <INTEGER>
+ { return integerValue(t.image) ; }
+}
+#endif
+
+
+
Path PathPrimary() : { String str ; Path p ; Node n ; }
{
(
@@ -1517,12 +1586,6 @@ P_Path0 PathOneInPropertySet() : { String str ; Node n ; }
)
}
-long Integer() : {Token t ;}
-{
- t = <INTEGER>
- { return integerValue(t.image) ; }
-}
-
// -------- Triple expansions
// Anything that can stand in a node slot and which is
@@ -1530,13 +1593,9 @@ long Integer() : {Token t ;}
Node TriplesNode(TripleCollectorMark acc) : { Node n ; }
{
- n = Collection(acc) { return n ; }
- |
- n = BlankNodePropertyList(acc) { return n ; }
-#if 0
+ n = Collection(acc) { return n ; }
|
- n = Reification(null, acc) { return n ; }
-#endif
+ n = BlankNodePropertyList(acc) { return n ; }
}
Node BlankNodePropertyList(TripleCollector acc) : { Token t ; }
@@ -1550,13 +1609,9 @@ Node BlankNodePropertyList(TripleCollector acc) : { Token t ; }
Node TriplesNodePath(TripleCollectorMark acc) : { Node n ; }
{
- n = CollectionPath(acc) { return n ; }
- |
- n = BlankNodePropertyListPath(acc) { return n ; }
-#if 0
+ n = CollectionPath(acc) { return n ; }
|
- n = Reification(null, acc) { return n ; }
-#endif
+ n = BlankNodePropertyListPath(acc) { return n ; }
}
Node BlankNodePropertyListPath(TripleCollector acc) : { Token t ; }
@@ -1568,32 +1623,6 @@ Node BlankNodePropertyListPath(TripleCollector acc) : { Token t ; }
{ return n ; }
}
-// << >> as reification. Allows any subject/predicate/object nodes.
-#if 0
-Node Reification(Node id, TripleCollectorMark acc) :
- { Node s , p , o ; int mark ; Token t ; }
-{
- // Insert reification triple before the resulting subtriples (if any)
- t = <LT2>
- { int beginLine = t.beginLine; int beginColumn = t.beginColumn; t = null; }
- { if ( id == null )
- id = createBNode(beginLine, beginColumn() ;
- mark = acc.mark() ; }
- s = GraphNode(acc)
- { insert(acc, mark, id, nRDFsubject, s) ;
- mark = acc.mark() ;
- }
- p = GraphNode(acc)
- { insert(acc, mark, id, nRDFpredicate, p) ;
- mark = acc.mark() ;
- }
- o = GraphNode(acc)
- { insert(acc, mark, id, nRDFobject, o) ; }
- <GT2>
- { return id ; }
-}
-#endif
-
// ------- RDF collections
Node Collection(TripleCollectorMark acc) :
@@ -1648,95 +1677,229 @@ Node CollectionPath(TripleCollectorMark acc) :
return listHead ; }
}
-// RDF-star Annotation Syntax
-void AnnotationPath(TripleCollector acc, Node s, Node p, Path path, Node o) : {}
+// ---- RDF-star Annotation Syntax
+// Allow paths. Query graph patterns.
+void AnnotationPath(TripleCollector acc, Node s, Node p, Path path, Node o) : { Node reifId = null ; }
{
(
- <L_ANN>
- { Node pAnn = preConditionAnnotation(s, p, path, o, token.beginLine, token.beginColumn) ;
- Node x = createQuotedTriple(s, pAnn, o, token.beginLine, token.beginColumn);
- }
- PropertyListPathNotEmpty(x, acc)
- <R_ANN>
- )?
+ { p = preConditionReifier(s, p, path, o, token.beginLine, token.beginColumn); }
+ reifId = Reifier()
+ { reifId = insertTripleReifier(acc, reifId, s, p, o, token.beginLine, token.beginColumn) ; }
+ { setReifierId(reifId); }
+ |
+ {
+ p = preConditionReifier(s, p, path, o, token.beginLine, token.beginColumn);
+ reifId = getOrAllocReifierId(acc, s, p, o, token.beginLine, token.beginColumn);
+ }
+ { clearReifierId(); }
+ AnnotationBlockPath(acc, reifId)
+ )*
+ { clearReifierId(); }
}
-// RDF-star Annotation Syntax
-void Annotation(TripleCollector acc, Node s, Node p, Path path, Node o) : { }
+void AnnotationBlockPath(TripleCollector acc, Node reifId) : { }
+{
+ <L_ANN>
+ PropertyListPathNotEmpty(reifId, acc)
+ <R_ANN>
+}
+
+// ---- RDF-star Annotation Syntax
+// No paths. Construct templates.
+void Annotation(TripleCollector acc, Node s, Node p, Path path, Node o) : { Node reifId = null ; }
{
- // path should be null.
(
- <L_ANN>
- { Node pAnn = preConditionAnnotation(s, p, path, o, token.beginLine, token.beginColumn) ;
- Node x = createQuotedTriple(s, p, o, token.beginLine, token.beginColumn);
- }
- PropertyListNotEmpty(x, acc)
- <R_ANN>
- )?
+ { p = preConditionReifier(s, p, path, o, token.beginLine, token.beginColumn); }
+ reifId = Reifier()
+ // @@ Rewrite java?
+ { reifId = insertTripleReifier(acc, reifId, s, p, o, token.beginLine, token.beginColumn) ; }
+ { setReifierId(reifId); }
+ |
+ {
+ p = preConditionReifier(s, p, path, o, token.beginLine, token.beginColumn);
+ reifId = getOrAllocReifierId(acc, s, p, o, token.beginLine, token.beginColumn);
+ }
+ { clearReifierId(); }
+ AnnotationBlock(acc, reifId)
+ )*
+}
+
+void AnnotationBlock(TripleCollector acc, Node reifId) : { }
+{
+ // Roll back into Annotation?
+ <L_ANN>
+ PropertyListNotEmpty(reifId, acc)
+ <R_ANN>
}
// -------- Nodes in a graph pattern or template
+// Object position RDF term, element of a list
+// No paths in TriplesNode
Node GraphNode(TripleCollectorMark acc) : { Node n ; }
{
- n = VarOrTerm() { return n ; }
+ n = VarOrTerm() { return n ; }
+ |
+ n = TriplesNode(acc) { return n ; }
|
- n = TriplesNode(acc) { return n ; }
+ n = ReifiedTriple(acc) { return n ; }
}
+// Object position RDF term. NEW-SYNTAX Rename?
Node GraphNodePath(TripleCollectorMark acc) : { Node n ; }
{
n = VarOrTerm() { return n ; }
- |
+|
n = TriplesNodePath(acc) { return n ; }
+|
+ n = ReifiedTriple(acc) { return n ; }
}
Node VarOrTerm() : { Node n = null ; String iri ; }
{
( n = Var()
| iri = iri() { return createNode(iri) ; }
- | n = RDFLiteral() { return n ; }
- | n = NumericLiteral() { return n ; }
- | n = BooleanLiteral() { return n ; }
- | n = BlankNode() { return n ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = BlankNode()
// <LPAREN> <RPAREN> { return nRDFnil ; }
| <NIL> { return nRDFnil ; }
- | n = QuotedTriple()
-)
- { return n ; }
+ | n = TripleTerm() { return n; }
+ )
+ { return n; }
}
-Node QuotedTriple() : { Node n = null ; Token t ; Node s , p , o ; }
+Node ReifiedTriple(TripleCollector acc) : { Node reifId = null ; Token tok ; Node s; Node p ; Node o ; }
{
- t = <LT2>
- s = VarOrTerm()
+ tok = <LT2>
+ s = ReifiedTripleSubject(acc)
p = Verb()
- o = VarOrTerm()
- { n = createQuotedTriple(s, p, o, t.beginLine, t.beginColumn); }
+ o = ReifiedTripleObject(acc)
+ (reifId = Reifier())?
+ { reifId = insertTripleReifier(acc, reifId, s, p, o, tok.beginLine, tok.beginColumn) ; }
<GT2>
+ { return reifId; }
+}
+
+Node ReifiedTripleSubject(TripleCollector acc) : { Node s; String iri; }
+{
+ ( s = Var()
+ | iri = iri() { s = createNode(iri) ; }
+ | s = RDFLiteral()
+ | s = NumericLiteral()
+ | s = BooleanLiteral()
+ | s = BlankNode()
+ | s = ReifiedTriple(acc)
+ // <LPAREN> <RPAREN> { s = RDFnil ; }
+ //| <NIL> { s = nRDFnil ; }
+ )
+ { return s; }
+}
+
+Node ReifiedTripleObject(TripleCollector acc) : { Node o; String iri; }
+{
+ ( o = Var()
+ | iri = iri() { o = createNode(iri) ; }
+ | o = RDFLiteral()
+ | o = NumericLiteral()
+ | o = BooleanLiteral()
+ | o = BlankNode()
+ | o = ReifiedTriple(acc)
+ // <LPAREN> <RPAREN> { o = nRDFnil ; }
+ //| <NIL> { o = nRDFnil ; }
+ | o = TripleTerm()
+ )
+ { return o; }
+}
+
+Node TripleTerm() : { Node n = null ; Token openToken ; String iri ; Node s , p , o ; }
+{
+ openToken = <L_TRIPLE>
+ // @@ Alt name. ttSubject()?
+ s = TripleTermSubject()
+ p = Verb()
+ o = TripleTermObject()
+ { n = createTripleTerm(s, p, o, openToken.beginLine, openToken.beginColumn); }
+ <R_TRIPLE>
+ { return n ; }
+}
+
+Node TripleTermSubject() : { Node n; String iri; }
+{
+ ( n = Var()
+ | iri = iri() { n = createNode(iri) ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = BlankNode()
+ // <LPAREN> <RPAREN> { return nRDFnil ; }
+ //| <NIL> { return nRDFnil ; }
+ //| n = TripleTerm() { return n; }
+ )
{ return n; }
}
-Node QuotedTripleData() : { Node n = null ; Token t ; String iri ; Node s , p , o ; }
+Node TripleTermObject() : { Node n; String iri; }
{
- t = <LT2>
- ( s = DataValueTerm() )
- ( iri = iri() { p = createNode(iri) ; } | <KW_A> { p = nRDFtype ; } )
- ( o = DataValueTerm() )
- { n = createQuotedTriple(s, p, o, t.beginLine, t.beginColumn); }
- <GT2>
+ ( n = Var()
+ | iri = iri() { n = createNode(iri) ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = BlankNode()
+ // <LPAREN> <RPAREN> { return nRDFnil ; }
+ //| <NIL> { return nRDFnil ; }
+ | n = TripleTerm() { return n; }
+ )
{ return n; }
}
-Node DataValueTerm() : { Node n = null ; String iri ; Node s , p , o ; }
+Node TripleTermData() : { Node n = null ; Token openToken ; String iri ; Node s , p , o ; }
{
- iri = iri() { return createNode(iri) ; }
-| n = RDFLiteral() { return n ; }
-| n = NumericLiteral() { return n ; }
-| n = BooleanLiteral() { return n ; }
-| n = QuotedTripleData() { return n ; }
+ openToken = <L_TRIPLE>
+ // @@ Alt name? ttDataValueTerm
+ s = TripleTermDataSubject()
+ ( iri = iri() { p = createNode(iri) ; } | <KW_A> { p = nRDFtype ; } )
+ o = TripleTermDataObject()
+ { n = createTripleTerm(s, p, o, openToken.beginLine, openToken.beginColumn); }
+ <R_TRIPLE>
+ { return n ; }
+}
+
+Node TripleTermDataSubject() : { Node n = null; String iri; }
+{
+ ( iri = iri() { n = createNode(iri) ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ //| n = TripleTermData()
+ )
+ { return n; }
}
+Node TripleTermDataObject() : { Node n = null; String iri; }
+{
+ ( iri = iri() { n = createNode(iri) ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = TripleTermData()
+ )
+ { return n; }
+}
+
+// // VarOrTerm except no var, no bnodes
+// // @@ Rename?
+// Node DataValueTerm() : { Node n = null ; String iri ; Node s , p , o ; }
+// {
+// iri = iri() { return createNode(iri) ; }
+// | n = RDFLiteral() { return n ; }
+// | n = NumericLiteral() { return n ; }
+// | n = BooleanLiteral() { return n ; }
+// | n = TripleTermData() { return n; }
+// }
+
// e.g. Property (if no bNodes) + DESCRIBE
Node VarOrIri() : {Node n = null ; String iri ; }
{
@@ -1892,15 +2055,14 @@ Expr PrimaryExpression() : { Expr expr ; Node n ; }
( expr = BrackettedExpression() { return expr ; }
| expr = BuiltInCall() { return expr ; }
| expr = iriOrFunction() { return expr ; }
-// NOT | n = VarOrTerm() { return asExpr(n) ; }
+// NOT | n = ExprVarOrTerm() { return asExpr(n) ; }
// Because of iriOrFunction
// Can't use iri() here
| n = RDFLiteral() { return asExpr(n) ; }
| n = NumericLiteral() { return asExpr(n) ; }
| n = BooleanLiteral() { return asExpr(n) ; }
| n = Var() { return asExpr(n) ; }
- | n = ExprQuotedTriple() { return asExpr(n) ; }
-
+ | n = ExprTripleTerm() { return asExpr(n) ; }
// and not SPARQL 12
// needs checking.
// Use this for ?var(args)
@@ -1908,28 +2070,56 @@ Expr PrimaryExpression() : { Expr expr ; Node n ; }
)
}
-Node ExprVarOrTerm() : { Node n; String s;}
+// Node ExprVarOrTerm() : { Node n; String s;}
+// {
+// ( s = iri() { n = createNode(s); }
+// | n = RDFLiteral()
+// | n = NumericLiteral()
+// | n = BooleanLiteral()
+// | n = Var()
+// | n = ExprTripleTerm()
+// )
+// { return n; }
+// }
+
+Node ExprTripleTerm() : { Token t ; Node s,p,o,n; }
{
- ( s = iri() { n = createNode(s); }
+ t = <L_TRIPLE>
+ s = ExprTripleTermSubject()
+ p = Verb()
+ o = ExprTripleTermObject()
+ { n = createTripleTerm(s, p, o, t.beginLine, t.beginColumn); }
+ <R_TRIPLE>
+ { return n; }
+}
+
+Node ExprTripleTermSubject() : { Node n; String iri; }
+{
+ ( iri = iri() { n = createNode(iri); }
| n = RDFLiteral()
| n = NumericLiteral()
| n = BooleanLiteral()
| n = Var()
- | n = ExprQuotedTriple()
+ //| n = ExprTripleTerm()
)
{ return n; }
}
-Node ExprQuotedTriple() : { Token t ; Node s,p,o,n; }
-{ t = <LT2>
- s = ExprVarOrTerm()
- p = Verb()
- o = ExprVarOrTerm()
- { n = createQuotedTriple(s, p, o, t.beginLine, t.beginColumn); }
- <GT2>
+Node ExprTripleTermObject() : { Node n; String iri; }
+{
+ ( iri = iri() { n = createNode(iri); }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = Var()
+ | n = ExprTripleTerm()
+ )
{ return n; }
}
+
+
+
Expr BrackettedExpression() : { Expr expr ; }
{
<LPAREN> expr = Expression() <RPAREN> { return expr ; }
@@ -1943,6 +2133,7 @@ Expr BuiltInCall() : { Expr expr ;
|
<STR> <LPAREN> expr = Expression() <RPAREN>
{ return new E_Str(expr) ; }
+
| <LANG> <LPAREN> expr = Expression() <RPAREN>
{ return new E_Lang(expr) ; }
@@ -1950,6 +2141,9 @@ Expr BuiltInCall() : { Expr expr ;
<LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <RPAREN>
{ return new E_LangMatches(expr1, expr2) ; }
+ | <LANGDIR> <LPAREN> expr = Expression() <RPAREN>
+ { return new E_LangDir(expr) ; }
+
| <DTYPE> <LPAREN> expr = Expression() <RPAREN>
{ return new E_Datatype(expr) ; }
@@ -2093,6 +2287,11 @@ Expr BuiltInCall() : { Expr expr ;
| <STRLANG> <LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <RPAREN>
{ return new E_StrLang(expr1, expr2) ; }
+ | <STRLANGDIR> <LPAREN> expr1 = Expression() <COMMA>
+ expr2 = Expression() <COMMA>
+ expr3 = Expression() <RPAREN>
+ { return new E_StrLangDir(expr1, expr2, expr3) ; }
+
| <STRDT> <LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <RPAREN>
{ return new E_StrDatatype(expr1, expr2) ; }
@@ -2113,6 +2312,13 @@ Expr BuiltInCall() : { Expr expr ;
| <IS_NUMERIC> <LPAREN> expr = Expression() <RPAREN>
{ return new E_IsNumeric(expr) ; }
+
+ | <HAS_LANG> <LPAREN> expr = Expression() <RPAREN>
+ { return new E_HasLang(expr) ; }
+
+ | <HAS_LANGDIR> <LPAREN> expr = Expression() <RPAREN>
+ { return new E_HasLangDir(expr) ; }
+
| // Regular expression matcher
expr = RegexExpression() { return expr ; }
@@ -2120,10 +2326,12 @@ Expr BuiltInCall() : { Expr expr ;
| expr = NotExistsFunc() { return expr ; }
-| <IS_TRIPLE> <LPAREN> expr = Expression() <RPAREN>
+ | <IS_TRIPLE> <LPAREN> expr = Expression() <RPAREN>
{ return new E_IsTriple(expr) ; }
- | <TRIPLE> <LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <COMMA> expr3 = Expression() <RPAREN>
+ | <TRIPLE> <LPAREN> expr1 = Expression() <COMMA>
+ expr2 = Expression() <COMMA>
+ expr3 = Expression() <RPAREN>
{ return new E_TripleFn(expr1, expr2, expr3) ; }
| <SUBJECT> <LPAREN> expr = Expression() <RPAREN>
@@ -2326,7 +2534,7 @@ Expr iriOrFunction() : { String iri ; Args a = null ; }
if ( AggregateRegistry.isRegistered(iri) ) {
// aggregates
if ( ! getAllowAggregatesInExpressions() )
- throwParseException("Aggregate expression not legal at this point : "+iri, -1, -1) ;
+ throwParseException("Aggregate expression not legal at this point : "+iri, token.beginLine, token.beginColumn) ;
Aggregator agg = AggregatorFactory.createCustom(iri, a) ;
Expr exprAgg = getQuery().allocAggregate(agg) ;
return exprAgg ;
@@ -2350,17 +2558,18 @@ Expr VarOrFunction() : { Var v ; ExprList a = null ; }
#endif
-Node RDFLiteral() : { Token t ; String lex = null ; }
+Node RDFLiteral() : { Token t ; String lex = null ; String uri = null ; }
{
lex = String()
// Optional lang tag and datatype.
- { String lang = null ; String uri = null ; }
(
- ( t = <LANGTAG> { lang = stripChars(t.image, 1) ; } )
+ t = <LANG_DIR>
+ { return createLiteralLang(lex, t.image, token.beginLine, token.beginColumn); }
|
- ( <DATATYPE> uri = iri() )
+ <DATATYPE> uri = iri()
+ { return createLiteralDT(lex, uri, token.beginLine, token.beginColumn); }
)?
- { return createLiteral(lex, lang, uri) ; }
+ { return createLiteralString(lex, token.beginLine, token.beginColumn) ; }
}
@@ -2500,7 +2709,7 @@ TOKEN:
| <BLANK_NODE_LABEL: "_:" (<PN_CHARS_U> | ["0"-"9"]) ((<PN_CHARS>|".")* <PN_CHARS>)? >
| <VAR1: "?" <VARNAME> >
| <VAR2: "$" <VARNAME> >
-| <LANGTAG: <AT> (<A2Z>)+("-" (<A2ZN>)+)* >
+| <LANG_DIR: <AT> (<A2Z>)+("-" (<A2ZN>)+)* ( "--" (<A2Z>)* )? >
| <#A2Z: ["a"-"z","A"-"Z"]>
| <#A2ZN: ["a"-"z","A"-"Z","0"-"9"]>
}
@@ -2555,7 +2764,9 @@ TOKEN [IGNORE_CASE] :
#ifdef ARQ
| < LET: "LET" >
-| < LATERAL: "LATERAL" >
+| < LATERAL: "lateral" >
+| < SEMIJOIN: "semijoin" >
+| < ANTIJOIN: "antijoin" >
| < UNFOLD: "unfold" >
#endif
@@ -2614,15 +2825,20 @@ TOKEN [IGNORE_CASE] :
| < STR: "str" >
| < STRLANG: "strlang" >
+| < STRLANGDIR: "strlangdir" >
+
| < STRDT: "strdt" >
| < DTYPE: "datatype" >
| < LANG: "lang" >
| < LANGMATCHES: "langmatches" >
+| < LANGDIR: "langdir" >
| < IS_URI: "isURI" >
| < IS_IRI: "isIRI" >
| < IS_BLANK: "isBlank" >
| < IS_LITERAL: "isLiteral" >
| < IS_NUMERIC: "isNumeric" >
+| < HAS_LANG: "hasLang" >
+| < HAS_LANGDIR: "hasLangDir" >
| < REGEX: "regex" >
| < SAME_TERM: "sameTerm" >
@@ -2795,13 +3011,15 @@ TOKEN :
| < LE: "<=" > // Maybe: | "=>" >
| < GE: ">=" > // Maybe: | "=<" >
-| < GT2: ">>" >
+| < L_TRIPLE: "<<(" >
+| < R_TRIPLE: ")>>" >
| < LT2: "<<" >
-| <L_ANN: "{|" >
-| <R_ANN: "|}" >
+| < GT2: ">>" >
+| < L_ANN: "{|" >
+| < R_ANN: "|}" >
-| < BANG: "!" >
| < TILDE: "~" >
+| < BANG: "!" >
| < COLON: ":" >
| < SC_OR: "||" >
diff --git a/jena-arq/Grammar/sparql2bnf b/jena-arq/Grammar/sparql2bnf
new file mode 100755
index 0000000000..74b1b9034d
--- /dev/null
+++ b/jena-arq/Grammar/sparql2bnf
@@ -0,0 +1,7 @@
+#!/usr/bin/bash
+## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+echo "Grammar to sparql.bnf (text)"
+
+(
+ jj2bnf 'sparql_12.txt' 'tokens.txt'
+) > sparql.bnf
diff --git a/jena-arq/Grammar/sparql2html b/jena-arq/Grammar/sparql2html
index 19320cd406..e2d449bf97 100755
--- a/jena-arq/Grammar/sparql2html
+++ b/jena-arq/Grammar/sparql2html
@@ -1,13 +1,21 @@
+#!/usr/bin/bash
## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
-echo "Grammar to X.html, fragments file to Y.html"
+echo "Grammar output in sparql-grammar.html"
##jj2html 'sparql_11.txt' 'tokens.txt' > X11.html
##grammarExtracts < X11.html > Y11.html
-jj2html 'sparql_12.txt' 'tokens.txt' > X12.html
-grammarExtracts < X12.html > Y12.html
+(
+ echo " <!-- GRAMMAR -->"
+ jj2html 'sparql_12.txt' 'tokens.txt'
+ echo " <!-- GRAMMAR -->"
+) > sparql-grammar.html
+
+## Produce a standlone web page
+## mv sparql-grammar.html X12.hmtl
+## grammarExtracts < sparql-grammar.html > sparql-html.thml
## jj2html 'arq_12.txt' 'tokens.txt' > X.html
## grammarExtracts < X.html > Y.html
-echo "Check X and Y for IRI_REF because \" became '"
\ No newline at end of file
+##?? echo "Check X and Y for IRI_REF because \" became '"
diff --git a/jena-arq/Grammar/sparql_12.jj b/jena-arq/Grammar/sparql_12.jj
index 0073d7880b..8154839f00 100644
--- a/jena-arq/Grammar/sparql_12.jj
+++ b/jena-arq/Grammar/sparql_12.jj
@@ -525,6 +525,18 @@ Element TriplesBlock(ElementPathBlock acc) : { }
( <DOT> (TriplesBlock(acc))? )?
{ return acc ; }
}
+Node ReifiedTripleBlock(TripleCollector acc) : { Node reifId ; }
+{
+ reifId = ReifiedTriple(acc)
+ PropertyList(reifId, acc)
+ { return reifId ; }
+}
+Node ReifiedTripleBlockPath(TripleCollector acc) : { Node reifId ; }
+{
+ reifId = ReifiedTriple(acc)
+ PropertyListPath(reifId, acc)
+ { return reifId ; }
+}
Element GraphPatternNotTriples() : { Element el = null ; }
{
(
@@ -639,7 +651,20 @@ Node DataBlockValue() : { Node n ; String iri ; }
| n = NumericLiteral() { return n ; }
| n = BooleanLiteral() { return n ; }
| <UNDEF> { return null ; }
-| n = QuotedTripleData() { return n ; }
+| n = TripleTermData() { return n ; }
+}
+Node Reifier() : { Token tok = null ; Node reifId = null ; }
+{
+ tok = <TILDE>
+ (reifId = VarOrReifierId() )?
+ { return reifId; }
+}
+Node VarOrReifierId() : { Node n = null; String iri = null; }
+{
+ ( n = Var() { return n; }
+ | iri = iri() { return createNode(iri) ; }
+ | n = BlankNode() { return n ; }
+ )
}
Element MinusGraphPattern() : { Element el ; }
{
@@ -683,7 +708,7 @@ Expr FunctionCall() : { String fname ; Args a ; }
{
if ( AggregateRegistry.isRegistered(fname) ) {
if ( ! getAllowAggregatesInExpressions() )
- throwParseException("Aggregate expression not legal at this point : "+fname, -1, -1) ;
+ throwParseException("Aggregate expression not legal at this point : "+fname, token.beginLine, token.beginColumn) ;
Aggregator agg = AggregatorFactory.createCustom(fname, a) ;
Expr exprAgg = getQuery().allocAggregate(agg) ;
return exprAgg ;
@@ -747,6 +772,8 @@ void TriplesSameSubject(TripleCollector acc) : { Node s ; }
s = TriplesNode(tempAcc)
PropertyList(s, tempAcc)
{ insert(acc, tempAcc) ; }
+|
+ ReifiedTripleBlock(acc)
}
void PropertyList(Node s, TripleCollector acc) : { }
{
@@ -790,6 +817,8 @@ void TriplesSameSubjectPath(TripleCollector acc) : { Node s ; }
s = TriplesNodePath(tempAcc)
PropertyListPath(s, tempAcc)
{ insert(acc, tempAcc) ; }
+|
+ ReifiedTripleBlockPath(acc)
}
void PropertyListPath(Node s, TripleCollector acc) : { }
{
@@ -911,16 +940,11 @@ P_Path0 PathOneInPropertySet() : { String str ; Node n ; }
)
)
}
-long Integer() : {Token t ;}
-{
- t = <INTEGER>
- { return integerValue(t.image) ; }
-}
Node TriplesNode(TripleCollectorMark acc) : { Node n ; }
{
- n = Collection(acc) { return n ; }
+ n = Collection(acc) { return n ; }
|
- n = BlankNodePropertyList(acc) { return n ; }
+ n = BlankNodePropertyList(acc) { return n ; }
}
Node BlankNodePropertyList(TripleCollector acc) : { Token t ; }
{
@@ -932,9 +956,9 @@ Node BlankNodePropertyList(TripleCollector acc) : { Token t ; }
}
Node TriplesNodePath(TripleCollectorMark acc) : { Node n ; }
{
- n = CollectionPath(acc) { return n ; }
+ n = CollectionPath(acc) { return n ; }
|
- n = BlankNodePropertyListPath(acc) { return n ; }
+ n = BlankNodePropertyListPath(acc) { return n ; }
}
Node BlankNodePropertyListPath(TripleCollector acc) : { Token t ; }
{
@@ -992,80 +1016,177 @@ Node CollectionPath(TripleCollectorMark acc) :
insert(acc, lastCell, nRDFrest, nRDFnil) ;
return listHead ; }
}
-void AnnotationPath(TripleCollector acc, Node s, Node p, Path path, Node o) : {}
+void AnnotationPath(TripleCollector acc, Node s, Node p, Path path, Node o) : { Node reifId = null ; }
{
(
- <L_ANN>
- { Node pAnn = preConditionAnnotation(s, p, path, o, token.beginLine, token.beginColumn) ;
- Node x = createQuotedTriple(s, pAnn, o, token.beginLine, token.beginColumn);
- }
- PropertyListPathNotEmpty(x, acc)
- <R_ANN>
- )?
+ { p = preConditionReifier(s, p, path, o, token.beginLine, token.beginColumn); }
+ reifId = Reifier()
+ { reifId = insertTripleReifier(acc, reifId, s, p, o, token.beginLine, token.beginColumn) ; }
+ { setReifierId(reifId); }
+ |
+ {
+ p = preConditionReifier(s, p, path, o, token.beginLine, token.beginColumn);
+ reifId = getOrAllocReifierId(acc, s, p, o, token.beginLine, token.beginColumn);
+ }
+ { clearReifierId(); }
+ AnnotationBlockPath(acc, reifId)
+ )*
+ { clearReifierId(); }
+}
+void AnnotationBlockPath(TripleCollector acc, Node reifId) : { }
+{
+ <L_ANN>
+ PropertyListPathNotEmpty(reifId, acc)
+ <R_ANN>
}
-void Annotation(TripleCollector acc, Node s, Node p, Path path, Node o) : { }
+void Annotation(TripleCollector acc, Node s, Node p, Path path, Node o) : { Node reifId = null ; }
{
(
- <L_ANN>
- { Node pAnn = preConditionAnnotation(s, p, path, o, token.beginLine, token.beginColumn) ;
- Node x = createQuotedTriple(s, p, o, token.beginLine, token.beginColumn);
- }
- PropertyListNotEmpty(x, acc)
- <R_ANN>
- )?
+ { p = preConditionReifier(s, p, path, o, token.beginLine, token.beginColumn); }
+ reifId = Reifier()
+ { reifId = insertTripleReifier(acc, reifId, s, p, o, token.beginLine, token.beginColumn) ; }
+ { setReifierId(reifId); }
+ |
+ {
+ p = preConditionReifier(s, p, path, o, token.beginLine, token.beginColumn);
+ reifId = getOrAllocReifierId(acc, s, p, o, token.beginLine, token.beginColumn);
+ }
+ { clearReifierId(); }
+ AnnotationBlock(acc, reifId)
+ )*
+}
+void AnnotationBlock(TripleCollector acc, Node reifId) : { }
+{
+ <L_ANN>
+ PropertyListNotEmpty(reifId, acc)
+ <R_ANN>
}
Node GraphNode(TripleCollectorMark acc) : { Node n ; }
{
- n = VarOrTerm() { return n ; }
+ n = VarOrTerm() { return n ; }
+ |
+ n = TriplesNode(acc) { return n ; }
|
- n = TriplesNode(acc) { return n ; }
+ n = ReifiedTriple(acc) { return n ; }
}
Node GraphNodePath(TripleCollectorMark acc) : { Node n ; }
{
n = VarOrTerm() { return n ; }
- |
+|
n = TriplesNodePath(acc) { return n ; }
+|
+ n = ReifiedTriple(acc) { return n ; }
}
Node VarOrTerm() : { Node n = null ; String iri ; }
{
( n = Var()
| iri = iri() { return createNode(iri) ; }
- | n = RDFLiteral() { return n ; }
- | n = NumericLiteral() { return n ; }
- | n = BooleanLiteral() { return n ; }
- | n = BlankNode() { return n ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = BlankNode()
| <NIL> { return nRDFnil ; }
- | n = QuotedTriple()
-)
- { return n ; }
+ | n = TripleTerm() { return n; }
+ )
+ { return n; }
}
-Node QuotedTriple() : { Node n = null ; Token t ; Node s , p , o ; }
+Node ReifiedTriple(TripleCollector acc) : { Node reifId = null ; Token tok ; Node s; Node p ; Node o ; }
{
- t = <LT2>
- s = VarOrTerm()
+ tok = <LT2>
+ s = ReifiedTripleSubject(acc)
p = Verb()
- o = VarOrTerm()
- { n = createQuotedTriple(s, p, o, t.beginLine, t.beginColumn); }
+ o = ReifiedTripleObject(acc)
+ (reifId = Reifier())?
+ { reifId = insertTripleReifier(acc, reifId, s, p, o, tok.beginLine, tok.beginColumn) ; }
<GT2>
+ { return reifId; }
+}
+Node ReifiedTripleSubject(TripleCollector acc) : { Node s; String iri; }
+{
+ ( s = Var()
+ | iri = iri() { s = createNode(iri) ; }
+ | s = RDFLiteral()
+ | s = NumericLiteral()
+ | s = BooleanLiteral()
+ | s = BlankNode()
+ | s = ReifiedTriple(acc)
+ )
+ { return s; }
+}
+Node ReifiedTripleObject(TripleCollector acc) : { Node o; String iri; }
+{
+ ( o = Var()
+ | iri = iri() { o = createNode(iri) ; }
+ | o = RDFLiteral()
+ | o = NumericLiteral()
+ | o = BooleanLiteral()
+ | o = BlankNode()
+ | o = ReifiedTriple(acc)
+ | o = TripleTerm()
+ )
+ { return o; }
+}
+Node TripleTerm() : { Node n = null ; Token openToken ; String iri ; Node s , p , o ; }
+{
+ openToken = <L_TRIPLE>
+ s = TripleTermSubject()
+ p = Verb()
+ o = TripleTermObject()
+ { n = createTripleTerm(s, p, o, openToken.beginLine, openToken.beginColumn); }
+ <R_TRIPLE>
+ { return n ; }
+}
+Node TripleTermSubject() : { Node n; String iri; }
+{
+ ( n = Var()
+ | iri = iri() { n = createNode(iri) ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = BlankNode()
+ )
{ return n; }
}
-Node QuotedTripleData() : { Node n = null ; Token t ; String iri ; Node s , p , o ; }
+Node TripleTermObject() : { Node n; String iri; }
{
- t = <LT2>
- ( s = DataValueTerm() )
- ( iri = iri() { p = createNode(iri) ; } | <KW_A> { p = nRDFtype ; } )
- ( o = DataValueTerm() )
- { n = createQuotedTriple(s, p, o, t.beginLine, t.beginColumn); }
- <GT2>
+ ( n = Var()
+ | iri = iri() { n = createNode(iri) ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = BlankNode()
+ | n = TripleTerm() { return n; }
+ )
{ return n; }
}
-Node DataValueTerm() : { Node n = null ; String iri ; Node s , p , o ; }
+Node TripleTermData() : { Node n = null ; Token openToken ; String iri ; Node s , p , o ; }
{
- iri = iri() { return createNode(iri) ; }
-| n = RDFLiteral() { return n ; }
-| n = NumericLiteral() { return n ; }
-| n = BooleanLiteral() { return n ; }
-| n = QuotedTripleData() { return n ; }
+ openToken = <L_TRIPLE>
+ s = TripleTermDataSubject()
+ ( iri = iri() { p = createNode(iri) ; } | <KW_A> { p = nRDFtype ; } )
+ o = TripleTermDataObject()
+ { n = createTripleTerm(s, p, o, openToken.beginLine, openToken.beginColumn); }
+ <R_TRIPLE>
+ { return n ; }
+}
+Node TripleTermDataSubject() : { Node n = null; String iri; }
+{
+ ( iri = iri() { n = createNode(iri) ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ )
+ { return n; }
+}
+Node TripleTermDataObject() : { Node n = null; String iri; }
+{
+ ( iri = iri() { n = createNode(iri) ; }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = TripleTermData()
+ )
+ { return n; }
}
Node VarOrIri() : {Node n = null ; String iri ; }
{
@@ -1194,27 +1315,38 @@ Expr PrimaryExpression() : { Expr expr ; Node n ; }
| n = NumericLiteral() { return asExpr(n) ; }
| n = BooleanLiteral() { return asExpr(n) ; }
| n = Var() { return asExpr(n) ; }
- | n = ExprQuotedTriple() { return asExpr(n) ; }
+ | n = ExprTripleTerm() { return asExpr(n) ; }
)
}
-Node ExprVarOrTerm() : { Node n; String s;}
+Node ExprTripleTerm() : { Token t ; Node s,p,o,n; }
{
- ( s = iri() { n = createNode(s); }
+ t = <L_TRIPLE>
+ s = ExprTripleTermSubject()
+ p = Verb()
+ o = ExprTripleTermObject()
+ { n = createTripleTerm(s, p, o, t.beginLine, t.beginColumn); }
+ <R_TRIPLE>
+ { return n; }
+}
+Node ExprTripleTermSubject() : { Node n; String iri; }
+{
+ ( iri = iri() { n = createNode(iri); }
| n = RDFLiteral()
| n = NumericLiteral()
| n = BooleanLiteral()
| n = Var()
- | n = ExprQuotedTriple()
)
{ return n; }
}
-Node ExprQuotedTriple() : { Token t ; Node s,p,o,n; }
-{ t = <LT2>
- s = ExprVarOrTerm()
- p = Verb()
- o = ExprVarOrTerm()
- { n = createQuotedTriple(s, p, o, t.beginLine, t.beginColumn); }
- <GT2>
+Node ExprTripleTermObject() : { Node n; String iri; }
+{
+ ( iri = iri() { n = createNode(iri); }
+ | n = RDFLiteral()
+ | n = NumericLiteral()
+ | n = BooleanLiteral()
+ | n = Var()
+ | n = ExprTripleTerm()
+ )
{ return n; }
}
Expr BrackettedExpression() : { Expr expr ; }
@@ -1234,6 +1366,8 @@ Expr BuiltInCall() : { Expr expr ;
| <LANGMATCHES>
<LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <RPAREN>
{ return new E_LangMatches(expr1, expr2) ; }
+ | <LANGDIR> <LPAREN> expr = Expression() <RPAREN>
+ { return new E_LangDir(expr) ; }
| <DTYPE> <LPAREN> expr = Expression() <RPAREN>
{ return new E_Datatype(expr) ; }
| <BOUND> <LPAREN> gn = Var() <RPAREN>
@@ -1294,6 +1428,10 @@ Expr BuiltInCall() : { Expr expr ;
{ return new E_Conditional(expr, expr1, expr2) ; }
| <STRLANG> <LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <RPAREN>
{ return new E_StrLang(expr1, expr2) ; }
+ | <STRLANGDIR> <LPAREN> expr1 = Expression() <COMMA>
+ expr2 = Expression() <COMMA>
+ expr3 = Expression() <RPAREN>
+ { return new E_StrLangDir(expr1, expr2, expr3) ; }
| <STRDT> <LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <RPAREN>
{ return new E_StrDatatype(expr1, expr2) ; }
| <SAME_TERM> <LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <RPAREN>
@@ -1308,13 +1446,19 @@ Expr BuiltInCall() : { Expr expr ;
{ return new E_IsLiteral(expr) ; }
| <IS_NUMERIC> <LPAREN> expr = Expression() <RPAREN>
{ return new E_IsNumeric(expr) ; }
+ | <HAS_LANG> <LPAREN> expr = Expression() <RPAREN>
+ { return new E_HasLang(expr) ; }
+ | <HAS_LANGDIR> <LPAREN> expr = Expression() <RPAREN>
+ { return new E_HasLangDir(expr) ; }
|
expr = RegexExpression() { return expr ; }
| expr = ExistsFunc() { return expr ; }
| expr = NotExistsFunc() { return expr ; }
-| <IS_TRIPLE> <LPAREN> expr = Expression() <RPAREN>
+ | <IS_TRIPLE> <LPAREN> expr = Expression() <RPAREN>
{ return new E_IsTriple(expr) ; }
- | <TRIPLE> <LPAREN> expr1 = Expression() <COMMA> expr2 = Expression() <COMMA> expr3 = Expression() <RPAREN>
+ | <TRIPLE> <LPAREN> expr1 = Expression() <COMMA>
+ expr2 = Expression() <COMMA>
+ expr3 = Expression() <RPAREN>
{ return new E_TripleFn(expr1, expr2, expr3) ; }
| <SUBJECT> <LPAREN> expr = Expression() <RPAREN>
{ return new E_TripleSubject(expr) ; }
@@ -1421,7 +1565,7 @@ Expr iriOrFunction() : { String iri ; Args a = null ; }
return asExpr(createNode(iri)) ;
if ( AggregateRegistry.isRegistered(iri) ) {
if ( ! getAllowAggregatesInExpressions() )
- throwParseException("Aggregate expression not legal at this point : "+iri, -1, -1) ;
+ throwParseException("Aggregate expression not legal at this point : "+iri, token.beginLine, token.beginColumn) ;
Aggregator agg = AggregatorFactory.createCustom(iri, a) ;
Expr exprAgg = getQuery().allocAggregate(agg) ;
return exprAgg ;
@@ -1429,16 +1573,17 @@ Expr iriOrFunction() : { String iri ; Args a = null ; }
return new E_Function(iri, a) ;
}
}
-Node RDFLiteral() : { Token t ; String lex = null ; }
+Node RDFLiteral() : { Token t ; String lex = null ; String uri = null ; }
{
lex = String()
- { String lang = null ; String uri = null ; }
(
- ( t = <LANGTAG> { lang = stripChars(t.image, 1) ; } )
+ t = <LANG_DIR>
+ { return createLiteralLang(lex, t.image, token.beginLine, token.beginColumn); }
|
- ( <DATATYPE> uri = iri() )
+ <DATATYPE> uri = iri()
+ { return createLiteralDT(lex, uri, token.beginLine, token.beginColumn); }
)?
- { return createLiteral(lex, lang, uri) ; }
+ { return createLiteralString(lex, token.beginLine, token.beginColumn) ; }
}
Node NumericLiteral() : { Node n ; }
{
@@ -1532,7 +1677,7 @@ TOKEN:
| <BLANK_NODE_LABEL: "_:" (<PN_CHARS_U> | ["0"-"9"]) ((<PN_CHARS>|".")* <PN_CHARS>)? >
| <VAR1: "?" <VARNAME> >
| <VAR2: "$" <VARNAME> >
-| <LANGTAG: <AT> (<A2Z>)+("-" (<A2ZN>)+)* >
+| <LANG_DIR: <AT> (<A2Z>)+("-" (<A2ZN>)+)* ( "--" (<A2Z>)* )? >
| <#A2Z: ["a"-"z","A"-"Z"]>
| <#A2ZN: ["a"-"z","A"-"Z","0"-"9"]>
}
@@ -1600,15 +1745,19 @@ TOKEN [IGNORE_CASE] :
| < URI: "uri" >
| < STR: "str" >
| < STRLANG: "strlang" >
+| < STRLANGDIR: "strlangdir" >
| < STRDT: "strdt" >
| < DTYPE: "datatype" >
| < LANG: "lang" >
| < LANGMATCHES: "langmatches" >
+| < LANGDIR: "langdir" >
| < IS_URI: "isURI" >
| < IS_IRI: "isIRI" >
| < IS_BLANK: "isBlank" >
| < IS_LITERAL: "isLiteral" >
| < IS_NUMERIC: "isNumeric" >
+| < HAS_LANG: "hasLang" >
+| < HAS_LANGDIR: "hasLangDir" >
| < REGEX: "regex" >
| < SAME_TERM: "sameTerm" >
| < RAND: "RAND" >
@@ -1729,12 +1878,14 @@ TOKEN :
| < LT: "<" >
| < LE: "<=" >
| < GE: ">=" >
-| < GT2: ">>" >
+| < L_TRIPLE: "<<(" >
+| < R_TRIPLE: ")>>" >
| < LT2: "<<" >
-| <L_ANN: "{|" >
-| <R_ANN: "|}" >
-| < BANG: "!" >
+| < GT2: ">>" >
+| < L_ANN: "{|" >
+| < R_ANN: "|}" >
| < TILDE: "~" >
+| < BANG: "!" >
| < COLON: ":" >
| < SC_OR: "||" >
| < SC_AND: "&&" >
diff --git a/jena-arq/Grammar/sparql_12.txt b/jena-arq/Grammar/sparql_12.txt
deleted file mode 100644
index 98411b5f43..0000000000
--- a/jena-arq/Grammar/sparql_12.txt
+++ /dev/null
@@ -1,486 +0,0 @@
-
-DOCUMENT START
-TOKENS
-<DEFAULT> SKIP : {
-" "
-| "\t"
-| "\n"
-| "\r"
-| "\f"
-}
-
-<DEFAULT> SPECIAL : {
-<SINGLE_LINE_COMMENT: "#" (~["\n","\r"])* ("\n" | "\r" | "\r\n")?>
-}
-
-<DEFAULT> TOKEN : {
-<#WS: " " | "\t" | "\n" | "\r" | "\f">
-| <#WSC: <WS> | <SINGLE_LINE_COMMENT>>
-}
-
-<DEFAULT> TOKEN : {
-<IRIref: "<" (~[">","<","\"","{","}","^","\\","|","`","\u0000"-" "] | <UCHAR>)* ">">
-| <PNAME_NS: (<PN_PREFIX>)? ":">
-| <PNAME_LN: <PNAME_NS> <PN_LOCAL>>
-| <BLANK_NODE_LABEL: "_:" (<PN_CHARS_U> | ["0"-"9"]) ((<PN_CHARS> | ".")* <PN_CHARS>)?>
-| <VAR1: "?" <VARNAME>>
-| <VAR2: "$" <VARNAME>>
-| <LANGTAG: <AT> (<A2Z>)+ ("-" (<A2ZN>)+)*>
-| <#A2Z: ["a"-"z","A"-"Z"]>
-| <#A2ZN: ["a"-"z","A"-"Z","0"-"9"]>
-}
-
-<DEFAULT> TOKEN : {
-<KW_A: "a">
-}
-
-<DEFAULT> TOKEN [IGNORE_CASE] : {
-<BASE: "base">
-| <PREFIX: "prefix">
-| <SELECT: "select">
-| <DISTINCT: "distinct">
-| <REDUCED: "reduced">
-| <DESCRIBE: "describe">
-| <CONSTRUCT: "construct">
-| <ASK: "ask">
-| <LIMIT: "limit">
-| <OFFSET: "offset">
-| <ORDER: "order">
-| <BY: "by">
-| <VALUES: "values">
-| <UNDEF: "undef">
-| <ASC: "asc">
-| <DESC: "desc">
-| <NAMED: "named">
-| <FROM: "from">
-| <WHERE: "where">
-| <AND: "and">
-| <GRAPH: "graph">
-| <OPTIONAL: "optional">
-| <UNION: "union">
-| <MINUS_P: "minus">
-| <BIND: "bind">
-| <SERVICE: "service">
-| <TRIPLE: "TRIPLE">
-| <IS_TRIPLE: "isTRIPLE">
-| <SUBJECT: "SUBJECT">
-| <PREDICATE: "PREDICATE">
-| <OBJECT: "OBJECT">
-| <EXISTS: "exists">
-| <NOT: "not">
-| <AS: "as">
-| <GROUP: "group">
-| <HAVING: "having">
-| <SEPARATOR: "separator">
-| <AGG: "agg">
-| <COUNT: "count">
-| <MIN: "min">
-| <MAX: "max">
-| <SUM: "sum">
-| <AVG: "avg">
-| <STDEV: "stdev">
-| <STDEV_SAMP: "stdev_samp">
-| <STDEV_POP: "stdev_pop">
-| <VARIANCE: "variance">
-| <VAR_SAMP: "var_samp">
-| <VAR_POP: "var_pop">
-| <SAMPLE: "sample">
-| <GROUP_CONCAT: "group_concat">
-| <FILTER: "filter">
-| <BOUND: "bound">
-| <COALESCE: "coalesce">
-| <IN: "in">
-| <IF: "if">
-| <BNODE: "bnode">
-| <IRI: "iri">
-| <URI: "uri">
-| <STR: "str">
-| <STRLANG: "strlang">
-| <STRDT: "strdt">
-| <DTYPE: "datatype">
-| <LANG: "lang">
-| <LANGMATCHES: "langmatches">
-| <IS_URI: "isURI">
-| <IS_IRI: "isIRI">
-| <IS_BLANK: "isBlank">
-| <IS_LITERAL: "isLiteral">
-| <IS_NUMERIC: "isNumeric">
-| <REGEX: "regex">
-| <SAME_TERM: "sameTerm">
-| <RAND: "RAND">
-| <ABS: "ABS">
-| <CEIL: "CEIL">
-| <FLOOR: "FLOOR">
-| <ROUND: "ROUND">
-| <CONCAT: "CONCAT">
-| <SUBSTR: "SUBSTR">
-| <STRLEN: "STRLEN">
-| <REPLACE: "REPLACE">
-| <UCASE: "UCASE">
-| <LCASE: "LCASE">
-| <ENCODE_FOR_URI: "ENCODE_FOR_URI">
-| <CONTAINS: "CONTAINS">
-| <STRSTARTS: "STRSTARTS">
-| <STRENDS: "STRENDS">
-| <STRBEFORE: "STRBEFORE">
-| <STRAFTER: "STRAFTER">
-| <YEAR: "YEAR">
-| <MONTH: "MONTH">
-| <DAY: "DAY">
-| <HOURS: "HOURS">
-| <MINUTES: "MINUTES">
-| <SECONDS: "SECONDS">
-| <TIMEZONE: "TIMEZONE">
-| <TZ: "TZ">
-| <NOW: "NOW">
-| <UUID: "UUID">
-| <STRUUID: "STRUUID">
-| <MD5: "MD5">
-| <SHA1: "SHA1">
-| <SHA224: "SHA224">
-| <SHA256: "SHA256">
-| <SHA384: "SHA384">
-| <SHA512: "SHA512">
-| <TRUE: "true">
-| <FALSE: "false">
-}
-
-<DEFAULT> TOKEN [IGNORE_CASE] : {
-<DATA: "data">
-| <INSERT: "insert">
-| <DELETE: "delete">
-| <INSERT_DATA: <INSERT> (<WSC>)* <DATA>>
-| <DELETE_DATA: <DELETE> (<WSC>)* <DATA>>
-| <DELETE_WHERE: <DELETE> (<WSC>)* <WHERE>>
-| <LOAD: "load">
-| <CLEAR: "clear">
-| <CREATE: "create">
-| <ADD: "add">
-| <MOVE: "move">
-| <COPY: "copy">
-| <META: "meta">
-| <SILENT: "silent">
-| <DROP: "drop">
-| <INTO: "into">
-| <TO: "to">
-| <DFT: "default">
-| <ALL: "all">
-| <WITH: "with">
-| <USING: "using">
-}
-
-<DEFAULT> TOKEN : {
-<#DIGITS: (["0"-"9"])+>
-| <INTEGER: <DIGITS>>
-| <DECIMAL: (<DIGITS>)? "." <DIGITS>>
-| <DOUBLE: (["0"-"9"])+ "." (["0"-"9"])* <EXPONENT> | "." (["0"-"9"])+ <EXPONENT> | (["0"-"9"])+ <EXPONENT>>
-| <INTEGER_POSITIVE: <PLUS> <INTEGER>>
-| <DECIMAL_POSITIVE: <PLUS> <DECIMAL>>
-| <DOUBLE_POSITIVE: <PLUS> <DOUBLE>>
-| <INTEGER_NEGATIVE: <MINUS> <INTEGER>>
-| <DECIMAL_NEGATIVE: <MINUS> <DECIMAL>>
-| <DOUBLE_NEGATIVE: <MINUS> <DOUBLE>>
-| <#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+>
-| <#QUOTE_3D: "\"\"\"">
-| <#QUOTE_3S: "\'\'\'">
-| <ECHAR: "\\" ("t" | "b" | "n" | "r" | "f" | "\\" | "\"" | "\'")>
-| <#UCHAR: <UCHAR8>>
-| <#UCHAR4: "\\" "u" <HEX> <HEX> <HEX> <HEX>>
-| <#UCHAR8: "\\" "U" <HEX> <HEX> <HEX> <HEX> <HEX> <HEX> <HEX> <HEX>>
-| <STRING_LITERAL1: "\'" (~["\'","\\","\n","\r"] | <ECHAR> | <UCHAR>)* "\'">
-| <STRING_LITERAL2: "\"" (~["\"","\\","\n","\r"] | <ECHAR> | <UCHAR>)* "\"">
-| <STRING_LITERAL_LONG1: <QUOTE_3S> (("\'" | "\'\'")? (~["\'","\\"] | <ECHAR> | <UCHAR>))* <QUOTE_3S>>
-| <STRING_LITERAL_LONG2: <QUOTE_3D> (("\"" | "\"\"")? (~["\"","\\"] | <ECHAR> | <UCHAR>))* <QUOTE_3D>>
-}
-
-<DEFAULT> TOKEN : {
-<LPAREN: "(">
-| <RPAREN: ")">
-| <NIL: <LPAREN> (<WSC>)* <RPAREN>>
-| <LBRACE: "{">
-| <RBRACE: "}">
-| <LBRACKET: "[">
-| <RBRACKET: "]">
-| <ANON: <LBRACKET> (<WSC>)* <RBRACKET>>
-| <SEMICOLON: ";">
-| <COMMA: ",">
-| <DOT: ".">
-| <EQ: "=">
-| <NE: "!=">
-| <GT: ">">
-| <LT: "<">
-| <LE: "<=">
-| <GE: ">=">
-| <GT2: ">>">
-| <LT2: "<<">
-| <L_ANN: "{|">
-| <R_ANN: "|}">
-| <BANG: "!">
-| <TILDE: "~">
-| <COLON: ":">
-| <SC_OR: "||">
-| <SC_AND: "&&">
-| <PLUS: "+">
-| <MINUS: "-">
-| <STAR: "*">
-| <SLASH: "/">
-| <DATATYPE: "^^">
-| <AT: "@">
-| <VBAR: "|">
-| <CARAT: "^">
-| <FPATH: "->">
-| <RPATH: "<-">
-| <QMARK: "?">
-}
-
-<DEFAULT> TOKEN : {
-<#PN_CHARS_BASE: ["A"-"Z"] | ["a"-"z"] | ["\u00c0"-"\u00d6"] | ["\u00d8"-"\u00f6"] | ["\u00f8"-"\u02ff"] | ["\u0370"-"\u037d"] | ["\u037f"-"\u1fff"] | ["\u200c"-"\u200d"] | ["\u2070"-"\u218f"] | ["\u2c00"-"\u2fef"] | ["\u3001"-"\ud7ff"] | ["\uf900"-"\ufffd"]>
-| <#PN_CHARS_U: <PN_CHARS_BASE> | "_">
-| <#PN_CHARS: <PN_CHARS_U> | "-" | ["0"-"9"] | "\u00b7" | ["\u0300"-"\u036f"] | ["\u203f"-"\u2040"]>
-| <#PN_PREFIX: <PN_CHARS_BASE> ((<PN_CHARS> | ".")* <PN_CHARS>)?>
-| <#PN_LOCAL: (<PN_CHARS_U> | ":" | ["0"-"9"] | <PLX>) ((<PN_CHARS> | "." | ":" | <PLX>)* (<PN_CHARS> | ":" | <PLX>))?>
-| <#VARNAME: (<PN_CHARS_U> | ["0"-"9"]) (<PN_CHARS_U> | ["0"-"9"] | "\u00b7" | ["\u0300"-"\u036f"] | ["\u203f"-"\u2040"])*>
-| <#PN_LOCAL_ESC: "\\" ("_" | "~" | "." | "-" | "!" | "$" | "&" | "\'" | "(" | ")" | "*" | "+" | "," | ";" | "=" | "/" | "?" | "#" | "@" | "%")>
-| <#PLX: <PERCENT> | <PN_LOCAL_ESC>>
-| <#HEX: ["0"-"9"] | ["A"-"F"] | ["a"-"f"]>
-| <#PERCENT: "%" <HEX> <HEX>>
-}
-
-<DEFAULT> TOKEN : {
-<#UNKNOWN: (~[" ","\t","\n","\r","\f"])+>
-}
-
-NON-TERMINALS
- QueryUnit := Query <EOF>
- Query := Prologue ( SelectQuery | ConstructQuery | DescribeQuery | AskQuery ) ValuesClause
- UpdateUnit := Update <EOF>
- Prologue := ( BaseDecl | PrefixDecl )*
- BaseDecl := <BASE> IRIREF
- PrefixDecl := <PREFIX> <PNAME_NS> IRIREF
- SelectQuery := SelectClause ( DatasetClause )* WhereClause SolutionModifier
- SubSelect := SelectClause WhereClause SolutionModifier ValuesClause
- SelectClause := <SELECT> ( <DISTINCT> | <REDUCED> )? ( ( Var | ( <LPAREN> Expression <AS> Var <RPAREN> ) )+ | <STAR> )
- ConstructQuery := <CONSTRUCT> ( ConstructTemplate ( DatasetClause )* WhereClause SolutionModifier | ( DatasetClause )* <WHERE> <LBRACE> ( TriplesTemplate )? <RBRACE> SolutionModifier )
- DescribeQuery := <DESCRIBE> ( ( VarOrIri )+ | <STAR> ) ( DatasetClause )* ( WhereClause )? SolutionModifier
- AskQuery := <ASK> ( DatasetClause )* WhereClause SolutionModifier
- DatasetClause := <FROM> ( DefaultGraphClause | NamedGraphClause )
- DefaultGraphClause := SourceSelector
- NamedGraphClause := <NAMED> SourceSelector
- SourceSelector := iri
- WhereClause := ( <WHERE> )? GroupGraphPattern
- SolutionModifier := ( GroupClause )? ( HavingClause )? ( OrderClause )? ( LimitOffsetClauses )?
- GroupClause := <GROUP> <BY> ( GroupCondition )+
- GroupCondition := ( BuiltInCall | FunctionCall | <LPAREN> Expression ( <AS> Var )? <RPAREN> | Var )
- HavingClause := <HAVING> ( HavingCondition )+
- HavingCondition := Constraint
- OrderClause := <ORDER> <BY> ( OrderCondition )+
- OrderCondition := ( ( ( <ASC> | <DESC> ) BrackettedExpression ) | ( Constraint | Var ) )
- LimitOffsetClauses := ( LimitClause ( OffsetClause )? | OffsetClause ( LimitClause )? )
- LimitClause := <LIMIT> <INTEGER>
- OffsetClause := <OFFSET> <INTEGER>
- ValuesClause := ( <VALUES> DataBlock )?
- Update := Prologue ( Update1 ( <SEMICOLON> Update )? )?
- Update1 := ( Load | Clear | Drop | Add | Move | Copy | Create | DeleteWhere | Modify | InsertData | DeleteData )
- Load := <LOAD> ( <SILENT> )? iri ( <INTO> GraphRef )?
- Clear := <CLEAR> ( <SILENT> )? GraphRefAll
- Drop := <DROP> ( <SILENT> )? GraphRefAll
- Create := <CREATE> ( <SILENT> )? GraphRef
- Add := <ADD> ( <SILENT> )? GraphOrDefault <TO> GraphOrDefault
- Move := <MOVE> ( <SILENT> )? GraphOrDefault <TO> GraphOrDefault
- Copy := <COPY> ( <SILENT> )? GraphOrDefault <TO> GraphOrDefault
- InsertData := <INSERT_DATA> QuadData
- DeleteData := <DELETE_DATA> QuadData
- DeleteWhere := <DELETE_WHERE> QuadPattern
- Modify := ( <WITH> iri )? ( DeleteClause ( InsertClause )? | InsertClause ) ( UsingClause )* <WHERE> GroupGraphPattern
- DeleteClause := <DELETE> QuadPattern
- InsertClause := <INSERT> QuadPattern
- UsingClause := <USING> ( iri | <NAMED> iri )
- GraphOrDefault := ( <DFT> | ( <GRAPH> )? iri )
- GraphRef := <GRAPH> iri
- GraphRefAll := ( GraphRef | <DFT> | <NAMED> | <ALL> )
- QuadPattern := <LBRACE> Quads <RBRACE>
- QuadData := <LBRACE> Quads <RBRACE>
- Quads := ( TriplesTemplate )? ( QuadsNotTriples ( <DOT> )? ( TriplesTemplate )? )*
- QuadsNotTriples := <GRAPH> VarOrIri <LBRACE> ( TriplesTemplate )? <RBRACE>
- TriplesTemplate := TriplesSameSubject ( <DOT> ( TriplesTemplate )? )?
- GroupGraphPattern := <LBRACE> ( SubSelect | GroupGraphPatternSub ) <RBRACE>
- GroupGraphPatternSub := ( TriplesBlock )? ( GraphPatternNotTriples ( <DOT> )? ( TriplesBlock )? )*
- TriplesBlock := TriplesSameSubjectPath ( <DOT> ( TriplesBlock )? )?
- GraphPatternNotTriples := ( GroupOrUnionGraphPattern | OptionalGraphPattern | MinusGraphPattern | GraphGraphPattern | ServiceGraphPattern | Filter | Bind | InlineData )
- OptionalGraphPattern := <OPTIONAL> GroupGraphPattern
- GraphGraphPattern := <GRAPH> VarOrIri GroupGraphPattern
- ServiceGraphPattern := <SERVICE> ( <SILENT> )? VarOrIri GroupGraphPattern
- Bind := <BIND> <LPAREN> Expression <AS> Var <RPAREN>
- InlineData := <VALUES> DataBlock
- DataBlock := ( InlineDataOneVar | InlineDataFull )
- InlineDataOneVar := Var <LBRACE> ( DataBlockValue )* <RBRACE>
- InlineDataFull := ( <NIL> | <LPAREN> ( Var )* <RPAREN> ) <LBRACE> ( <LPAREN> ( DataBlockValue )* <RPAREN> | <NIL> )* <RBRACE>
- DataBlockValue := iri
- | RDFLiteral
- | NumericLiteral
- | BooleanLiteral
- | <UNDEF>
- | QuotedTripleData
- MinusGraphPattern := <MINUS_P> GroupGraphPattern
- GroupOrUnionGraphPattern := GroupGraphPattern ( <UNION> GroupGraphPattern )*
- Filter := <FILTER> Constraint
- Constraint := ( BrackettedExpression | BuiltInCall | FunctionCall )
- FunctionCall := iri ArgList
- ArgList := ( <NIL> | <LPAREN> ( <DISTINCT> )? Expression ( <COMMA> Expression )* <RPAREN> )
- ExpressionList := ( <NIL> | <LPAREN> Expression ( <COMMA> Expression )* <RPAREN> )
- ConstructTemplate := <LBRACE> ( ConstructTriples )? <RBRACE>
- ConstructTriples := TriplesSameSubject ( <DOT> ( ConstructTriples )? )?
- TriplesSameSubject := VarOrTerm PropertyListNotEmpty
- | TriplesNode PropertyList
- PropertyList := ( PropertyListNotEmpty )?
- PropertyListNotEmpty := Verb ObjectList ( <SEMICOLON> ( Verb ObjectList )? )*
- Verb := ( VarOrIri | <KW_A> )
- ObjectList := Object ( <COMMA> Object )*
- Object := GraphNode Annotation
- TriplesSameSubjectPath := VarOrTerm PropertyListPathNotEmpty
- | TriplesNodePath PropertyListPath
- PropertyListPath := ( PropertyListPathNotEmpty )?
- PropertyListPathNotEmpty := ( VerbPath | VerbSimple ) ObjectListPath ( <SEMICOLON> ( ( VerbPath | VerbSimple ) ObjectListPath )? )*
- VerbPath := Path
- VerbSimple := Var
- ObjectListPath := ObjectPath ( <COMMA> ObjectPath )*
- ObjectPath := GraphNodePath AnnotationPath
- Path := PathAlternative
- PathAlternative := PathSequence ( <VBAR> PathSequence )*
- PathSequence := PathEltOrInverse ( <SLASH> PathEltOrInverse )*
- PathElt := PathPrimary ( PathMod )?
- PathEltOrInverse := ( PathElt | <CARAT> PathElt )
- PathMod := ( <QMARK> | <STAR> | <PLUS> )
- PathPrimary := ( iri | <KW_A> | <BANG> PathNegatedPropertySet | <LPAREN> Path <RPAREN> )
- PathNegatedPropertySet := ( PathOneInPropertySet | <LPAREN> ( PathOneInPropertySet ( <VBAR> PathOneInPropertySet )* )? <RPAREN> )
- PathOneInPropertySet := ( iri | <KW_A> | <CARAT> ( iri | <KW_A> ) )
- Integer := <INTEGER>
- TriplesNode := Collection
- | BlankNodePropertyList
- BlankNodePropertyList := <LBRACKET> PropertyListNotEmpty <RBRACKET>
- TriplesNodePath := CollectionPath
- | BlankNodePropertyListPath
- BlankNodePropertyListPath := <LBRACKET> PropertyListPathNotEmpty <RBRACKET>
- Collection := <LPAREN> ( GraphNode )+ <RPAREN>
- CollectionPath := <LPAREN> ( GraphNodePath )+ <RPAREN>
- AnnotationPath := ( <L_ANN> PropertyListPathNotEmpty <R_ANN> )?
- Annotation := ( <L_ANN> PropertyListNotEmpty <R_ANN> )?
- GraphNode := VarOrTerm
- | TriplesNode
- GraphNodePath := VarOrTerm
- | TriplesNodePath
- VarOrTerm := ( Var | iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | <NIL> | QuotedTriple )
- QuotedTriple := <LT2> VarOrTerm Verb VarOrTerm <GT2>
- QuotedTripleData := <LT2> ( DataValueTerm ) ( iri | <KW_A> ) ( DataValueTerm ) <GT2>
- DataValueTerm := iri
- | RDFLiteral
- | NumericLiteral
- | BooleanLiteral
- | QuotedTripleData
- VarOrIri := ( Var | iri )
- Var := ( <VAR1> | <VAR2> )
- Expression := ConditionalOrExpression
- ConditionalOrExpression := ConditionalAndExpression ( <SC_OR> ConditionalAndExpression )*
- ConditionalAndExpression := ValueLogical ( <SC_AND> ValueLogical )*
- ValueLogical := RelationalExpression
- RelationalExpression := NumericExpression ( <EQ> NumericExpression | <NE> NumericExpression | <LT> NumericExpression | <GT> NumericExpression | <LE> NumericExpression | <GE> NumericExpression | <IN> ExpressionList | <NOT> <IN> ExpressionList )?
- NumericExpression := AdditiveExpression
- AdditiveExpression := MultiplicativeExpression ( <PLUS> MultiplicativeExpression | <MINUS> MultiplicativeExpression | ( NumericLiteralPositive | NumericLiteralNegative ) ( ( <STAR> UnaryExpression ) | ( <SLASH> UnaryExpression ) )* )*
- MultiplicativeExpression := UnaryExpression ( <STAR> UnaryExpression | <SLASH> UnaryExpression )*
- UnaryExpression := <BANG> PrimaryExpression
- | <PLUS> PrimaryExpression
- | <MINUS> PrimaryExpression
- | PrimaryExpression
- PrimaryExpression := ( BrackettedExpression | BuiltInCall | iriOrFunction | RDFLiteral | NumericLiteral | BooleanLiteral | Var | ExprQuotedTriple )
- ExprVarOrTerm := ( iri | RDFLiteral | NumericLiteral | BooleanLiteral | Var | ExprQuotedTriple )
- ExprQuotedTriple := <LT2> ExprVarOrTerm Verb ExprVarOrTerm <GT2>
- BrackettedExpression := <LPAREN> Expression <RPAREN>
- BuiltInCall := Aggregate
- | <STR> <LPAREN> Expression <RPAREN>
- | <LANG> <LPAREN> Expression <RPAREN>
- | <LANGMATCHES> <LPAREN> Expression <COMMA> Expression <RPAREN>
- | <DTYPE> <LPAREN> Expression <RPAREN>
- | <BOUND> <LPAREN> Var <RPAREN>
- | <IRI> <LPAREN> Expression <RPAREN>
- | <URI> <LPAREN> Expression <RPAREN>
- | <BNODE> ( <LPAREN> Expression <RPAREN> | <NIL> )
- | <RAND> <NIL>
- | <ABS> <LPAREN> Expression <RPAREN>
- | <CEIL> <LPAREN> Expression <RPAREN>
- | <FLOOR> <LPAREN> Expression <RPAREN>
- | <ROUND> <LPAREN> Expression <RPAREN>
- | <CONCAT> ExpressionList
- | SubstringExpression
- | <STRLEN> <LPAREN> Expression <RPAREN>
- | StrReplaceExpression
- | <UCASE> <LPAREN> Expression <RPAREN>
- | <LCASE> <LPAREN> Expression <RPAREN>
- | <ENCODE_FOR_URI> <LPAREN> Expression <RPAREN>
- | <CONTAINS> <LPAREN> Expression <COMMA> Expression <RPAREN>
- | <STRSTARTS> <LPAREN> Expression <COMMA> Expression <RPAREN>
- | <STRENDS> <LPAREN> Expression <COMMA> Expression <RPAREN>
- | <STRBEFORE> <LPAREN> Expression <COMMA> Expression <RPAREN>
- | <STRAFTER> <LPAREN> Expression <COMMA> Expression <RPAREN>
- | <YEAR> <LPAREN> Expression <RPAREN>
- | <MONTH> <LPAREN> Expression <RPAREN>
- | <DAY> <LPAREN> Expression <RPAREN>
- | <HOURS> <LPAREN> Expression <RPAREN>
- | <MINUTES> <LPAREN> Expression <RPAREN>
- | <SECONDS> <LPAREN> Expression <RPAREN>
- | <TIMEZONE> <LPAREN> Expression <RPAREN>
- | <TZ> <LPAREN> Expression <RPAREN>
- | <NOW> <NIL>
- | <UUID> <NIL>
- | <STRUUID> <NIL>
- | <MD5> <LPAREN> Expression <RPAREN>
- | <SHA1> <LPAREN> Expression <RPAREN>
- | <SHA256> <LPAREN> Expression <RPAREN>
- | <SHA384> <LPAREN> Expression <RPAREN>
- | <SHA512> <LPAREN> Expression <RPAREN>
- | <COALESCE> ExpressionList
- | <IF> <LPAREN> Expression <COMMA> Expression <COMMA> Expression <RPAREN>
- | <STRLANG> <LPAREN> Expression <COMMA> Expression <RPAREN>
- | <STRDT> <LPAREN> Expression <COMMA> Expression <RPAREN>
- | <SAME_TERM> <LPAREN> Expression <COMMA> Expression <RPAREN>
- | <IS_IRI> <LPAREN> Expression <RPAREN>
- | <IS_URI> <LPAREN> Expression <RPAREN>
- | <IS_BLANK> <LPAREN> Expression <RPAREN>
- | <IS_LITERAL> <LPAREN> Expression <RPAREN>
- | <IS_NUMERIC> <LPAREN> Expression <RPAREN>
- | RegexExpression
- | ExistsFunc
- | NotExistsFunc
- | <IS_TRIPLE> <LPAREN> Expression <RPAREN>
- | <TRIPLE> <LPAREN> Expression <COMMA> Expression <COMMA> Expression <RPAREN>
- | <SUBJECT> <LPAREN> Expression <RPAREN>
- | <PREDICATE> <LPAREN> Expression <RPAREN>
- | <OBJECT> <LPAREN> Expression <RPAREN>
- RegexExpression := <REGEX> <LPAREN> Expression <COMMA> Expression ( <COMMA> Expression )? <RPAREN>
- SubstringExpression := <SUBSTR> <LPAREN> Expression <COMMA> Expression ( <COMMA> Expression )? <RPAREN>
- StrReplaceExpression := <REPLACE> <LPAREN> Expression <COMMA> Expression <COMMA> Expression ( <COMMA> Expression )? <RPAREN>
- ExistsFunc := <EXISTS> GroupGraphPattern
- NotExistsFunc := <NOT> <EXISTS> GroupGraphPattern
- Aggregate := ( <COUNT> <LPAREN> ( <DISTINCT> )? ( <STAR> | Expression ) <RPAREN> | <SUM> <LPAREN> ( <DISTINCT> )? Expression <RPAREN> | <MIN> <LPAREN> ( <DISTINCT> )? Expression <RPAREN> | <MAX> <LPAREN> ( <DISTINCT> )? Expression <RPAREN> | <AVG> <LPAREN> ( <DISTINCT> )? Expression <RPAREN> | <SAMPLE> <LPAREN> ( <DISTINCT> )? Expression <RPAREN> | <GROUP_CONCAT> <LPAREN> ( <DISTINCT> )? Expression ( <SEMICOLON> <SEPARATOR> <EQ> String )? <RPAREN> )
- iriOrFunction := iri ( ArgList )?
- RDFLiteral := String ( ( <LANGTAG> ) | ( <DATATYPE> iri ) )?
- NumericLiteral := ( NumericLiteralUnsigned | NumericLiteralPositive | NumericLiteralNegative )
- NumericLiteralUnsigned := <INTEGER>
- | <DECIMAL>
- | <DOUBLE>
- NumericLiteralPositive := <INTEGER_POSITIVE>
- | <DECIMAL_POSITIVE>
- | <DOUBLE_POSITIVE>
- NumericLiteralNegative := <INTEGER_NEGATIVE>
- | <DECIMAL_NEGATIVE>
- | <DOUBLE_NEGATIVE>
- BooleanLiteral := <TRUE>
- | <FALSE>
- String := ( <STRING_LITERAL1> | <STRING_LITERAL2> | <STRING_LITERAL_LONG1> | <STRING_LITERAL_LONG2> )
- iri := IRIREF
- | PrefixedName
- PrefixedName := ( <PNAME_LN> | <PNAME_NS> )
- BlankNode := <BLANK_NODE_LABEL>
- | <ANON>
- IRIREF := <IRIref>
-
-DOCUMENT END
diff --git a/jena-arq/Grammar/sse/grammar-sse b/jena-arq/Grammar/sse/grammar-sse
index 3567de44b0..d7d35f9527 100755
--- a/jena-arq/Grammar/sse/grammar-sse
+++ b/jena-arq/Grammar/sse/grammar-sse
@@ -40,8 +40,8 @@ function grammar
## echo "---- Create HTML"
## jjdoc -OUTPUT_FILE=${FILE%%.jj}.html "${FILE}"
- echo "---- Create text form"
- jjdoc -TEXT=true -OUTPUT_FILE=${FILE%%.jj}.txt "${FILE}"
+## echo "---- Create text form"
+## jjdoc -TEXT=true -OUTPUT_FILE=${FILE%%.jj}.txt "${FILE}"
echo "---- Fixing Java warnings in TokenMgrError"
F="$DIR/TokenMgrError.java"
@@ -57,19 +57,18 @@ function grammar
if [ $# == 0 ]
then
set -- unisyn
- ## echo "Usage: grammar [arq|sparql|rdql]" 1>&2
- ## exit 1
- fi
+fi
for G in "$@"
do
case "$G" in
unisyn)
- cp ../header.jj parser.jj
- # The parser that is exactly the working group grammar
- cat "$GRAMMAR" | cpp -P >> parser.jj
- grammar parser.jj sse/lang/parser SSE_ParserCore
- [ "$RC" = 0 ] && rm parser.jj
+## cp ../header.jj parser.jj
+## # The parser that is exactly the working group grammar
+## cat "$GRAMMAR" | cpp -P >> parser.jj
+## grammar parser.jj sse/lang/parser SSE_ParserCore
+## [ "$RC" = 0 ] && rm parser.jj
+ grammar sse.jj sse/lang/parser SSE_ParserCore
;;
*) echo "**** Unknown grammar: $G" 1>&2
;;
diff --git a/jena-arq/Grammar/sse/jj2html b/jena-arq/Grammar/sse/jj2html
deleted file mode 100644
index 0f83ee7a9b..0000000000
--- a/jena-arq/Grammar/sse/jj2html
+++ /dev/null
@@ -1,469 +0,0 @@
-#!/bin/perl
-## 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
-##
-## http://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.
-
-# Grammar into HTML
-# Read in sparql.txt and the tokens.txt file
-
-## ToDo:
-## Check tokens exist and are used
-## Validate
-
-
-if ( $#ARGV != 1 )
-{
- print STDERR "Usage: grammar.txt tokens.txt\n" ;
- exit 1 ;
-}
-
-
-
-$/ = undef ;
-# Just table or full page.
-$TABLE = 1 ;
-
-$grammarFile = $ARGV[0] ;
-$tokensFile = $ARGV[1] ;
-
-## $grammarFile = 's.txt' ;
-## $tokensFile = 't.txt' ;
-
-
-$grammar = &readFile($grammarFile) ;
-$tokens = &readFile($tokensFile) ;
-
-$grammar =~ s!DOCUMENT START!! ;
-$grammar =~ s!NON-TERMINALS!! ;
-$grammar =~ s!DOCUMENT END!! ;
-
-$grammar =~ s!//.*!!g ;
-$grammar =~ s!\r!!g ;
-
-# remove leading whitespace
-$grammar =~ s!^[\n\s]*!\n! ;
-
-# Merge alts
-$grammar =~ s!\n\s*\|!\ |!g ;
-
-$tokens =~ s!//.*!!g ;
-$tokens =~ s!\r!!g ;
-
-
-## Grammar
-#print "GRAMMAR\n" ;
-
-@g = split(/\n\s*/, $grammar) ;
-
-@rules = () ;
-%ruleMap = () ;
-%tokenMap = () ;
-%inline = () ;
-
-# Grammar rules
-# Direct from "jjdoc -TEXT=true"
-
-for $g (@g)
-{
- ($rulename, $rulebody) = split(/:=/,$g) ;
-
- $rulename =~ s!^\s*!! ;
- $rulename =~ s!\s*$!! ;
-
- $rulebody =~ s!^\s*!! ;
- $rulebody =~ s!\s*$!! ;
-
- # Remove outer brackets
-# $rulebody =~ s!^\((.*)\)$!$1! ;
-
- # Remove <> around tokens in grammar.
- ## Now done very late (as <>) in fixups.
- ## $rulebody =~ s/\<(\w+)\>/$1/g ;
- # Leave in - so tokens distinguished from rules
-
- next if $rulename eq '' ;
- #next if $rulebody eq '' ;
-
- # Skip the root rule.
- next if ( $rulename eq 'CompilationUnit' ) ;
-
- $rulebody = 'Perl 5 regular expression'
- if ( $rulename eq 'PatternLiteral' ) ;
-
- push @rules, $rulename ;
- warn "Duplicate rule (grammar): $rulename\n" if defined($ruleMap{$rulename}) ;
- $ruleMap{$rulename} = $rulebody ;
-
-## print "----------\n" ;
-## print $rulename,"\n" ;
-## print $rulebody,"\n" ;
-
-}
-
-
-# Tokens
-# Produced by "jj2tokens"
-# Hand edited to indicate the inlines
-
-$tokens =~ s/\n+/\n/g ;
-$tokens =~ s/^\n// ;
-
-@t = split(/\n(?=\<|\[)/, $tokens) ;
-
-for $t (@t)
-{
- ($tokenname,$tokenbody) = split(/::=/, $t) ;
- $tokenname =~ s!^\s*!! ;
- $tokenname =~ s!\s*$!! ;
-
-## # remove <> around tokens
-## Do very late as a formatting fix up.
-## $tokenname =~ s/^\<// ;
-## $tokenname =~ s/\>$// ;
-
- $tokenname =~ s/#// ;
-
- $tokenbody =~ s!^\s*!! ;
- $tokenbody =~ s!\s*$!! ;
-
- # <> round tokens
- # Remove at last minute.
-
- # Remove outer ()
- # $tokenbody =~ s!^\((.*)\)$!$1! ;
-
- # Inline?
- if ( $tokenname =~ /^\[\<\w*\>\]/ )
- {
- warn "Duplicate inline (token): $tokenname\n" if defined($inline{$tokenname}) ;
- $tokenname =~ s/^\[//g ;
- $tokenname =~ s/\]$//g ;
- $tokenbody =~ s/"/'/g ; # '" -- But not literal " -- how?
- $tokenbody =~ s/\<\>\'\{\}/\<\>\"\{\}/ ; # '" IRI fixup
-
- $inline{$tokenname} = $tokenbody ;
-
- #print "INLINE: ",$tokenname," => ",$tokenbody,"\n" ;
- }
- else
- {
- push @rules, $tokenname ;
- warn "Duplicate rule (token): $tokenname\n" if defined($tokenMap{$tokenname}) ;
- $ruleMap{$tokenname} = $tokenbody ;
- }
-}
-
-# Table
-
-if ( ! $TABLE )
-{
- print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" ;
- print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n" ;
- print " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n" ;
- print "\n" ;
-
- print "<html>\n";
- print "<head>\n";
- print "<title>SPARQL Grammar</title>\n" ;
- print "<style type=\"text/css\">\n" ;
-
- # .token inline
- # .ruleHead
- # .ruleBody
-
- print <<'EOF' ;
-div.grammarTable table * { border-width: 0 ; }
-div.grammarTable table * tr { border: 1px solid black ; }
-
-.grammar { text-align: left ; vertical-align: top ; }
-.token { color: #3f3f5f; }
-.gRuleHead { font-style: italic ; font-family: monospace ; }
-.gRuleBody { font-family: monospace ; }
-.gRuleLabel { font-family: monospace ; }
-EOF
-
- print "</style>\n" ;
- print "</head>\n";
- print "<body>\n";
-
- print "\n" ;
-}
-
-print "<div class=\"grammarTable\">\n" ;
-print " <table><tbody>\n" ;
-
-$ruleNum = 0 ;
-
-for $r (@rules)
-{
- $DEBUG = 0 ;
- $ruleNum++ ;
- $rulename = $r ;
-
- $rulebody = $ruleMap{$rulename} ;
-
-## $DEBUG = 1 if ( $rulename =~ /Prolog/ ) ;
-
- $rb = $rulebody ;
-
- if ( $DEBUG )
- {
- print STDERR "\n" ;
- print STDERR "Rule: $rulename\n" ;
- print STDERR "Body: $rulebody\n" ;
- }
-
- ## Do before '||' substitution
- # Not perfect - some fixups later.
- #$rb =~ s%\|%\<br/\>\|%g ;
-
- # Escape HTML chars before adding markup.
- $rb = esc($rb) ;
-
- # Inlines
- for $k (keys %inline)
- {
- $s = span('token', $inline{$k}) ;
- $k = esc($k) ;
- # Assumes escaped <> round tokens.
- $k = quotemeta $k ;
- $rb =~ s/$k/$s/g ;
-
- }
-
- if ( $DEBUG )
- {
- print STDERR "After inlining\n" ;
- print STDERR $rb,"\n" ; ;
- }
-
-
- # Add hrefs - issue if one is a substring of another \W helps.
-
- for $k (keys %ruleMap)
- {
- $s = href("r-".$k,$k) ;
-
- $k = esc($k) ;
- $k = quotemeta $k ;
-
-## if ( $DEBUG )
-## {
-## print STDERR "K:$k\n" ;
-## }
-
-
- $rb =~ s/(?=\W)(\s*)$k(\s*)(?=\W)/$1$s$2/g ;
- $rb =~ s/^$k(\s*)(?=\W)/$s$1/g ;
- $rb =~ s/(?=\W)(\s*)$k$/$1$s/g ;
- $rb =~ s/^$k$/$s/g ;
- }
-
- if ( $DEBUG )
- {
- print STDERR "After hrefs\n" ;
- print STDERR $rb,"\n" ; ;
- }
-
- #exit if $ruleNum > 2 ;
-
- $rn = anchor("r-".$rulename, $rulename) ;
- $rn = fixupHead($rn) ;
-
- print "\n" ;
- print "<tr valign=\"baseline\">\n" ;
- $rlabel = '[' . $ruleNum . '] ' ;
-
- print " <td>",code('gRuleLabel', $rlabel),"</td>\n" ;
-
- #print " <td>",span('gRuleHead', $rn),"</td>\n" ;
- print " <td>",code('gRuleHead',$rn),"</td>\n" ;
-
- print " <td> ::= </td>\n" ;
-
- $rb = fixupRule($rulename, $rb) ;
- print " <td>",code('gRuleBody',$rb),"</td>\n" ;
-
- print "</tr>\n" ;
-
-# $rule{$rulename, $rulebody) ;
-# print $rulename , "\n" ;
-}
-
-print " </tbody></table>\n" ;
-print "</div>\n" ;
-
-if ( !$TABLE )
-{
- print "\n" ;
- print "</body>\n" ;
- print "</html>\n" ;
-}
-
-sub readFile
-{
- my $f = $_[0] ;
- open(F, "$f") || die "$!";
- my $s = <F> ;
- return $s ;
-}
-
-sub esc
-{
- my $s = $_[0] ;
- $s =~ s/&/&/g ;
- $s =~ s/</</g ;
- $s =~ s/>/>/g ;
- return $s ;
-}
-
-sub span
-{
- my $c = $_[0] ;
- my $t = $_[1] ;
- $t = esc($t) ;
- my $s = '<span class="' . $c . '">' . $t . '</span>' ;
- return $s ;
-}
-
-sub href
-{
- my $a = $_[0] ;
- my $t = $_[1] ;
- $a = sane($a) ;
- $t = esc($t) ;
- my $s = '<a href="#' . $a . '">' . $t . '</a>' ;
- return $s ;
-}
-
-sub anchor
-{
- my $a = $_[0] ;
- my $t = $_[1] ;
- $a = sane($a) ;
- $t = esc($t) ;
- my $s = '<a id="' . $a . '" name="' . $a . '">' . $t . '</a>' ;
- return $s ;
-}
-
-sub sane
-{
- my $a = $_[0] ;
- $a =~ s/\W//g ;
- return $a ;
-}
-
-sub code
-{
- my $c = $_[0] ;
- my $t = $_[1] ;
- return '<code class="' . $c . '">' . $t . '</code>' ;
-}
-
-sub fixupHead
-{
- my $head = $_[0] ;
- # Remove <> around tokens.
- $head =~ s/<(\w+)>/$1/g ;
- return $head ;
-}
-
-sub fixupRule
-{
- my $head = $_[0] ;
- my $body = $_[1] ;
-
- # Remove unnecessary ()
- $body =~ s/\(\s*([^()| ]*) \)/$1/g ;
-
-## if ( $body =~ m!\(\s+(\<a[^>]*\>[^<>]*\</a\>)\s+\)! )
-## {
-## $b = $body ;
-## print "================================\n" ;
-## print STDERR "$b\n" ;
-## print STDERR "--------\n" ;
-## $b =~ s!\(\s+(\<a[^>]*\>[^<>]*\</a\>)\s+\)!$1!g ;
-## $b =~ s!\(\s+(\<span[^>]*\>[^<>]*\</span\>)\s+\)!$1!g ;
-## print STDERR "$b\n" ;
-## print STDERR "=====\n" ;
-## print STDERR "\n" ;
-## }
-
-
- # Remove outer matching () where there are no inner ()
- $body =~ s/^\(\s+([^\(]*)\s+\)$/$1/ ;
-
- # ( A )* => A* and for + and ? where A is a linked or spanned object
- $body =~ s!\(\s+(\<a[^>]*\>[^<>]*\</a\>)\s+\)!$1!g ;
- $body =~ s!\(\s+(\<span[^>]*\>[^<>]*\</span\>)\s+\)!$1!g ;
-
- # There aren't any of these
-## $body =~ s!\(\s+(\S*)\s+\)!$1!g ;
-
- # Remove <> around tokens.
- $body =~ s/<(\w+)>/$1/g ;
-
- # Specials
- # Split long bodies
- if ( $head eq "CallExpression" ||
- $head eq "UnaryExpression" ||
- $head eq "<NCCHAR1p>" ||
- $head eq "PatternElement" ||
- $head eq "BuiltInCall" )
- {
- $body =~ s%\|%\<br/\>\|%g ;
- $body =~ s/^\s+// ;
- $body = " ".$body ;
- }
-
- if ( $head eq "RelationalExpression" ||
- $head eq "AdditiveExpression" ||
- $head eq "MultiplicativeExpression" ||
- $head eq "ConditionalOrExpression")
- {
- $body =~ s%\*\(%<br/>\(% ;
- }
-
- # These failed the outer () test because they have nested () in them
- if ( $head eq "QueryPattern" ||
- $head eq "OrderCondition" )
- {
- # Remove outer ()
- $body =~ s/^\((.*)\)$/$1/ ;
- }
-
- if ( $head eq "Query" )
- {
- $body =~ s! \(!<br/>\(! ;
- $body =~ s!\) !\)<br/>! ;
- }
-
- if ( $head =~ m/(Select|Construct|Describe|Ask)Query/ )
- {
- # Put a line break before the DatasetClause
- # <a href="#rDatasetClause">DatasetClause</a>
- $c = '<a href="#rDatasetClause">DatasetClause</a>' ;
- $c = quotemeta $c ;
- # Expects the dataset clause to be unbracketted
- $body =~ s!(\(\s*$c)!<br/>$1! ;
- }
-
- if ( $head eq "OrderCondition" )
- {
- $body =~ s!\)\s*\|\s*\(!\)<br/>\| \(! ;
- $body = " ".$body ;
- }
- return $body ;
-}
diff --git a/jena-arq/Grammar/sse/sse.jj b/jena-arq/Grammar/sse/sse.jj
index b0dbd9df6e..889ec82f26 100644
--- a/jena-arq/Grammar/sse/sse.jj
+++ b/jena-arq/Grammar/sse/sse.jj
@@ -197,7 +197,7 @@ void BlankNode() : { Token t ; }
void TripleTerm() : { Token t1 = null ; Token t2 = null ; }
{
- t1 = <LT2>
+ t1 = <L_TRIPLE>
(<WS>)*
{ tripleTermStart(t1.beginLine, t1.beginColumn); }
RDFTermAtom()
@@ -206,7 +206,7 @@ void TripleTerm() : { Token t1 = null ; Token t2 = null ; }
(<WS>)*
RDFTermAtom()
(<WS>)*
- t2 = <GT2>
+ t2 = <R_TRIPLE>
{ tripleTermFinish(t2.beginLine, t2.beginColumn); }
}
@@ -225,7 +225,7 @@ void RDFLiteral() : { Token t = null ; int currLine ; int currColumn ;
// Optional lang tag and datatype.
(
- t = <LANGTAG> { lang = stripChars(t.image, 1) ; }
+ t = <LANG_DIR> { lang = stripChars(t.image, 1) ; }
|
<DATATYPE>
( t = <IRIref> { dt_iri = stripQuotes(t.image) ; }
@@ -245,7 +245,6 @@ void NumericLiteral() : { Token t ; }
{ emitLiteralDouble(t.beginLine, t.beginColumn, t.image) ; }
}
-// Symbol!
// Node BooleanLiteral() : {}
// {
// <TRUE> { return XSD_TRUE ; }
@@ -253,9 +252,177 @@ void NumericLiteral() : { Token t ; }
// <FALSE> { return XSD_FALSE ; }
// }
+TOKEN: { <WS: " " | "\t" | "\n" | "\r" | "\f"> }
+
// No whitespace skipping.
-#undef SKIP
-#include "tokens.inc"
+// SKIP : { <WS> } //" " | "\t" | "\n" | "\r" | "\f" }
+
+SPECIAL_TOKEN :
+{
+ <SINGLE_LINE_COMMENT1: "#" (~["\n","\r"])* ("\n"|"\r"|"\r\n")? >
+|
+ // Lisp-style comments (makes Emacs lisp-mode more useful)
+ <SINGLE_LINE_COMMENT2: ";" (~["\n","\r"])* ("\n"|"\r"|"\r\n")? >
+}
+
+TOKEN:
+{
+ <IRIref: "<"
+ ( ~[ ">","<", "\"", "{", "}", "^", "\\", "|", "`","\u0000"-"\u0020"]
+ | <UCHAR>
+ )*
+ ">" >
+
+| <PNAME: (<PN_PREFIX>)? ":" (<PN_LOCAL>)? >
+| <BLANK_NODE_LABEL: "_:" (<PN_LOCAL>)? > // Allows no label
+
+ // Co-ordinate with ARQConstants
+ // Named variable - allows no name
+| <VAR_NAMED: "?" (<VARNAME>)?>
+
+// // Non-distinguished variable (BNode in SPARQL)
+// | <VAR_NAMED2: "?." (~[" " , "\t" , "\n" , "\r" , "\f",
+// "(", ")", "[", "]", "{", "}"])* >
+//
+// | <VAR_ANON: "??" (~[ " " , "\t" , "\n" , "\r" , "\f",
+// "(", ")", "[", "]", "{", "}"])* >
+
+| <VAR_OTHER: "?" (<SYM>)+ >
+}
+
+TOKEN :
+{
+ < BOM: "\uFEFF">
+| < #DIGITS: (["0"-"9"])+>
+| < INTEGER: (["+","-"])? <DIGITS> >
+| < DECIMAL: (["+","-"])? ( <DIGITS> "." (<DIGITS>)* | "." <DIGITS> ) >
+| < DOUBLE: // Required exponent.
+ ( (["+","-"])?
+ (["0"-"9"])+ "." (["0"-"9"])* <EXPONENT>
+ | "." (["0"-"9"])+ (<EXPONENT>)
+ | (["0"-"9"])+ <EXPONENT>
+ )
+ >
+| < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
+| < #QUOTE_3D: "\"\"\"">
+| < #QUOTE_3S: "'''">
+
+| < #ECHAR: "\\" ( "t"|"b"|"n"|"r"|"f"|"\\"|"\""|"'") >
+| < #UCHAR: <UCHAR4> | <UCHAR8> >
+| < #UCHAR4: "\\" "u" <HEX> <HEX> <HEX> <HEX> >
+| < #UCHAR8: "\\" "U" <HEX> <HEX> <HEX> <HEX> <HEX> <HEX> <HEX> <HEX> >
+
+| < STRING_LITERAL1:
+ // Single quoted string
+ "'" ( (~["'","\\","\n","\r"]) | <ECHAR> | <UCHAR> )* "'" >
+| < STRING_LITERAL2:
+ // Double quoted string
+ "\"" ( (~["\"","\\","\n","\r"]) | <ECHAR> | <UCHAR> )* "\"" >
+| < STRING_LITERAL_LONG1:
+ <QUOTE_3S>
+ ( ("'" | "''")? (~["'","\\"] | <ECHAR> | <UCHAR> ))*
+ <QUOTE_3S> >
+| < STRING_LITERAL_LONG2:
+ <QUOTE_3D>
+ ( ("\"" | "\"\"")? (~["\"","\\"] | <ECHAR> | <UCHAR> ))*
+ <QUOTE_3D> >
+}
+
+TOKEN :
+{
+ < LPAREN: "(" >
+| < RPAREN: ")" >
+
+| < LBRACE: "{" >
+| < RBRACE: "}" >
+
+| < LBRACKET: "[" >
+| < RBRACKET: "]" >
+
+// RDF 1.2 triple term.
+| < L_TRIPLE : "<<(" >
+| < R_TRIPLE : ")>>" >
+}
+
+// Specials for literals trailing parts
+// Otherwise include in Symbol() rule for when out of position.
+TOKEN :
+{
+ < DATATYPE: "^^" >
+| <LANG_DIR: <AT> (<A2Z>)+("-" (<A2ZN>)+)* ( "--" (<A2Z>)* )? >
+| < #AT: "@">
+| <#A2Z: ["a"-"z","A"-"Z"]>
+| <#A2ZN: ["a"-"z","A"-"Z","0"-"9"]>
+}
+
+TOKEN:
+{
+ <#PN_CHARS_BASE:
+ ["A"-"Z"] | ["a"-"z"] |
+ ["\u00C0"-"\u00D6"] | ["\u00D8"-"\u00F6"] | ["\u00F8"-"\u02FF"] |
+ ["\u0370"-"\u037D"] | ["\u037F"-"\u1FFF"] |
+ ["\u200C"-"\u200D"] | ["\u2070"-"\u218F"] | ["\u2C00"-"\u2FEF"] |
+ ["\u3001"-"\uD7FF"] | ["\uF900"-"\uFFFD"]
+ // | [#x10000-#xEFFFF]
+ >
+|
+ // With underscore
+ <#PN_CHARS_U: <PN_CHARS_BASE> | "_" >
+|
+ <#PN_CHARS: (<PN_CHARS_U> | "-" | ["0"-"9"] | "\u00B7" |
+ ["\u0300"-"\u036F"] | ["\u203F"-"\u2040"] ) >
+|
+ // No leading "_", no trailing ".", can have dot inside prefix name.
+ <#PN_PREFIX: <PN_CHARS_BASE> ((<PN_CHARS>|".")* <PN_CHARS>)? >
+|
+ // Local part.
+ <#PN_LOCAL: (<PN_CHARS_U> | ":" | ["0"-"9"] | <PLX> )
+ ( (<PN_CHARS> | "." |":" | <PLX> )*
+ (<PN_CHARS> | ":" | <PLX>) )? >
+|
+ <#VARNAME: ( <PN_CHARS_U> | ["0"-"9"] )
+ ( <PN_CHARS_U> | ["0"-"9"] | "\u00B7" |
+ ["\u0300"-"\u036F"] | ["\u203F"-"\u2040"] )* >
+|
+ < #PN_LOCAL_ESC: "\\"
+ ( "_" |
+ "~" | "." | "-" | "!" | "$" | "&" | "'" |
+ "(" | ")" | "*" | "+" | "," | ";" | "=" |
+ "/" | "?" | "#" | "@" | "%" ) >
+|
+ <#PLX: <PERCENT> | <PN_LOCAL_ESC> >
+|
+ < #HEX: ["0"-"9"] | ["A"-"F"] | ["a"-"f"] >
+|
+ < #PERCENT: "%" <HEX> <HEX> >
+
+}
+
+TOKEN:
+{
+ // Anything left that isn't structural
+ // Excludes:
+ // LPAREN and RPAREN / LBRACKET/RBRACKET / LBRACE/RBRACE
+ // Quotes, Whitespace
+ <#SYM: (~["<", ">", "(", ")", "[", "]", "{", "}", "'", "\"", " ", "\t","\n","\r","\f" ])>
+|
+ <#SYM1: (~["^", "@",
+ "(", ")", "[", "]", "{", "}", "'", "\"", " ", "\t","\n","\r","\f" ])>
+| <#SYM_ESC: "\\" ( " " | "'" | "\"" ) >
+|
+ <SYMBOL: ( "<" | ">"
+ | (<SYM1> (<SYM>)*)
+ ) >
+}
+
+// Catch-all tokens. Must be last.
+// Any non-whitespace. Causes a parser exception, rather than a
+// token manager error (with hidden line numbers).
+// Only bad IRIs (e.g. spaces) now give unhelpful parse errors.
+TOKEN:
+{
+ <#UNKNOWN: (~[" ","\t","\n","\r","\f" ])+ >
+}
/*
# Local Variables:
diff --git a/jena-arq/Grammar/sse/tokens.inc b/jena-arq/Grammar/sse/tokens.inc
deleted file mode 100644
index 211dfaff03..0000000000
--- a/jena-arq/Grammar/sse/tokens.inc
+++ /dev/null
@@ -1,203 +0,0 @@
-/**
- * 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
- *
- * http://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.
- */
-
-// Basic tokens for SPARQL / RDF terms.
-// SSE - SPARQL S-Expressions
-// Not the keywords.
-
-
-TOKEN: { <WS: " " | "\t" | "\n" | "\r" | "\f"> }
-
-#ifdef SKIP
-SKIP : { <WS> } //" " | "\t" | "\n" | "\r" | "\f" }
-#endif
-
-SPECIAL_TOKEN :
-{
- <SINGLE_LINE_COMMENT1: "#" (~["\n","\r"])* ("\n"|"\r"|"\r\n")? >
-|
- // Lisp-style comments (makes Emacs lisp-mode more useful
- <SINGLE_LINE_COMMENT2: ";" (~["\n","\r"])* ("\n"|"\r"|"\r\n")? >
-}
-
-TOKEN:
-{
- <IRIref: "<"
- ( ~[ ">","<", "\"", "{", "}", "^", "\\", "|", "`","\u0000"-"\u0020"]
- | <UCHAR>
- )*
- ">" >
-
-| <PNAME: (<PN_PREFIX>)? ":" (<PN_LOCAL>)? >
-| <BLANK_NODE_LABEL: "_:" (<PN_LOCAL>)? > // Allows no label
-
- // Co-ordinate with ARQConstants
- // Named variable - allows no name
-| <VAR_NAMED: "?" (<VARNAME>)?>
-
-// // Non-distinguished variable (BNode in SPARQL)
-// | <VAR_NAMED2: "?." (~[" " , "\t" , "\n" , "\r" , "\f",
-// "(", ")", "[", "]", "{", "}"])* >
-//
-// | <VAR_ANON: "??" (~[ " " , "\t" , "\n" , "\r" , "\f",
-// "(", ")", "[", "]", "{", "}"])* >
-
-| <VAR_OTHER: "?" (<SYM>)+ >
-}
-
-TOKEN :
-{
- < BOM: "\uFEFF">
-| < #DIGITS: (["0"-"9"])+>
-| < INTEGER: (["+","-"])? <DIGITS> >
-| < DECIMAL: (["+","-"])? ( <DIGITS> "." (<DIGITS>)* | "." <DIGITS> ) >
-| < DOUBLE: // Required exponent.
- ( (["+","-"])?
- (["0"-"9"])+ "." (["0"-"9"])* <EXPONENT>
- | "." (["0"-"9"])+ (<EXPONENT>)
- | (["0"-"9"])+ <EXPONENT>
- )
- >
-| < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
-| < #QUOTE_3D: "\"\"\"">
-| < #QUOTE_3S: "'''">
-
-| < #ECHAR: "\\" ( "t"|"b"|"n"|"r"|"f"|"\\"|"\""|"'") >
-| < #UCHAR: <UCHAR4> | <UCHAR8> >
-| < #UCHAR4: "\\" "u" <HEX> <HEX> <HEX> <HEX> >
-| < #UCHAR8: "\\" "U" <HEX> <HEX> <HEX> <HEX> <HEX> <HEX> <HEX> <HEX> >
-
-| < STRING_LITERAL1:
- // Single quoted string
- "'" ( (~["'","\\","\n","\r"]) | <ECHAR> | <UCHAR> )* "'" >
-| < STRING_LITERAL2:
- // Double quoted string
- "\"" ( (~["\"","\\","\n","\r"]) | <ECHAR> | <UCHAR> )* "\"" >
-| < STRING_LITERAL_LONG1:
- <QUOTE_3S>
- ( ("'" | "''")? (~["'","\\"] | <ECHAR> | <UCHAR> ))*
- <QUOTE_3S> >
-| < STRING_LITERAL_LONG2:
- <QUOTE_3D>
- ( ("\"" | "\"\"")? (~["\"","\\"] | <ECHAR> | <UCHAR> ))*
- <QUOTE_3D> >
-}
-
-TOKEN :
-{
- < LPAREN: "(" >
-| < RPAREN: ")" >
-
-| < LBRACE: "{" >
-| < RBRACE: "}" >
-
-| < LBRACKET: "[" >
-| < RBRACKET: "]" >
-
-// RDF-start quoted triple. written with <<>>.,not (qtriple...)
-| < LT2 : "<<" >
-| < GT2 : ">>" >
-}
-
-// Specials for literals trailing parts
-// Otherwise include in Symbol() rule for when out of position.
-TOKEN :
-{
- < DATATYPE: "^^" >
-| <LANGTAG: <AT> (<A2Z>)+("-" (<A2ZN>)+)* > : DEFAULT
-| < #AT: "@">
-| <#A2Z: ["a"-"z","A"-"Z"]>
-| <#A2ZN: ["a"-"z","A"-"Z","0"-"9"]>
-}
-
-TOKEN:
-{
- <#PN_CHARS_BASE:
- ["A"-"Z"] | ["a"-"z"] |
- ["\u00C0"-"\u00D6"] | ["\u00D8"-"\u00F6"] | ["\u00F8"-"\u02FF"] |
- ["\u0370"-"\u037D"] | ["\u037F"-"\u1FFF"] |
- ["\u200C"-"\u200D"] | ["\u2070"-"\u218F"] | ["\u2C00"-"\u2FEF"] |
- ["\u3001"-"\uD7FF"] | ["\uF900"-"\uFFFD"]
- // | [#x10000-#xEFFFF]
- >
-|
- // With underscore
- <#PN_CHARS_U: <PN_CHARS_BASE> | "_" >
-|
- <#PN_CHARS: (<PN_CHARS_U> | "-" | ["0"-"9"] | "\u00B7" |
- ["\u0300"-"\u036F"] | ["\u203F"-"\u2040"] ) >
-|
- // No leading "_", no trailing ".", can have dot inside prefix name.
- <#PN_PREFIX: <PN_CHARS_BASE> ((<PN_CHARS>|".")* <PN_CHARS>)? >
-|
- // Local part.
- <#PN_LOCAL: (<PN_CHARS_U> | ":" | ["0"-"9"] | <PLX> )
- ( (<PN_CHARS> | "." |":" | <PLX> )*
- (<PN_CHARS> | ":" | <PLX>) )? >
-|
- <#VARNAME: ( <PN_CHARS_U> | ["0"-"9"] )
- ( <PN_CHARS_U> | ["0"-"9"] | "\u00B7" |
- ["\u0300"-"\u036F"] | ["\u203F"-"\u2040"] )* >
-|
- < #PN_LOCAL_ESC: "\\"
- ( "_" |
- "~" | "." | "-" | "!" | "$" | "&" | "'" |
- "(" | ")" | "*" | "+" | "," | ";" | "=" |
- "/" | "?" | "#" | "@" | "%" ) >
-|
- <#PLX: <PERCENT> | <PN_LOCAL_ESC> >
-|
- < #HEX: ["0"-"9"] | ["A"-"F"] | ["a"-"f"] >
-|
- < #PERCENT: "%" <HEX> <HEX> >
-
-}
-
-TOKEN:
-{
- // Anything left that isn't structural
- // Excludes:
- // LPAREN and RPAREN / LBRACKET/RBRACKET / LBRACE/RBRACE
- // Quotes, Whitespace
- <#SYM: (~["<", ">", "(", ")", "[", "]", "{", "}", "'", "\"", " ", "\t","\n","\r","\f" ])>
-|
- <#SYM1: (~["^", "@",
- "(", ")", "[", "]", "{", "}", "'", "\"", " ", "\t","\n","\r","\f" ])>
-| <#SYM_ESC: "\\" ( " " | "'" | "\"" ) >
-|
- <SYMBOL: ( "<" | ">"
- | (<SYM1> (<SYM>)*)
- ) >
-}
-
-// Catch-all tokens. Must be last.
-// Any non-whitespace. Causes a parser exception, rather than a
-// token manager error (with hidden line numbers).
-// Only bad IRIs (e.g. spaces) now give unhelpful parse errors.
-TOKEN:
-{
- <#UNKNOWN: (~[" ","\t","\n","\r","\f" ])+ >
-}
-
-/*
-# Local Variables:
-# tab-width: 4
-# indent-tabs-mode: nil
-# comment-default-style: "//"
-# End:
-*/
diff --git a/jena-arq/Grammar/tokens.txt b/jena-arq/Grammar/tokens.txt
index 83a45a1c07..9e706184fe 100644
--- a/jena-arq/Grammar/tokens.txt
+++ b/jena-arq/Grammar/tokens.txt
@@ -12,7 +12,11 @@
<VAR1> ::= '?' <VARNAME>
<VAR2> ::= '$' <VARNAME>
-<LANGTAG> ::= '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)*
+
+// SPARQL 1.1
+// <LANGTAG> ::= '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)*
+// SPARQL 1.2
+<LANG_DIR> ::= '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)* ('--' [a-zA-Z]+)?
<INTEGER> ::= [0-9]+
<DECIMAL> ::= ( [0-9]* '.' [0-9]+ )
@@ -91,20 +95,26 @@
[<SERVICE>] ::= 'SERVICE'
[<MINUS_P>] ::= 'MINUS'
-[<DIFF>] ::= 'DIFF'
[<EXISTS>] ::= 'EXISTS'
[<NOT>] ::= 'NOT'
-[<UNSAID>] ::= 'UNSAID'
+// [<DIFF>] ::= 'DIFF'
+// [<UNSAID>] ::= 'UNSAID'
[<LET>] ::= 'LET'
[<BIND>] ::= 'BIND'
-[<FIND>] ::= 'FIND'
+// [<FIND>] ::= 'FIND'
[<FILTER>] ::= 'FILTER'
[<REGEXP>] ::= 'REGEXP'
[<GRAPH>] ::= 'GRAPH'
[<UNION>] ::= 'UNION'
[<OPTIONAL>] ::= 'OPTIONAL'
+
[<LATERAL>] ::= 'LATERAL'
+[<SEMIJOIN>] ::= 'SEMIJOIN'
+[<ANTIJOIN>] ::= 'ANTIJOIN'
+
+[<UNFOLD>] ::= 'UNFOLD'
+
[<BOUND>] ::= 'BOUND'
[<COALESCE>] ::= 'COALESCE'
[<IF>] ::= 'IF'
@@ -114,10 +124,14 @@
[<BNODE>] ::= 'BNODE'
[<LITERAL>] ::= 'LITERAL'
[<DTYPE>] ::= 'DATATYPE'
+[<isLANG>] ::= 'isLANG'
+[<isLANGDIR>] ::= 'isLANGDIR'
[<LANG>] ::= 'LANG'
-[<LANGMATCHES>] ::= 'LANGMATCHES'
+[<LANGMATCHES>] ::= 'LANGMATCHES'
+[<LANGDIR>] ::= 'LANGDIR'
[<STRLANG>] ::= 'STRLANG'
+[<STRLANGDIR>] ::= 'STRLANGDIR'
[<STRDT>] ::= 'STRDT'
[<IN>] ::= 'IN'
@@ -174,6 +188,8 @@
[<IS_BLANK>] ::= 'isBLANK'
[<IS_LITERAL>] ::= 'isLITERAL'
[<IS_NUMERIC>] ::= 'isNUMERIC'
+[<HAS_LANG>] ::= 'hasLANG'
+[<HAS_LANGDIR>] ::= 'hasLANGDIR'
[<SAME_TERM>] ::= 'sameTerm'
[<REGEX>] ::= 'REGEX'
[<TRUE>] ::= 'true'
@@ -238,10 +254,14 @@
[<DOT>] ::= '.'
[<GT>] ::= '>'
[<LT>] ::= '<'
+[<L_TRIPLE>] ::= '<<('
+[<R_TRIPLE>] ::= ')>>'
[<GT2>] ::= '>>'
[<LT2>] ::= '<<'
[<L_ANN>] ::= '{|'
[<R_ANN>] ::= '|}'
+[<TILDE>] ::= '~'
+
[<BANG>] ::= '!'
[<HOOK>] ::= '?'
[<COLON>] ::= ':'
diff --git a/jena-arq/src/main/java/org/apache/jena/query/ParameterizedSparqlString.java b/jena-arq/src/main/java/org/apache/jena/query/ParameterizedSparqlString.java
index 7d4f862953..93cc4d3727 100644
--- a/jena-arq/src/main/java/org/apache/jena/query/ParameterizedSparqlString.java
+++ b/jena-arq/src/main/java/org/apache/jena/query/ParameterizedSparqlString.java
@@ -483,7 +483,7 @@ public class ParameterizedSparqlString implements PrefixMapping {
* Lexical Value
*/
public void appendLiteral(String value) {
- this.appendNode(NodeFactoryExtra.createLiteralNode(value, null, null));
+ this.appendNode(NodeFactory.createLiteralString(value));
}
/**
@@ -496,7 +496,22 @@ public class ParameterizedSparqlString implements PrefixMapping {
* Language
*/
public void appendLiteral(String value, String lang) {
- this.appendNode(NodeFactoryExtra.createLiteralNode(value, lang, null));
+ this.appendNode(NodeFactory.createLiteralLang(value, lang));
+ }
+
+ /**
+ * Appends a literal with a lexical value, language and base direction to the command text
+ * as a constant using appropriate formatting
+ *
+ * @param value
+ * Lexical Value
+ * @param lang
+ * Language
+ * @param direction
+ * Base direction
+ */
+ public void appendLiteral(String value, String lang, String direction) {
+ this.appendNode(NodeFactory.createLiteralDirLang(value, lang, direction));
}
/**
@@ -509,7 +524,7 @@ public class ParameterizedSparqlString implements PrefixMapping {
* Datatype
*/
public void appendLiteral(String value, RDFDatatype datatype) {
- this.appendNode(NodeFactoryExtra.createLiteralNode(value, null, datatype.getURI()));
+ this.appendNode(NodeFactory.createLiteralDT(value, datatype));
}
/**
@@ -866,7 +881,7 @@ public class ParameterizedSparqlString implements PrefixMapping {
*
*/
public void setLiteral(int index, String value) {
- this.setParam(index, NodeFactoryExtra.createLiteralNode(value, null, null));
+ this.setParam(index, NodeFactory.createLiteralString(value));
}
/**
@@ -883,7 +898,7 @@ public class ParameterizedSparqlString implements PrefixMapping {
*
*/
public void setLiteral(String var, String value) {
- this.setParam(var, NodeFactoryExtra.createLiteralNode(value, null, null));
+ this.setParam(var, NodeFactory.createLiteralString(value));
}
/**
@@ -902,7 +917,47 @@ public class ParameterizedSparqlString implements PrefixMapping {
*
*/
public void setLiteral(int index, String value, String lang) {
- this.setParam(index, NodeFactoryExtra.createLiteralNode(value, lang, null));
+ this.setParam(index, NodeFactory.createLiteralLang(value, lang));
+ }
+
+ /**
+ * Sets a variable parameter to a literal with a language
+ * <p>
+ * Setting a parameter to null is equivalent to calling
+ * {@link #clearParam(String)} for the given variable
+ * </p>
+ *
+ * @param var
+ * Variable
+ * @param value
+ * Lexical Value
+ * @param lang
+ * Language
+ * @param baseDirection
+ * Base direction
+ */
+ public void setLiteral(String var, String value, String lang, String baseDirection) {
+ this.setParam(var, NodeFactory.createLiteralDirLang(value, lang, baseDirection));
+ }
+
+ /**
+ * Sets a positional parameter to a literal with a language and base direction
+ * <p>
+ * Setting a parameter to null is equivalent to calling
+ * {@link #clearParam(int)} for the given index
+ * </p>
+ *
+ * @param index
+ * Positional index
+ * @param value
+ * Lexical Value
+ * @param lang
+ * Language
+ * @param baseDirection
+ * Base direction
+ */
+ public void setLiteral(int index, String value, String lang, String baseDirection) {
+ this.setParam(index, NodeFactory.createLiteralDirLang(value, lang, baseDirection));
}
/**
@@ -921,7 +976,7 @@ public class ParameterizedSparqlString implements PrefixMapping {
*
*/
public void setLiteral(String var, String value, String lang) {
- this.setParam(var, NodeFactoryExtra.createLiteralNode(value, lang, null));
+ this.setParam(var, NodeFactory.createLiteralLang(value, lang));
}
/**
@@ -940,7 +995,7 @@ public class ParameterizedSparqlString implements PrefixMapping {
*
*/
public void setLiteral(int index, String value, RDFDatatype datatype) {
- this.setParam(index, this.model.createTypedLiteral(value, datatype));
+ this.setParam(index, NodeFactory.createLiteralDT(value, datatype));
}
/**
@@ -959,7 +1014,7 @@ public class ParameterizedSparqlString implements PrefixMapping {
*
*/
public void setLiteral(String var, String value, RDFDatatype datatype) {
- this.setParam(var, this.model.createTypedLiteral(value, datatype));
+ this.setParam(var, NodeFactory.createLiteralDT(value, datatype));
}
/**
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangEngine.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangEngine.java
index 1141767fb2..f1c0a3e0cf 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangEngine.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangEngine.java
@@ -58,6 +58,16 @@ public class LangEngine {
return peekIter.peek();
}
+ // Development!
+ protected final void printToken() {
+ if ( tokenEOF != null ) {
+ System.out.println("<EOF>");
+ return;
+ }
+ Token token = peekToken();
+ System.out.println(token);
+ }
+
// Set when we get to EOF to record line/col of the EOF.
private Token tokenEOF = null;
@@ -134,11 +144,17 @@ public class LangEngine {
protected final void exception(Token token, String msg, Object... args) {
if ( token != null )
- exceptionDirect(String.format(msg, args), token.getLine(), token.getColumn());
+ exception(String.format(msg, args), token.getLine(), token.getColumn());
else
- exceptionDirect(String.format(msg, args), -1, -1);
+ exception(String.format(msg, args), -1, -1);
+ }
+
+ protected final void exception(String msg, long line, long col) {
+ raiseException(new RiotParseException(msg, line, col));
}
+ /** @deprecated use {@link #exception(String, long, long)}*/
+ @Deprecated(forRemoval = true)
protected final void exceptionDirect(String msg, long line, long col) {
raiseException(new RiotParseException(msg, line, col));
}
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangNQuads.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangNQuads.java
index 76c6604350..3b35dd241a 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangNQuads.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangNQuads.java
@@ -58,33 +58,10 @@ public class LangNQuads extends LangNTuple<Quad> {
@Override
protected final Quad parseOne() {
- Token sToken = nextToken();
- if ( sToken.isEOF() )
- exception(sToken, "Premature end of file: %s", sToken);
- Node s;
- if ( sToken.hasType(TokenType.LT2) )
- s = parseTripleTerm();
- else {
- checkIRIOrBNode(sToken);
- s = tokenAsNode(sToken);
- }
-
- Token pToken = nextToken();
- if ( pToken.isEOF() )
- exception(pToken, "Premature end of file: %s", pToken);
- checkIRI(pToken);
- Node p = tokenAsNode(pToken);
-
- Token oToken = nextToken();
- if ( oToken.isEOF() )
- exception(oToken, "Premature end of file: %s", oToken);
- Node o;
- if ( oToken.hasType(TokenType.LT2) )
- o = parseTripleTerm();
- else {
- checkRDFTerm(oToken);
- o = tokenAsNode(oToken);
- }
+ Token token = peekToken();
+ Node s = parseSubject();
+ Node p = parsePredicate();
+ Node o = parseObject();
Token xToken = nextToken(); // Maybe DOT
if ( xToken.getType() == TokenType.EOF )
@@ -97,8 +74,6 @@ public class LangNQuads extends LangNTuple<Quad> {
if ( xToken.getType() != TokenType.DOT ) {
// Allow bNodes for graph names.
checkIRIOrBNode(xToken);
- // Allow only IRIs
- // checkIRI(xToken) ;
c = tokenAsNode(xToken);
xToken = nextToken();
currentGraph = c;
@@ -111,7 +86,7 @@ public class LangNQuads extends LangNTuple<Quad> {
if ( xToken.getType() != TokenType.DOT )
exception(xToken, "Quad not terminated by DOT: %s", xToken);
- return profile.createQuad(c, s, p, o, sToken.getLine(), sToken.getColumn());
+ return profile.createQuad(c, s, p, o, token.getLine(), token.getColumn());
}
@Override
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangNTuple.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangNTuple.java
index ff65640dbb..c90e0f9fa8 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangNTuple.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangNTuple.java
@@ -81,43 +81,63 @@ public abstract class LangNTuple<X> extends LangBase implements Iterator<X>
// One triple, not including terminator.
protected final Triple parseTriple() {
+ Token token = peekToken();
+ Node s = parseSubject();
+ Node p = parsePredicate();
+ Node o = parseObject();
+ return profile.createTriple(s, p, o, token.getLine(), token.getColumn());
+ }
+
+ protected final Node parseSubject() {
+ // If we allow triple term in the subject position.
+ // These would be rejected when the triple is created by the standard parser profile.
+ //Node s = parseRDFTerm("subject");
+
Token sToken = nextToken();
if ( sToken.isEOF() )
exception(sToken, "Premature end of file: %s", sToken);
- Node s;
- if ( sToken.hasType(TokenType.LT2) )
- s = parseTripleTerm();
- else {
- checkIRIOrBNode(sToken);
- s = tokenAsNode(sToken);
- }
+ checkIRIOrBNode(sToken);
+ Node s = tokenAsNode(sToken);
+ return s;
+ }
+ // Parse, must be a URI.
+ protected final Node parsePredicate() {
Token pToken = nextToken();
if ( pToken.isEOF() )
exception(pToken, "Premature end of file: %s", pToken);
checkIRI(pToken);
Node p = tokenAsNode(pToken);
+ return p;
+ }
+
+ // Parse, must be a URI.
+ protected final Node parseObject() {
+ return parseRDFTerm("object");
+ }
- Token oToken = nextToken();
- if ( oToken.isEOF() )
- exception(oToken, "Premature end of file: %s", oToken);
- Node o;
- if ( oToken.hasType(TokenType.LT2) )
- o = parseTripleTerm();
+ // General subject/object term
+ protected final Node parseRDFTerm(String posn) {
+ Token token = nextToken();
+ if ( token.isEOF() )
+ exception(token, "Premature end of file: %s", token);
+ Node term;
+ if ( token.hasType(TokenType.L_TRIPLE) )
+ term = parseTripleTerm();
else {
- checkRDFTerm(oToken);
- o = tokenAsNode(oToken);
+ checkRDFTerm(posn, token);
+ term = tokenAsNode(token);
}
- return profile.createTriple(s, p, o, sToken.getLine(), sToken.getColumn());
+ return term;
}
- // Looking at "<<" (LT2)
- final protected Node parseTripleTerm() {
+ // Looking at "<<(" (L_TRIPLE)
+ protected final Node parseTripleTerm() {
Triple t = parseTriple();
Token x = nextToken();
- if ( x.getType() != TokenType.GT2 )
- exception(x, "Triple term not terminated by >>: %s", x);
- return NodeFactory.createTripleNode(t);
+ if ( x.getType() != TokenType.R_TRIPLE )
+ exception(x, "Triple term not terminated by )>>: %s", x);
+ return NodeFactory.createTripleTerm(t);
}
protected final void checkIRIOrBNode(Token token) {
@@ -134,7 +154,7 @@ public abstract class LangNTuple<X> extends LangBase implements Iterator<X>
exception(token, "Expected IRI: Got: %s", token);
}
- protected final void checkRDFTerm(Token token) {
+ protected final void checkRDFTerm(String posn, Token token) {
switch (token.getType()) {
case IRI:
case BNODE:
@@ -147,7 +167,7 @@ public abstract class LangNTuple<X> extends LangBase implements Iterator<X>
checkString(token.getSubToken1());
return ;
default:
- exception(token, "Illegal object: %s", token) ;
+ exception(token, "Illegal %s: %s", posn, token) ;
}
}
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTriG.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTriG.java
index 4b35158057..15982c4d1c 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTriG.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTriG.java
@@ -45,12 +45,14 @@ public class LangTriG extends LangTurtleBase {
@Override
protected final void oneTopLevelElement() {
- //oneNamedGraphBlock() ;
- oneNamedGraphBlock2() ;
+ //oneNamedGraphBlockOriginal() ;
+ oneNamedGraphBlock() ;
}
- // Version for proposed Turtle-in-TriG and keyword GRAPH
- protected final void oneNamedGraphBlock2() {
+ // RDF 1.1 TriG
+ // Default graph can Turtle (i.e. no braces)
+ // keyword GRAPH
+ protected final void oneNamedGraphBlock() {
// Which may not be a graph block.
Node graphNode = null ;
Token token = peekToken() ;
@@ -99,7 +101,6 @@ public class LangTriG extends LangTurtleBase {
} else {
// [ :p ... ]
// [ :p ... ] :p ...
- // XXX This fragment must be in Turtle somewhere
if ( mustBeNamedGraph )
exception(t, "Keyword 'GRAPH' must start a named graph") ;
triplesBlankNode(blank) ;
@@ -113,7 +114,6 @@ public class LangTriG extends LangTurtleBase {
} else if ( token.isNode() ) {
// Either :s :p :o or :g { ... }
Node n = node() ;
- nextToken() ;
token = peekToken() ;
if ( lookingAt(LBRACE) )
graphNode = n ;
@@ -147,36 +147,36 @@ public class LangTriG extends LangTurtleBase {
protected final void turtle() {
// This does expectEndOfTriplesTurtle() ;
- triplesSameSubject() ;
+ triples() ;
}
- // Old version , tradition trig with RDF 1.1 Turtle tokens.
- protected final void oneNamedGraphBlock() {
- // Directives are only between graph blocks.
- Node graphNode = null ;
- Token token = peekToken() ;
- Token t = token ; // Keep for error message.
-
- // [ ] { ... }
- if ( lookingAt(LBRACKET) ) {
- nextToken() ;
- token = peekToken() ;
- if ( lookingAt(RBRACKET) )
- exception(t, "Broken term: [ not followed by ]") ;
-
- graphNode = profile.createBlankNode(graphNode, t.getLine(), t.getColumn()) ;
- nextToken() ;
- } else {
- // <uri> { ... }
- // { ... }
- if ( token.isNode() ) {
- graphNode = node() ;
- nextToken() ;
- }
- }
-
- bracedGraph(t, graphNode) ;
- }
+// // Pre RDF 1.1 standardization. Tradition trig with RDF 1.1 Turtle tokens.
+// // Default graph is always { ... }
+// protected final void oneNamedGraphBlockOriginal() {
+// // Directives are only between graph blocks.
+// Node graphNode = null ;
+// Token token = peekToken() ;
+// Token t = token ; // Keep for error message.
+//
+// // [ ] { ... }
+// if ( lookingAt(LBRACKET) ) {
+// nextToken() ;
+// token = peekToken() ;
+// if ( lookingAt(RBRACKET) )
+// exception(t, "Broken term: [ not followed by ]") ;
+//
+// graphNode = profile.createBlankNode(graphNode, t.getLine(), t.getColumn()) ;
+// nextToken() ;
+// } else {
+// // <uri> { ... }
+// // { ... }
+// if ( token.isNode() ) {
+// graphNode = node() ;
+// }
+// }
+//
+// bracedGraph(t, graphNode) ;
+// }
private void bracedGraph(Token t, Node graphNode) {
if ( graphNode != null ) {
@@ -213,7 +213,7 @@ public class LangTriG extends LangTurtleBase {
// this does not assume that we are definitely entering
// this state and can throw an error if the first token
// is not acceptable.
- triplesSameSubject() ;
+ triples() ;
}
// **** Turtle.
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtle.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtle.java
index f8a947032b..373a3e7790 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtle.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtle.java
@@ -43,7 +43,7 @@ public class LangTurtle extends LangTurtleBase {
@Override
protected final void oneTopLevelElement() {
- triplesSameSubject() ;
+ triples() ;
}
@Override
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java
index 863d504261..ef8cb2264a 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java
@@ -30,7 +30,15 @@ import org.apache.jena.riot.tokens.TokenType;
import org.apache.jena.riot.tokens.Tokenizer;
import org.apache.jena.sparql.graph.NodeConst;
-/** The main engine for all things Turtle-ish (Turtle, TriG). */
+/**
+ * The main engine for all things Turtle-ish (Turtle, TriG).
+ * <p>
+ * This parser generates a form of generalized RDF
+ * with literals and triple terms as subjects,
+ * but not arbitrary predicates.
+ * <p>
+ * The additional conditions area applied when the triples are created by the {@link ParserProfile}
+ */
public abstract class LangTurtleBase extends LangBase {
// See http://www.w3.org/TR/turtle/
// Some predicates (if accepted)
@@ -165,32 +173,33 @@ public abstract class LangTurtleBase extends LangBase {
nextToken();
}
+ // [8] triples ::= subject predicateObjectList
+ // | blankNodePropertyList predicateObjectList?
+ // | reifiedTriple predicateObjectList?
+ //
// Unlike many operations in this parser suite
// this does not assume that we are definitely
// entering this state. It does checks and may
// signal a parse exception.
- protected final void triplesSameSubject() {
+ protected final void triples() {
// Either a IRI/prefixed name or a construct that generates triples
-
- // TriplesSameSubject -> Term PropertyListNotEmpty
+ // subject predicateObjectList
if ( lookingAt(NODE) ) {
- triples();
+ triplesSameSubject();
return;
}
boolean maybeList = lookingAt(LPAREN);
- // Turtle: TriplesSameSubject -> TriplesNode PropertyList?
- // TriG: (blankNodePropertyList | collection) predicateObjectList? '.'
- // labelOrSubject (wrappedGraph | predicateObjectList '.')
- if ( peekTriplesNodeCompound() ) {
+ // blankNodePropertyList predicateObjectList?
+ if ( peekTriplesNodeCompound() ) { // LBRACKET, LBRACE, LPAREN
Node n = triplesNodeCompound();
// May be followed by:
- // A predicateObject list
- // A DOT or EOF.
- // But if a DOT or EOF, then it can't have been () or [].
+ // A predicateObject list
+ // A DOT or EOF.
+ // But if a DOT or EOF, then it can't have been () or [].
// Turtle, as spec'ed does not allow
// (1 2 3 4) .
@@ -224,61 +233,221 @@ public abstract class LangTurtleBase extends LangBase {
return;
}
+ // RDF 1.2
+ // reified triple,possible a declaration (empty predicateObjectList).
+ // reifiedTriple predicateObjectList?
// <<>> subject position. Rule [10]
if ( lookingAt(LT2) ) {
- Node subject = parseTripleTerm();
+ Node subject = parseReifiedTriple();
+ // predicateObjectList may be empty - peek for DOT.
+ if ( lookingAt(DOT) ) {
+ // ReifiedTriple declaration.
+ nextToken();
+ return;
+ }
predicateObjectList(subject);
expectEndOfTriples();
return;
}
+ // Triple Term in the subject position.
+ // This generates an error as the triple is created.
+ // The parser is more general.
+ if ( lookingAt(L_TRIPLE) ) {
+ // [RDF-1.2]
+ // ttSubject
+ // predicate
+ // ttObject
+ Node subject = parseTripleTerm();
+ // XXX Cleaner error handling to be general.
+ exception(peekToken(), "Subject is a triple term");
+// predicateObjectList(subject);
+// expectEndOfTriples();
+ return;
+ }
exception(peekToken(), "Out of place: %s", peekToken());
}
- // Parse a << >> : RDF-star
- // XXX Update grammar extract to RDF-star CG report.
- /* The Turtle grammar is:
- tripleX ::= ’<<’ subjectX predicate objectX ’>>’
- subjectX ::= iri | BlankNode | tripleX
- objectX ::= iri | BlankNode | literal | tripleX
- [10x] subject ::= iri | BlankNode | collection | tripleX
- [12x] object ::= iri | BlankNode | collection | blankNodePropertyList | literal | tripleX
- i.e. no compounds inside <<>>
- */
-
+ // RDF 1.2
+ // [26] reifiedTriple ::= '<<' (subject | reifiedTriple) verb object reifier? '>>'
+ // [26] reifiedTriple ::= '<<' rtSubject verb rtObject reifier? '>>'
// Assumes looking at << (LT2) on entry
- // node() or nodeX
- private Node parseTripleTerm() {
- Token token = nextToken();
- Node s = subjectX();
+ private Node parseReifiedTriple() {
+ Token startToken = nextToken(); // LT2
+ long startLine = startToken.getLine();
+ long startColumn = startToken.getColumn();
- Node p = predicate(); // predicate() == node();nextToken();
- nextToken();
+ Node s = rtSubject(startToken);
+ Node p = predicate();
+ // rtObject - no blankPredicateObjectList or collection.
+ Node o = rtObject(startToken);
- Node o = objectX();
+ Node reif = possibleReifier(s, p, o, startLine, startColumn);
if ( ! lookingAt(GT2) )
exception(peekToken(), "Expected >>, found %s", peekToken().text());
nextToken();
- return profile.createTripleNode(s, p, o, token.getLine(), token.getColumn());
+ Node tripleTerm = profile.createTripleTerm(s, p, o, startLine, startColumn);
+ // XXX profile.createTripleReifier
+ // emitTripleReifier(s, p, o, startReifiedTripleToken.getLine(), startReifiedTripleToken.getColumn());
+ emitTriple(reif, NodeConst.nodeReifies, tripleTerm);
+
+ return reif;
+ }
+
+ // -- rtSubject rules
+ // ??? profile.isValidTriple(s,p,o);
+ //profile.createTriple(s, p, o, token.getLine(), token.getColumn());
+
+ private Node rtSubject(Token startToken) {
+ if ( lookingAt(LT2) )
+ return parseReifiedTriple();
+ Node s = possibleAnon() ;
+ if ( s != null )
+ return s;
+ s = node();
+ if ( ! (s.isURI() || s.isBlank() ) )
+ // ReifiedTriple covered by branch.
+ exception(peekToken(), "Subject in a reified triple is not a URI, blank node or a nested reified triple: %s", s);
+ return s;
+ }
+
+ // -- rtObject rules
+ private Node rtObject(Token startToken) {
+ if (lookingAt(LT2) )
+ return parseReifiedTriple();
+ Node o = possibleAnon() ;
+ if ( o != null )
+ return o;
+ // Not compound triples (blankPredicateObjectList, collections).
+ o = object();
+ if ( ! (o.isURI() || o.isBlank() || o.isLiteral() || o.isTripleTerm() ) )
+ exception(startToken, "Illgeal object in a reified triple: %s", o);
+ return o;
+ }
+
+ // Possible [], not [ :p 123 ]
+ private Node possibleAnon() {
+ if ( ! lookingAt(LBRACKET) )
+ return null;
+ // Consume LBRACKET
+ nextToken();
+ if ( ! lookingAt(RBRACKET) )
+ exception(peekToken(), "Found '[' in reified triple. It must be followed by ']' but got: "+peekToken());
+ // Consume RBRACKET
+ Token token = nextToken();
+ Node x = profile.createBlankNode(currentGraph, token.getLine(), token.getColumn());
+ return x;
+ }
+
+// // XXX Checker.validateTriple
+// // XXX TripleTerm
+// private void validateTriple(Node s, Node p, Node o, String usage, Token token) {
+// if ( ! (s.isURI() || s.isBlank() ) )
+// // ReifiedTriple covered by branch.
+// exception(token, "Subject in a %s is not a URI, blank node or a nested reified triple: %s", usage, s);
+// if ( ! p.isURI() )
+// exception(token, "Predicate in a %s is not a URI: %s", usage, p);
+// if ( ! (o.isURI() || o.isBlank() || o.isLiteral() || o.isNodeTriple() ) )
+// exception(token, "Object in a %s is not a URI, blank node, nested reified triple or triple term : %s", usage, o);
+// }
+
+ private Node parseTripleTerm() {
+ Token entryToken = nextToken();
+ Node s = ttSubject();
+ if ( s.isTripleTerm() )
+ exception(entryToken, "Subject of a triple term is a triple term");
+ Node p = predicate();
+ Node o = ttObject();
+ if ( ! lookingAt(R_TRIPLE) )
+ exception(peekToken(), "Expected )>>, found %s", peekToken().text());
+ nextToken();
+ return profile.createTripleTerm(s, p, o, entryToken.getLine(), entryToken.getColumn());
+ }
+
+ protected Node possibleReifier(Node s, Node p, Node o, long line, long column) {
+ if ( lookingAt(TokenType.VBAR) )
+ exception(peekToken(), "Bad syntax: reifiers are '~', not '|'");
+
+ if ( ! lookingAt(TokenType.TILDE) )
+ return profile.createBlankNode(currentGraph, line, column);
+ // XXX Check BNF
+ return Reifier(s, p, o, line, column);
+ }
+
+ protected Node Reifier(Node s, Node p, Node o, long line, long column) {
+ // Tilde
+ Token tildeToken = nextToken();
+ Token tokenReif = peekToken();
+
+ if ( lookingAt(TokenType.LITERAL_DT) || lookingAt(TokenType.LITERAL_LANG) ) {
+ nextToken();
+ exception(tildeToken, "Reifiers are URIs or blank nodes: found %s", tokenReif);
+ }
+
+ Node reif;
+ // URI or bNode
+ if ( lookingAtIRIorBNode() ) {
+ // XXX and use elsewhere : nodeURIorBLankNode()
+ nextToken();
+ reif = tokenAsNode(tokenReif);
+ } else if ( lookingAt(LBRACKET) ) {
+ // ANON
+ nextToken();
+ Token t = peekToken();
+ if ( ! lookingAt(RBRACKET) )
+ exception(peekToken(), "Bad %s in RDF triple. Expected ] after [", "riefier", peekToken().text());
+ nextToken();
+ reif = profile.createBlankNode(currentGraph, t.getLine(), t.getColumn());
+ } else {
+ // Just "~" No reifier id
+ // or some syntax error we will detect later.
+ reif = profile.createBlankNode(currentGraph, tildeToken.getLine(), tildeToken.getColumn());
+ }
+ return reif;
}
- private Node subjectX() {
- Node node = nodeX("subject");
+ private Node ttSubject() {
+ Node node = term("subject");
+ // XXX Maybe allow but restrict later.
if ( node.isLiteral() )
- exception(peekToken(), "Literal as subject in RDF-star triple");
+ exception(peekToken(), "Literals are not legal in the subject position.");
+ if ( node.isTripleTerm() ) {
+ exception(peekToken(), "Triple terms are not legal in the subject position.");
+ }
return node;
}
- private Node objectX() {
- Node node = nodeX("object");
+ private Node ttObject() {
+ Node node = term("object");
return node;
}
- // Does consume the token.
- private Node nodeX(String posnLabel) {
+ // Generalized.
+ // Triples with, for example, literals in the subject position, are rejected when the triple is created.
+ private Node subject() {
+ return nodeTerm();
+ }
+
+ private Node object() {
+ return nodeTerm();
+ }
+
+ // Single token terms, triple terms and reified triples.
+ private Node nodeTerm() {
if ( lookingAt(LT2) )
+ return parseReifiedTriple();
+ if ( lookingAt(L_TRIPLE) )
+ return parseTripleTerm();
+ Node node = node();
+ return node;
+ }
+
+ /** Any RDFTerm, including compound structures but not reified triples. */
+ // XXX RENAME
+ private Node term(String posnLabel) {
+ if ( lookingAt(L_TRIPLE) )
return parseTripleTerm();
// ANON
@@ -287,30 +456,33 @@ public abstract class LangTurtleBase extends LangBase {
// Method triplesNodeCompound ()-> triplesBlankNode(subject)
// can cope with zero length, covering grammar token ANON and rule [7] predicateObjectList cases
// But here, in RDF-star, only [] is legal.
+
+ // XXX Generalize and reuse in Reifier.
+ // []
if ( lookingAt(LBRACKET) ) {
nextToken();
Token t = peekToken();
if ( ! lookingAt(RBRACKET) )
- exception(peekToken(), "Bad %s in RDF-star triple after [, expected ]", posnLabel, peekToken().text());
+ exception(peekToken(), "Bad %s in RDF triple. Expected ] after [", posnLabel, peekToken().text());
nextToken();
return profile.createBlankNode(currentGraph, t.getLine(), t.getColumn());
}
+ // Single token terms
if ( ! lookingAt(NODE) )
- exception(peekToken(), "Bad %s in RDF-star triple", posnLabel, peekToken().text());
+ exception(peekToken(), "Bad %s in RDF-star triple: %s", posnLabel, peekToken().text());
Node node = node();
- nextToken();
return node;
}
// Must be at least one triple.
- protected final void triples() {
+ // Not reifiedTriple
+ protected final void triplesSameSubject() {
// Looking at a node.
- Node subject = node();
+ Node subject = subject();
if ( subject == null )
exception(peekToken(), "Not recognized: expected node: %s", peekToken().text());
- nextToken();
predicateObjectList(subject);
expectEndOfTriples();
}
@@ -329,13 +501,21 @@ public abstract class LangTurtleBase extends LangBase {
expectOrEOF("Triples not terminated by DOT", DOT);
}
+ protected final boolean lookingAtIRIorBNode() {
+ if ( eof() )
+ return false;
+ Token t = peekToken();
+ // Does not cover "[ ]"
+ return t.isIRI() || t.isBNode();
+ }
+
protected final void predicateObjectList(Node subject) {
predicateObjectItem(subject);
for (;;) {
if ( !lookingAt(SEMICOLON) )
break;
- // predicatelist continues - move over all ";"
+ // predicateList continues - move over all ";"
while (lookingAt(SEMICOLON))
nextToken();
if ( !peekPredicate() )
@@ -348,34 +528,38 @@ public abstract class LangTurtleBase extends LangBase {
protected final void predicateObjectItem(Node subject) {
Node predicate = predicate();
- nextToken();
objectList(subject, predicate);
}
static protected final Node nodeSameAs = NodeConst.nodeOwlSameAs;
static protected final Node nodeLogImplies = NodeFactory.createURI("http://www.w3.org/2000/10/swap/log#implies");
- /** Get predicate - maybe null for "illegal" */
- protected final Node predicate() {
- Token t = peekToken();
+ // XXX verb()
- if ( t.hasType(TokenType.KEYWORD) ) {
- Token tErr = peekToken();
- String image = peekToken().getImage();
+ // [11] verb ::= predicate | 'a'
+ // [12] subject ::= iri | BlankNode | collection
+ // [13] predicate ::= iri
+ // and '=' (owl:sameAs),
+ /** Get predicate - return null for "illegal" */
+ protected final Node predicate() {
+ if ( lookingAt(TokenType.KEYWORD) ) {
+ Token kwToken = nextToken();
+ String image = kwToken.getImage();
if ( image.equals(KW_A) )
return NodeConst.nodeRDFType;
// N3-isms
if ( !isStrictMode() && image.equals(KW_SAME_AS) )
return nodeSameAs;
// Relationship between two formulae in N3.
-// if ( !strict && image.equals(KW_LOG_IMPLIES) )
+// if ( !isStrictMode() && image.equals(KW_LOG_IMPLIES) )
// return log:implies;
- exception(tErr, "Unrecognized keyword: " + image);
+ exception(kwToken, "Unrecognized keyword: " + image);
}
+ Token token = peekToken();
Node n = node();
if ( n == null || !n.isURI() )
- exception(t, "Expected IRI for predicate: got: %s", t);
+ exception(token, "Expected IRI for predicate: got: %s", token);
return n;
}
@@ -400,34 +584,30 @@ public abstract class LangTurtleBase extends LangBase {
return false;
}
- /** Create a Node for the current token.
- * Does not create nodes/triples for compound structures.
- * May return "null" for not-a-node.
- * Does not consume the token.
+ /**
+ * Create a Node for the current single token.
+ * <p>
+ * It does not cover tripleTerms, which involves multiple tokens,
+ * nodes/triples for compound structures, {@code ()} nor {@code []}.
+ * Returns "null" for not-a-node.
*/
protected final Node node() {
- // Token to Node
Node n = tokenAsNode(peekToken());
if ( n == null )
return null;
+ nextToken();
return n;
}
+ // XXX Update for RDF 1.2
protected final void objectList(Node subject, Node predicate) {
for (;;) {
// object ::=
Node object = triplesNode();
emitTriple(subject, predicate, object);
- // RDF-star annotation syntax
- if ( lookingAt(L_ANN) ) {
- Token tNext = nextToken();
- if ( lookingAt(R_ANN) )
- exception(tNext, "Empty annotation");
- Node x = profile.createTripleNode(subject, predicate, object, currLine, currCol);
- predicateObjectList(x);
- expect("Missing end annotation", R_ANN);
- }
+ // Maybe annotation.
+ possibleAnnotations(subject, predicate, object);
if ( !moreTokens() )
break;
if ( !lookingAt(COMMA) )
@@ -437,13 +617,35 @@ public abstract class LangTurtleBase extends LangBase {
}
}
+ private void possibleAnnotations(Node subject, Node predicate, Node object) {
+ for(;;) {
+ if ( !lookingAt(TokenType.TILDE) && !lookingAt(L_ANN) && /*old style, not adopted*/ !lookingAt(TokenType.VBAR) )
+ return;
+
+ Token tokenReifer = peekToken();
+ // Always allocate. TILDE or L_ANN.
+ Node reif = possibleReifier(subject, predicate, object, tokenReifer.getLine(), tokenReifer.getColumn());
+ Node tripleTerm = profile.createTripleTerm(subject, predicate, object, tokenReifer.getLine(), tokenReifer.getColumn());
+ emit(reif, NodeConst.nodeReifies, tripleTerm);
+
+ // RDF-star annotation syntax
+ if ( lookingAt(L_ANN) ) {
+ Token tNext = nextToken();
+ if ( lookingAt(R_ANN) )
+ exception(tNext, "Empty annotation");
+ predicateObjectList(reif);
+ expect("Missing end annotation", R_ANN);
+ }
+ }
+ }
+
// A structure of triples that itself generates a node.
// Special checks for [] and ().
+ // XXX Use object()
protected final Node triplesNode() { // == [12] object in the grammar.
if ( lookingAt(NODE) ) {
Node n = node();
- nextToken();
return n;
}
@@ -464,6 +666,9 @@ public abstract class LangTurtleBase extends LangBase {
}
if ( lookingAt(LT2) )
+ return parseReifiedTriple();
+
+ if ( lookingAt(L_TRIPLE) )
return parseTripleTerm();
return triplesNodeCompound();
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/ReaderTriX.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/ReaderTriX.java
index 2cc9f9c17f..7792fe5218 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/ReaderTriX.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/ReaderTriX.java
@@ -51,7 +51,7 @@ import java.util.Deque;
import java.util.NoSuchElementException;
import java.util.Objects;
-import static org.apache.jena.riot.lang.ReaderTriX.State.E_TRIPLE;
+import static org.apache.jena.riot.lang.ReaderTriX.State.TRIPLE_TERM;
import static org.apache.jena.riot.lang.ReaderTriX.State.GRAPH;
import static org.apache.jena.riot.lang.ReaderTriX.State.OUTER;
import static org.apache.jena.riot.lang.ReaderTriX.State.TRIPLE;
@@ -119,8 +119,8 @@ public class ReaderTriX implements ReaderRIOT {
private static String rdfXMLLiteral = RDF.xmlLiteral.getURI();
// State TRIPLE is "asserted triple" - a triple that will go into the output.
- // State E_TRIPLE is an "embedded triple" (<<>>) that will be term in another triple/quad.
- enum State { OUTER, TRIX, GRAPH, TRIPLE, E_TRIPLE }
+ // State TRIPLE_TERM is a triple term (<<()>>) that will be term in another triple/quad.
+ enum State { OUTER, TRIX, GRAPH, TRIPLE, TRIPLE_TERM }
private static class NodeMarker extends Node_Marker {
protected NodeMarker(String label) {
@@ -129,14 +129,14 @@ public class ReaderTriX implements ReaderRIOT {
}
private static Node nAssertedTriple = new NodeMarker("asserted triple");
- private static Node nEmbeddedTriple = new NodeMarker("embedded triple");
+ private static Node nTripleTerm = new NodeMarker("triple term");
private void read(XMLStreamReader parser, String baseURI, StreamRDF output) {
State state = OUTER;
Node g = null;
Deque<Node> terms = new ArrayDeque<>();
- // Depth of embedded triple nesting. 0 - not in an embedded triple
- int embeddedTripleDepth = 0;
+ // Depth of triple term nesting. 0 - not in a triple term
+ int tripleTermDepth = 0;
try {
while(parser.hasNext()) {
int event = parser.next();
@@ -173,13 +173,13 @@ public class ReaderTriX implements ReaderRIOT {
state = TRIPLE;
push(terms, nAssertedTriple);
break;
- // Embedded triple. If E_TRIPLE nested embedded triple.
+ // If TRIPLE_TERM, nested triple term
case TRIPLE:
- state = E_TRIPLE;
+ state = TRIPLE_TERM;
// fall through.
- case E_TRIPLE:
- embeddedTripleDepth++;
- push(terms, nEmbeddedTriple);
+ case TRIPLE_TERM:
+ tripleTermDepth++;
+ push(terms, nTripleTerm);
break;
default: staxErrorOutOfPlaceElement(parser);
}
@@ -189,7 +189,7 @@ public class ReaderTriX implements ReaderRIOT {
case TriX.tagId:
case TriX.tagQName:
case TriX.tagURI: {
- if ( state != GRAPH && state != TRIPLE && state != E_TRIPLE )
+ if ( state != GRAPH && state != TRIPLE && state != TRIPLE_TERM )
staxErrorOutOfPlaceElement(parser);
Node n = term(parser, profile);
@@ -272,17 +272,15 @@ public class ReaderTriX implements ReaderRIOT {
break;
}
- case E_TRIPLE: {
- if ( ! nEmbeddedTriple.equals(marker) )
+ case TRIPLE_TERM: {
+ if ( ! nTripleTerm.equals(marker) )
// Internal error.
- staxError(parser.getLocation(), "Misaligned embedded triple.");
- //System.out.println("Embedded: Terms: "+terms.size());
- // Embedded triple.
- Node nt = NodeFactory.createTripleNode(s, p, o);
+ staxError(parser.getLocation(), "Misaligned triple term.");
+ // Triple term.
+ Node nt = profile.createTripleTerm(s, p, o, line, col);
push(terms, nt);
- embeddedTripleDepth--;
- if ( embeddedTripleDepth == 0 )
- // Did this complete an embedded triple?
+ tripleTermDepth--;
+ if ( tripleTermDepth == 0 )
state = TRIPLE;
break;
}
@@ -293,7 +291,6 @@ public class ReaderTriX implements ReaderRIOT {
} catch (NoSuchElementException ex) {
staxError(parser.getLocation(), "Too few terms for a triple.");
}
-
}
case TriX.tagGraph:
state = TRIX;
@@ -383,13 +380,14 @@ public class ReaderTriX implements ReaderRIOT {
: parser.getElementText();
return profile.createTypedLiteral(lex, rdt, line, col);
}
- case TriX.tagTriple: {
- Node s = term(parser, profile);
- Node p = term(parser, profile);
- Node o = term(parser, profile);
- Node n = profile.createTripleNode(s, p, o, line, col);
- return n;
- }
+ // Triple term done elswwhere
+// case TriX.tagTriple: {
+// Node s = term(parser, profile);
+// Node p = term(parser, profile);
+// Node o = term(parser, profile);
+// Node n = profile.createTripleTerm(s, p, o, line, col);
+// return n;
+// }
default: {
QName qname = parser.getName();
staxError(parser.getLocation(), "Unrecognized tag -- "+qnameAsString(qname));
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/LangParserBase.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/LangParserBase.java
index 521a587119..a3948ff792 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/LangParserBase.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/LangParserBase.java
@@ -55,6 +55,8 @@ 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 StreamRDF stream;
protected ParserProfile profile;
@@ -130,8 +132,8 @@ public class LangParserBase {
return n ;
}
- protected Node createQuotedTriple(Node s, Node p, Node o, int line, int column) {
- return profile.createTripleNode(s, p, o, line, column);
+ protected Node createTripleTerm(Node s, Node p, Node o, int line, int column) {
+ return profile.createTripleTerm(s, p, o, line, column);
}
protected Node createLiteralInteger(String lexicalForm, int line, int column) {
@@ -188,11 +190,37 @@ public class LangParserBase {
profile.getPrefixMap().add(prefix,iri);
stream.prefix(prefix, iri);
}
-
protected void emitTriple(int line, int column, Node s, Node p, Node o) {
stream.triple(Triple.create(s, p, o));
}
+ protected Node emitTripleReifier(int line, int column, Node reifierId, Node s, Node p, Node o) {
+ Node tripleTerm = createTripleTerm(s, p, o, line, column);
+ if ( reifierId == null )
+ reifierId = createBNode(line, column);
+ Triple reifiedTriple = Triple.create(reifierId, nRDFreifies, tripleTerm);
+ stream.triple(reifiedTriple);
+ return reifierId;
+ }
+
+ private Node annotationReifierId = null;
+
+ protected void setReifierId(Node reifId) {
+ annotationReifierId = reifId;
+ }
+
+ protected Node getOrAllocReifierId(Node s, Node p, Node o, int line, int column) {
+ if ( annotationReifierId != null )
+ return annotationReifierId;
+ Node reifierId = createBNode(line, column);
+ emitTripleReifier(line, column, reifierId, s, p, o);
+ return reifierId;
+ }
+
+ protected void clearReifierId() {
+ annotationReifierId = null;
+ }
+
protected String unescapeIRI(String iriStr) {
try {
return EscapeStr.unescape(iriStr, '\\', true);
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/javacc/TurtleJavacc.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/javacc/TurtleJavacc.java
index 93284fd590..403ac258b1 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/javacc/TurtleJavacc.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/javacc/TurtleJavacc.java
@@ -89,7 +89,7 @@ public class TurtleJavacc extends LangParserBase implements TurtleJavaccConstant
case PNAME_NS:
case PNAME_LN:
case BLANK_NODE_LABEL:{
- TriplesSameSubject();
+ Triples();
jj_consume_token(DOT);
break;
}
@@ -149,28 +149,26 @@ setBase(iri, t.beginLine, t.beginColumn) ;
}
}
-// Turtle [6] triples
- final public void TriplesSameSubject() throws ParseException {Node s ;
+ final public void Triples() throws ParseException {Node n;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case IRIref:
case LPAREN:
case ANON:
- case LT2:
case PNAME_NS:
case PNAME_LN:
case BLANK_NODE_LABEL:{
- s = Subject();
- PredicateObjectList(s);
+ n = Subject();
+ PredicateObjectList(n);
break;
}
case LBRACKET:{
- s = BlankNodePropertyList();
+ n = BlankNodePropertyList();
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case KW_A:
case IRIref:
case PNAME_NS:
case PNAME_LN:{
- PredicateObjectList(s);
+ PredicateObjectList(n);
break;
}
default:
@@ -179,14 +177,29 @@ setBase(iri, t.beginLine, t.beginColumn) ;
}
break;
}
+ case LT2:{
+ n = ReifiedTriple();
+ switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
+ case KW_A:
+ case IRIref:
+ case PNAME_NS:
+ case PNAME_LN:{
+ PredicateObjectList(n);
+ break;
+ }
+ default:
+ jj_la1[6] = jj_gen;
+ ;
+ }
+ break;
+ }
default:
- jj_la1[6] = jj_gen;
+ jj_la1[7] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
-// Turtle [7] predicateObjectList
final public void PredicateObjectList(Node s) throws ParseException {Node p = null ;
p = Verb();
ObjectList(s, p);
@@ -198,7 +211,7 @@ setBase(iri, t.beginLine, t.beginColumn) ;
break;
}
default:
- jj_la1[7] = jj_gen;
+ jj_la1[8] = jj_gen;
break label_2;
}
jj_consume_token(SEMICOLON);
@@ -212,13 +225,12 @@ setBase(iri, t.beginLine, t.beginColumn) ;
break;
}
default:
- jj_la1[8] = jj_gen;
+ jj_la1[9] = jj_gen;
;
}
}
}
-// Turtle [8] objectList
final public void ObjectList(Node s, Node p) throws ParseException {Node o ;
o = Object();
emitTriple(token.beginLine, token.beginColumn, s, p, o) ;
@@ -231,7 +243,7 @@ emitTriple(token.beginLine, token.beginColumn, s, p, o) ;
break;
}
default:
- jj_la1[9] = jj_gen;
+ jj_la1[10] = jj_gen;
break label_3;
}
jj_consume_token(COMMA);
@@ -241,22 +253,6 @@ emitTriple(token.beginLine, token.beginColumn, s, p, o) ;
}
}
-// RDF-star Annotation Syntax
- final public void Annotation(Node s, Node p, Node o) throws ParseException {
- switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
- case L_ANN:{
- jj_consume_token(L_ANN);
-Node x = createQuotedTriple(s, p, o, token.beginLine, token.beginColumn);
- PredicateObjectList(x);
- jj_consume_token(R_ANN);
- break;
- }
- default:
- jj_la1[10] = jj_gen;
- ;
- }
-}
-
// Turtle [9] verb
final public Node Verb() throws ParseException {Node p ;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
@@ -298,10 +294,6 @@ s = createURI(iri, token.beginLine, token.beginColumn) ;
s = Collection();
break;
}
- case LT2:{
- s = QuotedTriple();
- break;
- }
default:
jj_la1[12] = jj_gen;
jj_consume_token(-1);
@@ -353,39 +345,16 @@ o = createURI(iri, token.beginLine, token.beginColumn) ;
o = Literal();
break;
}
- case LT2:{
- o = QuotedTriple();
- break;
- }
- default:
- jj_la1[13] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
-{if ("" != null) return o;}
- throw new Error("Missing return statement in function");
-}
-
- final public Node QuotedTripleSubject() throws ParseException {Node o ; String iri;
- switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
- case IRIref:
- case PNAME_NS:
- case PNAME_LN:{
- iri = iri();
-o = createURI(iri, token.beginLine, token.beginColumn) ;
- break;
- }
- case ANON:
- case BLANK_NODE_LABEL:{
- o = BlankNode();
+ case L_TRIPLE:{
+ o = TripleTerm();
break;
}
case LT2:{
- o = QuotedTriple();
+ o = ReifiedTriple();
break;
}
default:
- jj_la1[14] = jj_gen;
+ jj_la1[13] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -393,57 +362,6 @@ o = createURI(iri, token.beginLine, token.beginColumn) ;
throw new Error("Missing return statement in function");
}
- final public Node QuotedTripleObject() throws ParseException {Node o ; String iri;
- switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
- case IRIref:
- case PNAME_NS:
- case PNAME_LN:{
- iri = iri();
-o = createURI(iri, token.beginLine, token.beginColumn) ;
- break;
- }
- case ANON:
- case BLANK_NODE_LABEL:{
- o = BlankNode();
- break;
- }
- case TRUE:
- case FALSE:
- case INTEGER:
- case DECIMAL:
- case DOUBLE:
- case STRING_LITERAL1:
- case STRING_LITERAL2:
- case STRING_LITERAL_LONG1:
- case STRING_LITERAL_LONG2:{
- o = Literal();
- break;
- }
- case LT2:{
- o = QuotedTriple();
- break;
- }
- default:
- jj_la1[15] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
-{if ("" != null) return o ;}
- throw new Error("Missing return statement in function");
-}
-
-// The syntax for RDF-star <<>>
- final public Node QuotedTriple() throws ParseException {Node s , p , o ; Token t ;
- t = jj_consume_token(LT2);
- s = QuotedTripleSubject();
- p = Verb();
- o = QuotedTripleObject();
- jj_consume_token(GT2);
-Node n = createQuotedTriple(s, p, o, t.beginLine, t.beginColumn);
- {if ("" != null) return n;}
- throw new Error("Missing return statement in function");
-}
-
// Turtle [13] literal
final public Node Literal() throws ParseException {Node n ;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
@@ -469,7 +387,7 @@ Node n = createQuotedTriple(s, p, o, t.beginLine, t.beginColumn);
break;
}
default:
- jj_la1[16] = jj_gen;
+ jj_la1[14] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -507,6 +425,7 @@ int line = t.beginLine; int column = t.beginColumn;
case LPAREN:
case LBRACKET:
case ANON:
+ case L_TRIPLE:
case LT2:
case PNAME_NS:
case PNAME_LN:
@@ -515,7 +434,7 @@ int line = t.beginLine; int column = t.beginColumn;
break;
}
default:
- jj_la1[17] = jj_gen;
+ jj_la1[15] = jj_gen;
break label_4;
}
Node cell = createListNode(line, column) ;
@@ -561,7 +480,7 @@ if ( lastCell != null )
break;
}
default:
- jj_la1[18] = jj_gen;
+ jj_la1[16] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -576,11 +495,11 @@ String lang = null ; String uri = null ;
case BASE:
case PREFIX:
case DATATYPE:
- case LANGTAG:{
+ case LANG_DIR:{
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case BASE:
case PREFIX:
- case LANGTAG:{
+ case LANG_DIR:{
lang = LangTag();
break;
}
@@ -590,14 +509,14 @@ String lang = null ; String uri = null ;
break;
}
default:
- jj_la1[19] = jj_gen;
+ jj_la1[17] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
}
default:
- jj_la1[20] = jj_gen;
+ jj_la1[18] = jj_gen;
;
}
{if ("" != null) return createLiteral(lex, lang, uri, token.beginLine, token.beginColumn) ;}
@@ -606,8 +525,8 @@ String lang = null ; String uri = null ;
final public String LangTag() throws ParseException {Token t ;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
- case LANGTAG:{
- t = jj_consume_token(LANGTAG);
+ case LANG_DIR:{
+ t = jj_consume_token(LANG_DIR);
break;
}
case BASE:
@@ -616,7 +535,7 @@ String lang = null ; String uri = null ;
break;
}
default:
- jj_la1[21] = jj_gen;
+ jj_la1[19] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -635,7 +554,7 @@ String lang = stripChars(t.image, 1) ; {if ("" != null) return lang ;}
break;
}
default:
- jj_la1[22] = jj_gen;
+ jj_la1[20] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -657,7 +576,7 @@ String lang = stripChars(t.image, 1) ; {if ("" != null) return lang ;}
break;
}
default:
- jj_la1[23] = jj_gen;
+ jj_la1[21] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -688,7 +607,7 @@ lex = stripQuotes3(t.image) ;
break;
}
default:
- jj_la1[24] = jj_gen;
+ jj_la1[22] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -713,7 +632,7 @@ checkString(lex, t.beginLine, t.beginColumn) ;
break;
}
default:
- jj_la1[25] = jj_gen;
+ jj_la1[23] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -734,7 +653,7 @@ checkString(lex, t.beginLine, t.beginColumn) ;
break;
}
default:
- jj_la1[26] = jj_gen;
+ jj_la1[24] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -755,7 +674,7 @@ checkString(lex, t.beginLine, t.beginColumn) ;
break;
}
default:
- jj_la1[27] = jj_gen;
+ jj_la1[25] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -768,6 +687,250 @@ checkString(lex, t.beginLine, t.beginColumn) ;
throw new Error("Missing return statement in function");
}
+ final public Node Reifier() throws ParseException {Node n = null; String iriStr; Token t;
+ t = jj_consume_token(TILDE);
+ switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
+ case IRIref:
+ case ANON:
+ case PNAME_NS:
+ case PNAME_LN:
+ case BLANK_NODE_LABEL:{
+ switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
+ case IRIref:
+ case PNAME_NS:
+ case PNAME_LN:{
+ iriStr = iri();
+n = createURI(iriStr, token.beginLine, token.beginColumn) ;
+ break;
+ }
+ case ANON:
+ case BLANK_NODE_LABEL:{
+ n = BlankNode();
+ break;
+ }
+ default:
+ jj_la1[26] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ break;
+ }
+ default:
+ jj_la1[27] = jj_gen;
+ ;
+ }
+if ( n == null ) n = createBNode(t.beginLine, t.beginColumn) ;
+{if ("" != null) return n ;}
+ throw new Error("Missing return statement in function");
+}
+
+ final public Node ReifiedTriple() throws ParseException {Node reifId = null ; Token tok ; Node s; Node p ; Node o ;
+ tok = jj_consume_token(LT2);
+ s = ReifiedTripleSubject();
+ p = Verb();
+ o = ReifiedTripleObject();
+ switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
+ case TILDE:{
+ reifId = Reifier();
+ break;
+ }
+ default:
+ jj_la1[28] = jj_gen;
+ ;
+ }
+reifId = emitTripleReifier(tok.beginLine, tok.beginColumn, reifId, s, p, o);
+ jj_consume_token(GT2);
+{if ("" != null) return reifId ;}
+ throw new Error("Missing return statement in function");
+}
+
+// rtSubject
+ final public Node ReifiedTripleSubject() throws ParseException {Node s; String iri;
+ switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
+ case IRIref:
+ case PNAME_NS:
+ case PNAME_LN:{
+ iri = iri();
+s = createURI(iri, token.beginLine, token.beginColumn) ;
+ break;
+ }
+ case ANON:
+ case BLANK_NODE_LABEL:{
+ s = BlankNode();
+ break;
+ }
+ case LT2:{
+ s = ReifiedTriple();
+ break;
+ }
+ default:
+ jj_la1[29] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+{if ("" != null) return s;}
+ throw new Error("Missing return statement in function");
+}
+
+// rtObject
+ final public Node ReifiedTripleObject() throws ParseException {Node o; String iri;
+ switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
+ case IRIref:
+ case PNAME_NS:
+ case PNAME_LN:{
+ iri = iri();
+o = createURI(iri, token.beginLine, token.beginColumn) ;
+ break;
+ }
+ case ANON:
+ case BLANK_NODE_LABEL:{
+ o = BlankNode();
+ break;
+ }
+ case TRUE:
+ case FALSE:
+ case INTEGER:
+ case DECIMAL:
+ case DOUBLE:
+ case STRING_LITERAL1:
+ case STRING_LITERAL2:
+ case STRING_LITERAL_LONG1:
+ case STRING_LITERAL_LONG2:{
+ o = Literal();
+ break;
+ }
+ case L_TRIPLE:{
+ o = TripleTerm();
+ break;
+ }
+ case LT2:{
+ o = ReifiedTriple();
+ break;
+ }
+ default:
+ jj_la1[30] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+{if ("" != null) return o;}
+ throw new Error("Missing return statement in function");
+}
+
+ final public Node TripleTerm() throws ParseException {Node n = null ; Token openToken ; String iri ; Node s , p , o ;
+ jj_consume_token(L_TRIPLE);
+ s = TripleTermSubject();
+ p = Verb();
+ o = TripleTermObject();
+ jj_consume_token(R_TRIPLE);
+{if ("" != null) return createTripleTerm(s, p, o, token.beginLine, token.beginColumn) ;}
+ throw new Error("Missing return statement in function");
+}
+
+// ttSubject
+ final public Node TripleTermSubject() throws ParseException {Node o ; String iri;
+ switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
+ case IRIref:
+ case PNAME_NS:
+ case PNAME_LN:{
+ iri = iri();
+o = createURI(iri, token.beginLine, token.beginColumn) ;
+ break;
+ }
+ case ANON:
+ case BLANK_NODE_LABEL:{
+ o = BlankNode();
+ break;
+ }
+ default:
+ jj_la1[31] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+{if ("" != null) return o;}
+ throw new Error("Missing return statement in function");
+}
+
+// ttObject
+ final public Node TripleTermObject() throws ParseException {Node o ; String iri;
+ switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
+ case IRIref:
+ case PNAME_NS:
+ case PNAME_LN:{
+ iri = iri();
+o = createURI(iri, token.beginLine, token.beginColumn) ;
+ break;
+ }
+ case ANON:
+ case BLANK_NODE_LABEL:{
+ o = BlankNode();
+ break;
+ }
+ case TRUE:
+ case FALSE:
+ case INTEGER:
+ case DECIMAL:
+ case DOUBLE:
+ case STRING_LITERAL1:
+ case STRING_LITERAL2:
+ case STRING_LITERAL_LONG1:
+ case STRING_LITERAL_LONG2:{
+ o = Literal();
+ break;
+ }
+ case L_TRIPLE:{
+ o = TripleTerm();
+ break;
+ }
+ default:
+ jj_la1[32] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+{if ("" != null) return o ;}
+ throw new Error("Missing return statement in function");
+}
+
+// RDF-star Annotation Syntax
+ final public void Annotation(Node s, Node p, Node o) throws ParseException {Node reifId = null;
+ label_5:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
+ case L_ANN:
+ case TILDE:{
+ ;
+ break;
+ }
+ default:
+ jj_la1[33] = jj_gen;
+ break label_5;
+ }
+ switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
+ case TILDE:{
+ reifId = Reifier();
+reifId = emitTripleReifier(token.beginLine, token.beginColumn, reifId, s, p, o) ;
+setReifierId(reifId);
+ break;
+ }
+ case L_ANN:{
+reifId = getOrAllocReifierId(s, p, o, token.beginLine, token.beginColumn);
+clearReifierId();
+ AnnotationBlock(reifId);
+ break;
+ }
+ default:
+ jj_la1[34] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+}
+
+ final public void AnnotationBlock(Node reifId) throws ParseException {
+ jj_consume_token(L_ANN);
+ PredicateObjectList(reifId);
+ jj_consume_token(R_ANN);
+}
+
/** Generated Token Manager. */
public TurtleJavaccTokenManager token_source;
SimpleCharStream jj_input_stream;
@@ -777,7 +940,7 @@ checkString(lex, t.beginLine, t.beginColumn) ;
public Token jj_nt;
private int jj_ntk;
private int jj_gen;
- final private int[] jj_la1 = new int[28];
+ final private int[] jj_la1 = new int[35];
static private int[] jj_la1_0;
static private int[] jj_la1_1;
static private int[] jj_la1_2;
@@ -787,13 +950,13 @@ checkString(lex, t.beginLine, t.beginColumn) ;
jj_la1_init_2();
}
private static void jj_la1_init_0() {
- jj_la1_0 = new int[] {0x21e00,0x10000,0x21e00,0x1800,0x600,0x20100,0x20000,0x0,0x20100,0x0,0x0,0x20100,0x20000,0x80e26000,0x20000,0x80e26000,0x80e06000,0x80e26000,0xe00000,0x1800,0x1800,0x1800,0x1800,0x6000,0x80000000,0x20000,0x0,0x0,};
+ jj_la1_0 = new int[] {0x21e00,0x10000,0x21e00,0x1800,0x600,0x20100,0x20100,0x20000,0x0,0x20100,0x0,0x20100,0x20000,0x80e26000,0x80e06000,0x80e26000,0xe00000,0x1800,0x1800,0x1800,0x1800,0x6000,0x80000000,0x20000,0x0,0x0,0x20000,0x20000,0x0,0x20000,0x80e26000,0x20000,0x80e26000,0x0,0x0,};
}
private static void jj_la1_init_1() {
- jj_la1_1 = new int[] {0x382288,0x0,0x382288,0x0,0x0,0x180000,0x382288,0x400,0x180000,0x800,0x8000,0x180000,0x382208,0x38228f,0x382200,0x382207,0x7,0x38228f,0x0,0x420000,0x420000,0x400000,0x0,0x0,0x7,0x180000,0x180000,0x200200,};
+ jj_la1_1 = new int[] {0x3820288,0x0,0x3820288,0x0,0x0,0x1800000,0x1800000,0x3820288,0x400,0x1800000,0x800,0x1800000,0x3800208,0x382828f,0x7,0x382828f,0x0,0x4002000,0x4002000,0x4000000,0x0,0x0,0x7,0x1800000,0x1800000,0x2000200,0x3800200,0x3800200,0x200000,0x3820200,0x3828207,0x3800200,0x3808207,0x280000,0x280000,};
}
private static void jj_la1_init_2() {
- jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};
+ jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};
}
/** Constructor with InputStream. */
@@ -807,7 +970,7 @@ checkString(lex, t.beginLine, t.beginColumn) ;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 28; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 35; i++) jj_la1[i] = -1;
}
/** Reinitialise. */
@@ -821,7 +984,7 @@ checkString(lex, t.beginLine, t.beginColumn) ;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 28; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 35; i++) jj_la1[i] = -1;
}
/** Constructor. */
@@ -831,7 +994,7 @@ checkString(lex, t.beginLine, t.beginColumn) ;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 28; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 35; i++) jj_la1[i] = -1;
}
/** Reinitialise. */
@@ -849,7 +1012,7 @@ checkString(lex, t.beginLine, t.beginColumn) ;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 28; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 35; i++) jj_la1[i] = -1;
}
/** Constructor with generated Token Manager. */
@@ -858,7 +1021,7 @@ checkString(lex, t.beginLine, t.beginColumn) ;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 28; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 35; i++) jj_la1[i] = -1;
}
/** Reinitialise. */
@@ -867,7 +1030,7 @@ checkString(lex, t.beginLine, t.beginColumn) ;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 28; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 35; i++) jj_la1[i] = -1;
}
private Token jj_consume_token(int kind) throws ParseException {
@@ -918,12 +1081,12 @@ checkString(lex, t.beginLine, t.beginColumn) ;
/** Generate ParseException. */
public ParseException generateParseException() {
jj_expentries.clear();
- boolean[] la1tokens = new boolean[69];
+ boolean[] la1tokens = new boolean[73];
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
- for (int i = 0; i < 28; i++) {
+ for (int i = 0; i < 35; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<<j)) != 0) {
@@ -938,7 +1101,7 @@ checkString(lex, t.beginLine, t.beginColumn) ;
}
}
}
- for (int i = 0; i < 69; i++) {
+ for (int i = 0; i < 73; i++) {
if (la1tokens[i]) {
jj_expentry = new int[1];
jj_expentry[0] = i;
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/javacc/TurtleJavaccConstants.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/javacc/TurtleJavaccConstants.java
index 9051257c26..f6b80ecbcd 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/javacc/TurtleJavaccConstants.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/javacc/TurtleJavaccConstants.java
@@ -107,53 +107,61 @@ public interface TurtleJavaccConstants {
/** RegularExpression Id. */
int DOT = 44;
/** RegularExpression Id. */
- int LT2 = 45;
+ int DATATYPE = 45;
/** RegularExpression Id. */
- int GT2 = 46;
+ int AT = 46;
/** RegularExpression Id. */
- int L_ANN = 47;
+ int L_TRIPLE = 47;
/** RegularExpression Id. */
- int R_ANN = 48;
+ int R_TRIPLE = 48;
/** RegularExpression Id. */
- int DATATYPE = 49;
+ int LT2 = 49;
/** RegularExpression Id. */
- int AT = 50;
+ int GT2 = 50;
/** RegularExpression Id. */
- int PNAME_NS = 51;
+ int L_ANN = 51;
/** RegularExpression Id. */
- int PNAME_LN = 52;
+ int R_ANN = 52;
/** RegularExpression Id. */
- int BLANK_NODE_LABEL = 53;
+ int TILDE = 53;
/** RegularExpression Id. */
- int LANGTAG = 54;
+ int VBAR = 54;
/** RegularExpression Id. */
- int A2Z = 55;
+ int PNAME_NS = 55;
/** RegularExpression Id. */
- int A2ZN = 56;
+ int PNAME_LN = 56;
/** RegularExpression Id. */
- int SURROGATE_PAIR = 57;
+ int BLANK_NODE_LABEL = 57;
/** RegularExpression Id. */
- int PN_CHARS_BASE = 58;
+ int LANG_DIR = 58;
/** RegularExpression Id. */
- int PN_CHARS_U = 59;
+ int A2Z = 59;
/** RegularExpression Id. */
- int PN_CHARS = 60;
+ int A2ZN = 60;
/** RegularExpression Id. */
- int PN_PREFIX = 61;
+ int SURROGATE_PAIR = 61;
/** RegularExpression Id. */
- int PN_LOCAL = 62;
+ int PN_CHARS_BASE = 62;
/** RegularExpression Id. */
- int VARNAME = 63;
+ int PN_CHARS_U = 63;
/** RegularExpression Id. */
- int PN_LOCAL_ESC = 64;
+ int PN_CHARS = 64;
/** RegularExpression Id. */
- int PLX = 65;
+ int PN_PREFIX = 65;
/** RegularExpression Id. */
- int HEX = 66;
+ int PN_LOCAL = 66;
/** RegularExpression Id. */
- int PERCENT = 67;
+ int VARNAME = 67;
/** RegularExpression Id. */
- int UNKNOWN = 68;
+ int PN_LOCAL_ESC = 68;
+ /** RegularExpression Id. */
+ int PLX = 69;
+ /** RegularExpression Id. */
+ int HEX = 70;
+ /** RegularExpression Id. */
+ int PERCENT = 71;
+ /** RegularExpression Id. */
+ int UNKNOWN = 72;
/** Lexical state. */
int DEFAULT = 0;
@@ -205,16 +213,20 @@ public interface TurtleJavaccConstants {
"\";\"",
"\",\"",
"\".\"",
+ "\"^^\"",
+ "\"@\"",
+ "\"<<(\"",
+ "\")>>\"",
"\"<<\"",
"\">>\"",
"\"{|\"",
"\"|}\"",
- "\"^^\"",
- "\"@\"",
+ "\"~\"",
+ "\"|\"",
"<PNAME_NS>",
"<PNAME_LN>",
"<BLANK_NODE_LABEL>",
- "<LANGTAG>",
+ "<LANG_DIR>",
"<A2Z>",
"<A2ZN>",
"<SURROGATE_PAIR>",
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/javacc/TurtleJavaccTokenManager.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/javacc/TurtleJavaccTokenManager.java
index a9f0f5c776..d1f85309f1 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/javacc/TurtleJavaccTokenManager.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/extra/javacc/TurtleJavaccTokenManager.java
@@ -19,8 +19,12 @@
*/
package org.apache.jena.riot.lang.extra.javacc;
+import org.apache.jena.graph.*;
+import org.apache.jena.riot.lang.extra.* ;
+import static org.apache.jena.riot.lang.extra.LangParserLib.*;
/** Token Manager. */
+@SuppressWarnings ("unused")
public class TurtleJavaccTokenManager implements TurtleJavaccConstants {
/** Debug output. */
@@ -56,7 +60,7 @@ private int jjMoveStringLiteralDfa0_0(){
return jjMoveNfa_0(0, 0);
case 41:
jjmatchedKind = 36;
- return jjMoveNfa_0(0, 0);
+ return jjMoveStringLiteralDfa1_0(0x1000000000000L);
case 43:
jjmatchedKind = 18;
return jjMoveNfa_0(0, 0);
@@ -73,11 +77,11 @@ private int jjMoveStringLiteralDfa0_0(){
jjmatchedKind = 42;
return jjMoveNfa_0(0, 0);
case 60:
- return jjMoveStringLiteralDfa1_0(0x200000000000L);
+ return jjMoveStringLiteralDfa1_0(0x2800000000000L);
case 62:
- return jjMoveStringLiteralDfa1_0(0x400000000000L);
+ return jjMoveStringLiteralDfa1_0(0x4000000000000L);
case 64:
- jjmatchedKind = 50;
+ jjmatchedKind = 46;
return jjMoveStringLiteralDfa1_0(0x600L);
case 66:
return jjMoveStringLiteralDfa1_0(0x800L);
@@ -94,7 +98,7 @@ private int jjMoveStringLiteralDfa0_0(){
jjmatchedKind = 40;
return jjMoveNfa_0(0, 0);
case 94:
- return jjMoveStringLiteralDfa1_0(0x2000000000000L);
+ return jjMoveStringLiteralDfa1_0(0x200000000000L);
case 97:
jjmatchedKind = 8;
return jjMoveNfa_0(0, 0);
@@ -108,12 +112,16 @@ private int jjMoveStringLiteralDfa0_0(){
return jjMoveStringLiteralDfa1_0(0x2000L);
case 123:
jjmatchedKind = 37;
- return jjMoveStringLiteralDfa1_0(0x800000000000L);
+ return jjMoveStringLiteralDfa1_0(0x8000000000000L);
case 124:
- return jjMoveStringLiteralDfa1_0(0x1000000000000L);
+ jjmatchedKind = 54;
+ return jjMoveStringLiteralDfa1_0(0x10000000000000L);
case 125:
jjmatchedKind = 38;
return jjMoveNfa_0(0, 0);
+ case 126:
+ jjmatchedKind = 53;
+ return jjMoveNfa_0(0, 0);
case 65279:
jjmatchedKind = 16;
return jjMoveNfa_0(0, 0);
@@ -129,27 +137,27 @@ private int jjMoveStringLiteralDfa1_0(long active0){
switch(curChar)
{
case 60:
- if ((active0 & 0x200000000000L) != 0L)
+ if ((active0 & 0x2000000000000L) != 0L)
{
- jjmatchedKind = 45;
+ jjmatchedKind = 49;
jjmatchedPos = 1;
}
- break;
+ return jjMoveStringLiteralDfa2_0(active0, 0x800000000000L);
case 62:
- if ((active0 & 0x400000000000L) != 0L)
+ if ((active0 & 0x4000000000000L) != 0L)
{
- jjmatchedKind = 46;
+ jjmatchedKind = 50;
jjmatchedPos = 1;
}
- break;
+ return jjMoveStringLiteralDfa2_0(active0, 0x1000000000000L);
case 65:
return jjMoveStringLiteralDfa2_0(active0, 0x4800L);
case 82:
return jjMoveStringLiteralDfa2_0(active0, 0x3000L);
case 94:
- if ((active0 & 0x2000000000000L) != 0L)
+ if ((active0 & 0x200000000000L) != 0L)
{
- jjmatchedKind = 49;
+ jjmatchedKind = 45;
jjmatchedPos = 1;
}
break;
@@ -162,16 +170,16 @@ private int jjMoveStringLiteralDfa1_0(long active0){
case 114:
return jjMoveStringLiteralDfa2_0(active0, 0x3000L);
case 124:
- if ((active0 & 0x800000000000L) != 0L)
+ if ((active0 & 0x8000000000000L) != 0L)
{
- jjmatchedKind = 47;
+ jjmatchedKind = 51;
jjmatchedPos = 1;
}
break;
case 125:
- if ((active0 & 0x1000000000000L) != 0L)
+ if ((active0 & 0x10000000000000L) != 0L)
{
- jjmatchedKind = 48;
+ jjmatchedKind = 52;
jjmatchedPos = 1;
}
break;
@@ -189,6 +197,20 @@ private int jjMoveStringLiteralDfa2_0(long old0, long active0){
}
switch(curChar)
{
+ case 40:
+ if ((active0 & 0x800000000000L) != 0L)
+ {
+ jjmatchedKind = 47;
+ jjmatchedPos = 2;
+ }
+ break;
+ case 62:
+ if ((active0 & 0x1000000000000L) != 0L)
+ {
+ jjmatchedKind = 48;
+ jjmatchedPos = 2;
+ }
+ break;
case 69:
return jjMoveStringLiteralDfa3_0(active0, 0x1000L);
case 76:
@@ -402,7 +424,7 @@ private int jjMoveNfa_0(int startState, int curPos)
catch(java.io.IOException e) { throw new Error("Internal Error"); }
curPos = 0;
int startsAt = 0;
- jjnewStateCnt = 189;
+ jjnewStateCnt = 192;
int i = 1;
jjstateSet[0] = startState;
int kind = 0x7fffffff;
@@ -428,12 +450,12 @@ private int jjMoveNfa_0(int startState, int curPos)
{ jjCheckNAddStates(7, 11); }
else if (curChar == 58)
{
- if (kind > 51)
- kind = 51;
+ if (kind > 55)
+ kind = 55;
{ jjCheckNAddStates(12, 15); }
}
else if (curChar == 46)
- { jjCheckNAddTwoStates(132, 134); }
+ { jjCheckNAddTwoStates(135, 137); }
else if (curChar == 34)
jjstateSet[jjnewStateCnt++] = 104;
else if (curChar == 39)
@@ -824,8 +846,8 @@ private int jjMoveNfa_0(int startState, int curPos)
case 115:
if ((0x3ff000000000000L & l) == 0L)
break;
- if (kind > 53)
- kind = 53;
+ if (kind > 57)
+ kind = 57;
{ jjCheckNAddStates(51, 53); }
break;
case 116:
@@ -833,8 +855,8 @@ private int jjMoveNfa_0(int startState, int curPos)
{ jjCheckNAddStates(51, 53); }
break;
case 117:
- if ((0x3ff200000000000L & l) != 0L && kind > 53)
- kind = 53;
+ if ((0x3ff200000000000L & l) != 0L && kind > 57)
+ kind = 57;
break;
case 126:
if (curChar == 45)
@@ -843,202 +865,213 @@ private int jjMoveNfa_0(int startState, int curPos)
case 127:
if ((0x3ff000000000000L & l) == 0L)
break;
- if (kind > 54)
- kind = 54;
- { jjCheckNAddTwoStates(126, 127); }
+ if (kind > 58)
+ kind = 58;
+ { jjCheckNAddStates(54, 56); }
break;
case 128:
+ if (curChar != 45)
+ break;
+ if (kind > 58)
+ kind = 58;
+ jjstateSet[jjnewStateCnt++] = 129;
+ break;
+ case 130:
+ if (curChar == 45)
+ jjstateSet[jjnewStateCnt++] = 128;
+ break;
+ case 131:
if ((0x280000000000L & l) != 0L)
{ jjCheckNAddStates(7, 11); }
break;
- case 129:
+ case 132:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 21)
kind = 21;
- { jjCheckNAdd(129); }
+ { jjCheckNAdd(132); }
break;
- case 130:
+ case 133:
if ((0x3ff000000000000L & l) != 0L)
- { jjCheckNAddTwoStates(130, 131); }
+ { jjCheckNAddTwoStates(133, 134); }
break;
- case 131:
+ case 134:
if (curChar == 46)
- { jjCheckNAdd(132); }
+ { jjCheckNAdd(135); }
break;
- case 132:
+ case 135:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 22)
kind = 22;
- { jjCheckNAdd(132); }
+ { jjCheckNAdd(135); }
break;
- case 133:
+ case 136:
if (curChar == 46)
- { jjCheckNAdd(134); }
+ { jjCheckNAdd(137); }
break;
- case 134:
+ case 137:
if ((0x3ff000000000000L & l) != 0L)
- { jjCheckNAddTwoStates(134, 135); }
+ { jjCheckNAddTwoStates(137, 138); }
break;
- case 136:
+ case 139:
if ((0x280000000000L & l) != 0L)
- { jjCheckNAdd(137); }
+ { jjCheckNAdd(140); }
break;
- case 137:
+ case 140:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 23)
kind = 23;
- { jjCheckNAdd(137); }
+ { jjCheckNAdd(140); }
break;
- case 138:
+ case 141:
if ((0x3ff000000000000L & l) != 0L)
- { jjCheckNAddStates(54, 57); }
+ { jjCheckNAddStates(57, 60); }
break;
- case 139:
+ case 142:
if ((0x3ff000000000000L & l) != 0L)
- { jjCheckNAddTwoStates(139, 140); }
+ { jjCheckNAddTwoStates(142, 143); }
break;
- case 140:
+ case 143:
if (curChar == 46)
- { jjCheckNAddTwoStates(141, 142); }
+ { jjCheckNAddTwoStates(144, 145); }
break;
- case 141:
+ case 144:
if ((0x3ff000000000000L & l) != 0L)
- { jjCheckNAddTwoStates(141, 142); }
+ { jjCheckNAddTwoStates(144, 145); }
break;
- case 143:
+ case 146:
if ((0x280000000000L & l) != 0L)
- { jjCheckNAdd(144); }
+ { jjCheckNAdd(147); }
break;
- case 144:
+ case 147:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 23)
kind = 23;
- { jjCheckNAdd(144); }
+ { jjCheckNAdd(147); }
break;
- case 145:
+ case 148:
if ((0x3ff000000000000L & l) != 0L)
- { jjCheckNAddTwoStates(145, 146); }
+ { jjCheckNAddTwoStates(148, 149); }
break;
- case 147:
+ case 150:
if ((0x280000000000L & l) != 0L)
- { jjCheckNAdd(148); }
+ { jjCheckNAdd(151); }
break;
- case 148:
+ case 151:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 23)
kind = 23;
- { jjCheckNAdd(148); }
+ { jjCheckNAdd(151); }
break;
- case 149:
+ case 152:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 21)
kind = 21;
{ jjCheckNAddStates(0, 6); }
break;
- case 150:
+ case 153:
if (curChar == 46)
- { jjCheckNAddTwoStates(132, 134); }
+ { jjCheckNAddTwoStates(135, 137); }
break;
- case 152:
+ case 155:
if ((0x3ff600000000000L & l) != 0L)
- { jjAddStates(58, 60); }
+ { jjAddStates(61, 63); }
break;
- case 153:
+ case 156:
if ((0x3ff200000000000L & l) != 0L)
- jjstateSet[jjnewStateCnt++] = 154;
+ jjstateSet[jjnewStateCnt++] = 157;
break;
- case 154:
- if (curChar == 58 && kind > 51)
- kind = 51;
+ case 157:
+ if (curChar == 58 && kind > 55)
+ kind = 55;
break;
- case 158:
+ case 161:
if ((0x3ff600000000000L & l) != 0L)
- { jjAddStates(61, 63); }
+ { jjAddStates(64, 66); }
break;
- case 159:
+ case 162:
if ((0x3ff200000000000L & l) != 0L)
- jjstateSet[jjnewStateCnt++] = 160;
+ jjstateSet[jjnewStateCnt++] = 163;
break;
- case 160:
+ case 163:
if (curChar == 58)
{ jjCheckNAddStates(12, 15); }
break;
- case 161:
+ case 164:
if ((0x7ff000000000000L & l) == 0L)
break;
- if (kind > 52)
- kind = 52;
- { jjCheckNAddStates(64, 68); }
+ if (kind > 56)
+ kind = 56;
+ { jjCheckNAddStates(67, 71); }
break;
- case 162:
+ case 165:
if ((0x7ff600000000000L & l) != 0L)
- { jjCheckNAddStates(64, 68); }
+ { jjCheckNAddStates(67, 71); }
break;
- case 163:
- if ((0x7ff200000000000L & l) != 0L && kind > 52)
- kind = 52;
+ case 166:
+ if ((0x7ff200000000000L & l) != 0L && kind > 56)
+ kind = 56;
break;
- case 167:
+ case 170:
if ((0xa800fffa00000000L & l) != 0L)
- { jjCheckNAddStates(64, 68); }
+ { jjCheckNAddStates(67, 71); }
break;
- case 168:
+ case 171:
if (curChar == 37)
- { jjAddStates(69, 70); }
+ { jjAddStates(72, 73); }
break;
- case 169:
+ case 172:
if ((0x3ff000000000000L & l) != 0L)
- jjstateSet[jjnewStateCnt++] = 170;
+ jjstateSet[jjnewStateCnt++] = 173;
break;
- case 170:
+ case 173:
if ((0x3ff000000000000L & l) != 0L)
- { jjCheckNAddStates(64, 68); }
+ { jjCheckNAddStates(67, 71); }
break;
- case 171:
+ case 174:
if ((0x3ff000000000000L & l) != 0L)
- jjstateSet[jjnewStateCnt++] = 172;
- break;
- case 172:
- if ((0x3ff000000000000L & l) != 0L && kind > 52)
- kind = 52;
+ jjstateSet[jjnewStateCnt++] = 175;
break;
- case 173:
- if ((0xa800fffa00000000L & l) != 0L && kind > 52)
- kind = 52;
+ case 175:
+ if ((0x3ff000000000000L & l) != 0L && kind > 56)
+ kind = 56;
break;
case 176:
+ if ((0xa800fffa00000000L & l) != 0L && kind > 56)
+ kind = 56;
+ break;
+ case 179:
if ((0xa800fffa00000000L & l) == 0L)
break;
- if (kind > 52)
- kind = 52;
- { jjCheckNAddStates(64, 68); }
+ if (kind > 56)
+ kind = 56;
+ { jjCheckNAddStates(67, 71); }
break;
- case 177:
+ case 180:
if (curChar == 37)
- jjstateSet[jjnewStateCnt++] = 178;
+ jjstateSet[jjnewStateCnt++] = 181;
break;
- case 178:
+ case 181:
if ((0x3ff000000000000L & l) != 0L)
- jjstateSet[jjnewStateCnt++] = 179;
+ jjstateSet[jjnewStateCnt++] = 182;
break;
- case 179:
+ case 182:
if ((0x3ff000000000000L & l) == 0L)
break;
- if (kind > 52)
- kind = 52;
- { jjCheckNAddStates(64, 68); }
+ if (kind > 56)
+ kind = 56;
+ { jjCheckNAddStates(67, 71); }
break;
- case 188:
+ case 191:
if (curChar != 58)
break;
- if (kind > 51)
- kind = 51;
+ if (kind > 55)
+ kind = 55;
{ jjCheckNAddStates(12, 15); }
break;
default : break;
@@ -1054,7 +1087,7 @@ private int jjMoveNfa_0(int startState, int curPos)
{
case 0:
if ((0x7fffffe07fffffeL & l) != 0L)
- { jjCheckNAddStates(71, 78); }
+ { jjCheckNAddStates(74, 81); }
else if (curChar == 64)
{ jjCheckNAdd(125); }
else if (curChar == 95)
@@ -1073,7 +1106,7 @@ private int jjMoveNfa_0(int startState, int curPos)
break;
case 8:
if (curChar == 92)
- { jjAddStates(79, 80); }
+ { jjAddStates(82, 83); }
break;
case 9:
if (curChar == 85)
@@ -1130,7 +1163,7 @@ private int jjMoveNfa_0(int startState, int curPos)
break;
case 25:
if (curChar == 92)
- { jjAddStates(81, 83); }
+ { jjAddStates(84, 86); }
break;
case 26:
if ((0x14404410000000L & l) != 0L)
@@ -1191,7 +1224,7 @@ private int jjMoveNfa_0(int startState, int curPos)
break;
case 43:
if (curChar == 92)
- { jjAddStates(84, 86); }
+ { jjAddStates(87, 89); }
break;
case 44:
if ((0x14404410000000L & l) != 0L)
@@ -1252,7 +1285,7 @@ private int jjMoveNfa_0(int startState, int curPos)
break;
case 63:
if (curChar == 92)
- { jjAddStates(87, 89); }
+ { jjAddStates(90, 92); }
break;
case 64:
if ((0x14404410000000L & l) != 0L)
@@ -1313,7 +1346,7 @@ private int jjMoveNfa_0(int startState, int curPos)
break;
case 87:
if (curChar == 92)
- { jjAddStates(90, 92); }
+ { jjAddStates(93, 95); }
break;
case 88:
if ((0x14404410000000L & l) != 0L)
@@ -1382,8 +1415,8 @@ private int jjMoveNfa_0(int startState, int curPos)
case 115:
if ((0x7fffffe87fffffeL & l) == 0L)
break;
- if (kind > 53)
- kind = 53;
+ if (kind > 57)
+ kind = 57;
{ jjCheckNAddStates(51, 53); }
break;
case 116:
@@ -1391,8 +1424,8 @@ private int jjMoveNfa_0(int startState, int curPos)
{ jjCheckNAddStates(51, 53); }
break;
case 117:
- if ((0x7fffffe87fffffeL & l) != 0L && kind > 53)
- kind = 53;
+ if ((0x7fffffe87fffffeL & l) != 0L && kind > 57)
+ kind = 57;
break;
case 123:
if (curChar == 95)
@@ -1405,113 +1438,120 @@ private int jjMoveNfa_0(int startState, int curPos)
case 125:
if ((0x7fffffe07fffffeL & l) == 0L)
break;
- if (kind > 54)
- kind = 54;
- { jjCheckNAddTwoStates(125, 126); }
+ if (kind > 58)
+ kind = 58;
+ { jjCheckNAddStates(96, 98); }
break;
case 127:
if ((0x7fffffe07fffffeL & l) == 0L)
break;
- if (kind > 54)
- kind = 54;
- { jjCheckNAddTwoStates(126, 127); }
+ if (kind > 58)
+ kind = 58;
+ { jjCheckNAddStates(54, 56); }
break;
- case 135:
+ case 129:
+ if ((0x7fffffe07fffffeL & l) == 0L)
+ break;
+ if (kind > 58)
+ kind = 58;
+ jjstateSet[jjnewStateCnt++] = 129;
+ break;
+ case 138:
if ((0x2000000020L & l) != 0L)
- { jjAddStates(93, 94); }
+ { jjAddStates(99, 100); }
break;
- case 142:
+ case 145:
if ((0x2000000020L & l) != 0L)
- { jjAddStates(95, 96); }
+ { jjAddStates(101, 102); }
break;
- case 146:
+ case 149:
if ((0x2000000020L & l) != 0L)
- { jjAddStates(97, 98); }
+ { jjAddStates(103, 104); }
break;
- case 151:
+ case 154:
if ((0x7fffffe07fffffeL & l) != 0L)
- { jjCheckNAddStates(71, 78); }
+ { jjCheckNAddStates(74, 81); }
break;
- case 152:
+ case 155:
if ((0x7fffffe87fffffeL & l) != 0L)
- { jjCheckNAddStates(58, 60); }
+ { jjCheckNAddStates(61, 63); }
break;
- case 153:
+ case 156:
if ((0x7fffffe87fffffeL & l) != 0L)
- { jjCheckNAdd(154); }
+ { jjCheckNAdd(157); }
break;
- case 158:
+ case 161:
if ((0x7fffffe87fffffeL & l) != 0L)
- { jjCheckNAddStates(61, 63); }
+ { jjCheckNAddStates(64, 66); }
break;
- case 159:
+ case 162:
if ((0x7fffffe87fffffeL & l) != 0L)
- { jjCheckNAdd(160); }
+ { jjCheckNAdd(163); }
break;
- case 161:
+ case 164:
if ((0x7fffffe87fffffeL & l) == 0L)
break;
- if (kind > 52)
- kind = 52;
- { jjCheckNAddStates(64, 68); }
+ if (kind > 56)
+ kind = 56;
+ { jjCheckNAddStates(67, 71); }
break;
- case 162:
+ case 165:
if ((0x7fffffe87fffffeL & l) != 0L)
- { jjCheckNAddStates(64, 68); }
- break;
- case 163:
- if ((0x7fffffe87fffffeL & l) != 0L && kind > 52)
- kind = 52;
+ { jjCheckNAddStates(67, 71); }
break;
case 166:
+ if ((0x7fffffe87fffffeL & l) != 0L && kind > 56)
+ kind = 56;
+ break;
+ case 169:
if (curChar == 92)
- { jjAddStates(99, 100); }
+ { jjAddStates(105, 106); }
break;
- case 167:
+ case 170:
if ((0x4000000080000001L & l) != 0L)
- { jjCheckNAddStates(64, 68); }
+ { jjCheckNAddStates(67, 71); }
break;
- case 169:
+ case 172:
if ((0x7e0000007eL & l) != 0L)
- jjstateSet[jjnewStateCnt++] = 170;
+ jjstateSet[jjnewStateCnt++] = 173;
break;
- case 170:
+ case 173:
if ((0x7e0000007eL & l) != 0L)
- { jjCheckNAddStates(64, 68); }
+ { jjCheckNAddStates(67, 71); }
break;
- case 171:
+ case 174:
if ((0x7e0000007eL & l) != 0L)
- jjstateSet[jjnewStateCnt++] = 172;
+ jjstateSet[jjnewStateCnt++] = 175;
break;
- case 172:
- if ((0x7e0000007eL & l) != 0L && kind > 52)
- kind = 52;
+ case 175:
+ if ((0x7e0000007eL & l) != 0L && kind > 56)
+ kind = 56;
break;
- case 173:
- if ((0x4000000080000001L & l) != 0L && kind > 52)
- kind = 52;
+ case 176:
+ if ((0x4000000080000001L & l) != 0L && kind > 56)
+ kind = 56;
break;
- case 175:
+ case 178:
if (curChar == 92)
- jjstateSet[jjnewStateCnt++] = 176;
+ jjstateSet[jjnewStateCnt++] = 179;
break;
- case 176:
+ case 179:
if ((0x4000000080000001L & l) == 0L)
break;
- if (kind > 52)
- kind = 52;
- { jjCheckNAddStates(64, 68); }
+ if (kind > 56)
+ kind = 56;
+ { jjCheckNAddStates(67, 71); }
break;
- case 178:
+ case 181:
if ((0x7e0000007eL & l) != 0L)
- jjstateSet[jjnewStateCnt++] = 179;
+ jjstateSet[jjnewStateCnt++] = 182;
break;
- case 179:
+ case 182:
if ((0x7e0000007eL & l) == 0L)
break;
- if (kind > 52)
- kind = 52;
- { jjCheckNAddStates(64, 68); }
+ if (kind > 56)
+ kind = 56;
+ { jjCheckNAddStates(67, 71); }
break;
default : break;
}
@@ -1530,9 +1570,9 @@ private int jjMoveNfa_0(int startState, int curPos)
{
case 0:
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
- { jjCheckNAddStates(71, 78); }
+ { jjCheckNAddStates(74, 81); }
if (jjCanMove_19(hiByte, i1, i2, l1, l2))
- { jjAddStates(101, 102); }
+ { jjAddStates(107, 108); }
break;
case 1:
if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
@@ -1568,8 +1608,8 @@ private int jjMoveNfa_0(int startState, int curPos)
case 115:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
- if (kind > 53)
- kind = 53;
+ if (kind > 57)
+ kind = 57;
{ jjCheckNAddStates(51, 53); }
break;
case 116:
@@ -1577,20 +1617,20 @@ private int jjMoveNfa_0(int startState, int curPos)
{ jjCheckNAddStates(51, 53); }
break;
case 117:
- if (jjCanMove_2(hiByte, i1, i2, l1, l2) && kind > 53)
- kind = 53;
+ if (jjCanMove_2(hiByte, i1, i2, l1, l2) && kind > 57)
+ kind = 57;
break;
case 118:
if (jjCanMove_3(hiByte, i1, i2, l1, l2))
- { jjAddStates(103, 104); }
+ { jjAddStates(109, 110); }
break;
case 119:
if (jjCanMove_4(hiByte, i1, i2, l1, l2))
{ jjCheckNAddStates(51, 53); }
break;
case 120:
- if (jjCanMove_5(hiByte, i1, i2, l1, l2) && kind > 53)
- kind = 53;
+ if (jjCanMove_5(hiByte, i1, i2, l1, l2) && kind > 57)
+ kind = 57;
break;
case 121:
if (jjCanMove_6(hiByte, i1, i2, l1, l2))
@@ -1599,103 +1639,103 @@ private int jjMoveNfa_0(int startState, int curPos)
case 122:
if (!jjCanMove_7(hiByte, i1, i2, l1, l2))
break;
- if (kind > 53)
- kind = 53;
+ if (kind > 57)
+ kind = 57;
{ jjCheckNAddStates(51, 53); }
break;
- case 151:
+ case 154:
if (jjCanMove_1(hiByte, i1, i2, l1, l2))
- { jjCheckNAddStates(71, 78); }
+ { jjCheckNAddStates(74, 81); }
break;
- case 152:
+ case 155:
if (jjCanMove_2(hiByte, i1, i2, l1, l2))
- { jjCheckNAddStates(58, 60); }
+ { jjCheckNAddStates(61, 63); }
break;
- case 153:
+ case 156:
if (jjCanMove_2(hiByte, i1, i2, l1, l2))
- { jjCheckNAdd(154); }
+ { jjCheckNAdd(157); }
break;
- case 155:
+ case 158:
if (jjCanMove_8(hiByte, i1, i2, l1, l2))
- { jjAddStates(105, 106); }
+ { jjAddStates(111, 112); }
break;
- case 156:
+ case 159:
if (jjCanMove_9(hiByte, i1, i2, l1, l2))
- { jjCheckNAddStates(58, 60); }
+ { jjCheckNAddStates(61, 63); }
break;
- case 157:
+ case 160:
if (jjCanMove_10(hiByte, i1, i2, l1, l2))
- { jjCheckNAdd(154); }
+ { jjCheckNAdd(157); }
break;
- case 158:
+ case 161:
if (jjCanMove_2(hiByte, i1, i2, l1, l2))
- { jjCheckNAddStates(61, 63); }
+ { jjCheckNAddStates(64, 66); }
break;
- case 159:
+ case 162:
if (jjCanMove_2(hiByte, i1, i2, l1, l2))
- { jjCheckNAdd(160); }
+ { jjCheckNAdd(163); }
break;
- case 161:
+ case 164:
if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
break;
- if (kind > 52)
- kind = 52;
- { jjCheckNAddStates(64, 68); }
+ if (kind > 56)
+ kind = 56;
+ { jjCheckNAddStates(67, 71); }
break;
- case 162:
+ case 165:
if (jjCanMove_2(hiByte, i1, i2, l1, l2))
- { jjCheckNAddStates(64, 68); }
+ { jjCheckNAddStates(67, 71); }
break;
- case 163:
- if (jjCanMove_2(hiByte, i1, i2, l1, l2) && kind > 52)
- kind = 52;
+ case 166:
+ if (jjCanMove_2(hiByte, i1, i2, l1, l2) && kind > 56)
+ kind = 56;
break;
- case 164:
+ case 167:
if (jjCanMove_11(hiByte, i1, i2, l1, l2))
- { jjAddStates(107, 108); }
+ { jjAddStates(113, 114); }
break;
- case 165:
+ case 168:
if (jjCanMove_12(hiByte, i1, i2, l1, l2))
- { jjCheckNAddStates(64, 68); }
+ { jjCheckNAddStates(67, 71); }
break;
- case 174:
- if (jjCanMove_13(hiByte, i1, i2, l1, l2) && kind > 52)
- kind = 52;
+ case 177:
+ if (jjCanMove_13(hiByte, i1, i2, l1, l2) && kind > 56)
+ kind = 56;
break;
- case 180:
+ case 183:
if (jjCanMove_14(hiByte, i1, i2, l1, l2))
- jjstateSet[jjnewStateCnt++] = 181;
+ jjstateSet[jjnewStateCnt++] = 184;
break;
- case 181:
+ case 184:
if (!jjCanMove_15(hiByte, i1, i2, l1, l2))
break;
- if (kind > 52)
- kind = 52;
- { jjCheckNAddStates(64, 68); }
+ if (kind > 56)
+ kind = 56;
+ { jjCheckNAddStates(67, 71); }
break;
- case 182:
+ case 185:
if (jjCanMove_16(hiByte, i1, i2, l1, l2))
- { jjAddStates(109, 110); }
+ { jjAddStates(115, 116); }
break;
- case 183:
+ case 186:
if (jjCanMove_17(hiByte, i1, i2, l1, l2))
- { jjCheckNAddStates(61, 63); }
+ { jjCheckNAddStates(64, 66); }
break;
- case 184:
+ case 187:
if (jjCanMove_18(hiByte, i1, i2, l1, l2))
- { jjCheckNAdd(160); }
+ { jjCheckNAdd(163); }
break;
- case 185:
+ case 188:
if (jjCanMove_19(hiByte, i1, i2, l1, l2))
- { jjAddStates(101, 102); }
+ { jjAddStates(107, 108); }
break;
- case 186:
+ case 189:
if (jjCanMove_20(hiByte, i1, i2, l1, l2))
- { jjCheckNAddStates(111, 114); }
+ { jjCheckNAddStates(117, 120); }
break;
- case 187:
+ case 190:
if (jjCanMove_21(hiByte, i1, i2, l1, l2))
- { jjCheckNAddStates(115, 118); }
+ { jjCheckNAddStates(121, 124); }
break;
default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;
}
@@ -1708,7 +1748,7 @@ private int jjMoveNfa_0(int startState, int curPos)
kind = 0x7fffffff;
}
++curPos;
- if ((i = jjnewStateCnt) == (startsAt = 189 - (jjnewStateCnt = startsAt)))
+ if ((i = jjnewStateCnt) == (startsAt = 192 - (jjnewStateCnt = startsAt)))
break;
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) { break; }
@@ -1736,12 +1776,13 @@ private int jjMoveNfa_0(int startState, int curPos)
/** Token literal values. */
public static final String[] jjstrLiteralImages = {
-"", null, null, null, null, null, null, null, "\141",
-"\100\160\162\145\146\151\170", "\100\142\141\163\145", null, null, null, null, null, "\ufeff", null, "\53",
-"\55", null, null, null, null, null, null, null, null, null, null, null, null, null,
-null, null, "\50", "\51", "\173", "\175", "\133", "\135", null, "\73", "\54", "\56",
-"\74\74", "\76\76", "\173\174", "\174\175", "\136\136", "\100", null, null, null, null,
-null, null, null, null, null, null, null, null, null, null, null, null, null, null, };
+"", null, null, null, null, null, null, null, "\141",
+"\100\160\162\145\146\151\170", "\100\142\141\163\145", null, null, null, null, null, "\ufeff", null, "\53",
+"\55", null, null, null, null, null, null, null, null, null, null, null, null, null,
+null, null, "\50", "\51", "\173", "\175", "\133", "\135", null, "\73", "\54", "\56",
+"\136\136", "\100", "\74\74\50", "\51\76\76", "\74\74", "\76\76", "\173\174", "\174\175",
+"\176", "\174", null, null, null, null, null, null, null, null, null, null, null, null,
+null, null, null, null, null, null, };
protected Token jjFillToken()
{
final Token t;
@@ -1766,14 +1807,14 @@ protected Token jjFillToken()
return t;
}
static final int[] jjnextStates = {
- 129, 130, 131, 139, 140, 145, 146, 129, 130, 131, 133, 138, 161, 175, 177, 180,
- 6, 7, 8, 1, 2, 4, 41, 42, 43, 23, 24, 25, 59, 60, 61, 63,
- 62, 79, 83, 84, 85, 87, 86, 103, 107, 108, 109, 113, 110, 111, 107, 110,
- 111, 115, 121, 116, 117, 118, 139, 140, 145, 146, 152, 153, 155, 158, 159, 182,
- 162, 163, 164, 166, 168, 169, 171, 152, 153, 154, 158, 159, 160, 182, 155, 9,
- 18, 26, 27, 36, 44, 45, 54, 64, 65, 74, 88, 89, 98, 136, 137, 143,
- 144, 147, 148, 167, 173, 186, 187, 119, 120, 156, 157, 165, 174, 183, 184, 152,
- 153, 154, 155, 158, 159, 160, 182,
+ 132, 133, 134, 142, 143, 148, 149, 132, 133, 134, 136, 141, 164, 178, 180, 183,
+ 6, 7, 8, 1, 2, 4, 41, 42, 43, 23, 24, 25, 59, 60, 61, 63,
+ 62, 79, 83, 84, 85, 87, 86, 103, 107, 108, 109, 113, 110, 111, 107, 110,
+ 111, 115, 121, 116, 117, 118, 126, 127, 130, 142, 143, 148, 149, 155, 156, 158,
+ 161, 162, 185, 165, 166, 167, 169, 171, 172, 174, 155, 156, 157, 161, 162, 163,
+ 185, 158, 9, 18, 26, 27, 36, 44, 45, 54, 64, 65, 74, 88, 89, 98,
+ 125, 126, 130, 139, 140, 146, 147, 150, 151, 170, 176, 189, 190, 119, 120, 159,
+ 160, 168, 177, 186, 187, 155, 156, 157, 158, 161, 162, 163, 185,
};
private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
{
@@ -2034,7 +2075,7 @@ int jjmatchedPos;
int jjmatchedKind;
/** Get the next Token. */
-public Token getNextToken()
+public Token getNextToken()
{
Token specialToken = null;
Token matchedToken;
@@ -2176,7 +2217,7 @@ private void jjCheckNAddStates(int start, int end)
}
/** Reinitialise parser. */
-
+
public void ReInit(SimpleCharStream stream)
{
@@ -2193,13 +2234,13 @@ private void jjCheckNAddStates(int start, int end)
{
int i;
jjround = 0x80000001;
- for (i = 189; i-- > 0;)
+ for (i = 192; i-- > 0;)
jjrounds[i] = 0x80000000;
}
/** Reinitialise parser. */
public void ReInit(SimpleCharStream stream, int lexState)
-
+
{
ReInit(stream);
SwitchTo(lexState);
@@ -2222,26 +2263,26 @@ public static final String[] lexStateNames = {
/** Lex State array. */
public static final int[] jjnewLexState = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};
static final long[] jjtoToken = {
- 0x7fffff80ef7f01L, 0x0L,
+ 0x7ffffff80ef7f01L, 0x0L,
};
static final long[] jjtoSkip = {
- 0xbeL, 0x0L,
+ 0xbeL, 0x0L,
};
static final long[] jjtoSpecial = {
- 0x80L, 0x0L,
+ 0x80L, 0x0L,
};
static final long[] jjtoMore = {
- 0x0L, 0x0L,
+ 0x0L, 0x0L,
};
protected SimpleCharStream input_stream;
- private final int[] jjrounds = new int[189];
- private final int[] jjstateSet = new int[2 * 189];
+ private final int[] jjrounds = new int[192];
+ private final int[] jjstateSet = new int[2 * 192];
private final StringBuilder jjimage = new StringBuilder();
private StringBuilder image = jjimage;
private int jjimageLen;
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatter.java b/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatter.java
index e846c31f7c..18e52aa6b9 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatter.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatter.java
@@ -46,6 +46,9 @@ public interface NodeFormatter
/** String with language tag */
public void formatLitLang(AWriter w, String lex, String langTag);
+ /** String with language tag and base direction */
+ public void formatLitLangDir(AWriter w, String lex, String langTag, String direction);
+
/** Literal with datatype, not a simple literal, not an xsd:string (RDF 1.1), no language tag. */
public void formatLitDT(AWriter w, String lex, String datatypeURI);
}
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatterBase.java b/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatterBase.java
index 2aa753d7ad..28885806ab 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatterBase.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatterBase.java
@@ -23,6 +23,7 @@ import org.apache.jena.datatypes.RDFDatatype;
import org.apache.jena.datatypes.xsd.XSDDatatype;
import org.apache.jena.graph.Node;
import org.apache.jena.graph.Node_Triple;
+import org.apache.jena.graph.TextDirection;
import org.apache.jena.graph.Triple;
import org.apache.jena.sparql.ARQInternalErrorException;
@@ -54,13 +55,13 @@ public abstract class NodeFormatterBase implements NodeFormatter
protected void formatNodeTriple(AWriter w, Node n) {
Triple t = n.getTriple();
- w.print("<< ");
+ w.print("<<( ");
format(w, t.getSubject());
w.print(" ");
format(w, t.getPredicate());
w.print(" ");
format(w, t.getObject());
- w.print(" >>");
+ w.print(" )>>");
}
@Override
@@ -74,8 +75,11 @@ public abstract class NodeFormatterBase implements NodeFormatter
RDFDatatype dt = n.getLiteralDatatype();
String lang = n.getLiteralLanguage();
String lex = n.getLiteralLexicalForm();
+ TextDirection textDir = n.getLiteralBaseDirection();
- if ( lang != null && ! lang.equals("") ) {
+ if ( textDir != null ) {
+ formatLitLangDir(w, lex, lang, textDir.direction());
+ } else if ( lang != null && ! lang.equals("") ) {
formatLitLang(w, lex, lang);
} else if ( dt == null ) {
// RDF 1.0, simple literal.
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatterNT.java b/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatterNT.java
index f02610fb2b..2c6f760de2 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatterNT.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/out/NodeFormatterNT.java
@@ -74,6 +74,15 @@ public class NodeFormatterNT extends NodeFormatterBase
w.print(langTag);
}
+ @Override
+ public void formatLitLangDir(AWriter w, String lex, String langTag, String direction) {
+ writeEscaped(w, lex);
+ w.print('@');
+ w.print(langTag);
+ w.print("--");
+ w.print(direction);
+ }
+
@Override
public void formatLitDT(AWriter w, String lex, String datatypeURI) {
writeEscaped(w, lex);
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/Binding2Protobuf.java b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/Binding2Protobuf.java
index ecd4340efa..c1a6c39fd8 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/Binding2Protobuf.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/Binding2Protobuf.java
@@ -18,28 +18,28 @@
package org.apache.jena.riot.protobuf;
-import java.io.OutputStream ;
-import java.util.Collection ;
-import java.util.Iterator ;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Iterator;
-import org.apache.jena.graph.Node ;
+import org.apache.jena.graph.Node;
import org.apache.jena.riot.protobuf.wire.PB_RDF.*;
-import org.apache.jena.sparql.core.Var ;
-import org.apache.jena.sparql.engine.binding.Binding ;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.engine.binding.Binding;
/** Converted from Bindings to SPARQL result set encoded in Protobuf */
public class Binding2Protobuf implements AutoCloseable {
private final RDF_DataTuple.Builder row = RDF_DataTuple.newBuilder();
private final RDF_Term.Builder term = RDF_Term.newBuilder();
- private final Collection<Var> vars ;
- private final OutputStream out ;
- private final boolean encodeValues ;
+ private final Collection<Var> vars;
+ private final OutputStream out;
+ private final boolean encodeValues;
public Binding2Protobuf(OutputStream out, Collection<Var> vars, boolean encodeValues) {
- this.out = out ;
- this.vars = vars ;
- this.encodeValues = encodeValues ;
- varsRow() ;
+ this.out = out;
+ this.vars = vars;
+ this.encodeValues = encodeValues;
+ varsRow();
}
private void varsRow() {
@@ -55,15 +55,15 @@ public class Binding2Protobuf implements AutoCloseable {
public void output(Binding binding) {
row.clear();
- Iterator<Var> vIter = (vars == null ? null : vars.iterator()) ;
+ Iterator<Var> vIter = (vars == null ? null : vars.iterator());
if ( vIter == null )
- vIter = binding.vars() ;
+ vIter = binding.vars();
vIter.forEachRemaining(v -> {
term.clear();
- Node n = binding.get(v) ;
+ Node n = binding.get(v);
RDF_Term rt = ProtobufConvert.toProtobuf(n, term, encodeValues);
row.addRow(rt);
- }) ;
+ });
PBufRDF.writeDelimitedTo(row.build(), out);
}
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/Protobuf2Binding.java b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/Protobuf2Binding.java
index 6f7f1f901e..15c977520c 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/Protobuf2Binding.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/Protobuf2Binding.java
@@ -19,32 +19,32 @@
package org.apache.jena.riot.protobuf;
import java.io.IOException;
-import java.io.InputStream ;
-import java.util.ArrayList ;
-import java.util.Iterator ;
-import java.util.List ;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import org.apache.jena.atlas.io.IO;
-import org.apache.jena.atlas.iterator.IteratorSlotted ;
-import org.apache.jena.graph.Node ;
+import org.apache.jena.atlas.iterator.IteratorSlotted;
+import org.apache.jena.graph.Node;
import org.apache.jena.riot.protobuf.wire.PB_RDF.RDF_DataTuple;
import org.apache.jena.riot.protobuf.wire.PB_RDF.RDF_Term;
import org.apache.jena.riot.protobuf.wire.PB_RDF.RDF_VarTuple;
-import org.apache.jena.sparql.core.Var ;
-import org.apache.jena.sparql.engine.binding.Binding ;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.engine.binding.Binding;
import org.apache.jena.sparql.engine.binding.BindingBuilder;
-/** Converted from SPARQL result set encoded in Thrift to Bindings */
-public class Protobuf2Binding extends IteratorSlotted<Binding> implements Iterator<Binding> {
+/** Convert from SPARQL result set encoded in Protobuf to Bindings */
+class Protobuf2Binding extends IteratorSlotted<Binding> implements Iterator<Binding> {
- private List<Var> vars = new ArrayList<>() ;
- private List<String> varNames = new ArrayList<>() ;
- private InputStream input ;
- private BindingBuilder b = Binding.builder() ;
+ private List<Var> vars = new ArrayList<>();
+ private List<String> varNames = new ArrayList<>();
+ private InputStream input;
+ private BindingBuilder b = Binding.builder();
- public Protobuf2Binding(InputStream input) {
- this.input = input ;
- readVars() ;
+ Protobuf2Binding(InputStream input) {
+ this.input = input;
+ readVars();
}
private void readVars() {
@@ -52,13 +52,13 @@ public class Protobuf2Binding extends IteratorSlotted<Binding> implements Iterat
RDF_VarTuple vrow = RDF_VarTuple.parseDelimitedFrom(input);
if ( vrow != null )
vrow.getVarsList().forEach(rv->varNames.add(rv.getName()));
- vars = Var.varList(varNames) ;
+ vars = Var.varList(varNames);
} catch (IOException ex) { IO.exception(ex); }
}
- public List<Var> getVars() { return vars ; }
+ List<Var> getVars() { return vars; }
- public List<String> getVarNames() { return varNames ; }
+ List<String> getVarNames() { return varNames; }
@Override
protected Binding moveToNext() {
@@ -69,22 +69,22 @@ public class Protobuf2Binding extends IteratorSlotted<Binding> implements Iterat
return null;
List<RDF_Term> row = dataTuple.getRowList();
if ( row.size() != vars.size() )
- throw new RiotProtobufException(String.format("Vars %d : Row length : %d", vars.size(), row.size())) ;
- for ( int i = 0 ; i < vars.size() ; i++ ) {
+ throw new RiotProtobufException(String.format("Vars %d : Row length : %d", vars.size(), row.size()));
+ for ( int i = 0; i < vars.size(); i++ ) {
// Old school
- Var v = vars.get(i) ;
- RDF_Term rt = row.get(i) ;
+ Var v = vars.get(i);
+ RDF_Term rt = row.get(i);
if ( rt.hasUndefined() )
- continue ;
- Node n = ProtobufConvert.convert(rt) ;
- b.add(v, n) ;
+ continue;
+ Node n = ProtobufConvert.convert(rt);
+ b.add(v, n);
}
} catch (IOException ex) { IO.exception(ex); }
- return b.build() ;
+ return b.build();
}
@Override
protected boolean hasMore() {
- return true ;
+ return true;
}
}
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/ProtobufConvert.java b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/ProtobufConvert.java
index 80413b5a81..89669baa20 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/ProtobufConvert.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/ProtobufConvert.java
@@ -20,23 +20,25 @@ package org.apache.jena.riot.protobuf;
import java.math.BigDecimal;
-import java.math.BigInteger ;
+import java.math.BigInteger;
import org.apache.jena.atlas.lib.Cache;
-import org.apache.jena.atlas.lib.Pair ;
-import org.apache.jena.datatypes.RDFDatatype ;
-import org.apache.jena.datatypes.xsd.XSDDatatype ;
-import org.apache.jena.datatypes.xsd.impl.RDFLangString ;
-import org.apache.jena.graph.Node ;
-import org.apache.jena.graph.NodeFactory ;
-import org.apache.jena.graph.Triple ;
+import org.apache.jena.atlas.lib.Pair;
+import org.apache.jena.datatypes.RDFDatatype;
+import org.apache.jena.datatypes.xsd.XSDDatatype;
+import org.apache.jena.datatypes.xsd.impl.RDFDirLangString;
+import org.apache.jena.datatypes.xsd.impl.RDFLangString;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.graph.TextDirection;
+import org.apache.jena.graph.Triple;
import org.apache.jena.riot.protobuf.wire.PB_RDF.*;
-import org.apache.jena.riot.system.PrefixMap ;
-import org.apache.jena.riot.system.PrefixMapFactory ;
+import org.apache.jena.riot.system.PrefixMap;
+import org.apache.jena.riot.system.PrefixMapFactory;
import org.apache.jena.riot.system.RiotLib;
import org.apache.jena.sparql.core.Quad;
-//port org.apache.jena.sparql.core.Quad ;
-import org.apache.jena.sparql.core.Var ;
+//port org.apache.jena.sparql.core.Quad;
+import org.apache.jena.sparql.core.Var;
/** Convert to and from Protobuf wire objects.
* <p>
@@ -52,8 +54,8 @@ import org.apache.jena.sparql.core.Var ;
*/
public class ProtobufConvert
{
- static final BigInteger MAX_I = BigInteger.valueOf(Long.MAX_VALUE) ;
- static final BigInteger MIN_I = BigInteger.valueOf(Long.MIN_VALUE) ;
+ static final BigInteger MAX_I = BigInteger.valueOf(Long.MAX_VALUE);
+ static final BigInteger MIN_I = BigInteger.valueOf(Long.MIN_VALUE);
/** Attempt to encode a node by value (integer, decimal, double) into an RDF_term.
* @param node
@@ -62,25 +64,25 @@ public class ProtobufConvert
*/
private static RDF_Term toProtobufValue(Node node, RDF_Term.Builder term) {
if ( ! node.isLiteral() )
- return null ;
+ return null;
term.clear();
// Value cases : Integer, Double, Decimal
- String lex = node.getLiteralLexicalForm() ;
- RDFDatatype rdt = node.getLiteralDatatype() ;
+ String lex = node.getLiteralLexicalForm();
+ RDFDatatype rdt = node.getLiteralDatatype();
// RDF 1.1
if ( rdt == null )
- return null ;
+ return null;
if ( rdt.equals(XSDDatatype.XSDdecimal) ) {
if ( rdt.isValid(lex)) {
- BigDecimal decimal = new BigDecimal(lex.trim()) ;
- int scale = decimal.scale() ;
- BigInteger bigInt = decimal.unscaledValue() ;
+ BigDecimal decimal = new BigDecimal(lex.trim());
+ int scale = decimal.scale();
+ BigInteger bigInt = decimal.unscaledValue();
if ( bigInt.compareTo(MAX_I) <= 0 && bigInt.compareTo(MIN_I) >= 0 ) {
// This check makes sure that bigInt.longValue() is safe
RDF_Decimal.Builder d = RDF_Decimal.newBuilder().setValue(bigInt.longValue()).setScale(scale);
- term.setValDecimal(d) ;
+ term.setValDecimal(d);
return term.build();
}
}
@@ -97,8 +99,8 @@ public class ProtobufConvert
// Conservative - no derived types.
if ( rdt.isValid(lex)) {
try {
- long v = ((Number)node.getLiteralValue()).longValue() ;
- term.setValInteger(v) ;
+ long v = ((Number)node.getLiteralValue()).longValue();
+ term.setValInteger(v);
return term.build();
}
// Out of range for the type, not a long etc etc.
@@ -108,15 +110,15 @@ public class ProtobufConvert
// XSDfloat??
if ( rdt.isValid(lex)) {
try {
- double v = ((Double)node.getLiteralValue()).doubleValue() ;
- term.setValDouble(v) ;
- return term.build() ;
+ double v = ((Double)node.getLiteralValue()).doubleValue();
+ term.setValDouble(v);
+ return term.build();
}
// Out of range for the type, ...
catch (Throwable ex) { }
}
}
- return null ;
+ return null;
}
private static RDF_UNDEF rdfUNDEF = RDF_UNDEF.newBuilder().build();
@@ -127,18 +129,18 @@ public class ProtobufConvert
private static String dtXSDString = XSDDatatype.XSDstring.getURI();
- private static final PrefixMap emptyPrefixMap = PrefixMapFactory.emptyPrefixMap() ;
+ private static final PrefixMap emptyPrefixMap = PrefixMapFactory.emptyPrefixMap();
// ---- From Protobuf
/** Build a {@link Node} from an {@link RDF_Term}. */
public static Node convert(RDF_Term term) {
- return convert(null, term) ;
+ return convert(null, term);
}
/** Build a {@link Node} from an {@link RDF_Term}. */
public static Node convert(Cache<String, Node> uriCache, RDF_Term term) {
- return convert(uriCache, term, null) ;
+ return convert(uriCache, term, null);
}
// Create URI, using a cached copy if possible.
@@ -164,31 +166,46 @@ public class ProtobufConvert
public static Node convert(Cache<String, Node> uriCache, RDF_Term term, PrefixMap pmap) {
switch (term.getTermCase()) {
case IRI :
- return uri(uriCache, term.getIri().getIri()) ;
+ return uri(uriCache, term.getIri().getIri());
case BNODE :
- return NodeFactory.createBlankNode(term.getBnode().getLabel()) ;
+ return NodeFactory.createBlankNode(term.getBnode().getLabel());
case LITERAL : {
if ( term.hasLiteral() ) {
- RDF_Literal lit = term.getLiteral() ;
- String lex = lit.getLex() ;
+ RDF_Literal lit = term.getLiteral();
+ String lex = lit.getLex();
switch ( lit.getLiteralKindCase() ) {
case SIMPLE :
- return NodeFactory.createLiteralString(lex) ;
+ return NodeFactory.createLiteralString(lex);
case LANGTAG : {
String lang = lit.getLangtag();
- return NodeFactory.createLiteralLang(lex, lang) ;
+ return NodeFactory.createLiteralLang(lex, lang);
+ }
+ case LANGDIR : {
+ // Combined language tag and base direction.
+ String langdir = lit.getLangdir();
+ String lang;
+ String dir;
+ int idx = langdir.indexOf("--");
+ if ( idx >= 0 ) {
+ lang = langdir.substring(0, idx);
+ dir = langdir.substring(idx+2);
+ } else {
+ throw new RiotProtobufException("Bad langusage-base direction value: "+langdir);
+ }
+ return NodeFactory.createLiteralDirLang(lex, lang, dir);
}
+
case DATATYPE : {
String dtString = lit.getDatatype();
- RDFDatatype dt = NodeFactory.getType(dtString) ;
- return NodeFactory.createLiteralDT(lex, dt) ;
+ RDFDatatype dt = NodeFactory.getType(dtString);
+ return NodeFactory.createLiteralDT(lex, dt);
}
case DTPREFIX : {
String x = expand(lit.getDtPrefix(), pmap);
if ( x == null )
- throw new RiotProtobufException("Failed to expand datatype prefix name: "+lit.getDtPrefix()) ;
- RDFDatatype dt = NodeFactory.getType(x) ;
- return NodeFactory.createLiteralDT(lex, dt) ;
+ throw new RiotProtobufException("Failed to expand datatype prefix name: "+lit.getDtPrefix());
+ RDFDatatype dt = NodeFactory.getType(x);
+ return NodeFactory.createLiteralDT(lex, dt);
}
case LITERALKIND_NOT_SET :
throw new RiotProtobufException("Literal kind not set.");
@@ -196,57 +213,57 @@ public class ProtobufConvert
}
}
case PREFIXNAME : {
- String x = expand(term.getPrefixName(), pmap) ;
+ String x = expand(term.getPrefixName(), pmap);
if ( x != null )
- return uri(uriCache, x) ;
- throw new RiotProtobufException("Failed to expand "+term) ;
+ return uri(uriCache, x);
+ throw new RiotProtobufException("Failed to expand "+term);
}
case VARIABLE :
- return Var.alloc(term.getVariable().getName()) ;
+ return Var.alloc(term.getVariable().getName());
case TRIPLETERM : {
RDF_Triple rt = term.getTripleTerm();
Triple t = convert(rt, pmap);
- return NodeFactory.createTripleNode(t);
+ return NodeFactory.createTripleTerm(t);
}
case ANY :
- return Node.ANY ;
+ return Node.ANY;
case REPEAT :
- throw new RiotProtobufException("REPEAT not implemented") ;
+ throw new RiotProtobufException("REPEAT not implemented");
case UNDEFINED :
return null;
case VALINTEGER : {
- long x = term.getValInteger() ;
- String lex = Long.toString(x, 10) ;
- RDFDatatype dt = XSDDatatype.XSDinteger ;
- return NodeFactory.createLiteralDT(lex, dt) ;
+ long x = term.getValInteger();
+ String lex = Long.toString(x, 10);
+ RDFDatatype dt = XSDDatatype.XSDinteger;
+ return NodeFactory.createLiteralDT(lex, dt);
}
case VALDOUBLE : {
- double x = term.getValDouble() ;
- String lex = Double.toString(x) ;
- RDFDatatype dt = XSDDatatype.XSDdouble ;
- return NodeFactory.createLiteralDT(lex, dt) ;
+ double x = term.getValDouble();
+ String lex = Double.toString(x);
+ RDFDatatype dt = XSDDatatype.XSDdouble;
+ return NodeFactory.createLiteralDT(lex, dt);
}
case VALDECIMAL : {
- long value = term.getValDecimal().getValue() ;
- int scale = term.getValDecimal().getScale() ;
- BigDecimal d = BigDecimal.valueOf(value, scale) ;
- String lex = d.toPlainString() ;
- RDFDatatype dt = XSDDatatype.XSDdecimal ;
- return NodeFactory.createLiteralDT(lex, dt) ;
+ long value = term.getValDecimal().getValue();
+ int scale = term.getValDecimal().getScale();
+ BigDecimal d = BigDecimal.valueOf(value, scale);
+ String lex = d.toPlainString();
+ RDFDatatype dt = XSDDatatype.XSDdecimal;
+ return NodeFactory.createLiteralDT(lex, dt);
}
case TERM_NOT_SET :
- throw new RiotProtobufException("RDF_Term not set") ;
+ throw new RiotProtobufException("RDF_Term not set");
default:
- throw new RiotProtobufException("No conversion to a Node: "+term.toString()) ;
+ throw new RiotProtobufException("No conversion to a Node: "+term.toString());
}
}
public static Triple convert(RDF_Triple triple) {
- return convert(null, triple, null) ;
+ return convert(null, triple, null);
}
public static Triple convert(Cache<String, Node> uriCache, RDF_Triple triple) {
- return convert(uriCache, triple, null) ;
+ return convert(uriCache, triple, null);
}
public static Triple convert(RDF_Triple rt, PrefixMap pmap) {
@@ -254,10 +271,10 @@ public class ProtobufConvert
}
public static Triple convert(Cache<String, Node> uriCache, RDF_Triple rt, PrefixMap pmap) {
- Node s = convert(uriCache, rt.getS(), pmap) ;
- Node p = convert(uriCache, rt.getP(), pmap) ;
- Node o = convert(uriCache, rt.getO(), pmap) ;
- return Triple.create(s, p, o) ;
+ Node s = convert(uriCache, rt.getS(), pmap);
+ Node p = convert(uriCache, rt.getP(), pmap);
+ Node o = convert(uriCache, rt.getO(), pmap);
+ return Triple.create(s, p, o);
}
public static Quad convert(RDF_Quad rq, PrefixMap pmap) {
@@ -265,11 +282,11 @@ public class ProtobufConvert
}
public static Quad convert(Cache<String, Node> uriCache, RDF_Quad rq, PrefixMap pmap) {
- Node g = (rq.hasG() ? convert(uriCache,rq.getG(), pmap) : null ) ;
- Node s = convert(uriCache,rq.getS(), pmap) ;
- Node p = convert(uriCache,rq.getP(), pmap) ;
- Node o = convert(uriCache,rq.getO(), pmap) ;
- return Quad.create(g, s, p, o) ;
+ Node g = (rq.hasG() ? convert(uriCache,rq.getG(), pmap) : null );
+ Node s = convert(uriCache,rq.getS(), pmap);
+ Node p = convert(uriCache,rq.getP(), pmap);
+ Node o = convert(uriCache,rq.getO(), pmap);
+ return Quad.create(g, s, p, o);
}
/**
@@ -294,12 +311,12 @@ public class ProtobufConvert
return UNDEF;
if ( node.isURI() ) {
- RDF_PrefixName prefixName = abbrev(node.getURI(), pmap) ;
+ RDF_PrefixName prefixName = abbrev(node.getURI(), pmap);
if ( prefixName != null ) {
- termBuilder.setPrefixName(prefixName) ;
+ termBuilder.setPrefixName(prefixName);
return termBuilder.build();
}
- RDF_IRI iri = RDF_IRI.newBuilder().setIri(node.getURI()).build() ;
+ RDF_IRI iri = RDF_IRI.newBuilder().setIri(node.getURI()).build();
return termBuilder.setIri(iri).build();
}
@@ -311,42 +328,50 @@ public class ProtobufConvert
if ( node.isLiteral() ) {
// Value cases : Integer, Double, Decimal
if ( allowValues) {
- RDF_Term term = toProtobufValue(node, termBuilder) ;
+ RDF_Term term = toProtobufValue(node, termBuilder);
if ( term != null )
return termBuilder.build();
}
RDF_Literal.Builder literal = RDF_Literal.newBuilder();
- String lex = node.getLiteralLexicalForm() ;
+ String lex = node.getLiteralLexicalForm();
literal.setLex(lex);
// Protobuf default string is ""
- String dt = node.getLiteralDatatypeURI() ;
- String lang = node.getLiteralLanguage() ;
+ String dt = node.getLiteralDatatypeURI();
+ String lang = node.getLiteralLanguage();
+ TextDirection baseDir = node.getLiteralBaseDirection();
+
if ( lang.isEmpty() )
lang = null;
// General encoding.
if ( node.getLiteralDatatype().equals(XSDDatatype.XSDstring) ||
- node.getLiteralDatatype().equals(RDFLangString.rdfLangString) ) {
- dt = null ;
+ node.getLiteralDatatype().equals(RDFLangString.rdfLangString) ||
+ node.getLiteralDatatype().equals(RDFDirLangString.rdfDirLangString) ) {
+ dt = null;
}
- if ( dt == null && lang == null ) {
- literal.setSimple(true);
- } else if ( dt != null ) {
- RDF_PrefixName dtPrefixName = abbrev(dt, pmap) ;
- if ( dtPrefixName != null )
- literal.setDtPrefix(dtPrefixName) ;
+ if ( dt == null ) {
+ if ( lang == null )
+ literal.setSimple(true);
+ else if ( baseDir == null )
+ literal.setLangtag(lang);
else {
- literal.setDatatype(dt) ;
+ String langdir = lang+"--"+baseDir.direction();
+ literal.setLangdir(langdir);
}
} else {
- //if ( lang != null && ! lang.isEmpty() )
- literal.setLangtag(lang);
+ // datatype
+ RDF_PrefixName dtPrefixName = abbrev(dt, pmap);
+ if ( dtPrefixName != null )
+ literal.setDtPrefix(dtPrefixName);
+ else {
+ literal.setDatatype(dt);
+ }
}
- termBuilder.setLiteral(literal) ;
+ termBuilder.setLiteral(literal);
return termBuilder.build();
}
@@ -355,7 +380,7 @@ public class ProtobufConvert
return termBuilder.setVariable(var).build();
}
- if ( node.isNodeTriple() ) {
+ if ( node.isTripleTerm() ) {
Triple triple = node.getTriple();
RDF_Term sTerm = toProtobuf(triple.getSubject(), pmap, termBuilder, allowValues);
@@ -375,78 +400,78 @@ public class ProtobufConvert
if ( Node.ANY.equals(node))
return ANY;
- throw new RiotProtobufException("Node conversion not supported: "+node) ;
+ throw new RiotProtobufException("Node conversion not supported: "+node);
}
private static String expand(RDF_PrefixName prefixName, PrefixMap pmap) {
if ( pmap == null )
- return null ;
+ return null;
- String prefix = prefixName.getPrefix() ;
- String localname = prefixName.getLocalName() ;
- String x = pmap.expand(prefix, localname) ;
+ String prefix = prefixName.getPrefix();
+ String localname = prefixName.getLocalName();
+ String x = pmap.expand(prefix, localname);
if ( x == null )
- throw new RiotProtobufException("Failed to expand "+prefixName) ;
- return x ;
+ throw new RiotProtobufException("Failed to expand "+prefixName);
+ return x;
}
public static RDF_Term convert(Node node, boolean allowValues) {
- return convert(node, null, allowValues) ;
+ return convert(node, null, allowValues);
}
public static RDF_Term convert(Node node, PrefixMap pmap, boolean allowValues) {
RDF_Term.Builder n = RDF_Term.newBuilder();
- return toProtobuf(node, pmap, n, allowValues) ;
+ return toProtobuf(node, pmap, n, allowValues);
}
/** Produce a {@link RDF_PrefixName} is possible. */
private static RDF_PrefixName abbrev(String uriStr, PrefixMap pmap) {
if ( pmap == null )
- return null ;
- Pair<String, String> p = pmap.abbrev(uriStr) ;
+ return null;
+ Pair<String, String> p = pmap.abbrev(uriStr);
if ( p == null )
- return null ;
+ return null;
return RDF_PrefixName.newBuilder().setPrefix(p.getLeft()).setLocalName(p.getRight()).build();
}
public static RDF_Triple convert(Triple triple, boolean allowValues) {
- return convert(triple, null, allowValues) ;
+ return convert(triple, null, allowValues);
}
public static RDF_Triple convert(Triple triple, PrefixMap pmap, boolean allowValues) {
RDF_Triple.Builder t = RDF_Triple.newBuilder();
- RDF_Term s = convert(triple.getSubject(), pmap, allowValues) ;
- RDF_Term p = convert(triple.getPredicate(), pmap, allowValues) ;
- RDF_Term o = convert(triple.getObject(), pmap, allowValues) ;
- t.setS(s) ;
- t.setP(p) ;
- t.setO(o) ;
- return t.build() ;
+ RDF_Term s = convert(triple.getSubject(), pmap, allowValues);
+ RDF_Term p = convert(triple.getPredicate(), pmap, allowValues);
+ RDF_Term o = convert(triple.getObject(), pmap, allowValues);
+ t.setS(s);
+ t.setP(p);
+ t.setO(o);
+ return t.build();
}
public static Quad convert(RDF_Quad quad) {
- return convert(quad, null) ;
+ return convert(quad, null);
}
public static RDF_Quad convert(Quad quad, boolean allowValues) {
- return convert(quad, null, allowValues) ;
+ return convert(quad, null, allowValues);
}
public static RDF_Quad convert(Quad quad, PrefixMap pmap, boolean allowValues) {
RDF_Quad.Builder q = RDF_Quad.newBuilder();
- RDF_Term g = null ;
+ RDF_Term g = null;
if ( quad.getGraph() != null )
- g = convert(quad.getGraph(), pmap, allowValues) ;
- RDF_Term s = convert(quad.getSubject(), pmap, allowValues) ;
- RDF_Term p = convert(quad.getPredicate(), pmap, allowValues) ;
- RDF_Term o = convert(quad.getObject(), pmap, allowValues) ;
+ g = convert(quad.getGraph(), pmap, allowValues);
+ RDF_Term s = convert(quad.getSubject(), pmap, allowValues);
+ RDF_Term p = convert(quad.getPredicate(), pmap, allowValues);
+ RDF_Term o = convert(quad.getObject(), pmap, allowValues);
if ( g != null )
- q.setG(g) ;
- q.setS(s) ;
- q.setP(p) ;
- q.setO(o) ;
- return q.build() ;
+ q.setG(g);
+ q.setS(s);
+ q.setP(p);
+ q.setO(o);
+ return q.build();
}
// /**
@@ -491,31 +516,31 @@ public class ProtobufConvert
// RDF_Tuple => RDF_row (for result sets) or List<RDFTerm>
// public static Tuple<Node> convert(RDF_Tuple row) {
-// return convert(row, null) ;
+// return convert(row, null);
// }
//
// public static Tuple<Node> convert(RDF_Tuple row, PrefixMap pmap) {
-// List<RDF_Term> terms = row.getTerms() ;
-// Node[] tuple = new Node[terms.size()] ;
-// int idx = 0 ;
+// List<RDF_Term> terms = row.getTerms();
+// Node[] tuple = new Node[terms.size()];
+// int idx = 0;
// for ( RDF_Term rt : terms ) {
-// tuple[idx] = convert(rt, pmap) ;
-// idx ++ ;
+// tuple[idx] = convert(rt, pmap);
+// idx ++;
// }
-// return Tuple.create(tuple) ;
+// return Tuple.create(tuple);
// }
//
// public static RDF_Tuple convert(Tuple<Node> tuple) {
-// return convert(tuple, null) ;
+// return convert(tuple, null);
// }
//
// public static RDF_Tuple convert(Tuple<Node> tuple, PrefixMap pmap) {
-// RDF_Tuple rTuple = new RDF_Tuple() ;
+// RDF_Tuple rTuple = new RDF_Tuple();
// for ( Node n : tuple ) {
-// RDF_Term rt = convert(n, pmap) ;
-// rTuple.addToTerms(rt) ;
+// RDF_Term rt = convert(n, pmap);
+// rTuple.addToTerms(rt);
// }
-// return rTuple ;
+// return rTuple;
// }
}
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/ProtobufRDF.java b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/ProtobufRDF.java
index e4012ca692..3e16229f42 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/ProtobufRDF.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/ProtobufRDF.java
@@ -49,7 +49,7 @@ public class ProtobufRDF {
* @return StreamRDF A stream to send to.
*/
public static StreamRDF streamToFile(String filename) {
- return streamToFile(filename, false) ;
+ return streamToFile(filename, false);
}
/**
@@ -63,7 +63,7 @@ public class ProtobufRDF {
* @return StreamRDF A stream to send to.
*/
public static StreamRDF streamToFile(String filename, boolean withValues) {
- OutputStream out = IO.openOutputFile(filename) ;
+ OutputStream out = IO.openOutputFile(filename);
out = IO.ensureBuffered(out);
return streamToOutputStream(out);
}
@@ -95,7 +95,7 @@ public class ProtobufRDF {
* @param dest Sink
*/
public static void fileToStream(String filename, StreamRDF dest) {
- InputStream in = IO.openFileBuffered(filename) ;
+ InputStream in = IO.openFileBuffered(filename);
inputStreamToStreamRDF(in, dest);
}
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/RiotProtobufException.java b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/RiotProtobufException.java
index 14b0e9234a..34a4ac5a79 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/RiotProtobufException.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/RiotProtobufException.java
@@ -18,12 +18,12 @@
package org.apache.jena.riot.protobuf;
-import org.apache.jena.riot.RiotException ;
+import org.apache.jena.riot.RiotException;
public class RiotProtobufException extends RiotException {
- public RiotProtobufException() { super() ; }
- public RiotProtobufException(String msg) { super(msg) ; }
- public RiotProtobufException(Throwable th) { super(th) ; }
- public RiotProtobufException(String msg, Throwable th) { super(msg, th) ; }
+ public RiotProtobufException() { super(); }
+ public RiotProtobufException(String msg) { super(msg); }
+ public RiotProtobufException(Throwable th) { super(th); }
+ public RiotProtobufException(String msg, Throwable th) { super(msg, th); }
}
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/WriterDatasetProtobuf.java b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/WriterDatasetProtobuf.java
index ef6ea2576d..35022c19f9 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/WriterDatasetProtobuf.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/WriterDatasetProtobuf.java
@@ -21,38 +21,38 @@ package org.apache.jena.riot.protobuf;
import static org.apache.jena.riot.Lang.RDFPROTO;
import static org.apache.jena.riot.RDFFormat.RDF_PROTO_VALUES;
-import java.io.OutputStream ;
-import java.io.Writer ;
+import java.io.OutputStream;
+import java.io.Writer;
import org.apache.jena.riot.Lang;
import org.apache.jena.riot.RDFFormat;
-import org.apache.jena.riot.WriterDatasetRIOT ;
-import org.apache.jena.riot.system.PrefixMap ;
-import org.apache.jena.riot.system.StreamRDF ;
-import org.apache.jena.riot.system.StreamRDFOps ;
-import org.apache.jena.sparql.core.DatasetGraph ;
-import org.apache.jena.sparql.util.Context ;
+import org.apache.jena.riot.WriterDatasetRIOT;
+import org.apache.jena.riot.system.PrefixMap;
+import org.apache.jena.riot.system.StreamRDF;
+import org.apache.jena.riot.system.StreamRDFOps;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.util.Context;
/** Write a dataset as RDF Protobuf */
public class WriterDatasetProtobuf implements WriterDatasetRIOT
{
- private final boolean withValues ;
+ private final boolean withValues;
public WriterDatasetProtobuf(RDFFormat fmt) {
- this.withValues = RDF_PROTO_VALUES.equals(fmt) ;
+ this.withValues = RDF_PROTO_VALUES.equals(fmt);
}
@Override
public Lang getLang() {
- return RDFPROTO ;
+ return RDFPROTO;
}
@Override
public void write(Writer out, DatasetGraph dsg, PrefixMap prefixMap, String baseURI, Context context) {
- throw new RiotProtobufException("Writing binary data to a java.io.Writer is not supported. Please use an OutputStream") ;
+ throw new RiotProtobufException("Writing binary data to a java.io.Writer is not supported. Please use an OutputStream");
}
@Override
public void write(OutputStream out, DatasetGraph dsg, PrefixMap prefixMap, String baseURI, Context context) {
- StreamRDF stream = ProtobufRDF.streamToOutputStream(out, withValues) ;
+ StreamRDF stream = ProtobufRDF.streamToOutputStream(out, withValues);
stream.start();
- StreamRDFOps.sendDatasetToStream(dsg, stream, baseURI, prefixMap) ;
+ StreamRDFOps.sendDatasetToStream(dsg, stream, baseURI, prefixMap);
stream.finish();
}
}
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/WriterGraphProtobuf.java b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/WriterGraphProtobuf.java
index 250081d2ef..f30b0ecc22 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/WriterGraphProtobuf.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/WriterGraphProtobuf.java
@@ -21,40 +21,40 @@ package org.apache.jena.riot.protobuf;
import static org.apache.jena.riot.RDFFormat.RDF_PROTO_VALUES;
import static org.apache.jena.riot.RDFLanguages.RDFPROTO;
-import java.io.OutputStream ;
-import java.io.Writer ;
+import java.io.OutputStream;
+import java.io.Writer;
-import org.apache.jena.atlas.lib.NotImplemented ;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.riot.Lang ;
+import org.apache.jena.atlas.lib.NotImplemented;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.riot.Lang;
import org.apache.jena.riot.RDFFormat;
-import org.apache.jena.riot.WriterGraphRIOT ;
-import org.apache.jena.riot.system.PrefixMap ;
-import org.apache.jena.riot.system.StreamRDFOps ;
-import org.apache.jena.riot.system.StreamRDF ;
-import org.apache.jena.sparql.util.Context ;
+import org.apache.jena.riot.WriterGraphRIOT;
+import org.apache.jena.riot.system.PrefixMap;
+import org.apache.jena.riot.system.StreamRDFOps;
+import org.apache.jena.riot.system.StreamRDF;
+import org.apache.jena.sparql.util.Context;
/** Write a graph as RDF Protobuf */
public class WriterGraphProtobuf implements WriterGraphRIOT
{
- private final boolean withValues ;
+ private final boolean withValues;
public WriterGraphProtobuf(RDFFormat fmt) {
- this.withValues = RDF_PROTO_VALUES.equals(fmt) ;
+ this.withValues = RDF_PROTO_VALUES.equals(fmt);
}
@Override
public Lang getLang() {
- return RDFPROTO ;
+ return RDFPROTO;
}
@Override
public void write(Writer out, Graph graph, PrefixMap prefixMap, String baseURI, Context context) {
- throw new NotImplemented("Writing binary data to a java.io.Writer is not supported. Please use an OutputStream") ;
+ throw new NotImplemented("Writing binary data to a java.io.Writer is not supported. Please use an OutputStream");
}
@Override
public void write(OutputStream out, Graph graph, PrefixMap prefixMap, String baseURI, Context context) {
- StreamRDF stream = ProtobufRDF.streamToOutputStream(out, withValues) ;
- stream.start() ;
- StreamRDFOps.graphToStream(graph, stream) ;
- stream.finish() ;
+ StreamRDF stream = ProtobufRDF.streamToOutputStream(out, withValues);
+ stream.start();
+ StreamRDFOps.graphToStream(graph, stream);
+ stream.finish();
}
}
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/wire/PB_RDF.java b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/wire/PB_RDF.java
index 6cbecfcdf7..c27ffd7c52 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/protobuf/wire/PB_RDF.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/protobuf/wire/PB_RDF.java
@@ -1794,22 +1794,63 @@ public final class PB_RDF {
boolean getSimple();
/**
+ * <pre>
+ * Language tag only literal
+ * </pre>
+ *
* <code>string langtag = 2;</code>
* @return Whether the langtag field is set.
*/
boolean hasLangtag();
/**
+ * <pre>
+ * Language tag only literal
+ * </pre>
+ *
* <code>string langtag = 2;</code>
* @return The langtag.
*/
java.lang.String getLangtag();
/**
+ * <pre>
+ * Language tag only literal
+ * </pre>
+ *
* <code>string langtag = 2;</code>
* @return The bytes for langtag.
*/
com.google.protobuf.ByteString
getLangtagBytes();
+ /**
+ * <pre>
+ * Language tag and base direction separated by "--"
+ * </pre>
+ *
+ * <code>string langdir = 5;</code>
+ * @return Whether the langdir field is set.
+ */
+ boolean hasLangdir();
+ /**
+ * <pre>
+ * Language tag and base direction separated by "--"
+ * </pre>
+ *
+ * <code>string langdir = 5;</code>
+ * @return The langdir.
+ */
+ java.lang.String getLangdir();
+ /**
+ * <pre>
+ * Language tag and base direction separated by "--"
+ * </pre>
+ *
+ * <code>string langdir = 5;</code>
+ * @return The bytes for langdir.
+ */
+ com.google.protobuf.ByteString
+ getLangdirBytes();
+
/**
* <code>string datatype = 3;</code>
* @return Whether the datatype field is set.
@@ -1890,6 +1931,7 @@ public final class PB_RDF {
com.google.protobuf.AbstractMessage.InternalOneOfEnum {
SIMPLE(9),
LANGTAG(2),
+ LANGDIR(5),
DATATYPE(3),
DTPREFIX(4),
LITERALKIND_NOT_SET(0);
@@ -1911,6 +1953,7 @@ public final class PB_RDF {
switch (value) {
case 9: return SIMPLE;
case 2: return LANGTAG;
+ case 5: return LANGDIR;
case 3: return DATATYPE;
case 4: return DTPREFIX;
case 0: return LITERALKIND_NOT_SET;
@@ -1990,6 +2033,10 @@ public final class PB_RDF {
public static final int LANGTAG_FIELD_NUMBER = 2;
/**
+ * <pre>
+ * Language tag only literal
+ * </pre>
+ *
* <code>string langtag = 2;</code>
* @return Whether the langtag field is set.
*/
@@ -1997,6 +2044,10 @@ public final class PB_RDF {
return literalKindCase_ == 2;
}
/**
+ * <pre>
+ * Language tag only literal
+ * </pre>
+ *
* <code>string langtag = 2;</code>
* @return The langtag.
*/
@@ -2018,6 +2069,10 @@ public final class PB_RDF {
}
}
/**
+ * <pre>
+ * Language tag only literal
+ * </pre>
+ *
* <code>string langtag = 2;</code>
* @return The bytes for langtag.
*/
@@ -2040,6 +2095,70 @@ public final class PB_RDF {
}
}
+ public static final int LANGDIR_FIELD_NUMBER = 5;
+ /**
+ * <pre>
+ * Language tag and base direction separated by "--"
+ * </pre>
+ *
+ * <code>string langdir = 5;</code>
+ * @return Whether the langdir field is set.
+ */
+ public boolean hasLangdir() {
+ return literalKindCase_ == 5;
+ }
+ /**
+ * <pre>
+ * Language tag and base direction separated by "--"
+ * </pre>
+ *
+ * <code>string langdir = 5;</code>
+ * @return The langdir.
+ */
+ public java.lang.String getLangdir() {
+ java.lang.Object ref = "";
+ if (literalKindCase_ == 5) {
+ ref = literalKind_;
+ }
+ if (ref instanceof java.lang.String) {
+ return (java.lang.String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ if (literalKindCase_ == 5) {
+ literalKind_ = s;
+ }
+ return s;
+ }
+ }
+ /**
+ * <pre>
+ * Language tag and base direction separated by "--"
+ * </pre>
+ *
+ * <code>string langdir = 5;</code>
+ * @return The bytes for langdir.
+ */
+ public com.google.protobuf.ByteString
+ getLangdirBytes() {
+ java.lang.Object ref = "";
+ if (literalKindCase_ == 5) {
+ ref = literalKind_;
+ }
+ if (ref instanceof java.lang.String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ if (literalKindCase_ == 5) {
+ literalKind_ = b;
+ }
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
public static final int DATATYPE_FIELD_NUMBER = 3;
/**
* <code>string datatype = 3;</code>
@@ -2149,6 +2268,9 @@ public final class PB_RDF {
if (literalKindCase_ == 4) {
output.writeMessage(4, (org.apache.jena.riot.protobuf.wire.PB_RDF.RDF_PrefixName) literalKind_);
}
+ if (literalKindCase_ == 5) {
+ com.google.protobuf.GeneratedMessage.writeString(output, 5, literalKind_);
+ }
if (literalKindCase_ == 9) {
output.writeBool(
9, (boolean)((java.lang.Boolean) literalKind_));
@@ -2175,6 +2297,9 @@ public final class PB_RDF {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(4, (org.apache.jena.riot.protobuf.wire.PB_RDF.RDF_PrefixName) literalKind_);
}
+ if (literalKindCase_ == 5) {
+ size += com.google.protobuf.GeneratedMessage.computeStringSize(5, literalKind_);
+ }
if (literalKindCase_ == 9) {
size += com.google.protobuf.CodedOutputStream
.computeBoolSize(
@@ -2207,6 +2332,10 @@ public final class PB_RDF {
if (!getLangtag()
.equals(other.getLangtag())) return false;
break;
+ case 5:
+ if (!getLangdir()
+ .equals(other.getLangdir())) return false;
+ break;
case 3:
if (!getDatatype()
.equals(other.getDatatype())) return false;
@@ -2241,6 +2370,10 @@ public final class PB_RDF {
hash = (37 * hash) + LANGTAG_FIELD_NUMBER;
hash = (53 * hash) + getLangtag().hashCode();
break;
+ case 5:
+ hash = (37 * hash) + LANGDIR_FIELD_NUMBER;
+ hash = (53 * hash) + getLangdir().hashCode();
+ break;
case 3:
hash = (37 * hash) + DATATYPE_FIELD_NUMBER;
hash = (53 * hash) + getDatatype().hashCode();
@@ -2465,6 +2598,12 @@ public final class PB_RDF {
onChanged();
break;
}
+ case LANGDIR: {
+ literalKindCase_ = 5;
+ literalKind_ = other.literalKind_;
+ onChanged();
+ break;
+ }
case DATATYPE: {
literalKindCase_ = 3;
literalKind_ = other.literalKind_;
@@ -2529,6 +2668,12 @@ public final class PB_RDF {
literalKindCase_ = 4;
break;
} // case 34
+ case 42: {
+ java.lang.String s = input.readStringRequireUtf8();
+ literalKindCase_ = 5;
+ literalKind_ = s;
+ break;
+ } // case 42
case 72: {
literalKind_ = input.readBool();
literalKindCase_ = 9;
@@ -2681,6 +2826,10 @@ public final class PB_RDF {
}
/**
+ * <pre>
+ * Language tag only literal
+ * </pre>
+ *
* <code>string langtag = 2;</code>
* @return Whether the langtag field is set.
*/
@@ -2689,6 +2838,10 @@ public final class PB_RDF {
return literalKindCase_ == 2;
}
/**
+ * <pre>
+ * Language tag only literal
+ * </pre>
+ *
* <code>string langtag = 2;</code>
* @return The langtag.
*/
@@ -2711,6 +2864,10 @@ public final class PB_RDF {
}
}
/**
+ * <pre>
+ * Language tag only literal
+ * </pre>
+ *
* <code>string langtag = 2;</code>
* @return The bytes for langtag.
*/
@@ -2734,6 +2891,10 @@ public final class PB_RDF {
}
}
/**
+ * <pre>
+ * Language tag only literal
+ * </pre>
+ *
* <code>string langtag = 2;</code>
* @param value The langtag to set.
* @return This builder for chaining.
@@ -2747,6 +2908,10 @@ public final class PB_RDF {
return this;
}
/**
+ * <pre>
+ * Language tag only literal
+ * </pre>
+ *
* <code>string langtag = 2;</code>
* @return This builder for chaining.
*/
@@ -2759,6 +2924,10 @@ public final class PB_RDF {
return this;
}
/**
+ * <pre>
+ * Language tag only literal
+ * </pre>
+ *
* <code>string langtag = 2;</code>
* @param value The bytes for langtag to set.
* @return This builder for chaining.
@@ -2773,6 +2942,123 @@ public final class PB_RDF {
return this;
}
+ /**
+ * <pre>
+ * Language tag and base direction separated by "--"
+ * </pre>
+ *
+ * <code>string langdir = 5;</code>
+ * @return Whether the langdir field is set.
+ */
+ @java.lang.Override
+ public boolean hasLangdir() {
+ return literalKindCase_ == 5;
+ }
+ /**
+ * <pre>
+ * Language tag and base direction separated by "--"
+ * </pre>
+ *
+ * <code>string langdir = 5;</code>
+ * @return The langdir.
+ */
+ @java.lang.Override
+ public java.lang.String getLangdir() {
+ java.lang.Object ref = "";
+ if (literalKindCase_ == 5) {
+ ref = literalKind_;
+ }
+ if (!(ref instanceof java.lang.String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ if (literalKindCase_ == 5) {
+ literalKind_ = s;
+ }
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * <pre>
+ * Language tag and base direction separated by "--"
+ * </pre>
+ *
+ * <code>string langdir = 5;</code>
+ * @return The bytes for langdir.
+ */
+ @java.lang.Override
+ public com.google.protobuf.ByteString
+ getLangdirBytes() {
+ java.lang.Object ref = "";
+ if (literalKindCase_ == 5) {
+ ref = literalKind_;
+ }
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ if (literalKindCase_ == 5) {
+ literalKind_ = b;
+ }
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * <pre>
+ * Language tag and base direction separated by "--"
+ * </pre>
+ *
+ * <code>string langdir = 5;</code>
+ * @param value The langdir to set.
+ * @return This builder for chaining.
+ */
+ public Builder setLangdir(
+ java.lang.String value) {
+ if (value == null) { throw new NullPointerException(); }
+ literalKindCase_ = 5;
+ literalKind_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <pre>
+ * Language tag and base direction separated by "--"
+ * </pre>
+ *
+ * <code>string langdir = 5;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearLangdir() {
+ if (literalKindCase_ == 5) {
+ literalKindCase_ = 0;
+ literalKind_ = null;
+ onChanged();
+ }
+ return this;
+ }
+ /**
+ * <pre>
+ * Language tag and base direction separated by "--"
+ * </pre>
+ *
+ * <code>string langdir = 5;</code>
+ * @param value The bytes for langdir to set.
+ * @return This builder for chaining.
+ */
+ public Builder setLangdirBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) { throw new NullPointerException(); }
+ checkByteStringIsUtf8(value);
+ literalKindCase_ = 5;
+ literalKind_ = value;
+ onChanged();
+ return this;
+ }
+
/**
* <code>string datatype = 3;</code>
* @return Whether the datatype field is set.
@@ -15256,37 +15542,38 @@ public final class PB_RDF {
"\n\020binary-rdf.proto\"\026\n\007RDF_IRI\022\013\n\003iri\030\001 \001" +
"(\t\"3\n\016RDF_PrefixName\022\016\n\006prefix\030\001 \001(\t\022\021\n\t" +
"localName\030\002 \001(\t\"\032\n\tRDF_BNode\022\r\n\005label\030\001 " +
- "\001(\t\"\207\001\n\013RDF_Literal\022\013\n\003lex\030\001 \001(\t\022\020\n\006simp" +
- "le\030\t \001(\010H\000\022\021\n\007langtag\030\002 \001(\tH\000\022\022\n\010datatyp" +
- "e\030\003 \001(\tH\000\022#\n\010dtPrefix\030\004 \001(\0132\017.RDF_Prefix" +
- "NameH\000B\r\n\013literalKind\"+\n\013RDF_Decimal\022\r\n\005" +
- "value\030\001 \001(\022\022\r\n\005scale\030\002 \001(\021\"\027\n\007RDF_Var\022\014\n" +
- "\004name\030\001 \001(\t\"\t\n\007RDF_ANY\"\013\n\tRDF_UNDEF\"\014\n\nR" +
- "DF_REPEAT\"\371\002\n\010RDF_Term\022\027\n\003iri\030\001 \001(\0132\010.RD" +
- "F_IRIH\000\022\033\n\005bnode\030\002 \001(\0132\n.RDF_BNodeH\000\022\037\n\007" +
- "literal\030\003 \001(\0132\014.RDF_LiteralH\000\022%\n\nprefixN" +
- "ame\030\004 \001(\0132\017.RDF_PrefixNameH\000\022\034\n\010variable" +
- "\030\005 \001(\0132\010.RDF_VarH\000\022!\n\ntripleTerm\030\006 \001(\0132\013" +
- ".RDF_TripleH\000\022\027\n\003any\030\007 \001(\0132\010.RDF_ANYH\000\022\037" +
- "\n\tundefined\030\010 \001(\0132\n.RDF_UNDEFH\000\022\035\n\006repea" +
- "t\030\t \001(\0132\013.RDF_REPEATH\000\022\024\n\nvalInteger\030\024 \001" +
- "(\022H\000\022\023\n\tvalDouble\030\025 \001(\001H\000\022\"\n\nvalDecimal\030" +
- "\026 \001(\0132\014.RDF_DecimalH\000B\006\n\004term\"N\n\nRDF_Tri" +
- "ple\022\024\n\001S\030\001 \001(\0132\t.RDF_Term\022\024\n\001P\030\002 \001(\0132\t.R" +
- "DF_Term\022\024\n\001O\030\003 \001(\0132\t.RDF_Term\"b\n\010RDF_Qua" +
- "d\022\024\n\001S\030\001 \001(\0132\t.RDF_Term\022\024\n\001P\030\002 \001(\0132\t.RDF" +
- "_Term\022\024\n\001O\030\003 \001(\0132\t.RDF_Term\022\024\n\001G\030\004 \001(\0132\t" +
- ".RDF_Term\"-\n\016RDF_PrefixDecl\022\016\n\006prefix\030\001 " +
- "\001(\t\022\013\n\003uri\030\002 \001(\t\"\221\001\n\rRDF_StreamRow\022%\n\npr" +
- "efixDecl\030\001 \001(\0132\017.RDF_PrefixDeclH\000\022\035\n\006tri" +
- "ple\030\002 \001(\0132\013.RDF_TripleH\000\022\031\n\004quad\030\003 \001(\0132\t" +
- ".RDF_QuadH\000\022\030\n\004base\030\004 \001(\0132\010.RDF_IRIH\000B\005\n" +
- "\003row\")\n\nRDF_Stream\022\033\n\003row\030\001 \003(\0132\016.RDF_St" +
- "reamRow\"&\n\014RDF_VarTuple\022\026\n\004vars\030\001 \003(\0132\010." +
- "RDF_Var\"\'\n\rRDF_DataTuple\022\026\n\003row\030\001 \003(\0132\t." +
- "RDF_Term\"(\n\tRDF_Graph\022\033\n\006triple\030\001 \003(\0132\013." +
- "RDF_TripleB.\n\"org.apache.jena.riot.proto" +
- "buf.wireB\006PB_RDFH\001b\006proto3"
+ "\001(\t\"\232\001\n\013RDF_Literal\022\013\n\003lex\030\001 \001(\t\022\020\n\006simp" +
+ "le\030\t \001(\010H\000\022\021\n\007langtag\030\002 \001(\tH\000\022\021\n\007langdir" +
+ "\030\005 \001(\tH\000\022\022\n\010datatype\030\003 \001(\tH\000\022#\n\010dtPrefix" +
+ "\030\004 \001(\0132\017.RDF_PrefixNameH\000B\r\n\013literalKind" +
+ "\"+\n\013RDF_Decimal\022\r\n\005value\030\001 \001(\022\022\r\n\005scale\030" +
+ "\002 \001(\021\"\027\n\007RDF_Var\022\014\n\004name\030\001 \001(\t\"\t\n\007RDF_AN" +
+ "Y\"\013\n\tRDF_UNDEF\"\014\n\nRDF_REPEAT\"\371\002\n\010RDF_Ter" +
+ "m\022\027\n\003iri\030\001 \001(\0132\010.RDF_IRIH\000\022\033\n\005bnode\030\002 \001(" +
+ "\0132\n.RDF_BNodeH\000\022\037\n\007literal\030\003 \001(\0132\014.RDF_L" +
+ "iteralH\000\022%\n\nprefixName\030\004 \001(\0132\017.RDF_Prefi" +
+ "xNameH\000\022\034\n\010variable\030\005 \001(\0132\010.RDF_VarH\000\022!\n" +
+ "\ntripleTerm\030\006 \001(\0132\013.RDF_TripleH\000\022\027\n\003any\030" +
+ "\007 \001(\0132\010.RDF_ANYH\000\022\037\n\tundefined\030\010 \001(\0132\n.R" +
+ "DF_UNDEFH\000\022\035\n\006repeat\030\t \001(\0132\013.RDF_REPEATH" +
+ "\000\022\024\n\nvalInteger\030\024 \001(\022H\000\022\023\n\tvalDouble\030\025 \001" +
+ "(\001H\000\022\"\n\nvalDecimal\030\026 \001(\0132\014.RDF_DecimalH\000" +
+ "B\006\n\004term\"N\n\nRDF_Triple\022\024\n\001S\030\001 \001(\0132\t.RDF_" +
+ "Term\022\024\n\001P\030\002 \001(\0132\t.RDF_Term\022\024\n\001O\030\003 \001(\0132\t." +
+ "RDF_Term\"b\n\010RDF_Quad\022\024\n\001S\030\001 \001(\0132\t.RDF_Te" +
+ "rm\022\024\n\001P\030\002 \001(\0132\t.RDF_Term\022\024\n\001O\030\003 \001(\0132\t.RD" +
+ "F_Term\022\024\n\001G\030\004 \001(\0132\t.RDF_Term\"-\n\016RDF_Pref" +
+ "ixDecl\022\016\n\006prefix\030\001 \001(\t\022\013\n\003uri\030\002 \001(\t\"\221\001\n\r" +
+ "RDF_StreamRow\022%\n\nprefixDecl\030\001 \001(\0132\017.RDF_" +
+ "PrefixDeclH\000\022\035\n\006triple\030\002 \001(\0132\013.RDF_Tripl" +
+ "eH\000\022\031\n\004quad\030\003 \001(\0132\t.RDF_QuadH\000\022\030\n\004base\030\004" +
+ " \001(\0132\010.RDF_IRIH\000B\005\n\003row\")\n\nRDF_Stream\022\033\n" +
+ "\003row\030\001 \003(\0132\016.RDF_StreamRow\"&\n\014RDF_VarTup" +
+ "le\022\026\n\004vars\030\001 \003(\0132\010.RDF_Var\"\'\n\rRDF_DataTu" +
+ "ple\022\026\n\003row\030\001 \003(\0132\t.RDF_Term\"(\n\tRDF_Graph" +
+ "\022\033\n\006triple\030\001 \003(\0132\013.RDF_TripleB.\n\"org.apa" +
+ "che.jena.riot.protobuf.wireB\006PB_RDFH\001b\006p" +
+ "roto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
@@ -15315,7 +15602,7 @@ public final class PB_RDF {
internal_static_RDF_Literal_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_RDF_Literal_descriptor,
- new java.lang.String[] { "Lex", "Simple", "Langtag", "Datatype", "DtPrefix", "LiteralKind", });
+ new java.lang.String[] { "Lex", "Simple", "Langtag", "Langdir", "Datatype", "DtPrefix", "LiteralKind", });
internal_static_RDF_Decimal_descriptor =
getDescriptor().getMessageTypes().get(4);
internal_static_RDF_Decimal_fieldAccessorTable = new
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/JSONResultsKW.java b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/JSONResultsKW.java
index 15d16a6e77..b5edefff66 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/JSONResultsKW.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/JSONResultsKW.java
@@ -39,6 +39,7 @@ public class JSONResultsKW
// Legacy: kTypedLiteral
public static final String kTypedLiteral = "typed-literal" ;
public static final String kXmlLang = "xml:lang" ;
+ public static final String kBaseDirection = "its:dir" ;
public static final String kDatatype = "datatype" ;
public static final String kBnode = "bnode" ;
public static final String kBoolean = "boolean" ;
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetReaderJSON_V1.java b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetReaderJSON_V1.java
index 5912f6c2e6..3f4f4a2413 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetReaderJSON_V1.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetReaderJSON_V1.java
@@ -256,7 +256,7 @@ public class RowSetReaderJSON_V1 implements RowSetReader {
Node s = parseOneTerm(sTerm, labelMap);
Node p = parseOneTerm(pTerm, labelMap);
Node o = parseOneTerm(oTerm, labelMap);
- return NodeFactory.createTripleNode(s, p, o);
+ return NodeFactory.createTripleTerm(s, p, o);
}
// Get a object from an object - use the first name in the fields list
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetReaderXML.java b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetReaderXML.java
index b2eb6c0b5c..5c95ac309a 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetReaderXML.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetReaderXML.java
@@ -348,8 +348,9 @@ public class RowSetReaderXML implements RowSetReader {
return ;
}
-
+ //xmlns:its="http://www.w3.org/2005/11/its" its:version="2.0"
static final String XML_NS = ARQConstants.XML_NS ;
+ static final String ITS_NS = ARQConstants.ITS_NS ;
private Binding getOneSolution() throws XMLStreamException {
if ( finished )
@@ -420,6 +421,7 @@ public class RowSetReaderXML implements RowSetReader {
// "If the namespaceURI is null the namespace is not checked for equality"
// StAX(.codehaus.org) copes both ways round
String langTag = parser.getAttributeValue(XML_NS, "lang") ;
+ String baseDir = parser.getAttributeValue(ITS_NS, "dir") ;
// Works for XML literals (returning them as a string)
String text = parser.getElementText() ;
@@ -428,7 +430,7 @@ public class RowSetReaderXML implements RowSetReader {
if ( datatype != null )
dType = TypeMapper.getInstance().getSafeTypeByName(datatype) ;
- Node n = NodeFactory.createLiteral(text, langTag, dType) ;
+ Node n = NodeFactory.createLiteral(text, langTag, baseDir, dType) ;
return n ;
}
@@ -497,7 +499,7 @@ public class RowSetReaderXML implements RowSetReader {
if ( s == null || p == null || o == null )
staxError("Bad <triple> term");
- Node node = NodeFactory.createTripleNode(s, p, o);
+ Node node = NodeFactory.createTripleTerm(s, p, o);
return node;
}
return null;
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterJSON.java b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterJSON.java
index d54477bbe9..9604397d65 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterJSON.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterJSON.java
@@ -30,6 +30,7 @@ import org.apache.jena.atlas.io.IndentedWriter;
import org.apache.jena.atlas.json.io.JSWriter;
import org.apache.jena.atlas.logging.Log;
import org.apache.jena.graph.Node;
+import org.apache.jena.graph.TextDirection;
import org.apache.jena.graph.Triple;
import org.apache.jena.query.ARQ;
import org.apache.jena.rdf.model.impl.Util;
@@ -242,7 +243,7 @@ public class RowSetWriterJSON implements RowSetWriter {
}
private void writeValue(IndentedWriter out, Node value, boolean multiLine) {
- if ( multiLine || value.isNodeTriple() )
+ if ( multiLine || value.isTripleTerm() )
println(out, "{");
else
print(out, "{ ");
@@ -257,13 +258,13 @@ public class RowSetWriterJSON implements RowSetWriter {
writeValueURI(out, value, multiLine);
else if ( value.isBlank() )
writeValueBlankNode(out, value, multiLine);
- else if ( value.isNodeTriple() )
+ else if ( value.isTripleTerm() )
writeValueNodeTriple(out, value, multiLine);
else if ( value.isNodeGraph() )
writeValueNodeGraph(out, value, multiLine);
else
Log.warn(RowSetWriterJSON.class, "Unknown RDFNode type in result set: " + value.getClass());
- if ( multiLine || value.isNodeTriple()) // OR triple
+ if ( multiLine || value.isTripleTerm()) // OR triple
println(out) ;
else
print(out, " ");
@@ -282,9 +283,11 @@ public class RowSetWriterJSON implements RowSetWriter {
private void writeValueLiteral(IndentedWriter out, Node literal, boolean multiLine) {
String datatype = literal.getLiteralDatatypeURI();
- String lang = literal.getLiteralLanguage();
- if ( Util.isSimpleString(literal) || Util.isLangString(literal) ) {
+ if ( Util.isSimpleString(literal) || Util.isLangString(literal) || Util.isDirLangString(literal) ) {
+ String lang = literal.getLiteralLanguage();
+ TextDirection direction = literal.getLiteralBaseDirection();
+
print(out, quoteName(kType), ": ", quote(kLiteral), " , ");
if ( multiLine )
println(out);
@@ -294,6 +297,13 @@ public class RowSetWriterJSON implements RowSetWriter {
if ( multiLine )
println(out);
}
+
+ if ( direction != null ) {
+ print(out, quoteName(kBaseDirection), ": ", quote(direction.direction()), " , ");
+ if ( multiLine )
+ println(out);
+ }
+
} else {
print(out, quoteName(kType), ": ", quote(kLiteral), " , ");
if ( MultiLineValues )
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterXML.java b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterXML.java
index fa4539c9e3..470b3d07bb 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterXML.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/RowSetWriterXML.java
@@ -291,7 +291,7 @@ public class RowSetWriterXML implements RowSetWriter {
printBlankNode(node);
return;
}
- if ( node.isNodeTriple() ) {
+ if ( node.isTripleTerm() ) {
printTripleTerm(node);
return;
}
@@ -330,11 +330,21 @@ public class RowSetWriterXML implements RowSetWriter {
out.print("<");
out.print(dfLiteral);
- if ( Util.isLangString(literal) ) {
+ if ( Util.isLangString(literal) || Util.isDirLangString(literal) ) {
String lang = literal.getLiteralLanguage();
+ if ( Util.isDirLangString(literal) ) {
+ out.print(" xmlns:its=\"http://www.w3.org/2005/11/its\" its:version=\"2.0\"");
+ out.println();
+ out.print(" ");
+ }
out.print(" xml:lang=\"");
out.print(lang);
out.print("\"");
+ if ( Util.isDirLangString(literal) ) {
+ out.print(" its:dir=\"");
+ out.print(literal.getLiteralBaseDirection().direction());
+ out.print("\"");
+ }
} else if ( !Util.isSimpleString(literal) ) {
// Datatype
// (RDF 1.1) not xsd:string nor rdf:langString.
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/rs_json/RowSetJSONStreaming.java b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/rs_json/RowSetJSONStreaming.java
index a762b78bfa..2c701aae53 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/rs_json/RowSetJSONStreaming.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/rowset/rw/rs_json/RowSetJSONStreaming.java
@@ -32,9 +32,17 @@ import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.reflect.TypeToken;
+import com.google.gson.stream.JsonReader;
+
import org.apache.jena.atlas.data.DataBag;
import org.apache.jena.atlas.iterator.IteratorCloseable;
import org.apache.jena.atlas.iterator.IteratorSlotted;
+import org.apache.jena.datatypes.RDFDatatype;
+import org.apache.jena.datatypes.TypeMapper;
import org.apache.jena.graph.Node;
import org.apache.jena.graph.NodeFactory;
import org.apache.jena.riot.lang.LabelToNode;
@@ -45,15 +53,8 @@ import org.apache.jena.sparql.engine.binding.BindingBuilder;
import org.apache.jena.sparql.engine.binding.BindingFactory;
import org.apache.jena.sparql.exec.RowSet;
import org.apache.jena.sparql.resultset.ResultSetException;
-import org.apache.jena.sparql.util.NodeFactoryExtra;
import org.apache.jena.vocabulary.RDF;
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.reflect.TypeToken;
-import com.google.gson.stream.JsonReader;
-
/**
* Streaming RowSet implementation for application/sparql-results+json
* The {@link #getResultVars()} will return null as long as the header has not
@@ -384,24 +385,33 @@ public class RowSetJSONStreaming<E> extends IteratorSlotted<Binding> implements
valueStr = valueJson.getAsString();
JsonElement langJson = term.get(kXmlLang);
JsonElement dtJson = term.get(kDatatype);
+ JsonElement dirJson = term.get(kBaseDirection);
String lang = langJson == null ? null : langJson.getAsString();
String dtStr = dtJson == null ? null : dtJson.getAsString();
+ String dirStr = dirJson == null ? null : dirJson.getAsString();
+
+ // Strictly, xml:lang=... and datatype=rdf:langString is wrong
+ // (the datatype should be absent)
+ // The RDF specs recommend omitting the datatype. They did
+ // however come after the SPARQL 1.1 docs
+ // it's more of a "SHOULD" than a "MUST".
+ // datatype=xsd:string is also unnecessary.
if ( lang != null ) {
- // Strictly, xml:lang=... and datatype=rdf:langString is wrong
- // (the datatype should be absent)
- // The RDF specs recommend omitting the datatype. They did
- // however come after the SPARQL 1.1 docs
- // it's more of a "SHOULD" than a "MUST".
- // datatype=xsd:string is also unnecessary.
- if ( dtStr != null && !dtStr.equals(RDF.dtLangString.getURI()) ) {
- // Must agree.
- throw new ResultSetException("Both language and datatype defined, datatype is not rdf:langString:\n" + term);
+ if ( dirStr != null ) {
+ if ( dtStr != null && !dtStr.equals(RDF.dtDirLangString.getURI()) )
+ throw new ResultSetException("Language, base direction and datatype defined, datatype is not rdf:dirLangString: " + term);
+ } else {
+ if ( dtStr != null && !dtStr.equals(RDF.dtLangString.getURI()) )
+ throw new ResultSetException("Language datatype defined, datatype is not rdf:langString: " + term);
}
+ } else if ( dirStr != null ) {
+ throw new ResultSetException("Base direction defined, but no language given: " + term);
}
- result = NodeFactoryExtra.createLiteralNode(valueStr, lang, dtStr);
+ RDFDatatype dType = ( dtStr == null ) ? null : TypeMapper.getInstance().getSafeTypeByName(dtStr) ;
+ result = NodeFactory.createLiteral(valueStr, lang, dirStr, dType);
break;
case kBnode:
valueStr = valueJson.getAsString();
@@ -419,7 +429,7 @@ public class RowSetJSONStreaming<E> extends IteratorSlotted<Binding> implements
Node p = parseOneTerm(jp, labelMap, onUnknownRdfTermType);
Node o = parseOneTerm(jo, labelMap, onUnknownRdfTermType);
- result = NodeFactory.createTripleNode(s, p, o);
+ result = NodeFactory.createTripleTerm(s, p, o);
break;
default:
if (onUnknownRdfTermType != null) {
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java b/jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java
index 85bd530fe2..628eb821b7 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java
@@ -20,8 +20,10 @@ package org.apache.jena.riot.system;
import org.apache.jena.datatypes.RDFDatatype;
import org.apache.jena.datatypes.xsd.XSDDatatype;
+import org.apache.jena.datatypes.xsd.impl.RDFDirLangString;
import org.apache.jena.datatypes.xsd.impl.RDFLangString;
import org.apache.jena.graph.Node;
+import org.apache.jena.graph.TextDirection;
import org.apache.jena.graph.Triple;
import org.apache.jena.iri.IRI;
import org.apache.jena.irix.*;
@@ -66,7 +68,7 @@ public class Checker {
return checkLiteral(node, errorHandler, line, col);
else if ( node.isVariable() )
return checkVar(node, errorHandler, line, col);
- else if ( node.isNodeTriple() ) {
+ else if ( node.isTripleTerm() ) {
Triple t = node.getTriple();
return check(t.getSubject()) && check(t.getPredicate()) && check(t.getObject())
&& checkTriple(t);
@@ -138,24 +140,40 @@ public class Checker {
errorHandler(errorHandler).error("Not a literal: " + node, line, col);
return false;
}
-
- return checkLiteral(node.getLiteralLexicalForm(), node.getLiteralLanguage(), node.getLiteralDatatype(), errorHandler, line, col);
+ return checkLiteral(node.getLiteralLexicalForm(), node.getLiteralLanguage(), node.getLiteralBaseDirection(), node.getLiteralDatatype(), errorHandler, line, col);
}
public static boolean checkLiteral(String lexicalForm, RDFDatatype datatype, ErrorHandler errorHandler, long line, long col) {
- return checkLiteral(lexicalForm, null, datatype, errorHandler, line, col);
+ return checkLiteral(lexicalForm, null, (TextDirection)null, datatype, errorHandler, line, col);
}
public static boolean checkLiteral(String lexicalForm, String lang, ErrorHandler errorHandler, long line, long col) {
- return checkLiteral(lexicalForm, lang, null, errorHandler, line, col);
+ return checkLiteral(lexicalForm, lang, (TextDirection)null, null, errorHandler, line, col);
}
+ /** @deprecated Use {@link #checkLiteral(String, String, ErrorHandler, long, long)} */
+ @Deprecated
public static boolean checkLiteral(String lexicalForm, String lang, RDFDatatype datatype, ErrorHandler errorHandler, long line, long col) {
+ return checkLiteral(lexicalForm, lang, (TextDirection)null, datatype, errorHandler, line, col);
+ }
+
+ public static boolean checkLiteral(String lexicalForm, String lang, String direction, RDFDatatype datatype, ErrorHandler errorHandler, long line, long col) {
+ TextDirection textDir = null;
+ if ( direction != null ) {
+ textDir = TextDirection.createOrNull(direction);
+ if ( textDir == null )
+ errorHandler(errorHandler).error("Language direction not valid: " + direction, line, col);
+ }
+ return checkLiteral(lexicalForm, lang, textDir, datatype, errorHandler, line, col);
+ }
+
+ public static boolean checkLiteral(String lexicalForm, String lang, TextDirection direction, RDFDatatype datatype, ErrorHandler errorHandler, long line, long col) {
boolean hasLang = ( lang != null && !lang.isEmpty() );
+ boolean hasTextDirection = direction != null;
boolean hasDatatype = datatype != null;
if ( !hasDatatype && !hasLang) {
- // This will become an xsd:string or rdf:langString.
+ // This will become an xsd:string
// No further checking needed.
return true;
}
@@ -171,16 +189,25 @@ public class Checker {
// No datatype is acceptable - NodeFactory deal with that case.
if ( hasDatatype ) {
// Jena is using the RDF 1.1 or later standard...
- if ( ! datatype.equals( RDFLangString.rdfLangString ) ) {
- errorHandler(errorHandler).error("Literal has language but wrong datatype", line, col);
+ if ( hasTextDirection && ! datatype.equals( RDFDirLangString.rdfDirLangString ) ) {
+ errorHandler(errorHandler).error("Literal has language and base direction but wrong datatype: "+datatype, line, col);
+ return false;
+ }
+ else if ( ! datatype.equals( RDFLangString.rdfLangString ) ) {
+ errorHandler(errorHandler).error("Literal has language but wrong datatype: "+datatype, line, col);
return false;
}
}
return true;
+ } else {
+ // No lang => no base direction
+ if ( hasTextDirection )
+ errorHandler(errorHandler).error("Language base direction without language", line, col);
+ // Fallthrough
}
- // If the Literal has a datatype (but no language)...
- if ( datatype.equals( XSDDatatype.XSDstring) )
+ // If the Literal has a datatype (but no language or base direction)...
+ if ( datatype.equals(XSDDatatype.XSDstring) )
// Simple literals are always well-formed...
return true;
return validateByDatatype(lexicalForm, datatype, errorHandler, line, col);
@@ -319,7 +346,7 @@ public class Checker {
rc = false;
}
- if ( subject == null || (!subject.isURI() && !subject.isBlank() && !subject.isNodeTriple()) ) {
+ if ( subject == null || (!subject.isURI() && !subject.isBlank() && !subject.isTripleTerm()) ) {
errorHandler(errorHandler).error("Subject is not a URI, blank node or RDF-star triple term", line, col);
rc = false;
}
@@ -327,7 +354,7 @@ public class Checker {
errorHandler(errorHandler).error("Predicate not a URI", line, col);
rc = false;
}
- if ( object == null || (!object.isURI() && !object.isBlank() && !object.isLiteral() && !subject.isNodeTriple()) ) {
+ if ( object == null || (!object.isURI() && !object.isBlank() && !object.isLiteral() && !subject.isTripleTerm()) ) {
errorHandler(errorHandler).error("Object is not a URI, blank node, literal or RDF-star triple term", line, col);
rc = false;
}
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/system/FactoryRDF.java b/jena-arq/src/main/java/org/apache/jena/riot/system/FactoryRDF.java
index 83a9006c37..95b49c9f20 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/system/FactoryRDF.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/system/FactoryRDF.java
@@ -38,6 +38,8 @@ public interface FactoryRDF {
public Node createLangLiteral(String lexical, String langTag);
+ public Node createLangDirLiteral(String lexical, String langTag, String direction);
+
public Node createStringLiteral(String lexical);
/** Create a blank node which is completely new and used nowhere else. */
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/system/FactoryRDFStd.java b/jena-arq/src/main/java/org/apache/jena/riot/system/FactoryRDFStd.java
index 5eeab8b187..6e0b0b5b5f 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/system/FactoryRDFStd.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/system/FactoryRDFStd.java
@@ -65,6 +65,11 @@ public class FactoryRDFStd implements FactoryRDF {
return NodeFactory.createLiteralLang(lexical, langTag) ;
}
+ @Override
+ public Node createLangDirLiteral(String lexical, String langTag, String direction) {
+ return NodeFactory.createLiteralDirLang(lexical, langTag, direction) ;
+ }
+
@Override
public Node createStringLiteral(String lexical) {
return NodeFactory.createLiteralString(lexical) ;
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/system/ParserProfile.java b/jena-arq/src/main/java/org/apache/jena/riot/system/ParserProfile.java
index fc454c9a12..34e9b14609 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/system/ParserProfile.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/system/ParserProfile.java
@@ -62,6 +62,9 @@ public interface ParserProfile {
/** Create a literal for a string+language */
public Node createLangLiteral(String lexical, String langTag, long line, long col);
+ /** Create a literal for a string+language+base direction */
+ public Node createLangDirLiteral(String lexical, String langTag, String direction, long line, long col);
+
/** Create a literal for a string */
public Node createStringLiteral(String lexical, long line, long col);
@@ -71,11 +74,23 @@ public interface ParserProfile {
/** Create a fresh blank node */
public Node createBlankNode(Node scope, long line, long col);
- /** Create a triple node (RDF-star) */
- public Node createTripleNode(Node subject, Node predicate, Node object, long line, long col);
+ /** Create a triple term (RDF-star) */
+ public Node createTripleTerm(Node subject, Node predicate, Node object, long line, long col);
+
+ /** @deprecated Use {@link #createTripleTerm} */
+ @Deprecated
+ public default Node createTripleNode(Node subject, Node predicate, Node object, long line, long col) {
+ return createTripleTerm(subject, predicate, object, line, col);
+ }
/** Create a triple node (RDF-star) */
- public Node createTripleNode(Triple triple, long line, long col);
+ public Node createTripleTerm(Triple triple, long line, long col);
+
+ /** @deprecated Use {@link #createTripleTerm} */
+ @Deprecated
+ public default Node createTripleNode(Triple triple, long line, long col) {
+ return createTripleTerm(triple, line, col);
+ }
/** Create a graph node. This is an N3-formula and not named graphs */
public Node createGraphNode(Graph graph, long line, long col);
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/system/ParserProfileStd.java b/jena-arq/src/main/java/org/apache/jena/riot/system/ParserProfileStd.java
index 5f93eb309f..dc65624c93 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/system/ParserProfileStd.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/system/ParserProfileStd.java
@@ -144,11 +144,19 @@ public class ParserProfileStd implements ParserProfile {
}
private boolean allowSpecialNode(Node node) {
- return allowNodeExtentions && node instanceof Node_Triple;
+ return allowNodeExtentions;
}
protected void checkTriple(Node subject, Node predicate, Node object, long line, long col) {
if ( subject == null || (!subject.isURI() && !subject.isBlank()) ) {
+ if ( subject.isLiteral() ) {
+ errorHandler.error("Subject is a literal: "+subject, line, col);
+ throw new RiotException("Bad subject: " + subject);
+ }
+ if ( subject.isTripleTerm() ) {
+ errorHandler.error("Subject is a triple term: "+subject, line, col);
+ throw new RiotException("Bad subject: " + subject);
+ }
if ( !allowSpecialNode(subject) ) {
errorHandler.error("Subject is not a URI or blank node", line, col);
throw new RiotException("Bad subject: " + subject);
@@ -158,7 +166,7 @@ public class ParserProfileStd implements ParserProfile {
errorHandler.error("Predicate not a URI", line, col);
throw new RiotException("Bad predicate: " + predicate);
}
- if ( object == null || (!object.isURI() && !object.isBlank() && !object.isLiteral()) ) {
+ if ( object == null || (!object.isURI() && !object.isBlank() && !object.isLiteral() && !object.isTripleTerm() ) ) {
if ( !allowSpecialNode(object) ) {
errorHandler.error("Object is not a URI, blank node or literal", line, col);
throw new RiotException("Bad object: " + object);
@@ -212,10 +220,19 @@ public class ParserProfileStd implements ParserProfile {
@Override
public Node createLangLiteral(String lexical, String langTag, long line, long col) {
if ( checking )
- Checker.checkLiteral(lexical, langTag, null, errorHandler, line, col);
+ Checker.checkLiteral(lexical, langTag, errorHandler, line, col);
return factory.createLangLiteral(lexical, langTag);
}
+ @Override
+ public Node createLangDirLiteral(String lexical, String langTag, String direction, long line, long col) {
+ if ( ! TextDirection.isValid(direction) )
+ throw new RiotException("Invalid base direction: '"+direction+"'. Must be 'ltr' or 'rtl'");
+ if ( checking )
+ Checker.checkLiteral(lexical, langTag, direction, null, errorHandler, line, col);
+ return factory.createLangDirLiteral(lexical, langTag, direction);
+ }
+
@Override
public Node createStringLiteral(String lexical, long line, long col) {
// No checks
@@ -235,13 +252,17 @@ public class ParserProfileStd implements ParserProfile {
}
@Override
- public Node createTripleNode(Node subject, Node predicate, Node object, long line, long col) {
- return NodeFactory.createTripleNode(subject, predicate, object);
+ public Node createTripleTerm(Node subject, Node predicate, Node object, long line, long col) {
+ if ( checking )
+ checkTriple(subject, predicate, object, line, col);
+ return NodeFactory.createTripleTerm(subject, predicate, object);
}
@Override
- public Node createTripleNode(Triple triple, long line, long col) {
- return NodeFactory.createTripleNode(triple);
+ public Node createTripleTerm(Triple triple, long line, long col) {
+ if ( checking )
+ checkTriple(triple.getSubject(), triple.getPredicate(), triple.getObject(), line, col);
+ return NodeFactory.createTripleTerm(triple);
}
@Override
@@ -261,7 +282,7 @@ public class ParserProfileStd implements ParserProfile {
}
@Override
- public Node create(Node currentGraph, Token token) {
+ public final Node create(Node currentGraph, Token token) {
// Dispatches to the underlying ParserFactory operation
long line = token.getLine();
long col = token.getColumn();
@@ -305,6 +326,13 @@ public class ParserProfileStd implements ParserProfile {
}
case LITERAL_LANG :
+ String langdir = token.getImage2();
+ int idx = langdir.indexOf("--");
+ if ( idx >= 0 ) {
+ String textDir = langdir.substring(idx+2);
+ String lang = langdir.substring(0, idx);
+ return createLangDirLiteral(str, lang, textDir, line, col);
+ }
return createLangLiteral(str, token.getImage2(), line, col);
case STRING :
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/system/ParserProfileWrapper.java b/jena-arq/src/main/java/org/apache/jena/riot/system/ParserProfileWrapper.java
index c531c1e713..94a00fdf4e 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/system/ParserProfileWrapper.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/system/ParserProfileWrapper.java
@@ -78,6 +78,11 @@ public class ParserProfileWrapper implements ParserProfile
return get().createLangLiteral(lexical, langTag, line, col);
}
+ @Override
+ public Node createLangDirLiteral(String lexical, String langTag, String direction, long line, long col) {
+ return get().createLangDirLiteral(lexical, langTag, direction, line, col);
+ }
+
@Override
public Node createStringLiteral(String lexical, long line, long col) {
return get().createStringLiteral(lexical, line, col);
@@ -94,13 +99,13 @@ public class ParserProfileWrapper implements ParserProfile
}
@Override
- public Node createTripleNode(Node subject, Node predicate, Node object, long line, long col) {
- return get().createTripleNode(subject, predicate, object, line, col);
+ public Node createTripleTerm(Node subject, Node predicate, Node object, long line, long col) {
+ return get().createTripleTerm(subject, predicate, object, line, col);
}
@Override
- public Node createTripleNode(Triple triple, long line, long col) {
- return get().createTripleNode(triple, line, col);
+ public Node createTripleTerm(Triple triple, long line, long col) {
+ return get().createTripleTerm(triple, line, col);
}
@Override
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/thrift/Binding2Thrift.java b/jena-arq/src/main/java/org/apache/jena/riot/thrift/Binding2Thrift.java
index ed6d21e047..bc1443aaca 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/thrift/Binding2Thrift.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/thrift/Binding2Thrift.java
@@ -18,84 +18,84 @@
package org.apache.jena.riot.thrift;
-import java.io.OutputStream ;
+import java.io.OutputStream;
import java.util.ArrayList;
-import java.util.Collection ;
-import java.util.Iterator ;
+import java.util.Collection;
+import java.util.Iterator;
-import org.apache.jena.graph.Node ;
-import org.apache.jena.riot.thrift.wire.RDF_DataTuple ;
-import org.apache.jena.riot.thrift.wire.RDF_Term ;
-import org.apache.jena.riot.thrift.wire.RDF_VAR ;
-import org.apache.jena.riot.thrift.wire.RDF_VarTuple ;
-import org.apache.jena.sparql.core.Var ;
-import org.apache.jena.sparql.engine.binding.Binding ;
-import org.apache.thrift.TException ;
-import org.apache.thrift.protocol.TProtocol ;
-import org.apache.thrift.transport.TIOStreamTransport ;
+import org.apache.jena.graph.Node;
+import org.apache.jena.riot.thrift.wire.RDF_DataTuple;
+import org.apache.jena.riot.thrift.wire.RDF_Term;
+import org.apache.jena.riot.thrift.wire.RDF_VAR;
+import org.apache.jena.riot.thrift.wire.RDF_VarTuple;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.engine.binding.Binding;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TIOStreamTransport;
import org.apache.thrift.transport.TTransportException;
/** Converted from Bindings to SPARQL result set encoded in Thrift */
public class Binding2Thrift implements AutoCloseable {
- private final RDF_DataTuple row = new RDF_DataTuple() ;
- private final Collection<Var> vars ;
- private final OutputStream out ;
- private final TProtocol protocol ;
- private final boolean encodeValues ;
+ private final RDF_DataTuple row = new RDF_DataTuple();
+ private final Collection<Var> vars;
+ private final OutputStream out;
+ private final TProtocol protocol;
+ private final boolean encodeValues;
public Binding2Thrift(OutputStream out, Collection<Var> vars, boolean encodeValues) {
- this.out = out ;
- this.vars = vars ;
+ this.out = out;
+ this.vars = vars;
try {
- TIOStreamTransport transport = new TIOStreamTransport(out) ;
- this.protocol = TRDF.protocol(transport) ;
+ TIOStreamTransport transport = new TIOStreamTransport(out);
+ this.protocol = TRDF.protocol(transport);
} catch (TTransportException ex) { throw new RiotThriftException(ex); }
- this.encodeValues = encodeValues ;
- varsRow() ;
+ this.encodeValues = encodeValues;
+ varsRow();
}
private void varsRow() {
- RDF_VarTuple vrow = new RDF_VarTuple(new ArrayList<>(vars.size())) ;
+ RDF_VarTuple vrow = new RDF_VarTuple(new ArrayList<>(vars.size()));
for ( Var v : vars ) {
- RDF_VAR rv = new RDF_VAR() ;
- rv.setName(v.getName()) ;
- vrow.addToVars(rv) ;
+ RDF_VAR rv = new RDF_VAR();
+ rv.setName(v.getName());
+ vrow.addToVars(rv);
}
- try { vrow.write(protocol) ; }
- catch (TException e) { TRDF.exception(e) ; }
+ try { vrow.write(protocol); }
... 40645 lines suppressed ...