Production rules for satisfying the "prefix_only_IRI" turtle parser test

There is a turtle parser test in the W3C unit tests labelled
"prefix_only_IRI".

The RDF to be parsed is:

@prefix p: <http://a.example/s>.
p: <http://a.example/p> <http://a.example/o> .

The RDF graph expected in memory is:

<http://a.example/s> <http://a.example/p> <http://a.example/o> .

Because p in p: has been expanded to http://a.example/s and what follows
":" is an empty string, so the expanded prefix for p is the URI for the
subject.

My question is about how this conforms to the turtle grammar rules at
http://www.w3.org/TR/turtle/#sec-grammar-grammar . The relevant production
rules are:

[139s] PNAME_NS::= PN_PREFIX? ':'
[140s] PNAME_LN::= PNAME_NS PN_LOCAL
[168s] PN_LOCAL::= (PN_CHARS_U | ':' | [0-9] | PLX) ((PN_CHARS | '.' | ':'
| PLX)* (PN_CHARS | ':' | PLX))?

The "p:" satisfies PNAME_NS, so now to satisfy PN_LOCAL in order to satisfy
PNAME_LN. In the "prefix_only_IRI" test case, what follows the ":" is an
empty string. I don't see how an empty string can be satisfied by PN_LOCAL,
given the first component of PN_LOCAL is:

(PN_CHARS_U | ':' | [0-9] | PLX)

So, how does the "prefix_only_IRI" turtle parsing test conform to the
grammar rules for turtle syntax?

Thanks,

--
Rob Stewart

Received on Thursday, 19 November 2015 23:00:28 UTC