w3c / rdf-turtle

https://w3c.github.io/rdf-turtle/
Other
6 stars 4 forks source link

Need to save curTripleTerm on entry/exit to reifiedTriple and annotationBlock #67

Closed gkellogg closed 3 weeks ago

gkellogg commented 1 month ago

Consider the following:

:s :p :o ~:r1 {| :p1 << :s2 :p2 :o2 >> |} ~:r2

This is intended to be the same as the following N-Triples:

:s :p :o .
:r1 rdf:reifies <<(:s :p :o)>> .
:r1 :p1 _:r0 .
_:r0 rdf:reifies <<(:s2 :p2 :o2)>> .
:r2 rdf:reifies <<(:s :p :o)>> .

However, because curTripleTerm is reset to <<(:s2 :p2 :o2)>> when parsing the inner reified triple, it forgets the original <<(:s :p :o)>> when it gets to ~:r2. The same thing can happen with annotations. this would result in the following incorrect output:

:s :p :o .
:r1 rdf:reifies <<(:s :p :o)>> .
:r1 :p1 _:r0 .
_:r0 rdf:reifies <<(:s2 :p2 :o2)>> .
:r2 rdf:reifies <<(:s2 :p2 :o2)>> .

Instead, productions need to save and restore the value of curTripleTerm on entry and exit to reifiedTriple and annotationBlock productions.