W3C home > Mailing lists > Public > semantic-web@w3.org > September 2012

Re: N3 and Turtle Syntax Questions

From: Gregg Kellogg <gregg@greggkellogg.net>
Date: Mon, 10 Sep 2012 18:44:06 -0400
To: Hugh Glaser <hugh.glaser@seme4.com>
CC: "public-rdf-comments@w3.org" <public-rdf-comments@w3.org>, Sandro Hawke <sandro@w3.org>, SW-forum Web <semantic-web@w3.org>, Tim Berners-Lee <timbl@w3.org>
Message-ID: <CC02F56E-0000-4A33-B25C-66251A470D44@kellogg-assoc.com>
\On Sep 10, 2012, at 9:59 AM, Hugh Glaser <hugh.glaser@seme4.com> wrote:

> Hi,
> Sandro has asked on the SemWeb list if there are any comments on Turtle syntax.
> I raised an issue (forwarded below) a few years ago, but it looks to me like the syntax is still the same.
> 
> I would like the syntax to allow comma and semicolon as a terminator (and thus also to be compatible with N3).

Production 7 does allow a statement to end with a semicolon:

[7]	predicateObjectList	::=	verb objectList (';' predicateObjectList?)*

However, production 8 does not allow this:

[8]	objectList	::=	object (',' object)*

It would be fairly easy, and would allow exactly the same form as 7, to just make it objectList ::= object (',' object?)*, or even objectList ::= object (',' objectList?)*. Either of these would create more recursive parser states and are certainly not optimal, but that's not really the standard for publishing normative grammars. I could go either way on making this change.

Gregg

> Hopefully the message is still sufficiently explanatory, but please ask if you need elaboration.
> Best
> Hugh
> 
> On 10 Jan 2008, at 02:25, Tim Berners-Lee <timbl@w3.org> wrote:
> 
>> Oh, I completely understand why -- that's indeed why N3 has it.
>> (I have sed files for generating N3 -- very practical. Don't tell anyone.)
>> Mind you, I have always been generating pred-object pairs,
>> so I have used the ability to end in a semicolon, not a comma.
>> 
>> Tim
>> 
>> PS: IIRC  Pascal and Algol has the same problem. See e.g.http://www.lysator.liu.se/c/bwk-on-pascal.html "Pascal, in common with most other Algol-inspired languages, uses the semicolon as a statement separator rather than a terminator". Just because I shave it off doesn't mean it ain't grey ;-)  Ee bah gum, when I were a lad, were would be lucky to even *have* semicolons, ... ;-)
>> 
>> On 2008-01 -09, at 14:33, Hugh Glaser wrote:
>> 
>>> 
>>> This was going to be a quick confirmation on N3 and turtle syntax for ';'
>>> and ',', but seems to have got a bit complicated.
>>> 
>>> I want to write
>>> 
>>> @prefix owl:  <http://www.w3.org/2002/07/owl#> .
>>> <http://southampton.rkbexplorer.com/id/person-00021>
>>> owl:sameAs <http://citeseer.rkbexplorer.com/id/resource-CSP109020> ;
>>> owl:sameAs 
>>> <http://dblp.rkbexplorer.com/id/people-1726e6ee8fb20c8704f47285949b39b3-d101
>>> 32da488b7179a8b1844f88470032> ;
>>> .
>>> 
>>> Similarily:
>>> @prefix owl:  <http://www.w3.org/2002/07/owl#> .
>>> <http://southampton.rkbexplorer.com/id/person-00021> owl:sameAs
>>> <http://citeseer.rkbexplorer.com/id/resource-CSP109020> ,
>>> <http://dblp.rkbexplorer.com/id/people-1726e6ee8fb20c8704f47285949b39b3-d101
>>> 32da488b7179a8b1844f88470032> ,
>>> .
>>> 
>>> That is:
>>> <#pat> <#age> 24;  <#eyecolor> "blue"; .
>>> and
>>> <#pat> <#child> [ <#age> 4 ], [ <#age> 3 ], .
>>> 
>>> Looking at the syntagmata in (1) and (2), my reading is that I can do this
>>> for ';', although they have different structures:
>>> N3 seems to do it by the possibility of () for propertylist.
>>> Turtle seems to have an explicit optional ';' (in rule 7).
>>> 
>>> On the other hand, for ',':
>>> N3 seems to do it by the possibility of () for objecttail.
>>> However, I don't think I can do the same in turtle, as rule 8 in (2) lacks
>>> the extra (',')?
>>> 
>>> (I would have downloaded the yacc grammar for N3 and tried it for real, but
>>> the link on (3) to the yacc grammar gives 404, by the way.)
>>> 
>>> So the question is: have I got something wrong?
>>> If not, then to use the second, ',', construct, I need to use N3, not
>>> turtle.
>>> So some questions are:
>>> Is this what is intended, rather than an omission?
>>> If so, why?
>>> It seems a bit strange that such simple N3 is not compatible with turtle.
>>> 
>>> (1) http://www.w3.org/2000/10/swap/grammar/n3.n3
>>> (2) http://www.dajobe.org/2004/01/turtle/#sec-tutorial
>>> (3) http://www.w3.org/DesignIssues/Notation3.html
>>> 
>>> PS
>>> And if you want to know why, it is because I want to generate a load of
>>> sameAs triples. It is a common problem for program (and other) generators
>>> not to want to know you are generating the last item in a list, and simply
>>> treat the ';' or ',' as terminator, rather than separator. This can be
>>> achieved by allowing null productions (as N3 above), or an explicit optional
>>> (as turtle ';'), or by actually making it a terminator, although then you
>>> tend to end up with ';;;' in the code.
>>> And you can't put it at the front of each output either, otherwise you need
>>> to treat the first item in the list specially.
>>> (For the grey beards among us, this is why generating something like Algol68
>>> was more of a pain than generating Pascal!)
>>> 
>>> Best
>>> Hugh
>>> -- 
>>> Hugh Glaser,  Reader
>>>              Dependable Systems & Software Engineering
>>>              School of Electronics and Computer Science,
>>>              University of Southampton,
>>>              Southampton SO17 1BJ
>>> Work: +44 (0)23 8059 3670, Fax: +44 (0)23 8059 3045
>>> Mobile: +44 (0)78 9422 3822, Home: +44 (0)23 8061 5652
>>> http://www.ecs.soton.ac.uk/~hg/
>>> 
>>> 
>>> 
>> 
> 
> --
> Hugh Glaser
> Chief Architect
> Seme4 Limited
> 18 Soho Square
> LONDON
> W1D 3QL
> Mobile: +44 7595334155
> Main: +44 2070601590
> 
> hugh.glaser@seme4.com
> www.seme4.com
> 
> Seme4 - the experts in semantic web and linked data applications
> 
> Notice of Confidentiality. This e-mail message (including any attached
> documents) is proprietary and confidential to Seme4 Limited and/or its
> affiliates and may contain legally privileged information. It is intended
> for the named recipient(s) only. If you are not the intended recipient,
> you may not review, retain, copy or distribute this message and we ask you
> to notify the sender immediately, then delete this message from your
> system. Thank you for your cooperation.
> 
> 
Received on Monday, 10 September 2012 22:45:19 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 21:45:51 GMT