- From: Andy Seaborne <andy@apache.org>
- Date: Thu, 29 Aug 2013 14:25:20 +0100
- To: RDF-WG <public-rdf-wg@w3.org>
Here is a proposal for the final TriG grammar for discussion.
It's taken from the earlier discussions here, cleaned up, converted to
javacc for checking, and still needs refinement.
Graph labels can be blank nodes, where the blank node is just a blank
node, not a compound as in (1 2 3) or [:p 123 ]
---------------------------
trigDoc :=
( directive | block )*
block :=
triplesOrGraph
| wrappedGraph
| triples2
| [Gg][Rr][Aa][Pp][Hh] ( iri | BlankNode ) wrappedGraph
triplesOrGraph :=
( iri | BlankNode ) ( wrappedGraph | predicateObjectList '.' )
triples2 :=
( blankNodePropertyList | collection ) predicateObjectList? '.'
wrappedGraph :=
'{' triplesBlock '}'
triplesBlock :=
triples ( '.' triplesBlock? )?
---------------------------
Notes:
0/ Intelligibility of the grammar matters.
1/ Triples in a bare default graph section must end with a '.' yet
inside { } the final '.' is optional.
This is due to labelled graphs without GRAPH keyword.
i.e. allowing
:s :p :o
:g { :s1 :p :o1 }
without allowing
:s :p :o
:s1 :p1 :o1
This should be fixable and stay within the single token lookahead
grammar classes; in the process though, it may create a complicated
grammar and deviate more from Turtle.
It would mean that a Turtle document can not be simply extracted from a
TriG document by looking for the bare triples.
Thoughts and comments?
2/ Example below of a document that should parse
3/ (), which is rdf:nil written funny, is not legal as a graph label.
Andy
----------------------------------
@prefix : <http://example/> .
:s1 :p1 :o .
:s1 :p2 :o .
{ :s3 :p :o .
:s4 :p :o .}
{ :s5 :p :o .
:s6 :p :o }
:s1 :p1 :o .
:s1 :p2 :o .
GRAPH :g { :s :p :o }
GRAPH _:a { :s :p :o }
GRAPH [] { :s :p :o }
:g { :s :p :o }
_:a { :s :p :o }
[] { :s :p "THAT'S ALL FOLKS" }
Received on Thursday, 29 August 2013 13:25:50 UTC