w3c / rdf-star

RDF-star specification
https://w3c.github.io/rdf-star/
Other
119 stars 23 forks source link

the final report should include a complete grammar for any changed media type #104

Closed lisp closed 2 years ago

lisp commented 3 years ago

while it would be helpful to include isolated grammar changes inline in the text, to have complete grammars for any modified and/or supplanted media types would facilitate implementation.

gkellogg commented 3 years ago

Perhaps we can maintain separate HTML and EBNF files with the complete grammars and reference them from the spec?

If existing tools aren't working, I have tools to generate an HTML version of the EBNF grammars. (See, for example the N3 grammar).

afs commented 3 years ago

This is the tool chain used for SPARQL 1.0 and 1.1. https://github.com/apache/jena/tree/main/jena-arq/Grammar

It starts with a grammar that is checked and executable - given the size of the grammar, the checking is quite important. Then to HTML via a text form which protects quoting and keeps terminal separate from grammar productions. A text copy of the HTML is closest to EBNF.

It is most useful if the numbering in the EBNF aligns to the numbering in the SPARQL 1.1 spec. That is some manual adjustment so better done after the spec is stable. Also - the Turtle grammar references SPARQL numbering. If it is feasible, we should keep this for "-star" forms.

gkellogg commented 3 years ago

FWIW, the grammar I'm using is at https://github.com/ruby-rdf/sparql/blob/develop/etc/sparql11.bnf and rendered in HTML here.

afs commented 3 years ago

That BNF seems to exclude paths in annotations blocks even if used in a part of the query pattern that allows paths.

test case:

SELECT * {
  ?x :p ?o {| :q/:r ?z |} .
  }

and it could have further structure, ?x :p ?o {| :q [ :rdfs:subClassOf*/rdf:type ?T ] |}.

There are two cases: one with PropertyListNotEmpty inside, used from Object (for templates e.g. CONSTRUCT) and one with PropertyListPathNotEmpty used from ObjectPath inside for the WHERE clause.

ObjectPath        ::= GraphNodePath AnnotationPath ?
AnnotationPath    ::= "{|" PropertyListPathNotEmpty "|}"

Object            ::= GraphNodePath Annotation?
Annotation        ::= ( "{|" PropertyListNotEmpty "|}" )?
gkellogg commented 3 years ago

Yes, I think I that AnnotationPattern should have been '{|' PropertyListPathNotEmpty '|}' not PropertyListNotEmpty. This is symmetrical with the Turtle gramma where rather than putting the annotation on object, it's on objectList.

So, the changes in my grammar would be the following:

[79]  ObjectList              ::= Object Annotation? ( ',' Object Annotation? )*
[86]  ObjectListPath          ::= ObjectPath AnnotationPattern? ( ',' ObjectPath AnnotationPattern? )*
[177]   Annotation        ::=   '{|' PropertyListNotEmpty '|}'
[177p]  AnnotationPattern         ::=   '{|' PropertyListNotEmpty '|}'

I believe that parses this particular case, and has the advantage of being closer to the Turtle objectList production, but perhaps it misses some cases.

gkellogg commented 3 years ago

I think those changes do it. I get the following ASTs:

For ?x :p ?o {| :q/:r ?z |} .:

(join
  (bgp (triple ?x :p ?o))
  (path (triple ?x :p ?o) (seq :q :r) ?z))

And for ?x :p ?o {| :q [ rdfs:subClassOf*/rdf:type ?T ] |}.:

(join
  (bgp (triple ?x :p ?o))
  (path (triple ?x :p ?o)
    (seq (path* rdfs:subClassOf) rdf:type)
    ?T))
afs commented 3 years ago

The other case here is templates which are pathless -- CONSTRUCT { :s :p :o {| :q :z |} } (and INSERT, DELETE).

ObjectList is used in templates. ObjectListPath in patterns.

(previous example fixed)

hartig commented 3 years ago

Andy, Gregg, I see your discussion here only now. I had already extended the PR based on Andy's comment there. See my response to Andy's comment in the PR: https://github.com/w3c/rdf-star/pull/65#discussion_r579540076

afs commented 3 years ago

Discussions now on #106 together with the editor's changes.

hartig commented 3 years ago

I am re-opening this issue again to keep it as a reminder of James' initial request.

(the discussion in #106 is about the annotation syntax in SPARQL-star)

pchampin commented 2 years ago

I propose to defer this to the future WG (which will have, anyway, to update each concerned grammar accordingly)

pchampin commented 2 years ago

This was discussed during today's meeting: https://w3c.github.io/rdf-star/Minutes/2021-10-15.html#a01