Skip to content

Commit 7294f21

Browse files
domelgkelloggTallTed
authored
Grammar updates for triple terms and occurrences (#33)
* Grammar updates for triple terms and occurrences * update Parser State sec * A Triple Term can only be used as the object of a trpile, not the subject. --------- Co-authored-by: Gregg Kellogg <gregg@greggkellogg.net> Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
1 parent 2a68ff3 commit 7294f21

3 files changed

Lines changed: 202 additions & 101 deletions

File tree

spec/index.html

Lines changed: 125 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,19 @@
9898
Turtle [[RDF12-TURTLE]] format.
9999
</p>
100100

101-
<p>RDF 1.2 TriG shares <a>quoted triples</a> with [[RDF12-TURTLE]]
101+
<p>RDF 1.2 TriG shares <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a> with [[RDF12-TURTLE]]
102102
as a fourth kind of <a data-cite="RDF12-CONCEPTS#dfn-rdf-term">RDF term</a>
103103
which can be used as the
104-
<a data-cite="RDF12-CONCEPTS#dfn-subject">subject</a> or
105104
<a data-cite="RDF12-CONCEPTS#dfn-object">object</a> of another
106105
<a data-cite="RDF12-CONCEPTS#dfn-rdf-triple">triple</a>,
107106
making it possible to make statements about other statements.
108107
RDF 1.2 TriG also adds shares
109108
<a data-cite="RDF12-CONCEPTS#dfn-dir-lang-string">directional language-tagged strings</a>
110109
with [[RDF12-TURTLE]].</p>
111110

112-
<p>In addition, RDF 1.2 TriG shares the <a data-cite="RDF12-TURTLE#annotation-syntax">annotation syntax</a> with [[RDF12-TURTLE]] which allows
113-
<a>quoted triples</a> to also be <a data-cite="RDF12-CONCEPTS#dfn-asserted-triple">asserted</a>.</p>
111+
<p>In addition, RDF 1.2 TriG shares the <a data-cite="RDF12-TURTLE#reifying-triples">reifying triples</a> and
112+
<a data-cite="RDF12-TURTLE#annotation-syntax">annotation syntax</a> extensions with [[RDF12-TURTLE]] which allows
113+
<a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a> to also be <a data-cite="RDF12-CONCEPTS#dfn-asserted-triple">asserted</a>.</p>
114114
</section>
115115

116116
<section id='sotd' class="updateable-rec">
@@ -282,23 +282,23 @@ <h3>Graph Statements</h3>
282282

283283
</section>
284284

285-
<section id="quoted-triples">
286-
<h3>Quoted Triples</h3>
287-
288-
<p>TriG shares the same syntax for representing <dfn data-cite="RDF12-CONCEPTS#dfn-quoted-triple">quoted triples</dfn>
289-
as Turtle, including the <a data-cite="RDF12-TURTLE#annotation-syntax">Annotation Syntax</a>.</p>
290-
291-
<pre id="ex-annotated-triple"
292-
class="example trig"
293-
data-transform="updateExample"
294-
title="TriG annotated triples">
295-
<!--
296-
BASE <http://example.org/>
297-
PREFIX : <#>
298-
:G {
299-
_:a :name "Alice" {| :statedBy :bob |} .
300-
}
301-
-->
285+
<section id="triple-terms">
286+
<h3>Triple Terms</h3>
287+
288+
<p>TriG shares the same syntax for representing <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a>
289+
as Turtle, including <a data-cite="RDF12-TURTLE#reifying-triples">Reifying Triples</a>
290+
and the <a data-cite="RDF12-TURTLE#annotation-syntax">Annotation Syntax</a>.</p>
291+
292+
<pre id="ex-triple-term" class="example turtle" data-transform="updateExample"
293+
title="Triple Term">
294+
<!--
295+
PREFIX : <http://www.example.org/>
296+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
297+
298+
_:e38 :familyName "Smith" .
299+
_:anno rdf:reifies <<( _:e38 :jobTitle "Designer" )>> .
300+
_:anno :accordingTo _:e22 .
301+
-->
302302
</pre>
303303

304304
</section>
@@ -747,7 +747,7 @@ <h2>Parsing</h2>
747747
<a data-cite="RDF12-CONCEPTS#dfn-iri">IRIs</a>,
748748
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>,
749749
<a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank nodes</a>, and
750-
<a data-cite="RDF12-CONCEPTS#dfn-quoted-triple">quoted triples</a>.
750+
<a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a>.
751751

752752
Literals are composed of a <a data-cite="RDF12-CONCEPTS#dfn-lexical-form">lexical form</a>
753753
and an optional <a data-cite="RDF12-CONCEPTS#dfn-language-tag">language tag</a> [[!BCP47]]
@@ -762,7 +762,7 @@ <h2>Parsing</h2>
762762

763763
<section id="sec-parsing-state">
764764
<h3>Parser State</h3>
765-
<p>Parsing TriG requires a state of seven items:</p>
765+
<p>Parsing TriG requires a state of nine items:</p>
766766

767767
<ul>
768768
<li id="baseURI">IRI |baseURI|
@@ -778,29 +778,40 @@ <h3>Parser State</h3>
778778
per the <a href="#grammar-production-PNAME_NS"><code>PNAME_NS</code></a> production: <code>PN_PREFIX? ":"</code>.</li>
779779
<li id="bnodeLabels">Map[string -&gt; <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a>] |bnodeLabels|
780780
— A mapping from string to blank node.</li>
781-
<li id="curSubject">RDF_Term |curSubject|
781+
<li id="curSubject"><a data-cite="RDF12-CONCEPTS#dfn-rdf-term">RDF Term</a> |curSubject|
782782
— The |curSubject| is bound to the
783-
<a href="#grammar-production-subject"><code>subject</code></a>
784-
and <a href="#grammar-production-qtSubject"><code>qtSubject</code></a> productions.</li>
783+
<a href="#grammar-production-subject"><code>subject</code></a>,
784+
<a href="#grammar-production-blankNodePropertyList"><code>blankNodePropertyList</code></a>,
785+
<a href="#grammar-production-collection"><code>collection</code></a>,
786+
<a href="#grammar-production-tripleTerm"><code>tripleTerm</code></a>, and
787+
<a href="#grammar-production-annotationBlock"><code>annotationBlock</code></a>
788+
productions.</li>
785789
<li id="curPredicate">RDF_Term |curPredicate|
786790
— The |curPredicate| is bound to the
787-
<a href="#grammar-production-verb"><code>verb</code></a> production.
791+
the <a href="#grammar-production-verb"><code>verb</code></a> production.
788792
If token matched was <a href="#cp-lowercase-a"><code title="latin-small-letter-a">a</code></a>, |curPredicate|
789793
is bound to the IRI <code>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</code>.</li>
790-
<li id="curObject">RDF_Term |curObject| —
794+
<li id="curObject"><a data-cite="RDF12-CONCEPTS#dfn-rdf-term">RDF Term</a> |curObject| —
791795
The |curObject| is bound to the
792796
<a href="#grammar-production-object"><code>object</code></a> and
793-
<a href="#grammar-production-qtObject"><code>qtObject</code></a> productions.</li>
797+
<a href="#grammar-production-ttObject"><code>ttObject</code></a> productions.</li>
794798
<li id="curGraph">RDF_Term |curGraph| —
795799
The |curGraph| is bound to
796800
the label of the graph that is the destination of triples
797801
produced in parsing. When undefined, triples are destined
798802
for the <a data-cite="RDF12-CONCEPTS#dfn-default-graph">default graph</a>.
799803
</li>
804+
<li id="curReifier"><a data-cite="RDF12-CONCEPTS#dfn-rdf-term">RDF Term</a> |curReifier| —
805+
The |curReifier| is bound to the
806+
<a href="#grammar-production-reifier"><code>reifier</code></a> and
807+
<a href="#grammar-production-annotationBlock"><code>annotationBlock</code></a> productions.</li>
808+
<li id="curTripleTerm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple term</a> |curTripleTerm| —
809+
The |curTripleTerm| is set in the <a href="#annotation">Annotations</a> constructor.
810+
</li>
800811
</ul>
801-
<p>Additionally, |curSubject|
802-
can be bound to any RDF_Term
803-
(including a <a>quoted triple</a>).</p>
812+
813+
<p>Term Constructors can create a stack of these values indicated by
814+
using language such as "records the |curSubject| and |curPredicate|."</p>
804815
</section>
805816

806817
<section id="sec-parsing-terms">
@@ -834,13 +845,35 @@ <h3>RDF Term Constructors</h3>
834845
<tr id="handle-blankNodePropertyList" ><td style="text-align:left;" ><a class="type bNode" href="#grammar-production-blankNodePropertyList" ><code>blankNodePropertyList</code></a></td><td><a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node </a></td><td>A blank node is generated. Note the rules for <code>blankNodePropertyList</code> in the next section.</td></tr>
835846
<tr id="handle-collection" ><td style="text-align:left;" rowspan="2"><a class="type bNode" href="#grammar-production-collection" ><code>collection</code> </a></td><td><a data-cite="RDF12-CONCEPTS#dfn-blank-node"> blank node </a></td><td>For non-empty lists, a blank node is generated. Note the rules for <code>collection</code> in the next section.</td></tr>
836847
<tr id="handle-collection-IRI" ><td ><a data-cite="RDF12-CONCEPTS#dfn-iri"> IRI </a></td><td>For empty lists, the resulting IRI is <code>rdf:nil</code>. Note the rules for <code>collection</code> in the next section.</td></tr>
837-
<tr id="handle-quotedTriple" ><td style="text-align:left;" ><a class="type quotedTriple" href="#grammar-production-quotedTriple" >quotedTriple </a></td><td><a data-cite="RDF12-CONCEPTS#dfn-quoted-triple">quoted triple</a></td>
848+
<tr id="handle-reifier" ><td style="text-align:left;" ><a class="type reifier" href="#grammar-production-reifier" >reifier </a></td><td><a data-cite="RDF12-CONCEPTS#dfn-iri"> IRI </a>
849+
| <a data-cite="RDF12-CONCEPTS#dfn-blank-node"> blank node </a></td>
838850
<td>
839-
The <a data-cite="RDF12-CONCEPTS#dfn-quoted-triple">quoted triple</a>
851+
The |curReifier| is taken from <a data-cite="RDF12-CONCEPTS#dfn-rdf-term">term</a>, which is taken from the matched
852+
<a href="#grammar-production-iri"><code>iri</code></a> production
853+
or <a href="#grammar-production-BlankNode"><code>BlankNode</code></a> production, if any.
854+
If no such production is matched, <a data-cite="RDF12-CONCEPTS#dfn-rdf-term">term</a> is taken
855+
from a fresh RDF <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a>.
856+
</td>
857+
</tr>
858+
<tr id="handle-tripleTerm" ><td style="text-align:left;" ><a class="type tripleTerm" href="#grammar-production-tripleTerm" >tripleTerm </a></td><td><a data-cite="RDF12-CONCEPTS#dfn-triple-term"> triple term </a></td>
859+
<td>
860+
The <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple term</a>
840861
is composed of the terms constructed from
841-
the <a href="#grammar-production-subject"><code>subject</code></a>,
862+
the <a href="#grammar-production-ttSubject"><code>ttSubject</code></a>,
842863
<a href="#grammar-production-predicate"><code>predicate</code></a>, and
843-
<a href="#grammar-production-object"><code>object</code></a> productions.
864+
<a href="#grammar-production-ttObject"><code>ttObject</code></a> productions.
865+
</td>
866+
</tr>
867+
<tr id="handle-reifiedTriple" ><td style="text-align:left;" ><a class="type reifiedTriple" href="#grammar-production-reifiedTriple" >reifiedTriple </a></td><td><a data-cite="RDF12-CONCEPTS#dfn-iri">IRI</a> | <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a></td>
868+
<td>
869+
The <a data-cite="RDF12-CONCEPTS#dfn-rdf-term">term</a> is taken from the matched <a href="#grammar-production-reifier"><code>reifier</code></a>, if any,
870+
or from a fresh RDF <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a>.
871+
</td>
872+
</tr>
873+
<tr id="handle-annotationBlock" ><td style="text-align:left;" ><a class="type annotation" href="#grammar-production-annotationBlock" >annotationBlock </a></td><td><a data-cite="RDF12-CONCEPTS#dfn-iri">IRI</a> | <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a></td>
874+
<td>
875+
The <a data-cite="RDF12-CONCEPTS#dfn-rdf-term">term</a> is taken from a previously matched <a data-cite="RDF12-CONCEPTS#dfn-reifier">reifier</a>, if any,
876+
or from a fresh RDF <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a>.
844877
</td>
845878
</tr>
846879
</tbody>
@@ -892,18 +925,6 @@ <h4>Output Graph</h4>
892925
before handling the <a href="#grammar-production-predicateObjectList"><code>predicateObjectList</code></a> production
893926
in rule <a href="#grammar-production-triplesOrGraph"><code>triplesOrGraph</code></a>.
894927
</p>
895-
896-
<p>Beginning the <a href="#grammar-production-quotedTriple"><code>quotedTriple</code></a> production
897-
records the |curSubject| and |curPredicate|.
898-
Finishing the <a href="#grammar-production-quotedTriple"><code>quotedTriple</code></a> production
899-
yields the RDF triple |curSubject| |curPredicate| |curObject|
900-
and restores the recorded values of |curSubject| and |curPredicate|.</p>
901-
902-
<p>Beginning the <a href="#grammar-production-annotation"><code>annotation</code></a> production
903-
records the |curSubject| and |curPredicate|,
904-
and sets the |curSubject| to the RDF triple |curSubject| |curPredicate| |curObject|.
905-
Finishing the <a href="#grammar-production-annotation"><code>annotation</code></a> production
906-
907928
</section>
908929

909930
<section id="triple-output">
@@ -937,6 +958,60 @@ <h4 style="padding-bottom:0; margin-bottom:0;">Triple Production</h4>
937958
</p>
938959
</section>
939960

961+
<section id="reifier">
962+
<h4>Reifiers</h4>
963+
964+
<p>Beginning the <a href="#grammar-production-reifier"><code>reifier</code></a> production,
965+
the |curReifier| is taken from the <a href="#handle-reifier"><code>reifier</code></a> term constructor.
966+
Then yield the the RDF triple |curReifier| <code>rdf:reifies</code> |curTripleTerm|.</p>
967+
</section>
968+
969+
<section id="reifiedTriple">
970+
<h4>Reified Triples</h4>
971+
972+
<p>Beginning the <a href="#grammar-production-reifiedTriple"><code>reifiedTriple</code></a> production
973+
records the |curTripleTerm|.
974+
A new <a href="#grammar-production-tripleTerm"><code>tripleTerm</code></a> instance |curTripleTerm|
975+
is created using the
976+
<a href="#grammar-production-subject"><code>subject</code></a>,
977+
<a href="#grammar-production-verb"><code>verb</code></a>, and
978+
<a href="#grammar-production-object"><code>object</code></a> productions.
979+
980+
Finishing the <a href="#grammar-production-reifiedTriple"><code>reifiedTriple</code></a> production,
981+
if the |curReifier| is not set, it is assigned a fresh RDF <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a>;
982+
it next yields the RDF triple |curReifier| <code>rdf:reifies</code> |curTripleTerm|,
983+
and then restores the recorded value of the |curTripleTerm|.
984+
The node produced by matching <a href="#grammar-production-reifiedTriple"><code>reifiedTriple</code></a>
985+
is the the |curReifier|.</p>
986+
</section>
987+
988+
<section id="annotation">
989+
<h4>Annotations</h4>
990+
991+
<p>Beginning the <a href="#grammar-production-annotation"><code>annotation</code></a> production
992+
records the |curSubject| and |curPredicate|.
993+
A new <a href="#grammar-production-tripleTerm"><code>tripleTerm</code></a> instance |curTripleTerm|
994+
is created using the |curSubject| |curPredicate| |curObject|,
995+
and the value of the |curReifier| is cleared.
996+
Finishing the <a href="#grammar-production-annotation"><code>annotation</code></a> production
997+
restores the recorded values of the |curSubject| and |curPredicate|.</p>
998+
</section>
999+
1000+
<section id="annotationBlock">
1001+
<h4>Annotation Blocks</h4>
1002+
1003+
<p>Beginning the <a href="#grammar-production-annotationBlock"><code>annotationBlock</code></a> production records the |curTripleTerm|.
1004+
If the |curReifier| is not set, then it is assigned a fresh RDF <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a>
1005+
and the production yields the RDF triple |curReifier| <code>rdf:reifies</code> |curTripleTerm|.
1006+
The |curSubject| is taken from the |curReifier|
1007+
Finishing the <a href="#grammar-production-annotationBlock"><code>annotationBlock</code></a> production
1008+
clears the value of the |curReifier|
1009+
and restores the |curTripleTerm|.</p>
1010+
<p class="note">If the |curReifier| was already set, the
1011+
reifying triple |curReifier| <code>rdf:reifies</code> |curTripleTerm|
1012+
was emitted in <a href="#reifier"></a>.</p>
1013+
</section>
1014+
9401015
<section id="propertyList">
9411016
<h4 style="padding-bottom:0; margin-bottom:0;">Property Lists</h4>
9421017

@@ -1139,6 +1214,8 @@ <h2>Changes between RDF 1.1 and RDF 1.2</h2>
11391214
<li>Changes the `LANGTAG` terminal production to
11401215
<a href="#grammar-production-LANG_DIR" class="type langDir"><code>LANG_DIR</code></a> to include
11411216
an optional <a data-cite="RDF12-CONCEPTS#dfn-base-direction">base direction</a>.</li>
1217+
<li>Added <a href="#triple-terms" class="sectionRef">Triple Terms</a> for representing
1218+
<a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a> in TriG.</li>
11421219
<li>Removed the `NIL` terminal production from the grammar, which was unused.</li>
11431220
</ul>
11441221
</section>

0 commit comments

Comments
 (0)