Re: Possible issues with N3 grammar

Hi Gregg,

> On Jun 18, 2024, at 12:24 PM, Gregg Kellogg <gregg@greggkellogg.net> wrote:
> 
> Also sorry for late response.
> 
> Directives (@base and @prefix) are not scoped and are considered positionally in the parsed text stream. The Turtle document makes clear that the BASE directive sets a new Base IRI relative to the current base. It is not scoped to any graph that it might be contained in. The same should be true for PREFIX, and PREFIX definitions can be redefined, possibly including the previous mapping for that prefix.

Turtle does not have nested graph terms though.

> While not particularly relevant for Turtle, the TriG grammar does not allow a directive inside of a graph; directives only appear between statements. It would make sense to have the same restrictions for N3.
> 
> The N3 grammar has no such restrictions, and it might make sense to introduce them, but in any case, I consider the effect of directives to begin at the point their introduced and stay in effect until the end of parsing, unless another directive overrides it. This means that @prefix could be defined within a formula and still be in effect after that formula is closed.

I'm wondering how this would then work with log:semantics or log:parsedAsN3? An N3 string (e.g., loaded from a remote location) could thus override "internal" namespaces, or, they may not even be allowed their own namespaces.


W

> Gregg Kellogg
> gregg@greggkellogg.net
> 
>> On Jun 9, 2024, at 2:42 PM, William Van Woensel <william.vanwoensel@gmail.com> wrote:
>> 
>> Hello everyone,
>> 
>> Upon revisiting the N3 grammar, I found some potential issues / ambiguities:
>> 
>> 
>> - What do you expect the scope of @prefix, @base within these graph terms to be? E.g., 
>> @prefix : <http://example.org/> .
>> 
>> :a :b {
>>  @prefix : <http://anotherexample.org/> .
>>    :d :e :f .
>> } .
>> 
>> :g :h :i .
>> 
>> What should the namespace for :g, :h and :i  be? (eye thinks it's the second namespace; jen3 thinks it's the first).
>> https://editor.notation3.org/s/rXp1ZqnM 
>> 
>> 
>> - According to the grammar <https://w3c.github.io/N3/spec/#grammar>, collections can include any expression; so, also resource paths and (blank node / iri) property lists.
>> 
>> Admittedly, I never thought about this much, but I think that only the following should be allowed: iri | blankNode | quickVar | collection | literal | formula.
>> Both eye and jen3 generate the same for the following (adding separate triples outside of the collection):
>> 
>> @prefix : <http://example.org/> .
>> :a :b ( :x!:y [ :b 1 ; :c 2 ] :d ) .
>> 
>> https://editor.notation3.org/s/zzqFtaaa 
>> 
>> But is it what people would expect? Or is it useful as a kind of "shorthand"?
>> 
>> 
>> 
>> William
> 

Received on Tuesday, 18 June 2024 16:57:10 UTC