Skip to content

Commit

Permalink
Add SPARQL-start support.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeswr authored Jun 12, 2023
1 parent 66c1d26 commit f3fd546
Show file tree
Hide file tree
Showing 360 changed files with 7,593 additions and 2,122 deletions.
671 changes: 548 additions & 123 deletions lib/sparql.jison

Large diffs are not rendered by default.

2,721 changes: 1,043 additions & 1,678 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
"prepublishOnly": "npm run build",
"spec-base-query": "rdf-test-suite spec/parser.js http://w3c.github.io/rdf-tests/sparql11/data-sparql11/manifest-all.ttl -s http://www.w3.org/TR/sparql11-query/ -c .rdf-test-suite-cache/",
"spec-base-update": "rdf-test-suite spec/parser.js http://w3c.github.io/rdf-tests/sparql11/data-sparql11/manifest-all.ttl -s http://www.w3.org/TR/sparql11-update/ -c .rdf-test-suite-cache/",
"spec-star": "rdf-test-suite spec/parser.js https://w3c.github.io/rdf-star/tests/sparql/syntax/manifest.jsonld -i '{ \"sparqlStar\": true }' -c .rdf-test-suite-cache/",
"spec-earl-query": "npm run spec-base-query --silent -- -o earl -p spec/earl-meta.json > spec/earl-query.ttl",
"spec-earl-update": "npm run spec-base-update --silent -- -o earl -p spec/earl-meta.json > spec/earl-update.ttl",
"spec": "npm run spec-base-query && npm run spec-base-update"
"spec-earl-star": "npm run spec-star --silent -- -o earl -p spec/earl-meta.json > spec/earl-star.ttl",
"spec": "npm run spec-base-query && npm run spec-base-update && npm run spec-star"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
Expand All @@ -43,9 +45,9 @@
"devDependencies": {
"expect": "^24.9.0",
"jison": "0.4.18",
"mocha": "^7.2.0",
"mocha": "^10.1.0",
"pre-commit": "^1.2.2",
"rdf-test-suite": "^1.19.2"
"rdf-test-suite": "^1.20.0"
},
"browser": {
"_process": false,
Expand Down
2 changes: 1 addition & 1 deletion queries/sparql-skip-validation/implicit-grouping-1.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ select
(count(?y) as ?count)
{
?x ?y ?z
}
}
2 changes: 1 addition & 1 deletion queries/sparql-skip-validation/implicit-grouping-2.sparql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select ?x (count(?y) as ?count)
{
?x ?y ?z
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT * {
?s ?p ?o .
BIND([] AS ?t )
}
2 changes: 1 addition & 1 deletion queries/sparql/ask-in-anonymous-node.sparql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
BASE <ex:>
ask { [<>?o]. }
ask { [<>?o]. }
2 changes: 1 addition & 1 deletion queries/sparql/inverse-paths-anonymous-node.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ WHERE {
rdfs:label "Brad Pitt"@en ;
^dbpedia-owl:starring ?otherMovie
] .
}
}
2 changes: 1 addition & 1 deletion queries/sparql/inverse-paths-in-anonymous-node-2.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ WHERE {
rdfs:label "Brad Pitt"@en ;
^dbpedia-owl:starring ?otherMovie
] .
}
}
2 changes: 1 addition & 1 deletion queries/sparql/inverse-paths-in-anonymous-node.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ WHERE {
rdfs:label "Brad Pitt"@en ;
^dbpedia-owl:starring ?otherMovie
] .
}
}
2 changes: 1 addition & 1 deletion queries/sparql/sequence-paths-in-anonymous-node.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ select * {
:a [
:a/:a :a
] .
}
}
2 changes: 1 addition & 1 deletion queries/sparql/sparql-19-a.sparql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
select ?p (count(*) as ?n) {
[ ?p [] ].
}
}
9 changes: 9 additions & 0 deletions queries/sparqlstar-annotated/sparql-star-1.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
<<?s ?p ?o>> ex:author ex:Bob .
<< ex:Moscow a ex:City >> ex:author ?person .
# The list in a quoted triple is erroneous
<< _:b ex:x ( 1 2 3 ) >> ex:broken true .
}
8 changes: 8 additions & 0 deletions queries/sparqlstar-annotated/sparql-star-annotated-1.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
?s ?p ?o {| ex:author ex:Bob |} .
ex:Moscow a ex:City {| ex:author ?person |} .
_:b ex:x () {| ex:broken true |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
?s :p ("abc") {| :q 123 |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
("abc") :p :o {| :q 123 |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p12 ?o12 |},
?o2 {| ?p22 ?o22 |},
?o3 {| ?p32 ?o32 |}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s ?p ?o {| ?p1 ?o1 {| :p/:q ?o2 |} |}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p12 ?o12 |};
?p2 ?o2 {| ?p22 ?o22 |};
?p3 ?o3 {| ?p32 ?o32 |};
}
7 changes: 7 additions & 0 deletions queries/sparqlstar-annotated/sparql-star-annotated.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p12 ?o12 |};
?p2 ?o2 {| ?p22 ?o22 |}.

?sa1 ?p1 ?o1 {| ?p12 ?o12 |};
?p2 ?o2 {| ?p22 ?o22 |}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p2 ?o2 |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX : <http://example.org#>

CONSTRUCT {
?s1 ?p1 ?o1 {| :is true |}
} WHERE {
?s1 ?p1 ?o1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX : <http://example.org#>

CONSTRUCT {
?s1 ?p1 ?o1
} WHERE {
?s1 ?p1 ?o1 {| :is true |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
<<?s0 ?p0 ?o0>> ?p1 ?o1 {| ?p2 ?o2 |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
<<?s0 ?p0 ?o0>> ?p1 ?o1 {| ?p2 <<?s3 ?p3 ?o3>> |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
<<?s0 ?p0 ?o0>> ?p1 <<?s2 ?p2 ?o2>> {| ?p2 <<?s3 ?p3 ?o3>> |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
<<?s0 ?p0 <<?s2 ?p2 ?o2>>>> ?p1 ?p1 {| ?p2 <<?s3 ?p3 <<?s4 ?p4 ?o4>>>> |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p2 ?o2, ?o3 |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p2 ?o2; ?p3 ?o3 |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p2 ?o2 {| ?p3 ?o3 |} |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s1 ?p1 ?o1 {| ?p2 ?o2 {| ?p3 ?o3 {| ?p4 ?o4 |} |} |}
}
3 changes: 3 additions & 0 deletions queries/sparqlstar-annotated/sparql-star-path.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s ?p ?o {| :p/:q ?oo |}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s :p|:q ?o {| ?pp ?oo |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
:p ("abc") :o {| :q 123 |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s :p+ ?o {| ?pp ?oo |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * {
:s :p? :o {| ?p ?o |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
:s+ :p ?o {| ?pp ?oo |} .
}
5 changes: 5 additions & 0 deletions queries/sparqlstar-invalid/sparql-star-annotated-path.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s :p/:q ?o {| ?pp ?oo |}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s1 ?p1/?p2 ?o1 {| ?p2 ?o2 |}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * WHERE {
<<?s ?p ?o>> ex:author ex:Bob .
<< ex:Moscow a ex:City >> ex:author ?person .
# TODO: See if this should be throwing an error
<< _:b ex:x () >> ex:broken true .
}
9 changes: 9 additions & 0 deletions queries/sparqlstar-invalid/sparql-star-list-2.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
<<?s ?p ?o>> ex:author ex:Bob .
<< ex:Moscow a ex:City >> ex:author ?person .
# TODO: See if this should be throwing an error
<< _:b ex:x ( 1 2 3 ) >> ex:broken true .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s ?p ?o {| :p/:q ?oo {| ?a ?b |} |}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
<<s :p|:q ?o>>.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT * {
?s ?p ?o .
BIND(<< [] ?p ?o >> AS ?t )
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
<<?s [] ?o>> ?p2 ?o2 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
<<?s :p ("abc") >> :q 123 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
<<?s :p ("abc") >> :q 123 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
<<?s :p ("abc") >> :q 123 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
<<("abc") :p :o >> :q 123 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
<<("abc") :p :o >> :q 123 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PREFIX : <http://example.com/ns#>

SELECT * {
?s ?p ?o .
BIND(<< ?s :p/:q ?o >> AS ?t )
}
5 changes: 5 additions & 0 deletions queries/sparqlstar-invalid/sparql-star-quoted-path.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
<<?s :p/:q ?o>>.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
<<?s1 ?p1/?p2 ?o1>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
<<GRAPH ?g {?s ?p ?o}>> ex:author ex:Bob .
<< GRAPH ?g {?s ?p ?o} >> ex:author ex:Bob .
<< GRAPH ex:graph {ex:Moscow a ex:City} >> ex:author ?person .
<< GRAPH ex:g2 { _:b ex:x () }>> ex:broken true .
<< GRAPH ex:g2 { _:b ex:x () } >> ex:broken true .
}
7 changes: 7 additions & 0 deletions queries/sparqlstar-operators/sparql-star-istriple.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?s ?p ?o WHERE {
?s ?p ?o .
FILTER(isTriple(?s))
}
7 changes: 7 additions & 0 deletions queries/sparqlstar-operators/sparql-star-object.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT (object(?s) as ?o1) WHERE {
?s ?p ?o .
FILTER(isTriple(?s))
}
7 changes: 7 additions & 0 deletions queries/sparqlstar-operators/sparql-star-predicate.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT (predicate(?s) as ?p1) WHERE {
?s ?p ?o .
FILTER(isTriple(?s))
}
7 changes: 7 additions & 0 deletions queries/sparqlstar-operators/sparql-star-subject.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT (subject(?s) as ?s1) WHERE {
?s ?p ?o .
FILTER(isTriple(?s))
}
6 changes: 6 additions & 0 deletions queries/sparqlstar-operators/sparql-star-triple.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT (triple(?s, ?p, ?o) as ?t) WHERE {
?s ?p ?o .
}
5 changes: 5 additions & 0 deletions queries/sparqlstar-spec/sparql-star-annotation-01.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
?s ?p ?o {| :r ?Z |} .
}
12 changes: 12 additions & 0 deletions queries/sparqlstar-spec/sparql-star-annotation-02.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PREFIX : <http://example.com/ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT * {
:s :p :o {| :source [ :graph <http://host1/> ;
:date "2020-01-20"^^xsd:date
] ;
?source [ :graph <http://host2/> ;
:date "2020-12-31"^^xsd:date
]
|}
}
6 changes: 6 additions & 0 deletions queries/sparqlstar-spec/sparql-star-annotation-03.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PREFIX : <http://example.com/ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT * {
:s :p <<:a :b :c>> {| ?q ?z |}
}
Loading

0 comments on commit f3fd546

Please sign in to comment.