From aea34849d274019af2d2303df984da704985b0df Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Sat, 10 Aug 2024 17:45:36 -0700 Subject: [PATCH 01/22] * Add processor state, term constructor, and triple constructor for `annotationBlock`, `tripleTerm`, and `reifier`. * Extract the `annotationBlock` production from the `annotation` production. --- spec/index.html | 82 ++++++++++++++++++++++++++++---------------- spec/turtle-bnf.html | 58 +++++++++++++++++-------------- spec/turtle.bnf | 3 +- 3 files changed, 86 insertions(+), 57 deletions(-) diff --git a/spec/index.html b/spec/index.html index 662137c..d3e638f 100644 --- a/spec/index.html +++ b/spec/index.html @@ -1659,9 +1659,7 @@

Parsing

Parser State

-

Parsing Turtle requires a state of six items:

- -

Describe parser state for tracking reifier to be associated with an annotation block.

+

Parsing Turtle requires a state of seven items:

@@ -1753,6 +1758,16 @@

RDF Term Constructors

blankNodePropertyList blank node A blank node is generated. Note the rules for blankNodePropertyList in the next section. collection blank node For non-empty lists, a blank node is generated. Note the rules for collection in the next section. IRI For empty lists, the resulting IRI is rdf:nil. Note the rules for collection in the next section. + reifier IRI + | blank node + + The term sets |curReifier| and is taken from the matched + iri production + or BlankNode production, if any. + If no such production is matched, it is taken + from a fresh RDF blank node. + + tripleTerm triple term The triple term @@ -1762,28 +1777,19 @@

RDF Term Constructors

ttObject productions. - reifiedTriple IRI | blank node + reifiedTriple IRI | blank node - The reifiedTriple production - defines an RDF term in addition to a triple term. - The term constructed from this production - is composed of an optional identifier from either the iri - production or the BlankNode production, - if present, otherwise from a fresh RDF blank node. + The term taken from the matched reifier, if any, + or from a fresh RDF blank node. - annotation IRI | blank node + annotationBlock IRI | blank node - The annotation production - defines an RDF term in addition to a triple term. - The term constructed from this production - is composed of an identifier from either the iri - or BlankNode productions, - if present, otherwise from a fresh RDF blank node. -
Requires state to recall any previously defined reifier.
+ The term taken from a previously matched reifier, if any, + or from a fresh RDF blank node. - + @@ -1807,35 +1813,51 @@

Triple Term

Beginning the tripleTerm production records the |curSubject| and |curPredicate|. Finishing the tripleTerm production - and restores the recorded values of |curSubject| and |curPredicate|.

+ restores the recorded values of |curSubject| and |curPredicate|.

-

Reifiers:

+

Reifier:

+ +

Beginning the reifier production, + if |curReifier| is set, the production yields the RDF triple |curReifier| rdf:reifies |curTripleTerm|. + Finishing the reifier production + |curReifier| is taken from the reifier term constructor.

+ +

Reified Triple:

Beginning the reifiedTriple production records the |curSubject| and |curPredicate|. |curSubject| is taken from the - reifiedTriple term constructor. + reifiedTriple term constructor, + or a fresh RDF blank node, if not matched. A new tripleTerm instance |TT| is composed from the subject, predicate, and object productions. - Finishing the reifier production + Finishing the reifiedTriple production yields the RDF triple |curSubject| rdf:reifies |TT| and restores the recorded values of |curSubject| and |curPredicate|.

+

Annotation Block:

+ +

Beginning the annotationBlock production + |curReifier| is taken from a fresh RDF blank node if not already set, + and |curSubject| is taken from |curReifier|. + Finishing the annotationBlock production + yields the RDF triple |curReifier| rdf:reifies |curTripleTerm|, + and resets the value of |curReifier|.

+

Annotations:

Beginning the annotation production records the |curSubject| and |curPredicate|. - A new tripleTerm instance |TT| - is created using |curSubject| |curPredicate| |curObject|. - The identifier |TI| is taken from the - annotation term constructor. + A new tripleTerm instance |curTripleTerm| + is created using |curSubject| |curPredicate| |curObject|, + and the value of |curReifier| is reset. Finishing the annotation production - yields the RDF triple |TI| rdf:reifies |TT| + yields the RDF triple |curReifier| rdf:reifies |curTripleTerm|, + resets the value of |curReifier|, and restores the recorded values of |curSubject| and |curPredicate|.

-

Describe parser state for recording and assigning any reifier.

Property Lists:

@@ -2174,7 +2196,7 @@

Changes between RDF 1.1 and RDF 1.2

and `STRING_LITERAL_SINGLE_QUOTE`.
  • Separated from and updated language.
  • -
  • Added +
  • Added , , and for representing triple terms in Turtle.
  • Changes the `LANGTAG` terminal production to diff --git a/spec/turtle-bnf.html b/spec/turtle-bnf.html index 4bb5e0b..abf5210 100644 --- a/spec/turtle-bnf.html +++ b/spec/turtle-bnf.html @@ -179,7 +179,13 @@ [30] annotation ::= - (reifier | ('{|' predicateObjectList '|}'))* + (reifier | annotationBlock)* + + + [31] + annotationBlock + ::= + '{|' predicateObjectList '|}' @@ -194,103 +200,103 @@

    Productions for terminals


    /* #x00=NULL #x01-#x1F=control codes #x20=space */ - [33] + [34] PNAME_NS ::= PN_PREFIX? ':' - [34] + [35] PNAME_LN ::= PNAME_NS PN_LOCAL - [35] + [36] BLANK_NODE_LABEL ::= '_:' (PN_CHARS_U | [0-9]) ((PN_CHARS | '.')* PN_CHARS)? - [36] + [37] LANG_DIR ::= '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)* ('--' [a-zA-Z]+)? - [37] + [38] INTEGER ::= [+-]? [0-9]+ - [38] + [39] DECIMAL ::= [+-]? ([0-9]* '.' [0-9]+) - [39] + [40] DOUBLE ::= [+-]? (([0-9]+ '.' [0-9]* EXPONENT) | ('.' [0-9]+ EXPONENT) | ([0-9]+ EXPONENT)) - [40] + [41] EXPONENT ::= [eE] [+-]? [0-9]+ - [41] + [42] STRING_LITERAL_QUOTE ::= '"' ([^#x22#x5C#x0A#x0D] | ECHAR | UCHAR)* '"' - [42] + [43] STRING_LITERAL_SINGLE_QUOTE ::= "'" ([^#x27#x5C#x0A#x0D] | ECHAR | UCHAR)* "'" - [43] + [44] STRING_LITERAL_LONG_SINGLE_QUOTE ::= "'''" (("'" | "''")? ([^'\] | ECHAR | UCHAR))* "'''" - [44] + [45] STRING_LITERAL_LONG_QUOTE ::= '"""' (('"' | '""')? ([^"\] | ECHAR | UCHAR))* '"""' - [45] + [46] UCHAR ::= ('\u' HEX HEX HEX HEX) | ('\U' HEX HEX HEX HEX HEX HEX HEX HEX) - [46] + [47] ECHAR ::= '\' [tbnrf\"'] - [47] + [48] WS ::= #x20 | #x09 | #x0D | #x0A - [48] + [49] ANON ::= '[' WS* ']' - [49] + [50] PN_CHARS_BASE ::= [A-Z] @@ -361,49 +367,49 @@

    Productions for terminals

    [#x00010000-#x000EFFFF] - [50] + [51] PN_CHARS_U ::= PN_CHARS_BASE | '_' - [51] + [52] PN_CHARS ::= PN_CHARS_U | '-' | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040] - [52] + [53] PN_PREFIX ::= PN_CHARS_BASE ((PN_CHARS | '.')* PN_CHARS)? - [53] + [54] PN_LOCAL ::= (PN_CHARS_U | ':' | [0-9] | PLX) ((PN_CHARS | '.' | ':' | PLX)* (PN_CHARS | ':' | PLX))? - [54] + [55] PLX ::= PERCENT | PN_LOCAL_ESC - [55] + [56] PERCENT ::= '%' HEX HEX - [56] + [57] HEX ::= [0-9] | [A-F] | [a-f] - [57] + [58] PN_LOCAL_ESC ::= '\' ('_' | '~' | '.' | '-' | "!" | '$' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '%') diff --git a/spec/turtle.bnf b/spec/turtle.bnf index 81d5f1e..e99b0bf 100644 --- a/spec/turtle.bnf +++ b/spec/turtle.bnf @@ -30,7 +30,8 @@ reifiedTriple ::= '<<' (subject | reifiedTriple) predicate object reifie tripleTerm ::= '<<(' ttSubject predicate ttObject ')>>' ttSubject ::= iri | BlankNode ttObject ::= iri | BlankNode | literal | tripleTerm -annotation ::= (reifier | '{|' predicateObjectList '|}')* +annotation ::= (reifier | annotationBlock)* +annotationBlock ::= '{|' predicateObjectList '|}' @terminals From 102b6f7e47a635f1c6b12eac3897d138fb6d0453 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Sat, 10 Aug 2024 17:50:25 -0700 Subject: [PATCH 02/22] Eight state variables, not seven. --- spec/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/index.html b/spec/index.html index d3e638f..0efc018 100644 --- a/spec/index.html +++ b/spec/index.html @@ -1659,7 +1659,7 @@

    Parsing

    Parser State

    -

    Parsing Turtle requires a state of seven items:

    +

    Parsing Turtle requires a state of eight items:

    • IRI |baseURI| From 506d7e417670a6880b935136d8380ff23ff8d50b Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 12 Aug 2024 13:32:06 -0700 Subject: [PATCH 03/22] Apply suggestions from code review Co-authored-by: Ted Thibodeau Jr --- spec/index.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/index.html b/spec/index.html index 0efc018..ca31251 100644 --- a/spec/index.html +++ b/spec/index.html @@ -1721,7 +1721,7 @@

      Parser State

      reifier and annotationBlock productions.
    • Triple term |curTripleTerm| — - Is set in the Annotations constructor. + The |curTripleTerm| is set in the Annotations constructor.
    @@ -1761,10 +1761,10 @@

    RDF Term Constructors

    reifier IRI | blank node - The term sets |curReifier| and is taken from the matched + The |curReifier| is set from term, which is taken from the matched iri production or BlankNode production, if any. - If no such production is matched, it is taken + If no such production is matched, term is taken from a fresh RDF blank node. @@ -1779,13 +1779,13 @@

    RDF Term Constructors

    reifiedTriple IRI | blank node - The term taken from the matched reifier, if any, + The term is taken from the matched reifier, if any, or from a fresh RDF blank node. annotationBlock IRI | blank node - The term taken from a previously matched reifier, if any, + The term is taken from a previously matched reifier, if any, or from a fresh RDF blank node. @@ -1819,7 +1819,7 @@

    Reifier:Beginning the reifier production, if |curReifier| is set, the production yields the RDF triple |curReifier| rdf:reifies |curTripleTerm|. - Finishing the reifier production + Finishing the reifier production, |curReifier| is taken from the reifier term constructor.

    Reified Triple:

    @@ -1840,8 +1840,8 @@

    Reified

    Annotation Block:

    -

    Beginning the annotationBlock production - |curReifier| is taken from a fresh RDF blank node if not already set, +

    Beginning the annotationBlock production, + |curReifier| is taken from a fresh RDF blank node, if not already set, and |curSubject| is taken from |curReifier|. Finishing the annotationBlock production yields the RDF triple |curReifier| rdf:reifies |curTripleTerm|, From 18735654a7e9617b7ce8d20c1a707ccfbb029896 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Wed, 14 Aug 2024 12:12:05 -0700 Subject: [PATCH 04/22] Use "reifingTriple" instead of "reifiedTriple". --- spec/index.html | 50 ++++++++++++++++++++++---------------------- spec/turtle-bnf.html | 10 ++++----- spec/turtle.bnf | 6 +++--- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/spec/index.html b/spec/index.html index ca31251..1f48953 100644 --- a/spec/index.html +++ b/spec/index.html @@ -125,7 +125,7 @@ triple, making it possible to make statements about other statements. Triple terms are typically not used explicitly - as the reifiedTriple construction is generally preferred. + as the reifingTriple construction is generally preferred. RDF 1.2 Turtle also adds support for directional language-tagged strings.

    @@ -812,15 +812,15 @@

    Triple Terms

    -
    -

    Reified Triples

    +
    +

    Reifing Triples

    -

    A reified triple +

    A reifing triple may be the subject or object of an RDF triple.

    -

    A reified triple is syntactic sugar for a specific relationship between an +

    A reifing triple is syntactic sugar for a specific relationship between an identifier (reifier) and a triple term. The identifier becomes a way to indirectly refer to a triple term, which @@ -833,11 +833,11 @@

    Reified Triples

    RDF 1.2 uses the term to identify a triple term using the `rdf:reifies` predicate.

    -

    A reified triple is represented using the - reifiedTriple production +

    A reifing triple is represented using the + reifingTriple production starting with <<, followed by either a subject - or reifiedTriple, + or reifingTriple, a predicate, and a ttObject, followed by an optional reifier, @@ -854,20 +854,20 @@

    Reified Triples

    as with `<< :subject :predicate :object >>`, or `<< :subject :predicate :object ~ >>`.

    -

    Reified Triples may be nested, +

    Reifing Triples may be nested, like
    `<< :subject1 :predicate1 << :subject2 :predicate2 :object2 >> ~:IRIREF1 >>` or
    `<< :subject4 :predicate4 << :subject3 :predicate3 :object3 ~:IRIREF3 >> >>`.

    -

    If a reifiedTriple +

    If a reifingTriple is not identified by an IRI or blank node, a fresh RDF blank node is allocated and used to identify this relationship.

    -
    +         title="Reifing Triple">
           
         
    -
    +         title="Reifing Triple with explicit reifier">
           
         
    -
    +         title="Reifying Triple with explicit reifier">
           
         
    -
    +         title="Reified Triple with explicit reifier">