Re: [Turtle] Grammar ambiguity?

Hello!

Just copying an email from Jan Wielemaker (main developer of SWI-Prolog - he also wrote its Turtle parser), who suggests "18." should be made invalid.

> >> > The below valid N3 file cannot be parsed:
> >> > @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
> >> > @prefix : <http://localhost#>.
> >> > :Person
> >> > rdf:type        :Person;
> >> > :age            18.
> >
> > Which is (AFAIK) correct.  Rapper (from the Redland RDF toolkit)
> > agrees.  The problem is ambiguity introduced by the .  That is
> > why many people always put a space before the terminating ..
> >
>
> You're right - although the grammar [1] doesn't seem to forbid it?

This is not so clear.  It says that a decimal is (among others)

       [0-9]+ '.' [0-9]*

so, "18." is decimal.  Then, it says:

White space (production ws) is used to separate two tokens which would
otherwise be (mis-)recognized as one token.

I think that combining these justifies that you MUST write 18 .

Note that the . is similar as in Prolog, but Prolog does not accept
18. as a float.  This MUST be written as 18.0.

> Implementations seem to disagree on how to interpret it as well, e.g.
> http://www.rdfabout.com/demo/validator/ seems to think it is OK.

I think you should resubmit your bug report there :-)

> We're currently working on making the Turtle spec a recommendation in
> the new RDF XG at the W3C, so perhaps something to look into?

The role of the ., is as far as I'm concerned, the main issue about
Turtle.  I would love to be able to use . in local names, just like
SPARQL.  I guess the other topic is the relation to named graphs.

       Cheers --- Jan

Received on Monday, 28 February 2011 13:08:48 UTC