Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add processor state, term constructor, and triple constructors. Change reifiedTriple to reifingTriple. #62

Merged
merged 22 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
aea3484
* Add processor state, term constructor, and triple constructor for `…
gkellogg Aug 11, 2024
102b6f7
Eight state variables, not seven.
gkellogg Aug 11, 2024
506d7e4
Apply suggestions from code review
gkellogg Aug 12, 2024
1873565
Use "reifingTriple" instead of "reifiedTriple".
gkellogg Aug 14, 2024
d99af73
Update spec/index.html
gkellogg Aug 14, 2024
4d7e208
"reifingTriple" => "reifyingTriple".
gkellogg Aug 14, 2024
c1e90dd
Revert the `reifyingTriple` production to `reifiedTriple`. This bette…
gkellogg Aug 17, 2024
07960c1
`reifier` is optional, not zero or more, in `reifiedtriple`.
gkellogg Aug 17, 2024
c14ab8d
Apply suggestions from code review
gkellogg Aug 19, 2024
06cf7ff
Remove trailing ":" from RDF Triples Constructors sub-sections.
gkellogg Aug 24, 2024
79eb5f6
Switch Annotations and Annotation BLock Triples Constructors.
gkellogg Aug 24, 2024
778d4c0
Move emitting the reifing triple to the beginning of the Annotation B…
gkellogg Aug 24, 2024
9d6ada0
Use `verb` rather than `predicate` in the `reifiedTriple` EBNF produc…
gkellogg Aug 24, 2024
41b6da1
Update spec/index.html
gkellogg Aug 24, 2024
ca01a5f
Apply suggestions from code review
gkellogg Aug 26, 2024
91a72b2
* In the Annotations
gkellogg Aug 25, 2024
6300061
Add other productions that bind to curSubject.
gkellogg Aug 26, 2024
2d4b70a
Improve naming consistency.
gkellogg Aug 26, 2024
8e718f9
Retool Triple Constructors based on feedback.
gkellogg Aug 26, 2024
5d909e4
In Processor State explain that "records" creates a stack of saved va…
gkellogg Aug 26, 2024
3ad14fb
Stack `curReifier` in Annotations.
gkellogg Aug 26, 2024
15297c9
The value of `curReifier` does not need to be saved/restored in Annot…
gkellogg Aug 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 52 additions & 30 deletions spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1659,9 +1659,7 @@ <h2>Parsing</h2>
<section id="sec-parsing-state">
<h3>Parser State</h3>

<p>Parsing Turtle requires a state of six items:</p>

<p class="ednote">Describe parser state for tracking reifier to be associated with an annotation block.</p>
<p>Parsing Turtle requires a state of eight items:</p>

<ul>
<li id="baseURI">IRI |baseURI|
Expand Down Expand Up @@ -1718,6 +1716,13 @@ <h3>Parser State</h3>
The |curObject| is bound to the
<a href="#grammar-production-object"><code>object</code></a> and
<a href="#grammar-production-ttObject"><code>ttObject</code></a> productions.</li>
<li id="curReifier"><a data-cite="RDF12-CONCEPTS#dfn-rdf-term">RDF Term</a> |curReifier| —
The |curReifier| is bound to the
<a href="#grammar-production-reifier"><code>reifier</code></a> and
<a href="#grammar-production-annotationBlock"><code>annotationBlock</code></a> productions.</li>
<li id="curTripleTerm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple term</a> |curTripleTerm| —
Is set in the <a href="#annotation">Annotations</a> constructor.
gkellogg marked this conversation as resolved.
Show resolved Hide resolved
</li>
</ul>
</section>

Expand Down Expand Up @@ -1753,6 +1758,16 @@ <h3>RDF Term Constructors</h3>
<tr id="handle-blankNodePropertyList" ><td style="text-align:left;" ><a class="type bNode" href="#grammar-production-blankNodePropertyList" >blankNodePropertyList </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>
<tr id="handle-collection" ><td style="text-align:left;" rowspan="2"><a class="type bNode" href="#grammar-production-collection" >collection </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>
<tr id="handle-collection2" > <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>
<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>
| <a data-cite="RDF12-CONCEPTS#dfn-blank-node"> blank node </a></td>
<td>
The <a data-cite="RDF12-CONCEPTS#dfn-rdf-term">term</a> sets |curReifier| and is taken from the matched
<a href="#grammar-production-iri"><code>iri</code></a> production
or <a href="#grammar-production-BlankNode"><code>BlankNode</code></a> production, if any.
If no such production is matched, it is taken
from a fresh RDF <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a>.
gkellogg marked this conversation as resolved.
Show resolved Hide resolved
</td>
</tr>
<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>
<td>
The <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple term</a>
Expand All @@ -1762,28 +1777,19 @@ <h3>RDF Term Constructors</h3>
<a href="#grammar-production-ttObject"><code>ttObject</code></a> productions.
</td>
</tr>
<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>
<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>
<td>
The <a class="type reifiedTriple" href="#grammar-production-reifiedTriple">reifiedTriple</a> production
defines an RDF term in addition to a <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple term</a>.
The term constructed from this production
is composed of an optional identifier from either the <a href="#grammar-production-iri"><code>iri</code></a>
production or the <a href="#grammar-production-BlankNode"><code>BlankNode</code></a> production,
if present, otherwise from a fresh RDF <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a>.
The <a data-cite="RDF12-CONCEPTS#dfn-rdf-term">term</a> taken from the matched <a href="#grammar-production-reifier"><code>reifier</code></a>, if any,
gkellogg marked this conversation as resolved.
Show resolved Hide resolved
or from a fresh RDF <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a>.
</td>
</tr>
<tr id="handle-annotation" ><td style="text-align:left;" ><a class="type annotation" href="#grammar-production-annotation" >annotation </a></td><td><a data-cite="RDF12-CONCEPTS#dfn-iri">IRI</a> | <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a></td>
<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>
<td>
The <a href="#grammar-production-annotation"><code>annotation</code></a> production
defines an RDF term in addition to a <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple term</a>.
The term constructed from this production
is composed of an identifier from either the <a href="#grammar-production-iri"><code>iri</code></a>
or <a href="#grammar-production-BlankNode"><code>BlankNode</code></a> productions,
if present, otherwise from a fresh RDF <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a>.
<div class="ednote">Requires state to recall any previously defined <a href="#grammar-production-reifier"><code>reifier</code></a>.</div>
The <a data-cite="RDF12-CONCEPTS#dfn-rdf-term">term</a> taken from a previously matched <a>reifier</a>, if any,
gkellogg marked this conversation as resolved.
Show resolved Hide resolved
or from a fresh RDF <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a>.
</td>
</tr>
</tbody>
</tbody>
</table>

</section>
Expand All @@ -1807,35 +1813,51 @@ <h4 id="tripleTerm" style="padding-bottom:0; margin-bottom:0;"><span>Triple Term
<p>Beginning the <a href="#grammar-production-tripleTerm"><code>tripleTerm</code></a> production
records the |curSubject| and |curPredicate|.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small errata to RDF 1.1:

  • It does not say that curSubject and curPredicate are stacks, or alternative the parser state is a stack.
  • It says in 7.3 "The curSubject is bound to the subject production." True but it is more than just subject even in RDF 1.1 (subject position, blankNodePropertyList, property lists in the object position and collections). RDF 1.2 adds the tripleTerm, reifiedTriple, annotation and annotationBlock cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither curSubject nor curPredicate (nor the parser state in general) is a stack, they are global state. Triple constructors save and restore their values, so the "stack" is implemented via the activation records of these constructors, such as the Triple Term constructor.

Finishing the <a href="#grammar-production-tripleTerm"><code>tripleTerm</code></a> production
and restores the recorded values of |curSubject| and |curPredicate|.</p>
restores the recorded values of |curSubject| and |curPredicate|.</p>
gkellogg marked this conversation as resolved.
Show resolved Hide resolved

<h4 id="reifier" style="padding-bottom:0; margin-bottom:0;"><span>Reifiers:</span></h4>
<h4 id="reifier" style="padding-bottom:0; margin-bottom:0;"><span>Reifier:</span></h4>
gkellogg marked this conversation as resolved.
Show resolved Hide resolved

<p>Beginning the <a href="#grammar-production-reifier"><code>reifier</code></a> production,
if |curReifier| is set, the production yields the RDF triple |curReifier| <code>rdf:reifies</code> |curTripleTerm|.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if |curReifier| is set,

It is not set until the end of the production so it is that previous sate at this point.

The production will set curReifier - there 's no "if". Do this now and not at the end, then yield the reifies triple using curReifier.

Suggested change
if |curReifier| is set, the production yields the RDF triple |curReifier| <code>rdf:reifies</code> |curTripleTerm|.
|curReifier| is taken from the <a href="#handle-reifier"><code>reifier</code></a> term constructor.
For the |tripleTerm| from the last RDF triple yielded then yield the the RDF triple |curReifier| <code>rdf:reifies</code> |curTripleTerm|.

There is no need to have a stack for curReifier. Even in annotations, only the last value is needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The text is intended to capture the events generated by :s :p :o ~:r1 ~:r2. When seeing ~:r1 there is no previously established curReifier so nothing is emitted, then curReifier is set from the reifier term constructor. The next time when it sees ~:r2, curReifier would be :r1 so :ri rdf:reifies <<(...)>> is emitted and then curReifier is set to :r2.

There is no stack for curReifier, there is just if it was previously set or not (Note that there is no text that says to save the value of curReifier anywhere). It is cleared when entering Annotations, set in either ReifierorAnnotation Block, and consumed in Reifier, Annotation BlockorAnnotations`.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm beginning to see what you want to do here but then some text does seem right.

Finishing the annotation production yields the RDF triple curReifier rdf:reifies curTripleTerm, resets the value of curReifier

needs a condition that curReifier is set. In :s :p :o ~:r {| :x :y |} it is not (it's been used). That's where I see identical triples being emitted once for the annotationBlock and one at the and of annotations.

There needs to be more recording and restoring:

  :s :p :o ~:r1 {| :x1 :y2 ~:r2 {| :xx1 :yy2 |} ;
                   :x2 :y2
                 |}.

which I think is:

:s :p :o .
:r1 rdf:reifies <<( :s :p :o )>> .
:r1 :x1 :y2 .
:r2 rdf:reifies <<( :r1 :x1 :y2 )>> .
:r2 :xx1 :yy2 .
:r1 :x2 :y2 .

note :r1 :x2 :y2.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what my parser produces.

Finishing the <a href="#grammar-production-reifier"><code>reifier</code></a> production
gkellogg marked this conversation as resolved.
Show resolved Hide resolved
|curReifier| is taken from the <a href="#handle-reifier"><code>reifier</code></a> term constructor.</p>

<h4 id="reifiedTriple" style="padding-bottom:0; margin-bottom:0;"><span>Reified Triple:</span></h4>

<p>Beginning the <a href="#grammar-production-reifiedTriple"><code>reifiedTriple</code></a> production
records the |curSubject| and |curPredicate|.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the parser state section, maybe explain "record" means a stack.

|curSubject| is taken from the
<a href="#handle-reifiedTriple"><code>reifiedTriple</code></a> term constructor.
<a href="#handle-reifiedTriple"><code>reifiedTriple</code></a> term constructor,
gkellogg marked this conversation as resolved.
Show resolved Hide resolved
or a fresh RDF blank node, if not matched.
A new <a href="#grammar-production-tripleTerm"><code>tripleTerm</code></a> instance |TT|
is composed from
the <a href="#grammar-production-subject"><code>subject</code></a>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may not be the subject production. It can be reifiedTriple. They both set curSubject but that is used used later as the reifier carried over.

<a href="#grammar-production-predicate"><code>predicate</code></a>, and
<a href="#grammar-production-object"><code>object</code></a> productions.
Finishing the <a href="#grammar-production-reifier"><code>reifier</code></a> production
Finishing the <a href="#grammar-production-reifiedTriple"><code>reifiedTriple</code></a> production
yields the RDF triple |curSubject| <code>rdf:reifies</code> |TT|
Copy link
Contributor

@afs afs Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curSubject may have been modified by the subject/reifiedTriple in the subject position inside << >>.
It might be batter use curReifier and make it a stack (for annotation and asserted triples it does not need to be a stack as in comment above.

and restores the recorded values of |curSubject| and |curPredicate|.</p>

<h4 id="annotationBlock" style="padding-bottom:0; margin-bottom:0;"><span>Annotation Block:</span></h4>
afs marked this conversation as resolved.
Show resolved Hide resolved

<p>Beginning the <a href="#grammar-production-annotationBlock"><code>annotationBlock</code></a> production
gkellogg marked this conversation as resolved.
Show resolved Hide resolved
|curReifier| is taken from a fresh RDF <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a> if not already set,
gkellogg marked this conversation as resolved.
Show resolved Hide resolved
and |curSubject| is taken from |curReifier|.
Finishing the <a href="#grammar-production-annotationBlock"><code>annotationBlock</code></a> production
yields the RDF triple |curReifier| <code>rdf:reifies</code> |curTripleTerm|,
and resets the value of |curReifier|.</p>
gkellogg marked this conversation as resolved.
Show resolved Hide resolved

<h4 id="annotation" style="padding-bottom:0; margin-bottom:0;"><span>Annotations:</span></h4>

<p>Beginning the <a href="#grammar-production-annotation"><code>annotation</code></a> production
records the |curSubject| and |curPredicate|.
A new <a href="#grammar-production-tripleTerm"><code>tripleTerm</code></a> instance |TT|
is created using |curSubject| |curPredicate| |curObject|.
The identifier |TI| is taken from the
<a href="#handle-annotation"><code>annotation</code></a> term constructor.
A new <a href="#grammar-production-tripleTerm"><code>tripleTerm</code></a> instance |curTripleTerm|
is created using |curSubject| |curPredicate| |curObject|,
and the value of |curReifier| is reset.
gkellogg marked this conversation as resolved.
Show resolved Hide resolved
Finishing the <a href="#grammar-production-annotation"><code>annotation</code></a> production
yields the RDF triple |TI| <code>rdf:reifies</code> |TT|
yields the RDF triple |curReifier| <code>rdf:reifies</code> |curTripleTerm|,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rdf:reifies triple is generated in AnnotationBlock.

The "annotation" production is annotation ::= (reifier | annotationBlock)* so I don't think there is much to do here especially if the rdf:refies triple is generated at the start of an annotationBlock and all reifier needs to do is set curReifier which gets carried to the next block only (or the reifiedTriple case).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, this is needed to emit the reifying triple if |curReifier| was not consumed in an Annotation Block. For example :s :p :o ~ :r.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - I will reread but I thought a reifing triple was created in both parts for ~:r {| :q :z |}. Maybe Annotation Block only handled the "no explicit reifier case".

And :s :p :o :~r1 ~:r2 .

resets the value of |curReifier|,
and restores the recorded values of |curSubject| and |curPredicate|.</p>
<p class="ednote">Describe parser state for recording and assigning any <a>reifier</a>.</p>

<h4 id="propertyList" style="padding-bottom:0; margin-bottom:0;"><span>Property Lists:</span></h4>

Expand Down Expand Up @@ -2174,7 +2196,7 @@ <h2>Changes between RDF 1.1 and RDF 1.2</h2>
and `STRING_LITERAL_SINGLE_QUOTE`.</li>
<li>Separated <a href="#security"></a> from <a href="#sec-mediaReg"></a>
and updated language.</li>
<li>Added <a href="#reifiers" class="sectionRef"></a>
<li>Added <a href="#triple-terms" class="sectionRef"></a>, <a href="#reified-triples" class="sectionRef"></a>,
and <a href="#annotation-syntax" class="sectionRef"></a>
for representing <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a> in Turtle.</li>
<li>Changes the `LANGTAG` terminal production to
Expand Down
Loading
Loading