diff --git a/VERSION b/VERSION index 9cec7165..23887f6e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.6 +3.1.7 diff --git a/etc/earl-rdf-star.ttl b/etc/earl-rdf-star.ttl index cd0388ca..7c25b289 100644 --- a/etc/earl-rdf-star.ttl +++ b/etc/earl-rdf-star.ttl @@ -46,12 +46,12 @@ foaf:name "Arto Bendiken" . doap:release [ - doap:name "sparql-3.1.6"; - doap:revision "3.1.6"; - doap:created "2021-03-21"^^xsd:date; + doap:name "sparql-3.1.7"; + doap:revision "3.1.7"; + doap:created "2021-05-29"^^xsd:date; ] . <> foaf:primaryTopic ; - dc:issued "2021-03-21T12:59:07-07:00"^^xsd:dateTime ; + dc:issued "2021-05-29T11:33:48-07:00"^^xsd:dateTime ; foaf:maker . a earl:Assertor; @@ -65,7 +65,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - subject embedded triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -76,7 +76,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - object embedded triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -87,7 +87,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - subject embedded triple - vars"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -98,7 +98,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - object embedded triple - vars"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -109,7 +109,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Embedded triple in VALUES"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -120,7 +120,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Embedded triple in CONSTRUCT"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -131,7 +131,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Embedded triples in CONSTRUCT WHERE"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -142,7 +142,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - embedded triple inside blankNodePropertyList"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -153,7 +153,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - embedded triple inside collection"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -164,7 +164,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - nested embedded triple, subject position"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -175,7 +175,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - nested embedded triple, object position"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -186,7 +186,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - compound forms"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -197,7 +197,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - blank node subject"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -208,7 +208,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - blank node object"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -219,7 +219,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - blank node"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -230,7 +230,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Annotation form"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -241,7 +241,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Annotation example"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -252,7 +252,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Annotation example"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -263,7 +263,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Annotation with embedding"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -274,7 +274,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Annotation on triple with embedded object"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -285,7 +285,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Annotation with path"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -296,7 +296,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Annotation with nested path"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -307,7 +307,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Annotation in CONSTRUCT """; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -318,7 +318,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Annotation in CONSTRUCT WHERE"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -329,7 +329,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Expressions - Embedded triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -340,7 +340,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Expressions - Embedded triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -351,7 +351,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Expressions - Functions"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -362,7 +362,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Expressions - TRIPLE"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -373,7 +373,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Expressions - Functions"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -384,7 +384,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Expressions - BIND - CONSTRUCT"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -395,7 +395,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - embedded triple as predicate"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -406,7 +406,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - embedded triple outside triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -417,7 +417,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - collection list in embedded triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -428,7 +428,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - literal in subject position of embedded triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -439,7 +439,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - blank node as predicate in embedded triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -450,7 +450,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - compound blank node expression"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -461,7 +461,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - incomplete embedded triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -472,7 +472,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - quad embedded triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -483,7 +483,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - variable in embedded triple in VALUES """; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -494,7 +494,29 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - blank node in embedded triple in VALUES """; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; + earl:mode earl:automatic ] . + +[ a earl:Assertion; + earl:assertedBy ; + earl:subject ; + earl:test ; + earl:result [ + a earl:TestResult; + earl:outcome earl:passed; + dc:name """SPARQL-star - bad - blank node in embedded triple in FILTER"""; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; + earl:mode earl:automatic ] . + +[ a earl:Assertion; + earl:assertedBy ; + earl:subject ; + earl:test ; + earl:result [ + a earl:TestResult; + earl:outcome earl:passed; + dc:name """SPARQL-star - bad - blank node in embedded triple in BIND"""; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -505,7 +527,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - empty annotation"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -516,7 +538,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - triples in annotation"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -527,7 +549,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - path - seq"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -538,7 +560,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - path - alt"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -549,7 +571,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - path - p*"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -560,7 +582,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - path - p+"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -571,7 +593,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - path - p?"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -582,7 +604,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - path in CONSTRUCT"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -593,7 +615,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - bad - path in CONSTRUCT"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -604,7 +626,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - update"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -615,7 +637,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - update"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -626,7 +648,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - update"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -637,7 +659,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - update with embedding"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -648,7 +670,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - update with embedded object"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -659,7 +681,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - update with annotation template"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -670,7 +692,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - update with annotation, template and pattern"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -681,7 +703,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - update DATA with annotation"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -692,7 +714,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - update - bad syntax"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -703,7 +725,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - update - bad syntax"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -714,7 +736,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - update - bad syntax"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -725,7 +747,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - update - bad syntax"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -736,7 +758,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - all graph triples (JSON results)"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -747,7 +769,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - all graph triples (XML results)"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -758,7 +780,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - match constant embedded triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -769,7 +791,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - match embedded triple, var subject"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -780,7 +802,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - match embedded triple, var predicate"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -791,7 +813,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - match embedded triple, var object"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -802,7 +824,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - no match of embedded triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -813,7 +835,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Asserted and embedded triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -824,7 +846,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Asserted and embedded triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -835,7 +857,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Pattern - Variable for embedded triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -846,7 +868,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Pattern - No match"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -857,7 +879,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Pattern - match variables in triple terms"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -868,7 +890,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Pattern - Nesting 1"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -879,7 +901,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Pattern - Nesting - 2"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -890,7 +912,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Pattern - Match and nesting"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -901,7 +923,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Pattern - Same variable"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -912,7 +934,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - CONSTRUCT with constant template"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -923,7 +945,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - CONSTRUCT WHERE with constant template"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -934,7 +956,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - CONSTRUCT - about every triple"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -945,7 +967,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - CONSTRUCT with annotation syntax"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -956,7 +978,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - CONSTRUCT WHERE with annotation syntax"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -967,7 +989,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - GRAPH"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -978,7 +1000,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - GRAPHs with blank node"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -989,7 +1011,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Embedded triple - BIND - CONSTRUCT"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -1000,7 +1022,51 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Embedded triple - Functions"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; + earl:mode earl:automatic ] . + +[ a earl:Assertion; + earl:assertedBy ; + earl:subject ; + earl:test ; + earl:result [ + a earl:TestResult; + earl:outcome earl:passed; + dc:name """SPARQL-star - Embedded triple - sameTerm"""; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; + earl:mode earl:automatic ] . + +[ a earl:Assertion; + earl:assertedBy ; + earl:subject ; + earl:test ; + earl:result [ + a earl:TestResult; + earl:outcome earl:passed; + dc:name """SPARQL-star - Embedded triple - value-equality"""; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; + earl:mode earl:automatic ] . + +[ a earl:Assertion; + earl:assertedBy ; + earl:subject ; + earl:test ; + earl:result [ + a earl:TestResult; + earl:outcome earl:passed; + dc:name """SPARQL-star - Embedded triple - value-inequality"""; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; + earl:mode earl:automatic ] . + +[ a earl:Assertion; + earl:assertedBy ; + earl:subject ; + earl:test ; + earl:result [ + a earl:TestResult; + earl:outcome earl:passed; + dc:name """SPARQL-star - Embedded triple - value-inequality"""; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -1010,8 +1076,19 @@ earl:result [ a earl:TestResult; earl:outcome earl:passed; - dc:name """SPARQL-star - Embedded triple ORDER BY"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:name """SPARQL-star - Embedded triple - ORDER BY"""; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; + earl:mode earl:automatic ] . + +[ a earl:Assertion; + earl:assertedBy ; + earl:subject ; + earl:test ; + earl:result [ + a earl:TestResult; + earl:outcome earl:passed; + dc:name """SPARQL-star - Embedded triple - ordering"""; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -1022,7 +1099,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Update"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -1033,7 +1110,7 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Update - annotation"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . [ a earl:Assertion; @@ -1044,5 +1121,5 @@ a earl:TestResult; earl:outcome earl:passed; dc:name """SPARQL-star - Update - data"""; - dc:date "2021-03-21T12:59:07-07:00"^^xsd:dateTime]; + dc:date "2021-05-29T11:33:48-07:00"^^xsd:dateTime]; earl:mode earl:automatic ] . diff --git a/etc/sparql11.bnf b/etc/sparql11.bnf index c77e70c5..be4c9e0f 100644 --- a/etc/sparql11.bnf +++ b/etc/sparql11.bnf @@ -157,7 +157,10 @@ [119] PrimaryExpression ::= BrackettedExpression | BuiltInCall | iriOrFunction | RDFLiteral | NumericLiteral | BooleanLiteral | Var - | EmbTP + | ExprEmbTP + [119a] ExprEmbTP ::= '<<' ExprVarOrTerm Verb ExprVarOrTerm '>>' + [119b] ExprVarOrTerm ::= iri | RDFLiteral | NumericLiteral | BooleanLiteral + | Var | ExprEmbTP [120] BrackettedExpression ::= '(' Expression ')' [121] BuiltInCall ::= Aggregate | 'STR' '(' Expression ')' diff --git a/etc/sparql11.html b/etc/sparql11.html index 325040b4..8c4bd4fc 100644 --- a/etc/sparql11.html +++ b/etc/sparql11.html @@ -61,12 +61,12 @@ ::= "CONSTRUCT" - + ( ( ConstructTemplate DatasetClause* WhereClause SolutionModifier)( DatasetClause* "WHERE" "{" TriplesTemplate? "}" SolutionModifier) ) - + ValuesClause @@ -695,7 +695,7 @@ ::= NumericExpression - + ( ( "=" NumericExpression)( "!=" NumericExpression) | ( "<" NumericExpression) | ( ">" NumericExpression) | ( "<=" NumericExpression) | ( ">=" NumericExpression) | ( "IN" ExpressionList) | ( "NOT" "IN" ExpressionList) ) ? @@ -712,7 +712,7 @@ ::= MultiplicativeExpression - + ( ( "+" MultiplicativeExpression)( "-" MultiplicativeExpression) | ( ( NumericLiteralPositive | NumericLiteralNegative) ( ( "*" UnaryExpression) | ( "/" UnaryExpression) ) ? ) ) * @@ -733,7 +733,19 @@ [119] PrimaryExpression ::= - BrackettedExpression | BuiltInCall | iriOrFunction | RDFLiteral | NumericLiteral | BooleanLiteral | Var | EmbTP + BrackettedExpression | BuiltInCall | iriOrFunction | RDFLiteral | NumericLiteral | BooleanLiteral | Var | ExprEmbTP + + + [119a] + ExprEmbTP + ::= + "<<" ExprVarOrTerm Verb ExprVarOrTerm ">>" + + + [119b] + ExprVarOrTerm + ::= + iri | RDFLiteral | NumericLiteral | BooleanLiteral | Var | ExprEmbTP [120] @@ -1221,7 +1233,7 @@ ::= EmbTD | iri | RDFLiteral | NumericLiteral | BooleanLiteral - + @terminals # Productions for terminals @@ -1338,7 +1350,7 @@ [157] STRING_LITERAL2 ::= - '"' ( [ ^#x22#x5C#x0A#x0D] | ECHAR) * '"' + '"' ( [ ^>"#x5C#x0A#x0D] | ECHAR) * '"' [158] @@ -1390,62 +1402,62 @@ | - [ #xC0-#xD6] + [ #xC0-#xD6] | - [ #xD8-#xF6] + [ #xD8-#xF6] | - [ #xF8-#x02FF] + [ #xF8-#x02FF] | - [ #x0370-#x037D] + [ #x0370-#x037D] | - [ #x037F-#x1FFF] + [ #x037F-#x1FFF] | - [ #x200C-#x200D] + [ #x200C-#x200D] | - [ #x2070-#x218F] + [ #x2070-#x218F] | - [ #x2C00-#x2FEF] + [ #x2C00-#x2FEF] | - [ #x3001-#xD7FF] + [ #x3001-#xD7FF] | - [ #xF900-#xFDCF] + [ #xF900-#xFDCF] | - [ #xFDF0-#xFFFD] + [ #xFDF0-#xFFFD] | - [ #x00010000-#x000EFFFF] + [ #x00010000-#x000EFFFF] [165] @@ -1457,13 +1469,13 @@ [166] VARNAME ::= - ( PN_CHARS_U | [ 0-9] ) ( PN_CHARS_U | [ 0-9] | #xB7 | [ #x0300-#x036F] | [ #x203F-#x2040] ) * + ( PN_CHARS_U | [ 0-9] ) ( PN_CHARS_U | [ 0-9] | #xB7 | [ #x0300-#x036F] | [ #x203F-#x2040] ) * [167] PN_CHARS ::= - PN_CHARS_U | "-" | [ 0-9] | #xB7 | [ #x0300-#x036F] | [ #x203F-#x2040] + PN_CHARS_U | "-" | [ 0-9] | #xB7 | [ #x0300-#x036F] | [ #x203F-#x2040] [168] diff --git a/etc/sparql11.ll1.sxp b/etc/sparql11.ll1.sxp index 47af81fe..46ac2b78 100644 --- a/etc/sparql11.ll1.sxp +++ b/etc/sparql11.ll1.sxp @@ -2315,7 +2315,21 @@ DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE_NEGATIVE DOUBLE_POSITIVE "IN" INTEGER_NEGATIVE INTEGER_POSITIVE "NOT" "||" ) (alt BrackettedExpression BuiltInCall iriOrFunction RDFLiteral NumericLiteral - BooleanLiteral Var EmbTP )) + BooleanLiteral Var ExprEmbTP )) + (rule ExprEmbTP "119a" + (first "<<") + (follow "!=" "&&" ")" "*" "+" "," "-" "/" ";" "<" "<=" "=" ">" ">=" ">>" "AS" + DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE_NEGATIVE DOUBLE_POSITIVE "IN" + INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF "NOT" PNAME_LN PNAME_NS VAR1 VAR2 + "a" "||" ) + (seq "<<" ExprVarOrTerm Verb ExprVarOrTerm ">>")) + (rule ExprVarOrTerm "119b" + (first "<<" DECIMAL DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE DOUBLE_NEGATIVE + DOUBLE_POSITIVE INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF PNAME_LN + PNAME_NS STRING_LITERAL1 STRING_LITERAL2 STRING_LITERAL_LONG1 + STRING_LITERAL_LONG2 VAR1 VAR2 "false" "true" ) + (follow ">>" IRIREF PNAME_LN PNAME_NS VAR1 VAR2 "a") + (alt iri RDFLiteral NumericLiteral BooleanLiteral Var ExprEmbTP)) (rule BrackettedExpression "120" (first "(") (follow "!=" "&&" "(" ")" "*" "+" "," "-" "." "/" ";" "<" "<<" "<=" "=" ">" @@ -4010,13 +4024,12 @@ (alt BLANK_NODE_LABEL ANON)) (rule EmbTP "174" (first "<<") - (follow "!" "!=" "&&" "(" ")" "*" "+" "," "-" "." "/" ";" "<" "<<" "<=" "=" - ">" ">=" ">>" ANON "AS" "BIND" BLANK_NODE_LABEL DECIMAL DECIMAL_NEGATIVE - DECIMAL_POSITIVE DOUBLE DOUBLE_NEGATIVE DOUBLE_POSITIVE "FILTER" "GRAPH" - "IN" INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF "MINUS" NIL "NOT" - "OPTIONAL" PNAME_LN PNAME_NS "SERVICE" STRING_LITERAL1 STRING_LITERAL2 - STRING_LITERAL_LONG1 STRING_LITERAL_LONG2 "VALUES" VAR1 VAR2 "[" "]" "^" "a" - "false" "true" "{" "{|" "||" "|}" "}" ) + (follow "!" "(" ")" "," "." ";" "<<" ">>" ANON "BIND" BLANK_NODE_LABEL + DECIMAL DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE DOUBLE_NEGATIVE + DOUBLE_POSITIVE "FILTER" "GRAPH" INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE + IRIREF "MINUS" NIL "OPTIONAL" PNAME_LN PNAME_NS "SERVICE" STRING_LITERAL1 + STRING_LITERAL2 STRING_LITERAL_LONG1 STRING_LITERAL_LONG2 "VALUES" VAR1 VAR2 + "[" "]" "^" "a" "false" "true" "{" "{|" "|}" "}" ) (seq "<<" EmbSubjectOrObject Verb EmbSubjectOrObject ">>")) (rule EmbSubjectOrObject "175" (first "<<" ANON BLANK_NODE_LABEL DECIMAL DECIMAL_NEGATIVE DECIMAL_POSITIVE @@ -5447,6 +5460,16 @@ DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE_NEGATIVE DOUBLE_POSITIVE "IN" INTEGER_NEGATIVE INTEGER_POSITIVE "NOT" "||" ) (seq PrimaryExpression)) + (rule _ExprEmbTP_1 "119a.1" + (first "<<" DECIMAL DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE DOUBLE_NEGATIVE + DOUBLE_POSITIVE INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF PNAME_LN + PNAME_NS STRING_LITERAL1 STRING_LITERAL2 STRING_LITERAL_LONG1 + STRING_LITERAL_LONG2 VAR1 VAR2 "false" "true" ) + (follow "!=" "&&" ")" "*" "+" "," "-" "/" ";" "<" "<=" "=" ">" ">=" ">>" "AS" + DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE_NEGATIVE DOUBLE_POSITIVE "IN" + INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF "NOT" PNAME_LN PNAME_NS VAR1 VAR2 + "a" "||" ) + (seq ExprVarOrTerm Verb ExprVarOrTerm ">>")) (rule _BrackettedExpression_1 "120.1" (first "!" "(" "+" "-" "<<" "ABS" "AVG" "BNODE" "BOUND" "CEIL" "COALESCE" "CONCAT" "CONTAINS" "COUNT" "DATATYPE" "DAY" DECIMAL DECIMAL_NEGATIVE @@ -6147,13 +6170,12 @@ DOUBLE DOUBLE_NEGATIVE DOUBLE_POSITIVE INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF PNAME_LN PNAME_NS STRING_LITERAL1 STRING_LITERAL2 STRING_LITERAL_LONG1 STRING_LITERAL_LONG2 VAR1 VAR2 "false" "true" ) - (follow "!" "!=" "&&" "(" ")" "*" "+" "," "-" "." "/" ";" "<" "<<" "<=" "=" - ">" ">=" ">>" ANON "AS" "BIND" BLANK_NODE_LABEL DECIMAL DECIMAL_NEGATIVE - DECIMAL_POSITIVE DOUBLE DOUBLE_NEGATIVE DOUBLE_POSITIVE "FILTER" "GRAPH" - "IN" INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF "MINUS" NIL "NOT" - "OPTIONAL" PNAME_LN PNAME_NS "SERVICE" STRING_LITERAL1 STRING_LITERAL2 - STRING_LITERAL_LONG1 STRING_LITERAL_LONG2 "VALUES" VAR1 VAR2 "[" "]" "^" "a" - "false" "true" "{" "{|" "||" "|}" "}" ) + (follow "!" "(" ")" "," "." ";" "<<" ">>" ANON "BIND" BLANK_NODE_LABEL + DECIMAL DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE DOUBLE_NEGATIVE + DOUBLE_POSITIVE "FILTER" "GRAPH" INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE + IRIREF "MINUS" NIL "OPTIONAL" PNAME_LN PNAME_NS "SERVICE" STRING_LITERAL1 + STRING_LITERAL2 STRING_LITERAL_LONG1 STRING_LITERAL_LONG2 "VALUES" VAR1 VAR2 + "[" "]" "^" "a" "false" "true" "{" "{|" "|}" "}" ) (seq EmbSubjectOrObject Verb EmbSubjectOrObject ">>")) (rule _AnnotationPattern_1 "177.1" (first IRIREF PNAME_LN PNAME_NS VAR1 VAR2 "a") @@ -6477,6 +6499,13 @@ STRING_LITERAL_LONG1 STRING_LITERAL_LONG2 "VALUES" VAR1 VAR2 "[" "]" "^" "a" "false" "true" "{" "{|" "|}" "}" ) (seq ")")) + (rule _ExprEmbTP_2 "119a.2" + (first IRIREF PNAME_LN PNAME_NS VAR1 VAR2 "a") + (follow "!=" "&&" ")" "*" "+" "," "-" "/" ";" "<" "<=" "=" ">" ">=" ">>" "AS" + DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE_NEGATIVE DOUBLE_POSITIVE "IN" + INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF "NOT" PNAME_LN PNAME_NS VAR1 VAR2 + "a" "||" ) + (seq Verb ExprVarOrTerm ">>")) (rule _BrackettedExpression_2 "120.2" (first ")") (follow "!=" "&&" "(" ")" "*" "+" "," "-" "." "/" ";" "<" "<<" "<=" "=" ">" @@ -7174,13 +7203,12 @@ (rule _Aggregate_33 "127.33" (first "=") (follow ")") (seq "=" String)) (rule _EmbTP_2 "174.2" (first IRIREF PNAME_LN PNAME_NS VAR1 VAR2 "a") - (follow "!" "!=" "&&" "(" ")" "*" "+" "," "-" "." "/" ";" "<" "<<" "<=" "=" - ">" ">=" ">>" ANON "AS" "BIND" BLANK_NODE_LABEL DECIMAL DECIMAL_NEGATIVE - DECIMAL_POSITIVE DOUBLE DOUBLE_NEGATIVE DOUBLE_POSITIVE "FILTER" "GRAPH" - "IN" INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF "MINUS" NIL "NOT" - "OPTIONAL" PNAME_LN PNAME_NS "SERVICE" STRING_LITERAL1 STRING_LITERAL2 - STRING_LITERAL_LONG1 STRING_LITERAL_LONG2 "VALUES" VAR1 VAR2 "[" "]" "^" "a" - "false" "true" "{" "{|" "||" "|}" "}" ) + (follow "!" "(" ")" "," "." ";" "<<" ">>" ANON "BIND" BLANK_NODE_LABEL + DECIMAL DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE DOUBLE_NEGATIVE + DOUBLE_POSITIVE "FILTER" "GRAPH" INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE + IRIREF "MINUS" NIL "OPTIONAL" PNAME_LN PNAME_NS "SERVICE" STRING_LITERAL1 + STRING_LITERAL2 STRING_LITERAL_LONG1 STRING_LITERAL_LONG2 "VALUES" VAR1 VAR2 + "[" "]" "^" "a" "false" "true" "{" "{|" "|}" "}" ) (seq Verb EmbSubjectOrObject ">>")) (rule _AnnotationPattern_2 "177.2" (first "|}") @@ -7258,6 +7286,16 @@ "isIRI" "isLITERAL" "isNUMERIC" "isTRIPLE" "isURI" "sameTerm" "true" "{" "||" "}" ) (seq _ArgList_3 ")")) + (rule _ExprEmbTP_3 "119a.3" + (first "<<" DECIMAL DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE DOUBLE_NEGATIVE + DOUBLE_POSITIVE INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF PNAME_LN + PNAME_NS STRING_LITERAL1 STRING_LITERAL2 STRING_LITERAL_LONG1 + STRING_LITERAL_LONG2 VAR1 VAR2 "false" "true" ) + (follow "!=" "&&" ")" "*" "+" "," "-" "/" ";" "<" "<=" "=" ">" ">=" ">>" "AS" + DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE_NEGATIVE DOUBLE_POSITIVE "IN" + INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF "NOT" PNAME_LN PNAME_NS VAR1 VAR2 + "a" "||" ) + (seq ExprVarOrTerm ">>")) (rule _BuiltInCall_91 "121.91" (first ",") (follow "!=" "&&" "(" ")" "*" "+" "," "-" "." "/" ";" "<" "<<" "<=" "=" ">" @@ -7593,13 +7631,12 @@ DOUBLE DOUBLE_NEGATIVE DOUBLE_POSITIVE INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF PNAME_LN PNAME_NS STRING_LITERAL1 STRING_LITERAL2 STRING_LITERAL_LONG1 STRING_LITERAL_LONG2 VAR1 VAR2 "false" "true" ) - (follow "!" "!=" "&&" "(" ")" "*" "+" "," "-" "." "/" ";" "<" "<<" "<=" "=" - ">" ">=" ">>" ANON "AS" "BIND" BLANK_NODE_LABEL DECIMAL DECIMAL_NEGATIVE - DECIMAL_POSITIVE DOUBLE DOUBLE_NEGATIVE DOUBLE_POSITIVE "FILTER" "GRAPH" - "IN" INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF "MINUS" NIL "NOT" - "OPTIONAL" PNAME_LN PNAME_NS "SERVICE" STRING_LITERAL1 STRING_LITERAL2 - STRING_LITERAL_LONG1 STRING_LITERAL_LONG2 "VALUES" VAR1 VAR2 "[" "]" "^" "a" - "false" "true" "{" "{|" "||" "|}" "}" ) + (follow "!" "(" ")" "," "." ";" "<<" ">>" ANON "BIND" BLANK_NODE_LABEL + DECIMAL DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE DOUBLE_NEGATIVE + DOUBLE_POSITIVE "FILTER" "GRAPH" INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE + IRIREF "MINUS" NIL "OPTIONAL" PNAME_LN PNAME_NS "SERVICE" STRING_LITERAL1 + STRING_LITERAL2 STRING_LITERAL_LONG1 STRING_LITERAL_LONG2 "VALUES" VAR1 VAR2 + "[" "]" "^" "a" "false" "true" "{" "{|" "|}" "}" ) (seq EmbSubjectOrObject ">>")) (rule _EmbTD_4 "179.4" (first "<<" DECIMAL DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE DOUBLE_NEGATIVE @@ -7627,6 +7664,13 @@ (first "DEFAULT" "GRAPH" IRIREF PNAME_LN PNAME_NS) (follow ";" _eof) (seq GraphOrDefault)) + (rule _ExprEmbTP_4 "119a.4" + (first ">>") + (follow "!=" "&&" ")" "*" "+" "," "-" "/" ";" "<" "<=" "=" ">" ">=" ">>" "AS" + DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE_NEGATIVE DOUBLE_POSITIVE "IN" + INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF "NOT" PNAME_LN PNAME_NS VAR1 VAR2 + "a" "||" ) + (seq ">>")) (rule _RegexExpression_7 "122.7" (first "!" "(" "+" "-" "<<" "ABS" "AVG" "BNODE" "BOUND" "CEIL" "COALESCE" "CONCAT" "CONTAINS" "COUNT" "DATATYPE" "DAY" DECIMAL DECIMAL_NEGATIVE @@ -7738,13 +7782,12 @@ (seq _Aggregate_16 ")")) (rule _EmbTP_4 "174.4" (first ">>") - (follow "!" "!=" "&&" "(" ")" "*" "+" "," "-" "." "/" ";" "<" "<<" "<=" "=" - ">" ">=" ">>" ANON "AS" "BIND" BLANK_NODE_LABEL DECIMAL DECIMAL_NEGATIVE - DECIMAL_POSITIVE DOUBLE DOUBLE_NEGATIVE DOUBLE_POSITIVE "FILTER" "GRAPH" - "IN" INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE IRIREF "MINUS" NIL "NOT" - "OPTIONAL" PNAME_LN PNAME_NS "SERVICE" STRING_LITERAL1 STRING_LITERAL2 - STRING_LITERAL_LONG1 STRING_LITERAL_LONG2 "VALUES" VAR1 VAR2 "[" "]" "^" "a" - "false" "true" "{" "{|" "||" "|}" "}" ) + (follow "!" "(" ")" "," "." ";" "<<" ">>" ANON "BIND" BLANK_NODE_LABEL + DECIMAL DECIMAL_NEGATIVE DECIMAL_POSITIVE DOUBLE DOUBLE_NEGATIVE + DOUBLE_POSITIVE "FILTER" "GRAPH" INTEGER INTEGER_NEGATIVE INTEGER_POSITIVE + IRIREF "MINUS" NIL "OPTIONAL" PNAME_LN PNAME_NS "SERVICE" STRING_LITERAL1 + STRING_LITERAL2 STRING_LITERAL_LONG1 STRING_LITERAL_LONG2 "VALUES" VAR1 VAR2 + "[" "]" "^" "a" "false" "true" "{" "{|" "|}" "}" ) (seq ">>")) (rule _EmbTD_5 "179.5" (first ">>") diff --git a/etc/sparql11.sxp b/etc/sparql11.sxp index 9b919ebe..24bef299 100644 --- a/etc/sparql11.sxp +++ b/etc/sparql11.sxp @@ -420,7 +420,10 @@ (rule _UnaryExpression_3 "118.3" (seq "-" PrimaryExpression)) (rule PrimaryExpression "119" (alt BrackettedExpression BuiltInCall iriOrFunction RDFLiteral NumericLiteral - BooleanLiteral Var EmbTP )) + BooleanLiteral Var ExprEmbTP )) + (rule ExprEmbTP "119a" (seq "<<" ExprVarOrTerm Verb ExprVarOrTerm ">>")) + (rule ExprVarOrTerm "119b" + (alt iri RDFLiteral NumericLiteral BooleanLiteral Var ExprEmbTP)) (rule BrackettedExpression "120" (seq "(" Expression ")")) (rule BuiltInCall "121" (alt Aggregate _BuiltInCall_1 _BuiltInCall_2 _BuiltInCall_3 _BuiltInCall_4 diff --git a/lib/sparql/algebra/aggregate.rb b/lib/sparql/algebra/aggregate.rb index 7e8ae6c9..6e60e79b 100644 --- a/lib/sparql/algebra/aggregate.rb +++ b/lib/sparql/algebra/aggregate.rb @@ -44,7 +44,7 @@ def aggregate(solutions = [], **options) # Enumerable yielding evaluated operands # @return [RDF::Term] # @abstract - def apply(enum) + def apply(enum, **options) raise NotImplementedError, "#{self.class}#apply(#{operands.map(&:class).join(', ')})" end diff --git a/lib/sparql/algebra/evaluatable.rb b/lib/sparql/algebra/evaluatable.rb index 15645253..85a2fd1d 100644 --- a/lib/sparql/algebra/evaluatable.rb +++ b/lib/sparql/algebra/evaluatable.rb @@ -15,16 +15,16 @@ module Evaluatable # @abstract def evaluate(bindings, **options) args = operands.map { |operand| operand.evaluate(bindings, depth: options[:depth].to_i + 1, **options) } - options[:memoize] ? memoize(*args) : apply(*args) + options[:memoize] ? memoize(*args, **options) : apply(*args, **options) end ## # @param [Array] operands # evaluated operands # @return [RDF::Term] the memoized result - def memoize(*operands) + def memoize(*operands, **options) @cache ||= RDF::Util::Cache.new(options[:memoize].is_a?(Integer) ? options[:memoize] : -1) - @cache[operands] ||= apply(*operands) + @cache[operands] ||= apply(*operands, **options) end ## @@ -32,7 +32,7 @@ def memoize(*operands) # evaluated operands # @return [RDF::Term] # @abstract - def apply(*operands) + def apply(*operands, **options) raise NotImplementedError, "#{self.class}#apply(#{operands.map(&:class).join(', ')})" end diff --git a/lib/sparql/algebra/operator.rb b/lib/sparql/algebra/operator.rb index 2224a6ba..a2e4ccba 100644 --- a/lib/sparql/algebra/operator.rb +++ b/lib/sparql/algebra/operator.rb @@ -314,8 +314,8 @@ def self.for(name, arity = nil) # @param [Array] operands # @return [RDF::Term] # @see Operator#evaluate - def self.evaluate(*operands) - self.new(*operands).evaluate(RDF::Query::Solution.new) + def self.evaluate(*operands, **options) + self.new(*operands, **options).evaluate(RDF::Query::Solution.new, **options) end ## diff --git a/lib/sparql/algebra/operator/abs.rb b/lib/sparql/algebra/operator/abs.rb index cdcb547e..5692a815 100644 --- a/lib/sparql/algebra/operator/abs.rb +++ b/lib/sparql/algebra/operator/abs.rb @@ -20,7 +20,7 @@ class Abs < Operator::Unary # the operand # @return [RDF::Literal] literal of same type # @raise [TypeError] if the operand is not a numeric value - def apply(operand) + def apply(operand, **options) case operand when RDF::Literal::Numeric then operand.abs else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}" diff --git a/lib/sparql/algebra/operator/avg.rb b/lib/sparql/algebra/operator/avg.rb index 947ed7a3..7f6c81ee 100644 --- a/lib/sparql/algebra/operator/avg.rb +++ b/lib/sparql/algebra/operator/avg.rb @@ -29,7 +29,7 @@ def initialize(*operands, **options) # @param [Enumerable>] enum # enum of evaluated operand # @return [RDF::Literal::Numeric] The numeric average of the terms - def apply(enum) + def apply(enum, **options) # FIXME: we don't actually do anything with distinct operands.shift if distinct = (operands.first == :distinct) if enum.empty? diff --git a/lib/sparql/algebra/operator/bnode.rb b/lib/sparql/algebra/operator/bnode.rb index f32f6328..e37c90ab 100644 --- a/lib/sparql/algebra/operator/bnode.rb +++ b/lib/sparql/algebra/operator/bnode.rb @@ -57,7 +57,7 @@ def evaluate(bindings, **options) # a query solution containing zero or more variable bindings # @return [RDF::Node] # @raise [TypeError] if the operand is not a simple literal or nil - def apply(literal, bindings) + def apply(literal, bindings, **options) @@bnode_base ||= "b0" @@bindings ||= bindings @@bnodes ||= {} diff --git a/lib/sparql/algebra/operator/ceil.rb b/lib/sparql/algebra/operator/ceil.rb index b1921d25..dba923bc 100644 --- a/lib/sparql/algebra/operator/ceil.rb +++ b/lib/sparql/algebra/operator/ceil.rb @@ -20,7 +20,7 @@ class Ceil < Operator::Unary # the operand # @return [RDF::Literal] literal of same type # @raise [TypeError] if the operand is not a numeric value - def apply(operand) + def apply(operand, **options) case operand when RDF::Literal::Numeric then operand.ceil else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}" diff --git a/lib/sparql/algebra/operator/compare.rb b/lib/sparql/algebra/operator/compare.rb index ef19f465..4927a8ee 100644 --- a/lib/sparql/algebra/operator/compare.rb +++ b/lib/sparql/algebra/operator/compare.rb @@ -30,69 +30,68 @@ class Compare < Operator::Binary # @param [RDF::Literal] right # a literal # @return [RDF::Literal::Integer] `-1`, `0`, or `1` - # @raise [TypeError] if either operand is not a literal - def apply(left, right) + # @raise [TypeError] if either operand is not a term + def apply(left, right, **options) + RDF::Literal(spaceship(left, right, **options)) + end + + private + # Define <=> as private for recursive statements + def spaceship(left, right, **options) case # @see https://www.w3.org/TR/sparql11-query/#OperatorMapping # @see https://www.w3.org/TR/sparql11-query/#modOrderBy when left.is_a?(RDF::Literal) && right.is_a?(RDF::Literal) - case # @see https://www.w3.org/TR/xpath-functions/#string-compare # @see https://www.w3.org/TR/xpath-functions/#comp.numeric # @see https://www.w3.org/TR/xpath-functions/#op.boolean # @see https://www.w3.org/TR/xpath-functions/#comp.duration.datetime - when (left.simple? && right.simple?) || - (left.is_a?(RDF::Literal::Numeric) && right.is_a?(RDF::Literal::Numeric)) || - (left.datatype == right.datatype && left.language == right.language) - RDF::Literal(left.send(self.class.const_get(:NAME), right)) - - # A plain literal is lower than an RDF literal with type xsd:string of the same lexical form. - when left.simple? && right.datatype == RDF::XSD.string && left.value == right.value - RDF::Literal(-1) - when right.simple? && left.datatype == RDF::XSD.string && right.value == left.value - RDF::Literal(-1) - - else - left <=> right - end - + left <=> right when left.is_a?(RDF::URI) && right.is_a?(RDF::URI) + raise TypeError, "Comparing IRIs not supported" unless options[:order_by] || left == right # Pairs of IRIs are ordered by comparing them as simple literals. - RDF::Literal(RDF::Literal(left.to_s).send(self.class.const_get(:NAME), RDF::Literal(right.to_s))) + left.to_s <=> right.to_s when left.is_a?(RDF::Node) && right.is_a?(RDF::Node) + raise TypeError, "Comparing Blank nodes not supported" unless options[:order_by] || left == right # BNode comparison is undefined. - RDF::Literal(0) - when left.is_a?(RDF::Statement) && right.is_a?(RDF::Statement) - RDF::Literal(RDF::Literal(left.to_s).send(self.class.const_get(:NAME), RDF::Literal(right.to_s))) + left == right ? 0 : 1 when left.nil? && right.nil? - RDF::Literal(0) - + 0 + + when left.is_a?(RDF::Statement) && right.is_a?(RDF::Statement) + v = spaceship(left.subject, right.subject, **options) + v = spaceship(left.predicate, right.predicate, **options) if v == 0 + v = spaceship(left.object, right.object, **options) if v == 0 + v + when left.is_a?(RDF::Statement) && right.is_a?(RDF::Term) + raise TypeError, "Comparing statement with #{right.inspect}" unless options[:order_by] + 1 + when right.is_a?(RDF::Statement) && left.is_a?(RDF::Term) + raise TypeError, "Comparing statement with #{left.inspect}" unless options[:order_by] + -1 + # SPARQL also fixes an order between some kinds of RDF terms that would not otherwise be ordered: when left.nil? && !right.nil? - RDF::Literal(-1) + -1 when right.nil? - RDF::Literal(1) + 1 when left.is_a?(RDF::Node) && right.is_a?(RDF::Term) - RDF::Literal(-1) + raise TypeError, "Comparing Blank nodes not supported" unless options[:order_by] + # Nodes lower than other terms + -1 when right.is_a?(RDF::Node) && left.is_a?(RDF::Term) - RDF::Literal(1) - - when left.is_a?(RDF::Statement) && right.is_a?(RDF::Term) - RDF::Literal(-1) - when right.is_a?(RDF::Statement) && left.is_a?(RDF::Term) - RDF::Literal(1) - - when left.is_a?(RDF::Node) && right.is_a?(RDF::URI) - RDF::Literal(-1) - when right.is_a?(RDF::Node) && left.is_a?(RDF::URI) - RDF::Literal(1) + raise TypeError, "Comparing Blank nodes not supported" unless options[:order_by] + 1 when left.is_a?(RDF::URI) && right.is_a?(RDF::Term) - RDF::Literal(-1) + raise TypeError, "Comparing IRIs not supported" unless options[:order_by] + # IRIs lower than terms other than nodes + -1 when right.is_a?(RDF::URI) && left.is_a?(RDF::Term) - RDF::Literal(1) + raise TypeError, "Comparing IRIs not supported" unless options[:order_by] + 1 else raise TypeError, "expected two RDF::Term operands, but got #{left.inspect} and #{right.inspect}" end end diff --git a/lib/sparql/algebra/operator/contains.rb b/lib/sparql/algebra/operator/contains.rb index dbb3e86b..4ca705f1 100644 --- a/lib/sparql/algebra/operator/contains.rb +++ b/lib/sparql/algebra/operator/contains.rb @@ -31,7 +31,7 @@ class Contains < Operator::Binary # a literal # @return [RDF::Literal::Boolean] # @raise [TypeError] if operands are not compatible - def apply(left, right) + def apply(left, right, **options) case when !left.compatible?(right) raise TypeError, "expected two RDF::Literal operands, but got #{left.inspect} and #{right.inspect}" diff --git a/lib/sparql/algebra/operator/count.rb b/lib/sparql/algebra/operator/count.rb index a257f437..a3578dc8 100644 --- a/lib/sparql/algebra/operator/count.rb +++ b/lib/sparql/algebra/operator/count.rb @@ -22,7 +22,7 @@ class Count < Operator # @param [Enumerable>] enum # enum of evaluated operand # @return [RDF::Literal::Integer] The number of non-error terms in the multiset - def apply(enum) + def apply(enum, **options) RDF::Literal(enum.length) end end # Count diff --git a/lib/sparql/algebra/operator/datatype.rb b/lib/sparql/algebra/operator/datatype.rb index 904eb66a..4eba701f 100644 --- a/lib/sparql/algebra/operator/datatype.rb +++ b/lib/sparql/algebra/operator/datatype.rb @@ -27,7 +27,7 @@ class Datatype < Operator::Unary # a typed or simple literal # @return [RDF::URI] the datatype IRI, or `xsd:string` for simple literals # @raise [TypeError] if the operand is not a typed or simple literal - def apply(literal) + def apply(literal, **options) case literal when RDF::Literal then literal.datatype else raise TypeError, "expected an RDF::Literal, but got #{literal.inspect}" diff --git a/lib/sparql/algebra/operator/day.rb b/lib/sparql/algebra/operator/day.rb index 0eee3d79..6f8cf221 100644 --- a/lib/sparql/algebra/operator/day.rb +++ b/lib/sparql/algebra/operator/day.rb @@ -22,7 +22,7 @@ class Day < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime) RDF::Literal(operand.object.day) end diff --git a/lib/sparql/algebra/operator/divide.rb b/lib/sparql/algebra/operator/divide.rb index 86dd8cd1..0543977a 100644 --- a/lib/sparql/algebra/operator/divide.rb +++ b/lib/sparql/algebra/operator/divide.rb @@ -21,7 +21,7 @@ class Divide < Operator::Binary # a numeric literal # @return [RDF::Literal::Numeric] # @raise [TypeError] if either operand is not a numeric literal - def apply(left, right) + def apply(left, right, **options) case when left.is_a?(RDF::Literal::Numeric) && right.is_a?(RDF::Literal::Numeric) # For xsd:decimal and xsd:integer operands, if the divisor is diff --git a/lib/sparql/algebra/operator/encode_for_uri.rb b/lib/sparql/algebra/operator/encode_for_uri.rb index 752570c6..547836ec 100644 --- a/lib/sparql/algebra/operator/encode_for_uri.rb +++ b/lib/sparql/algebra/operator/encode_for_uri.rb @@ -27,7 +27,7 @@ class EncodeForURI < Operator::Unary # the operand # @return [RDF::Literal] literal of same type # @raise [TypeError] if the operand is not a literal value - def apply(operand) + def apply(operand, **options) case operand when RDF::Literal then RDF::Literal(CGI.escape(operand.to_s)) else raise TypeError, "expected an RDF::Literal, but got #{operand.inspect}" diff --git a/lib/sparql/algebra/operator/equal.rb b/lib/sparql/algebra/operator/equal.rb index a4017310..302abbfc 100644 --- a/lib/sparql/algebra/operator/equal.rb +++ b/lib/sparql/algebra/operator/equal.rb @@ -26,7 +26,7 @@ class Equal < Compare # @raise [TypeError] if either operand is not an RDF term or operands are not comperable # # @see RDF::Term#== - def apply(term1, term2) + def apply(term1, term2, **options) term1 = term1.dup.extend(RDF::TypeCheck) term2 = term2.dup.extend(RDF::TypeCheck) RDF::Literal(term1 == term2) diff --git a/lib/sparql/algebra/operator/floor.rb b/lib/sparql/algebra/operator/floor.rb index a5e425a5..21e13c46 100644 --- a/lib/sparql/algebra/operator/floor.rb +++ b/lib/sparql/algebra/operator/floor.rb @@ -24,7 +24,7 @@ class Floor < Operator::Unary # the operand # @return [RDF::Literal] literal of same type # @raise [TypeError] if the operand is not a numeric value - def apply(operand) + def apply(operand, **options) case operand when RDF::Literal::Numeric then operand.floor else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}" diff --git a/lib/sparql/algebra/operator/greater_than.rb b/lib/sparql/algebra/operator/greater_than.rb index bf94c729..6ad9f0f8 100644 --- a/lib/sparql/algebra/operator/greater_than.rb +++ b/lib/sparql/algebra/operator/greater_than.rb @@ -24,8 +24,9 @@ class GreaterThan < Compare # a literal # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if either operand is not a literal - def apply(left, right) - super + def apply(left, right, **options) + #require 'byebug'; byebug if super == RDF::Literal(1) + RDF::Literal(super == RDF::Literal(1)) end end # GreaterThan end # Operator diff --git a/lib/sparql/algebra/operator/greater_than_or_equal.rb b/lib/sparql/algebra/operator/greater_than_or_equal.rb index 9952a2d1..bc8f8dd6 100644 --- a/lib/sparql/algebra/operator/greater_than_or_equal.rb +++ b/lib/sparql/algebra/operator/greater_than_or_equal.rb @@ -25,8 +25,8 @@ class GreaterThanOrEqual < Compare # a literal # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if either operand is not a literal - def apply(left, right) - super + def apply(left, right, **options) + RDF::Literal(super >= RDF::Literal(0)) end end # GreaterThanOrEqual end # Operator diff --git a/lib/sparql/algebra/operator/group_concat.rb b/lib/sparql/algebra/operator/group_concat.rb index 69122f57..59afa500 100644 --- a/lib/sparql/algebra/operator/group_concat.rb +++ b/lib/sparql/algebra/operator/group_concat.rb @@ -50,7 +50,7 @@ def aggregate(solutions = [], **options) # enum of evaluated operand # @return [RDF::Term] An arbitrary term # @raise [TypeError] If enum is empty - def apply(enum, separator) + def apply(enum, separator, **options) RDF::Literal(enum.flatten.map(&:to_s).join(separator.to_s)) end end # GroupConcat diff --git a/lib/sparql/algebra/operator/hours.rb b/lib/sparql/algebra/operator/hours.rb index 6747bd9c..3144c9df 100644 --- a/lib/sparql/algebra/operator/hours.rb +++ b/lib/sparql/algebra/operator/hours.rb @@ -22,7 +22,7 @@ class Hours < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime) RDF::Literal(operand.object.hour) end diff --git a/lib/sparql/algebra/operator/iri.rb b/lib/sparql/algebra/operator/iri.rb index a04e85c2..2ce25589 100644 --- a/lib/sparql/algebra/operator/iri.rb +++ b/lib/sparql/algebra/operator/iri.rb @@ -29,7 +29,7 @@ class IRI < Operator::Unary # a simple literal # @return [RDF::URI] # @raise [TypeError] if the operand is not a simple literal - def apply(literal) + def apply(literal, **options) raise TypeError, "expected an simple literal, but got #{literal.inspect}" unless literal.literal? && literal.simple? base = Operator.base_uri || RDF::URI("") base.join(literal.to_s) diff --git a/lib/sparql/algebra/operator/is_blank.rb b/lib/sparql/algebra/operator/is_blank.rb index ad62aef7..ac547f04 100644 --- a/lib/sparql/algebra/operator/is_blank.rb +++ b/lib/sparql/algebra/operator/is_blank.rb @@ -23,7 +23,7 @@ class IsBlank < Operator::Unary # an RDF term # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if the operand is not an RDF term - def apply(term) + def apply(term, **options) case term when RDF::Node then RDF::Literal::TRUE when RDF::Term then RDF::Literal::FALSE diff --git a/lib/sparql/algebra/operator/is_iri.rb b/lib/sparql/algebra/operator/is_iri.rb index db3651ff..72233b82 100644 --- a/lib/sparql/algebra/operator/is_iri.rb +++ b/lib/sparql/algebra/operator/is_iri.rb @@ -23,7 +23,7 @@ class IsIRI < Operator::Unary # an RDF term # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if the operand is not an RDF term - def apply(term) + def apply(term, **options) case term when RDF::URI then RDF::Literal::TRUE when RDF::Term then RDF::Literal::FALSE diff --git a/lib/sparql/algebra/operator/is_literal.rb b/lib/sparql/algebra/operator/is_literal.rb index 2646c4f3..6f33f9a1 100644 --- a/lib/sparql/algebra/operator/is_literal.rb +++ b/lib/sparql/algebra/operator/is_literal.rb @@ -24,7 +24,7 @@ class IsLiteral < Operator::Unary # an RDF term # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if the operand is not an RDF term - def apply(term) + def apply(term, **options) case term when RDF::Literal then RDF::Literal::TRUE when RDF::Term then RDF::Literal::FALSE diff --git a/lib/sparql/algebra/operator/is_numeric.rb b/lib/sparql/algebra/operator/is_numeric.rb index 8ac0149c..f8eca138 100644 --- a/lib/sparql/algebra/operator/is_numeric.rb +++ b/lib/sparql/algebra/operator/is_numeric.rb @@ -26,7 +26,7 @@ class IsNumeric < Operator::Unary # an RDF term # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if the operand is not an RDF term - def apply(term) + def apply(term, **options) case term when RDF::Literal::NonPositiveInteger then RDF::Literal::FALSE when RDF::Literal::NonNegativeInteger then RDF::Literal::FALSE diff --git a/lib/sparql/algebra/operator/is_triple.rb b/lib/sparql/algebra/operator/is_triple.rb index c485343f..5b1cf02e 100644 --- a/lib/sparql/algebra/operator/is_triple.rb +++ b/lib/sparql/algebra/operator/is_triple.rb @@ -18,7 +18,7 @@ class IsTriple < Operator::Unary # an RDF term # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if the operand is not an RDF term - def apply(term) + def apply(term, **options) case term when RDF::Statement then RDF::Literal::TRUE when RDF::Term then RDF::Literal::FALSE diff --git a/lib/sparql/algebra/operator/lang.rb b/lib/sparql/algebra/operator/lang.rb index bbd82158..9b5e7dab 100644 --- a/lib/sparql/algebra/operator/lang.rb +++ b/lib/sparql/algebra/operator/lang.rb @@ -18,7 +18,7 @@ class Lang < Operator::Unary # a literal # @return [RDF::Literal] a simple literal # @raise [TypeError] if the operand is not a literal - def apply(literal) + def apply(literal, **options) case literal when RDF::Literal then RDF::Literal(literal.language.to_s) else raise TypeError, "expected an RDF::Literal, but got #{literal.inspect}" diff --git a/lib/sparql/algebra/operator/lang_matches.rb b/lib/sparql/algebra/operator/lang_matches.rb index 5d9a3ec9..1c068e3d 100644 --- a/lib/sparql/algebra/operator/lang_matches.rb +++ b/lib/sparql/algebra/operator/lang_matches.rb @@ -27,7 +27,7 @@ class LangMatches < Operator::Binary # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if either operand is unbound # @raise [TypeError] if either operand is not a simple literal - def apply(language_tag, language_range) + def apply(language_tag, language_range, **options) raise TypeError, "expected a plain RDF::Literal for language_tag, but got #{language_tag.inspect}" unless language_tag.is_a?(RDF::Literal) && language_tag.simple? language_tag = language_tag.to_s.downcase diff --git a/lib/sparql/algebra/operator/lcase.rb b/lib/sparql/algebra/operator/lcase.rb index 70db2e99..ee76bb4d 100644 --- a/lib/sparql/algebra/operator/lcase.rb +++ b/lib/sparql/algebra/operator/lcase.rb @@ -20,7 +20,7 @@ class LCase < Operator::Unary # the operand # @return [RDF::Literal] literal of same type # @raise [TypeError] if the operand is not a literal value - def apply(operand) + def apply(operand, **options) case operand when RDF::Literal then RDF::Literal(operand.to_s.downcase, datatype: operand.datatype, language: operand.language) else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}" diff --git a/lib/sparql/algebra/operator/less_than.rb b/lib/sparql/algebra/operator/less_than.rb index 6c5c5b5b..98a584e5 100644 --- a/lib/sparql/algebra/operator/less_than.rb +++ b/lib/sparql/algebra/operator/less_than.rb @@ -24,8 +24,9 @@ class LessThan < Compare # a literal # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if either operand is not a literal - def apply(left, right) - super + def apply(left, right, **options) + #require 'byebug'; byebug if super == RDF::Literal(-1) + RDF::Literal(super == RDF::Literal(-1)) end end # LessThan end # Operator diff --git a/lib/sparql/algebra/operator/less_than_or_equal.rb b/lib/sparql/algebra/operator/less_than_or_equal.rb index cc65731a..8b1cc5c9 100644 --- a/lib/sparql/algebra/operator/less_than_or_equal.rb +++ b/lib/sparql/algebra/operator/less_than_or_equal.rb @@ -24,8 +24,8 @@ class LessThanOrEqual < Compare # a literal # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if either operand is not a literal - def apply(left, right) - super + def apply(left, right, **options) + RDF::Literal(super <= RDF::Literal(0)) end end # LessThanOrEqual end # Operator diff --git a/lib/sparql/algebra/operator/max.rb b/lib/sparql/algebra/operator/max.rb index 64b3969e..002f5857 100644 --- a/lib/sparql/algebra/operator/max.rb +++ b/lib/sparql/algebra/operator/max.rb @@ -31,7 +31,7 @@ def initialize(*operands, **options) # @param [Enumerable>] enum # enum of evaluated operand # @return [RDF::Literal] The maximum value of the terms - def apply(enum) + def apply(enum, **options) # FIXME: we don't actually do anything with distinct operands.shift if distinct = (operands.first == :distinct) if enum.empty? diff --git a/lib/sparql/algebra/operator/md5.rb b/lib/sparql/algebra/operator/md5.rb index 533df2f2..bdcaf962 100644 --- a/lib/sparql/algebra/operator/md5.rb +++ b/lib/sparql/algebra/operator/md5.rb @@ -26,7 +26,7 @@ class MD5 < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Literal, but got #{operand.inspect}" unless operand.literal? raise TypeError, "expected simple literal or xsd:string, but got #{operand.inspect}" unless (operand.datatype || RDF::XSD.string) == RDF::XSD.string RDF::Literal(Digest::MD5.new.hexdigest(operand.to_s)) diff --git a/lib/sparql/algebra/operator/min.rb b/lib/sparql/algebra/operator/min.rb index 84aef96c..b2520587 100644 --- a/lib/sparql/algebra/operator/min.rb +++ b/lib/sparql/algebra/operator/min.rb @@ -31,7 +31,7 @@ def initialize(*operands, **options) # @param [Enumerable>] enum # enum of evaluated operand # @return [RDF::Literal] The maximum value of the terms - def apply(enum) + def apply(enum, **options) # FIXME: we don't actually do anything with distinct operands.shift if distinct = (operands.first == :distinct) if enum.empty? diff --git a/lib/sparql/algebra/operator/minutes.rb b/lib/sparql/algebra/operator/minutes.rb index cc4868df..70576892 100644 --- a/lib/sparql/algebra/operator/minutes.rb +++ b/lib/sparql/algebra/operator/minutes.rb @@ -24,7 +24,7 @@ class Minutes < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime) RDF::Literal(operand.object.minute) end diff --git a/lib/sparql/algebra/operator/month.rb b/lib/sparql/algebra/operator/month.rb index 8cf61f84..a82f3beb 100644 --- a/lib/sparql/algebra/operator/month.rb +++ b/lib/sparql/algebra/operator/month.rb @@ -24,7 +24,7 @@ class Month < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime) RDF::Literal(operand.object.month) end diff --git a/lib/sparql/algebra/operator/multiply.rb b/lib/sparql/algebra/operator/multiply.rb index 4ed31f08..2eba25ef 100644 --- a/lib/sparql/algebra/operator/multiply.rb +++ b/lib/sparql/algebra/operator/multiply.rb @@ -22,7 +22,7 @@ class Multiply < Operator::Binary # a numeric literal # @return [RDF::Literal::Numeric] # @raise [TypeError] if either operand is not a numeric literal - def apply(left, right) + def apply(left, right, **options) case when left.is_a?(RDF::Literal::Numeric) && right.is_a?(RDF::Literal::Numeric) left * right diff --git a/lib/sparql/algebra/operator/negate.rb b/lib/sparql/algebra/operator/negate.rb index ccf3a052..c583c837 100644 --- a/lib/sparql/algebra/operator/negate.rb +++ b/lib/sparql/algebra/operator/negate.rb @@ -20,7 +20,7 @@ class Negate < Operator::Unary # a numeric literal # @return [RDF::Literal::Numeric] # @raise [TypeError] if the operand is not a numeric literal - def apply(term) + def apply(term, **options) case term when RDF::Literal::Numeric then -term else raise TypeError, "expected an RDF::Literal::Numeric, but got #{term.inspect}" diff --git a/lib/sparql/algebra/operator/not.rb b/lib/sparql/algebra/operator/not.rb index e2676e8c..80c2da7f 100644 --- a/lib/sparql/algebra/operator/not.rb +++ b/lib/sparql/algebra/operator/not.rb @@ -23,7 +23,7 @@ class Not < Operator::Unary # the operand # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if the operand could not be coerced to a boolean literal - def apply(operand) + def apply(operand, **options) case bool = boolean(operand) when RDF::Literal::Boolean RDF::Literal(bool.false?) diff --git a/lib/sparql/algebra/operator/not_equal.rb b/lib/sparql/algebra/operator/not_equal.rb index 25b00a93..7b8f6242 100644 --- a/lib/sparql/algebra/operator/not_equal.rb +++ b/lib/sparql/algebra/operator/not_equal.rb @@ -12,13 +12,15 @@ class NotEqual < Equal # Returns `true` if the operands are not equal; returns `false` # otherwise. # + # Comparing unknown datatypes might have different lexical forms but be the same value. + # # @param [RDF::Term] term1 # an RDF term # @param [RDF::Term] term2 # an RDF term # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if either operand is not an RDF term - def apply(term1, term2) + def apply(term1, term2, **options) RDF::Literal(super.false?) end end # NotEqual diff --git a/lib/sparql/algebra/operator/now.rb b/lib/sparql/algebra/operator/now.rb index 5fb380d7..51594ee5 100644 --- a/lib/sparql/algebra/operator/now.rb +++ b/lib/sparql/algebra/operator/now.rb @@ -23,7 +23,7 @@ class Now < Operator::Nullary # Returns an XSD dateTime value for the current query execution. All calls to this function in any one query execution must return the same value. The exact moment returned is not specified. # # @return [RDF::Literal::Double] random value - def apply + def apply(**options) RDF::Literal(DateTime.now) end end # Now diff --git a/lib/sparql/algebra/operator/object.rb b/lib/sparql/algebra/operator/object.rb index fb7336d3..1d08e8fb 100644 --- a/lib/sparql/algebra/operator/object.rb +++ b/lib/sparql/algebra/operator/object.rb @@ -18,7 +18,7 @@ class Object < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a statement - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Statement, but got #{operand.inspect}" unless operand.is_a?(RDF::Statement) operand.object end diff --git a/lib/sparql/algebra/operator/order.rb b/lib/sparql/algebra/operator/order.rb index 162729f0..0426ff64 100644 --- a/lib/sparql/algebra/operator/order.rb +++ b/lib/sparql/algebra/operator/order.rb @@ -40,7 +40,13 @@ def execute(queryable, **options, &block) memo = begin a_eval = op.evaluate(a, queryable: queryable, depth: options[:depth].to_i + 1, **options) rescue nil b_eval = op.evaluate(b, queryable: queryable, depth: options[:depth].to_i + 1, **options) rescue nil - comp = Operator::Compare.evaluate(a_eval, b_eval).to_i + comp = begin + Operator::Compare.evaluate(a_eval, b_eval, order_by: true).to_s.to_i + rescue TypeError + # Type sError is effectively zero + debug(options) {"(order) rescue(#{$!}): #{a_eval.inspect}, #{b_eval.inspect}"} + RDF::Literal(0) + end comp = -comp if op.is_a?(Operator::Desc) comp end if memo == 0 diff --git a/lib/sparql/algebra/operator/plus.rb b/lib/sparql/algebra/operator/plus.rb index ee01cbbe..bea09a24 100644 --- a/lib/sparql/algebra/operator/plus.rb +++ b/lib/sparql/algebra/operator/plus.rb @@ -23,7 +23,7 @@ class Plus < Operator # a numeric literal # @return [RDF::Literal::Numeric] # @raise [TypeError] if either operand is not a numeric literal - def apply(left, right = nil) + def apply(left, right = nil, **options) case when left.is_a?(RDF::Literal::Numeric) && right.is_a?(RDF::Literal::Numeric) left + right diff --git a/lib/sparql/algebra/operator/predicate.rb b/lib/sparql/algebra/operator/predicate.rb index 7b2537b4..d2f746ab 100644 --- a/lib/sparql/algebra/operator/predicate.rb +++ b/lib/sparql/algebra/operator/predicate.rb @@ -18,7 +18,7 @@ class Predicate < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a statement - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Statement, but got #{operand.inspect}" unless operand.is_a?(RDF::Statement) operand.predicate end diff --git a/lib/sparql/algebra/operator/rand.rb b/lib/sparql/algebra/operator/rand.rb index 2f5f1806..2e503db4 100644 --- a/lib/sparql/algebra/operator/rand.rb +++ b/lib/sparql/algebra/operator/rand.rb @@ -18,7 +18,7 @@ class Rand < Operator::Nullary # Returns a pseudo-random number between 0 (inclusive) and 1.0e0 (exclusive). Different numbers can be produced every time this function is invoked. Numbers should be produced with approximately equal probability. # # @return [RDF::Literal::Double] random value - def apply + def apply(**options) RDF::Literal::Double.new(Random.rand) end end # Rand diff --git a/lib/sparql/algebra/operator/regex.rb b/lib/sparql/algebra/operator/regex.rb index 177d74e1..ecc4a836 100644 --- a/lib/sparql/algebra/operator/regex.rb +++ b/lib/sparql/algebra/operator/regex.rb @@ -42,7 +42,7 @@ def initialize(text, pattern, flags = RDF::Literal(''), **options) # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if any operand is unbound # @raise [TypeError] if any operand is not a simple literal - def apply(text, pattern, flags = RDF::Literal('')) + def apply(text, pattern, flags = RDF::Literal(''), **options) # @see https://www.w3.org/TR/xpath-functions/#regex-syntax raise TypeError, "expected a plain RDF::Literal, but got #{text.inspect}" unless text.is_a?(RDF::Literal) && text.plain? text = text.to_s diff --git a/lib/sparql/algebra/operator/replace.rb b/lib/sparql/algebra/operator/replace.rb index d31031d6..281c965d 100644 --- a/lib/sparql/algebra/operator/replace.rb +++ b/lib/sparql/algebra/operator/replace.rb @@ -42,7 +42,7 @@ def initialize(text, pattern, replacement, flags = RDF::Literal(''), **options) # @return [RDF::Literal] # @raise [TypeError] if any operand is unbound # @raise [TypeError] if any operand is not a plain literal - def apply(text, pattern, replacement, flags = RDF::Literal('')) + def apply(text, pattern, replacement, flags = RDF::Literal(''), **options) raise TypeError, "expected a plain RDF::Literal, but got #{text.inspect}" unless text.literal? && text.plain? # TODO: validate text syntax diff --git a/lib/sparql/algebra/operator/round.rb b/lib/sparql/algebra/operator/round.rb index b7083123..feafd738 100644 --- a/lib/sparql/algebra/operator/round.rb +++ b/lib/sparql/algebra/operator/round.rb @@ -22,7 +22,7 @@ class Round < Operator::Unary # the operand # @return [RDF::Literal] literal of same type # @raise [TypeError] if the operand is not a numeric value - def apply(operand) + def apply(operand, **options) case operand when RDF::Literal::Numeric then operand.round else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}" diff --git a/lib/sparql/algebra/operator/same_term.rb b/lib/sparql/algebra/operator/same_term.rb index cf2968dc..4cf5646a 100644 --- a/lib/sparql/algebra/operator/same_term.rb +++ b/lib/sparql/algebra/operator/same_term.rb @@ -26,7 +26,7 @@ class SameTerm < Operator::Binary # an RDF term # @return [RDF::Literal::Boolean] `true` or `false` # @raise [TypeError] if either operand is unbound - def apply(term1, term2) + def apply(term1, term2, **options) RDF::Literal(term1.eql?(term2)) end diff --git a/lib/sparql/algebra/operator/sample.rb b/lib/sparql/algebra/operator/sample.rb index b87046dd..a1d6f77c 100644 --- a/lib/sparql/algebra/operator/sample.rb +++ b/lib/sparql/algebra/operator/sample.rb @@ -31,7 +31,7 @@ def initialize(*operands, **options) # enum of evaluated operand # @return [RDF::Term] An arbitrary term # @raise [TypeError] If enum is empty - def apply(enum) + def apply(enum, **options) enum.detect(lambda {raise TypeError, "Sampling an empty multiset"}) {|e| e.first}.first end end # LCase diff --git a/lib/sparql/algebra/operator/seconds.rb b/lib/sparql/algebra/operator/seconds.rb index 8c61d080..bb6b7fd7 100644 --- a/lib/sparql/algebra/operator/seconds.rb +++ b/lib/sparql/algebra/operator/seconds.rb @@ -24,7 +24,7 @@ class Seconds < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime) RDF::Literal(operand.object.second) end diff --git a/lib/sparql/algebra/operator/sha1.rb b/lib/sparql/algebra/operator/sha1.rb index 11be2791..f29be4d7 100644 --- a/lib/sparql/algebra/operator/sha1.rb +++ b/lib/sparql/algebra/operator/sha1.rb @@ -26,7 +26,7 @@ class SHA1 < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Literal, but got #{operand.inspect}" unless operand.literal? raise TypeError, "expected simple literal or xsd:string, but got #{operand.inspect}" unless (operand.datatype || RDF::XSD.string) == RDF::XSD.string RDF::Literal(Digest::SHA1.new.hexdigest(operand.to_s)) diff --git a/lib/sparql/algebra/operator/sha256.rb b/lib/sparql/algebra/operator/sha256.rb index a06eb6af..273f9d0e 100644 --- a/lib/sparql/algebra/operator/sha256.rb +++ b/lib/sparql/algebra/operator/sha256.rb @@ -26,7 +26,7 @@ class SHA256 < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Literal, but got #{operand.inspect}" unless operand.literal? raise TypeError, "expected simple literal or xsd:string, but got #{operand.inspect}" unless (operand.datatype || RDF::XSD.string) == RDF::XSD.string RDF::Literal(Digest::SHA256.new.hexdigest(operand.to_s)) diff --git a/lib/sparql/algebra/operator/sha384.rb b/lib/sparql/algebra/operator/sha384.rb index 7764f829..fe612802 100644 --- a/lib/sparql/algebra/operator/sha384.rb +++ b/lib/sparql/algebra/operator/sha384.rb @@ -26,7 +26,7 @@ class SHA384 < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Literal, but got #{operand.inspect}" unless operand.literal? raise TypeError, "expected simple literal or xsd:string, but got #{operand.inspect}" unless (operand.datatype || RDF::XSD.string) == RDF::XSD.string RDF::Literal(Digest::SHA384.new.hexdigest(operand.to_s)) diff --git a/lib/sparql/algebra/operator/sha512.rb b/lib/sparql/algebra/operator/sha512.rb index 47c46a3c..9f54d706 100644 --- a/lib/sparql/algebra/operator/sha512.rb +++ b/lib/sparql/algebra/operator/sha512.rb @@ -26,7 +26,7 @@ class SHA512 < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Literal, but got #{operand.inspect}" unless operand.literal? raise TypeError, "expected simple literal or xsd:string, but got #{operand.inspect}" unless (operand.datatype || RDF::XSD.string) == RDF::XSD.string RDF::Literal(Digest::SHA512.new.hexdigest(operand.to_s)) diff --git a/lib/sparql/algebra/operator/str.rb b/lib/sparql/algebra/operator/str.rb index e30382fb..58623745 100644 --- a/lib/sparql/algebra/operator/str.rb +++ b/lib/sparql/algebra/operator/str.rb @@ -23,7 +23,7 @@ class Str < Operator::Unary # a literal or IRI # @return [RDF::Literal] a simple literal # @raise [TypeError] if the operand is not a literal or IRI - def apply(term) + def apply(term, **options) case term when RDF::Literal then RDF::Literal(term.value) when RDF::URI then RDF::Literal(term.to_s) diff --git a/lib/sparql/algebra/operator/strafter.rb b/lib/sparql/algebra/operator/strafter.rb index 197d865a..02d42fd9 100644 --- a/lib/sparql/algebra/operator/strafter.rb +++ b/lib/sparql/algebra/operator/strafter.rb @@ -37,7 +37,7 @@ class StrAfter < Operator::Binary # a literal # @return [RDF::Literal] # @raise [TypeError] if operands are not compatible - def apply(left, right) + def apply(left, right, **options) case when !left.compatible?(right) raise TypeError, "expected two RDF::Literal operands, but got #{left.inspect} and #{right.inspect}" diff --git a/lib/sparql/algebra/operator/strbefore.rb b/lib/sparql/algebra/operator/strbefore.rb index 8fc77801..33343d2c 100644 --- a/lib/sparql/algebra/operator/strbefore.rb +++ b/lib/sparql/algebra/operator/strbefore.rb @@ -37,7 +37,7 @@ class StrBefore < Operator::Binary # a literal # @return [RDF::Literal] # @raise [TypeError] if operands are not compatible - def apply(left, right) + def apply(left, right, **options) case when !left.plain? || !right.plain? raise TypeError, "expected two RDF::Literal operands, but got #{left.inspect} and #{right.inspect}" diff --git a/lib/sparql/algebra/operator/strdt.rb b/lib/sparql/algebra/operator/strdt.rb index 01cf4aaa..b54d334d 100644 --- a/lib/sparql/algebra/operator/strdt.rb +++ b/lib/sparql/algebra/operator/strdt.rb @@ -24,7 +24,7 @@ class StrDT < Operator::Binary # datatype # @return [RDF::Literal] a datatyped literal # @see https://www.w3.org/TR/sparql11-query/#func-strdt - def apply(value, datatypeIRI) + def apply(value, datatypeIRI, **options) raise TypeError, "Literal #{value.inspect} is not simple" unless value.simple? RDF::Literal.new(value.to_s, datatype: datatypeIRI) end diff --git a/lib/sparql/algebra/operator/strends.rb b/lib/sparql/algebra/operator/strends.rb index f9c7cd21..3b55f068 100644 --- a/lib/sparql/algebra/operator/strends.rb +++ b/lib/sparql/algebra/operator/strends.rb @@ -33,7 +33,7 @@ class StrEnds < Operator::Binary # a literal # @return [RDF::Literal::Boolean] # @raise [TypeError] if operands are not compatible - def apply(left, right) + def apply(left, right, **options) case when !left.compatible?(right) raise TypeError, "expected two RDF::Literal operands, but got #{left.inspect} and #{right.inspect}" diff --git a/lib/sparql/algebra/operator/strlang.rb b/lib/sparql/algebra/operator/strlang.rb index 3eb53d94..8a2ea9b4 100644 --- a/lib/sparql/algebra/operator/strlang.rb +++ b/lib/sparql/algebra/operator/strlang.rb @@ -25,7 +25,7 @@ class StrLang < Operator::Binary # datatype # @return [RDF::Literal] a datatyped literal # @see https://www.w3.org/TR/sparql11-query/#func-strlang - def apply(value, langTag) + def apply(value, langTag, **options) raise TypeError, "Literal #{value.inspect} is not simple" unless value.simple? RDF::Literal.new(value.to_s, language: langTag.to_s) end diff --git a/lib/sparql/algebra/operator/strlen.rb b/lib/sparql/algebra/operator/strlen.rb index ea0ae417..b07952e7 100644 --- a/lib/sparql/algebra/operator/strlen.rb +++ b/lib/sparql/algebra/operator/strlen.rb @@ -25,7 +25,7 @@ class StrLen < Operator::Unary # the operand # @return [RDF::Literal::Integer] length of string # @raise [TypeError] if the operand is not a numeric value - def apply(operand) + def apply(operand, **options) raise TypeError, "expected a plain RDF::Literal, but got #{operand.inspect}" unless operand.literal? && operand.plain? RDF::Literal(operand.to_s.length) end diff --git a/lib/sparql/algebra/operator/strstarts.rb b/lib/sparql/algebra/operator/strstarts.rb index 1a460ef3..89fde231 100644 --- a/lib/sparql/algebra/operator/strstarts.rb +++ b/lib/sparql/algebra/operator/strstarts.rb @@ -33,7 +33,7 @@ class StrStarts < Operator::Binary # a literal # @return [RDF::Literal::Boolean] # @raise [TypeError] if operands are not compatible - def apply(left, right) + def apply(left, right, **options) case when !left.compatible?(right) raise TypeError, "expected two RDF::Literal operands, but got #{left.inspect} and #{right.inspect}" diff --git a/lib/sparql/algebra/operator/struuid.rb b/lib/sparql/algebra/operator/struuid.rb index 961333b0..173c1866 100644 --- a/lib/sparql/algebra/operator/struuid.rb +++ b/lib/sparql/algebra/operator/struuid.rb @@ -24,7 +24,7 @@ class StrUUID < Operator::Nullary # Return a string that is the scheme specific part of UUID. That is, as a simple literal, the result of generating a UUID, converting to a simple literal and removing the initial urn:uuid:. # # @return [RDF::URI] - def apply + def apply(**options) RDF::Literal(SecureRandom.uuid) end end # StrUUID diff --git a/lib/sparql/algebra/operator/subject.rb b/lib/sparql/algebra/operator/subject.rb index 230670ba..91b89abe 100644 --- a/lib/sparql/algebra/operator/subject.rb +++ b/lib/sparql/algebra/operator/subject.rb @@ -20,7 +20,7 @@ class Subject < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a statement - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Statement, but got #{operand.inspect}" unless operand.is_a?(RDF::Statement) operand.subject end diff --git a/lib/sparql/algebra/operator/substr.rb b/lib/sparql/algebra/operator/substr.rb index 986e5c99..c77ca1c8 100644 --- a/lib/sparql/algebra/operator/substr.rb +++ b/lib/sparql/algebra/operator/substr.rb @@ -49,7 +49,7 @@ def initialize(source, startingLoc, length = RDF::Literal(""), **options) # an optional length of the substring. # @return [RDF::Literal] # @raise [TypeError] if operands are not compatible - def apply(source, startingLoc, length) + def apply(source, startingLoc, length, **options) raise TypeError, "expected a plain RDF::Literal, but got #{source.inspect}" unless source.literal? && source.plain? text = text.to_s diff --git a/lib/sparql/algebra/operator/subtract.rb b/lib/sparql/algebra/operator/subtract.rb index eb439abf..a1e6995e 100644 --- a/lib/sparql/algebra/operator/subtract.rb +++ b/lib/sparql/algebra/operator/subtract.rb @@ -20,7 +20,7 @@ class Subtract < Operator::Binary # a numeric literal # @return [RDF::Literal::Numeric] # @raise [TypeError] if either operand is not a numeric literal - def apply(left, right) + def apply(left, right, **options) case when left.is_a?(RDF::Literal::Numeric) && right.is_a?(RDF::Literal::Numeric) left - right diff --git a/lib/sparql/algebra/operator/sum.rb b/lib/sparql/algebra/operator/sum.rb index a4565230..fb59e24e 100644 --- a/lib/sparql/algebra/operator/sum.rb +++ b/lib/sparql/algebra/operator/sum.rb @@ -22,7 +22,7 @@ class Sum < Operator # @param [Enumerable>] enum # enum of evaluated operand # @return [RDF::Literal::Numeric] The sum of the terms - def apply(enum) + def apply(enum, **options) # FIXME: we don't actually do anything with distinct operands.shift if distinct = (operands.first == :distinct) if enum.empty? diff --git a/lib/sparql/algebra/operator/timezone.rb b/lib/sparql/algebra/operator/timezone.rb index 9d2ff47c..0fc91bf6 100644 --- a/lib/sparql/algebra/operator/timezone.rb +++ b/lib/sparql/algebra/operator/timezone.rb @@ -26,7 +26,7 @@ class Timezone < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime) raise TypeError, "literal has no timezone" unless res = operand.timezone res diff --git a/lib/sparql/algebra/operator/triple.rb b/lib/sparql/algebra/operator/triple.rb index 74bf8674..99d2217d 100644 --- a/lib/sparql/algebra/operator/triple.rb +++ b/lib/sparql/algebra/operator/triple.rb @@ -17,7 +17,7 @@ class Triple < Operator::Ternary # @param [RDF::Term] object # @return [RDF::URI] # @raise [TypeError] if the operand is not a simple literal - def apply(subject, predicate, object) + def apply(subject, predicate, object, **options) triple = RDF::Statement(subject, predicate, object) raise TypeError, "valid components, but got #{triple.inspect}" unless triple.valid? triple diff --git a/lib/sparql/algebra/operator/tz.rb b/lib/sparql/algebra/operator/tz.rb index 2b65ff36..463c792d 100644 --- a/lib/sparql/algebra/operator/tz.rb +++ b/lib/sparql/algebra/operator/tz.rb @@ -24,7 +24,7 @@ class TZ < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime) operand.tz end diff --git a/lib/sparql/algebra/operator/ucase.rb b/lib/sparql/algebra/operator/ucase.rb index 3ee3cdf9..f26b0cd9 100644 --- a/lib/sparql/algebra/operator/ucase.rb +++ b/lib/sparql/algebra/operator/ucase.rb @@ -20,7 +20,7 @@ class UCase < Operator::Unary # the operand # @return [RDF::Literal] literal of same type # @raise [TypeError] if the operand is not a literal value - def apply(operand) + def apply(operand, **options) case operand when RDF::Literal then RDF::Literal(operand.to_s.upcase, datatype: operand.datatype, language: operand.language) else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}" diff --git a/lib/sparql/algebra/operator/uuid.rb b/lib/sparql/algebra/operator/uuid.rb index 0dc38f4c..ee202eb0 100644 --- a/lib/sparql/algebra/operator/uuid.rb +++ b/lib/sparql/algebra/operator/uuid.rb @@ -24,7 +24,7 @@ class UUID < Operator::Nullary # Return a fresh IRI from the UUID URN scheme. Each call of UUID() returns a different UUID. It must not be the "nil" UUID (all zeroes). The variant and version of the UUID is implementation dependent. # # @return [RDF::URI] - def apply + def apply(**options) RDF::URI("urn:uuid:#{SecureRandom.uuid}") end end # UUID diff --git a/lib/sparql/algebra/operator/year.rb b/lib/sparql/algebra/operator/year.rb index 100dcf09..4b0cfce3 100644 --- a/lib/sparql/algebra/operator/year.rb +++ b/lib/sparql/algebra/operator/year.rb @@ -24,7 +24,7 @@ class Year < Operator::Unary # the operand # @return [RDF::Literal] # @raise [TypeError] if the operand is not a simple literal - def apply(operand) + def apply(operand, **options) raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime) RDF::Literal(operand.object.year) end diff --git a/lib/sparql/grammar/meta.rb b/lib/sparql/grammar/meta.rb index c094f5f7..bf9599b7 100644 --- a/lib/sparql/grammar/meta.rb +++ b/lib/sparql/grammar/meta.rb @@ -2235,6 +2235,32 @@ module SPARQL::Grammar::Meta :ExistsFunc => { "EXISTS" => ["EXISTS", :GroupGraphPattern], }, + :ExprEmbTP => { + "<<" => ["<<", :ExprVarOrTerm, :Verb, :ExprVarOrTerm, ">>"], + }, + :ExprVarOrTerm => { + "<<" => [:ExprEmbTP], + :DECIMAL => [:NumericLiteral], + :DECIMAL_NEGATIVE => [:NumericLiteral], + :DECIMAL_POSITIVE => [:NumericLiteral], + :DOUBLE => [:NumericLiteral], + :DOUBLE_NEGATIVE => [:NumericLiteral], + :DOUBLE_POSITIVE => [:NumericLiteral], + :INTEGER => [:NumericLiteral], + :INTEGER_NEGATIVE => [:NumericLiteral], + :INTEGER_POSITIVE => [:NumericLiteral], + :IRIREF => [:iri], + :PNAME_LN => [:iri], + :PNAME_NS => [:iri], + :STRING_LITERAL1 => [:RDFLiteral], + :STRING_LITERAL2 => [:RDFLiteral], + :STRING_LITERAL_LONG1 => [:RDFLiteral], + :STRING_LITERAL_LONG2 => [:RDFLiteral], + :VAR1 => [:Var], + :VAR2 => [:Var], + "false" => [:BooleanLiteral], + "true" => [:BooleanLiteral], + }, :Expression => { "!" => [:ConditionalOrExpression], "(" => [:ConditionalOrExpression], @@ -4674,7 +4700,7 @@ module SPARQL::Grammar::Meta }, :PrimaryExpression => { "(" => [:BrackettedExpression], - "<<" => [:EmbTP], + "<<" => [:ExprEmbTP], "ABS" => [:BuiltInCall], "AVG" => [:BuiltInCall], "BNODE" => [:BuiltInCall], @@ -11236,6 +11262,83 @@ module SPARQL::Grammar::Meta "EXISTS"], :_ExistsFunc_1 => [ "{"], + :ExprEmbTP => [ + "<<"], + :_ExprEmbTP_1 => [ + :VAR1, + :VAR2, + "<<", + :IRIREF, + "true", + "false", + :PNAME_LN, + :PNAME_NS, + :STRING_LITERAL1, + :STRING_LITERAL2, + :STRING_LITERAL_LONG1, + :STRING_LITERAL_LONG2, + :INTEGER, + :DECIMAL, + :DOUBLE, + :INTEGER_POSITIVE, + :DECIMAL_POSITIVE, + :DOUBLE_POSITIVE, + :INTEGER_NEGATIVE, + :DECIMAL_NEGATIVE, + :DOUBLE_NEGATIVE], + :_ExprEmbTP_2 => [ + "a", + :VAR1, + :VAR2, + :IRIREF, + :PNAME_LN, + :PNAME_NS], + :_ExprEmbTP_3 => [ + :VAR1, + :VAR2, + "<<", + :IRIREF, + "true", + "false", + :PNAME_LN, + :PNAME_NS, + :STRING_LITERAL1, + :STRING_LITERAL2, + :STRING_LITERAL_LONG1, + :STRING_LITERAL_LONG2, + :INTEGER, + :DECIMAL, + :DOUBLE, + :INTEGER_POSITIVE, + :DECIMAL_POSITIVE, + :DOUBLE_POSITIVE, + :INTEGER_NEGATIVE, + :DECIMAL_NEGATIVE, + :DOUBLE_NEGATIVE], + :_ExprEmbTP_4 => [ + ">>"], + :ExprVarOrTerm => [ + :VAR1, + :VAR2, + "<<", + :IRIREF, + "true", + "false", + :PNAME_LN, + :PNAME_NS, + :STRING_LITERAL1, + :STRING_LITERAL2, + :STRING_LITERAL_LONG1, + :STRING_LITERAL_LONG2, + :INTEGER, + :DECIMAL, + :DOUBLE, + :INTEGER_POSITIVE, + :DECIMAL_POSITIVE, + :DOUBLE_POSITIVE, + :INTEGER_NEGATIVE, + :DECIMAL_NEGATIVE, + :DOUBLE_NEGATIVE], :Expression => [ "!", "+", @@ -38554,32 +38657,17 @@ module SPARQL::Grammar::Meta :DECIMAL_NEGATIVE, :DOUBLE_NEGATIVE], :EmbTP => [ - "AS", - ")", - ",", "a", ">>", "{|", - "=", - "!=", - "<", - ">", - "<=", - ">=", - "IN", - "NOT", - "&&", - "||", - ";", + ")", + ",", "]", "|}", - "*", - "/", - "+", - "-", :VAR1, :VAR2, :IRIREF, + ";", ".", "}", :NIL, @@ -38592,12 +38680,6 @@ module SPARQL::Grammar::Meta "false", :BLANK_NODE_LABEL, :ANON, - :INTEGER_POSITIVE, - :DECIMAL_POSITIVE, - :DOUBLE_POSITIVE, - :INTEGER_NEGATIVE, - :DECIMAL_NEGATIVE, - :DOUBLE_NEGATIVE, "GRAPH", :STRING_LITERAL1, :STRING_LITERAL2, @@ -38606,6 +38688,12 @@ module SPARQL::Grammar::Meta :INTEGER, :DECIMAL, :DOUBLE, + :INTEGER_POSITIVE, + :DECIMAL_POSITIVE, + :DOUBLE_POSITIVE, + :INTEGER_NEGATIVE, + :DECIMAL_NEGATIVE, + :DOUBLE_NEGATIVE, "{", "OPTIONAL", "MINUS", @@ -38616,32 +38704,17 @@ module SPARQL::Grammar::Meta "^", "!"], :_EmbTP_1 => [ - "AS", - ")", - ",", "a", ">>", "{|", - "=", - "!=", - "<", - ">", - "<=", - ">=", - "IN", - "NOT", - "&&", - "||", - ";", + ")", + ",", "]", "|}", - "*", - "/", - "+", - "-", :VAR1, :VAR2, :IRIREF, + ";", ".", "}", :NIL, @@ -38654,12 +38727,6 @@ module SPARQL::Grammar::Meta "false", :BLANK_NODE_LABEL, :ANON, - :INTEGER_POSITIVE, - :DECIMAL_POSITIVE, - :DOUBLE_POSITIVE, - :INTEGER_NEGATIVE, - :DECIMAL_NEGATIVE, - :DOUBLE_NEGATIVE, "GRAPH", :STRING_LITERAL1, :STRING_LITERAL2, @@ -38668,6 +38735,12 @@ module SPARQL::Grammar::Meta :INTEGER, :DECIMAL, :DOUBLE, + :INTEGER_POSITIVE, + :DECIMAL_POSITIVE, + :DOUBLE_POSITIVE, + :INTEGER_NEGATIVE, + :DECIMAL_NEGATIVE, + :DOUBLE_NEGATIVE, "{", "OPTIONAL", "MINUS", @@ -38678,32 +38751,17 @@ module SPARQL::Grammar::Meta "^", "!"], :_EmbTP_2 => [ - "AS", - ")", - ",", "a", ">>", "{|", - "=", - "!=", - "<", - ">", - "<=", - ">=", - "IN", - "NOT", - "&&", - "||", - ";", + ")", + ",", "]", "|}", - "*", - "/", - "+", - "-", :VAR1, :VAR2, :IRIREF, + ";", ".", "}", :NIL, @@ -38716,12 +38774,6 @@ module SPARQL::Grammar::Meta "false", :BLANK_NODE_LABEL, :ANON, - :INTEGER_POSITIVE, - :DECIMAL_POSITIVE, - :DOUBLE_POSITIVE, - :INTEGER_NEGATIVE, - :DECIMAL_NEGATIVE, - :DOUBLE_NEGATIVE, "GRAPH", :STRING_LITERAL1, :STRING_LITERAL2, @@ -38730,6 +38782,12 @@ module SPARQL::Grammar::Meta :INTEGER, :DECIMAL, :DOUBLE, + :INTEGER_POSITIVE, + :DECIMAL_POSITIVE, + :DOUBLE_POSITIVE, + :INTEGER_NEGATIVE, + :DECIMAL_NEGATIVE, + :DOUBLE_NEGATIVE, "{", "OPTIONAL", "MINUS", @@ -38740,32 +38798,17 @@ module SPARQL::Grammar::Meta "^", "!"], :_EmbTP_3 => [ - "AS", - ")", - ",", "a", ">>", "{|", - "=", - "!=", - "<", - ">", - "<=", - ">=", - "IN", - "NOT", - "&&", - "||", - ";", + ")", + ",", "]", "|}", - "*", - "/", - "+", - "-", :VAR1, :VAR2, :IRIREF, + ";", ".", "}", :NIL, @@ -38778,12 +38821,6 @@ module SPARQL::Grammar::Meta "false", :BLANK_NODE_LABEL, :ANON, - :INTEGER_POSITIVE, - :DECIMAL_POSITIVE, - :DOUBLE_POSITIVE, - :INTEGER_NEGATIVE, - :DECIMAL_NEGATIVE, - :DOUBLE_NEGATIVE, "GRAPH", :STRING_LITERAL1, :STRING_LITERAL2, @@ -38792,6 +38829,12 @@ module SPARQL::Grammar::Meta :INTEGER, :DECIMAL, :DOUBLE, + :INTEGER_POSITIVE, + :DECIMAL_POSITIVE, + :DOUBLE_POSITIVE, + :INTEGER_NEGATIVE, + :DECIMAL_NEGATIVE, + :DOUBLE_NEGATIVE, "{", "OPTIONAL", "MINUS", @@ -38802,32 +38845,17 @@ module SPARQL::Grammar::Meta "^", "!"], :_EmbTP_4 => [ - "AS", - ")", - ",", "a", ">>", "{|", - "=", - "!=", - "<", - ">", - "<=", - ">=", - "IN", - "NOT", - "&&", - "||", - ";", + ")", + ",", "]", "|}", - "*", - "/", - "+", - "-", :VAR1, :VAR2, :IRIREF, + ";", ".", "}", :NIL, @@ -38840,12 +38868,6 @@ module SPARQL::Grammar::Meta "false", :BLANK_NODE_LABEL, :ANON, - :INTEGER_POSITIVE, - :DECIMAL_POSITIVE, - :DOUBLE_POSITIVE, - :INTEGER_NEGATIVE, - :DECIMAL_NEGATIVE, - :DOUBLE_NEGATIVE, "GRAPH", :STRING_LITERAL1, :STRING_LITERAL2, @@ -38854,6 +38876,12 @@ module SPARQL::Grammar::Meta :INTEGER, :DECIMAL, :DOUBLE, + :INTEGER_POSITIVE, + :DECIMAL_POSITIVE, + :DOUBLE_POSITIVE, + :INTEGER_NEGATIVE, + :DECIMAL_NEGATIVE, + :DOUBLE_NEGATIVE, "{", "OPTIONAL", "MINUS", @@ -39119,6 +39147,174 @@ module SPARQL::Grammar::Meta :INTEGER, :DECIMAL, :DOUBLE], + :ExprEmbTP => [ + "AS", + ")", + ",", + "a", + ">>", + "=", + "!=", + "<", + ">", + "<=", + ">=", + "IN", + "NOT", + "&&", + "||", + ";", + "*", + "/", + "+", + "-", + :VAR1, + :VAR2, + :IRIREF, + :PNAME_LN, + :PNAME_NS, + :INTEGER_POSITIVE, + :DECIMAL_POSITIVE, + :DOUBLE_POSITIVE, + :INTEGER_NEGATIVE, + :DECIMAL_NEGATIVE, + :DOUBLE_NEGATIVE], + :_ExprEmbTP_1 => [ + "AS", + ")", + ",", + "a", + ">>", + "=", + "!=", + "<", + ">", + "<=", + ">=", + "IN", + "NOT", + "&&", + "||", + ";", + "*", + "/", + "+", + "-", + :VAR1, + :VAR2, + :IRIREF, + :PNAME_LN, + :PNAME_NS, + :INTEGER_POSITIVE, + :DECIMAL_POSITIVE, + :DOUBLE_POSITIVE, + :INTEGER_NEGATIVE, + :DECIMAL_NEGATIVE, + :DOUBLE_NEGATIVE], + :_ExprEmbTP_2 => [ + "AS", + ")", + ",", + "a", + ">>", + "=", + "!=", + "<", + ">", + "<=", + ">=", + "IN", + "NOT", + "&&", + "||", + ";", + "*", + "/", + "+", + "-", + :VAR1, + :VAR2, + :IRIREF, + :PNAME_LN, + :PNAME_NS, + :INTEGER_POSITIVE, + :DECIMAL_POSITIVE, + :DOUBLE_POSITIVE, + :INTEGER_NEGATIVE, + :DECIMAL_NEGATIVE, + :DOUBLE_NEGATIVE], + :_ExprEmbTP_3 => [ + "AS", + ")", + ",", + "a", + ">>", + "=", + "!=", + "<", + ">", + "<=", + ">=", + "IN", + "NOT", + "&&", + "||", + ";", + "*", + "/", + "+", + "-", + :VAR1, + :VAR2, + :IRIREF, + :PNAME_LN, + :PNAME_NS, + :INTEGER_POSITIVE, + :DECIMAL_POSITIVE, + :DOUBLE_POSITIVE, + :INTEGER_NEGATIVE, + :DECIMAL_NEGATIVE, + :DOUBLE_NEGATIVE], + :_ExprEmbTP_4 => [ + "AS", + ")", + ",", + "a", + ">>", + "=", + "!=", + "<", + ">", + "<=", + ">=", + "IN", + "NOT", + "&&", + "||", + ";", + "*", + "/", + "+", + "-", + :VAR1, + :VAR2, + :IRIREF, + :PNAME_LN, + :PNAME_NS, + :INTEGER_POSITIVE, + :DECIMAL_POSITIVE, + :DOUBLE_POSITIVE, + :INTEGER_NEGATIVE, + :DECIMAL_NEGATIVE, + :DOUBLE_NEGATIVE], + :ExprVarOrTerm => [ + "a", + ">>", + :VAR1, + :VAR2, + :IRIREF, + :PNAME_LN, + :PNAME_NS], :Expression => [ "AS", ")", @@ -42613,10 +42809,10 @@ module SPARQL::Grammar::Meta ")", "AS", ",", - "*", - "/", "a", ">>", + "*", + "/", :IRIREF, "UNDEF", "{|", @@ -42676,10 +42872,10 @@ module SPARQL::Grammar::Meta ")", "AS", ",", - "*", - "/", "a", ">>", + "*", + "/", :IRIREF, "UNDEF", "{|", @@ -44714,16 +44910,16 @@ module SPARQL::Grammar::Meta "{", :VAR1, :VAR2, + "<<", :BLANK_NODE_LABEL, :ANON, :IRIREF, "true", "false", - "<<", - "AS", - ",", "a", ">>", + "AS", + ",", "INTO", ";", :_eof, @@ -46937,10 +47133,10 @@ module SPARQL::Grammar::Meta ")", "AS", ",", - "FROM", - "USING", "a", ">>", + "FROM", + "USING", :IRIREF, "UNDEF", "{|", @@ -46968,9 +47164,9 @@ module SPARQL::Grammar::Meta "/", "+", "-", - "ORDER", :VAR1, :VAR2, + "ORDER", :STRING_LITERAL1, :STRING_LITERAL2, :STRING_LITERAL_LONG1, @@ -48037,9 +48233,9 @@ module SPARQL::Grammar::Meta ")", "AS", ",", - "^^", "a", ">>", + "^^", :IRIREF, "UNDEF", "{|", @@ -49348,12 +49544,12 @@ module SPARQL::Grammar::Meta ")", :VAR1, :VAR2, + "<<", :BLANK_NODE_LABEL, :ANON, :IRIREF, "true", "false", - "<<", "AS", ",", "a", @@ -49485,12 +49681,12 @@ module SPARQL::Grammar::Meta "{", :VAR1, :VAR2, + "<<", :BLANK_NODE_LABEL, :ANON, :IRIREF, "true", "false", - "<<", :PNAME_LN, :PNAME_NS, :STRING_LITERAL1, @@ -49567,12 +49763,12 @@ module SPARQL::Grammar::Meta :Verb => [ :VAR1, :VAR2, + "<<", :BLANK_NODE_LABEL, :ANON, :IRIREF, "true", "false", - "<<", :PNAME_LN, :PNAME_NS, :STRING_LITERAL1, @@ -49712,16 +49908,16 @@ module SPARQL::Grammar::Meta "{", :VAR1, :VAR2, + "<<", :BLANK_NODE_LABEL, :ANON, :IRIREF, "true", "false", - "<<", - "AS", - ",", "a", ">>", + "AS", + ",", "INTO", ";", :_eof, diff --git a/lib/sparql/grammar/parser11.rb b/lib/sparql/grammar/parser11.rb index ab32cebc..b0885d1c 100644 --- a/lib/sparql/grammar/parser11.rb +++ b/lib/sparql/grammar/parser11.rb @@ -1306,7 +1306,7 @@ class Parser # | iriOrFunction | RDFLiteral # | NumericLiteral | BooleanLiteral # | Var - # | EmbTP + # | ExprEmbTP production(:PrimaryExpression) do |input, data, callback| if data[:Expression] add_prod_datum(:Expression, data[:Expression]) @@ -1328,6 +1328,21 @@ class Parser add_prod_datum(:UnaryExpression, data[:UnaryExpression]) end + # [119a] ExprEmbTP ::= '<<' ExprVarOrTerm Verb ExprVarOrTerm '>>' + production(:ExprEmbTP) do |input, data, callback| + subject, object = data[:ExprVarOrTerm] + predicate = data[:Verb] + add_pattern(:ExprEmbTP, + subject: subject, + predicate: predicate, + object: object) + end + + # [119b] ExprVarOrTerm ::= iri | RDFLiteral | NumericLiteral | BooleanLiteral | Var | ExprEmbTP + production(:ExprVarOrTerm) do |input, data, callback| + data.values.each {|v| add_prod_datum(:ExprVarOrTerm, v)} + end + # [121] BuiltInCall ::= Aggregate # | 'STR' '(' Expression ')' # | 'LANG' '(' Expression ')' diff --git a/sparql.gemspec b/sparql.gemspec index cb28f10f..6dcdda78 100755 --- a/sparql.gemspec +++ b/sparql.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |gem| gem.required_ruby_version = '>= 2.4' gem.requirements = [] - gem.add_runtime_dependency 'rdf', '~> 3.1', '>= 3.1.12' + gem.add_runtime_dependency 'rdf', '~> 3.1', '>= 3.1.14' gem.add_runtime_dependency 'rdf-aggregate-repo', '~> 3.1' gem.add_runtime_dependency 'ebnf', '~> 2.1' gem.add_runtime_dependency 'builder', '~> 3.2' diff --git a/spec/algebra/operator/equal/term.sse b/spec/algebra/operator/equal/term.sse index e8559879..6b004f6f 100644 --- a/spec/algebra/operator/equal/term.sse +++ b/spec/algebra/operator/equal/term.sse @@ -29,10 +29,10 @@ # From open-eq-08 (equal (= "xyz" "xyz"^^xsd:integer) TypeError) -(equal (= "xyz" "xyz"^^) TypeError) +(equal (= "xyz" "xyz"^^) TypeError) (equal (= "xyz"@en "xyz"^^xsd:string) false) -(equal (= "xyz"@en "xyz"^^xsd:integer) false) -(equal (= "xyz"@en "xyz"^^) false) +#(equal (= "xyz"@en "xyz"^^xsd:integer) false) +(equal (= "xyz"@en "xyz"^^) false) (equal (= "xyz"@en "xyz") false) (equal (= "xyz"@EN "xyz"^^xsd:string) false) (equal (= _:xyz "xyz"^^xsd:integer) false) diff --git a/spec/support/extensions/isomorphic.rb b/spec/support/extensions/isomorphic.rb index 99100cf8..14f43efd 100644 --- a/spec/support/extensions/isomorphic.rb +++ b/spec/support/extensions/isomorphic.rb @@ -310,7 +310,7 @@ def node? # Blank nodes within a solution # @return [Array] def blank_nodes - bindings.values.select {|v| v.is_a?(RDF::Node)}.uniq + bindings.values.map(&:terms).select(&:node?) end end end