W3C home > Mailing lists > Public > www-rdf-interest@w3.org > March 2001

N3 syntax and parser

From: Graham Klyne <GK@NineByNine.org>
Date: Sun, 18 Mar 2001 15:41:01 +0000
Message-Id: <5.0.2.1.2.20010318152611.009fa910@joy.songbird.com>
To: Tim Berners-Lee <timbl@w3.org>
Cc: RDF interest group <www-rdf-interest@w3.org>
I've been playing with N3 and the Python parser linked from 
http:/www.w3.org/DesignIssues/Notation3.

I find myself puzzled by the motivation for the ':-' option, and note a 
discrepancy between the given syntax and behaviour of the Python program:

...

The syntax:

property-list
      void ( to allow [...]. )
      verb object-list
      verb object-list ; property-list
      :- anonnode
         (to allow two anonymous forms to be given eg [ a :Truth; :- { :sky 
:color :blue } ] )
      :- anonnode ; property-list

Suggests that the following should be allowed:

     @prefix default <#>.
     [ a :Truth;  ] .
     :foo a :thing ; :- { :sky :color :blue } ; a :other .

But the program gives the following result and syntax error:

     <STDIN>     <http://www.w3.org/2000/10/swap/log.n3#forSome> :_g0 .

     :_g0     a :Truth .

     :foo     a :thing .

     :sky     :color :blueTraceback (most recent call last):
   File "notati~2.py", line 1645, in ?
     doCommand()
   File "notati~2.py", line 1629, in doCommand
     p.load("")
   File "notati~2.py", line 185, in load
     self.feed(sys.stdin.read())     # May be big - buffered in memory!
   File "notati~2.py", line 200, in feed
     i = self.directiveOrStatement(str,j)
   File "notati~2.py", line 214, in directiveOrStatement
     if j>=0: return self.checkDot(str,j)
   File "notati~2.py", line 475, in checkDot
     raise BadSyntax(str, i, "expected '.' or '}' or ']' at end of statement")
__main__.BadSyntax: bad syntax (expected '.' or '}' or ']' at end of statement)
at: "...ing ; :- { :sky :color :blue }^ ; a :other .
"

...

Regarding the purpose of ":-".

As far as I can tell, the effect of

    s1 p1 o1 ; :- { s2 p2 o2 } .

is identical to:

    s1 p1 o1.
    s2 p2 o2.

I don't see the motivation for allowing this form.

...

And a final observation:  the Notation3.py source code contains a mix of 
tab and space characters that results in invalid Python syntax when the 
tabs are converted to anything other than 8 spaces.  For public 
distribution, I think it would be safer to convert all tabs in Python 
source code to spaces.

...

#g


------------
Graham Klyne
(GK@ACM.ORG)
Received on Sunday, 18 March 2001 20:35:02 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:51:48 GMT