W3C home > Mailing lists > Public > public-cwm-talk@w3.org > January to March 2006

Re: SPARQL grammar... in BNF? N3?

From: Dan Connolly <connolly@w3.org>
Date: Thu, 09 Feb 2006 17:48:31 -0600
To: Tim Berners-Lee <timbl@w3.org>
Cc: Eric Prud'hommeaux <eric@w3.org>, Yosi Scharf <syosi@MIT.EDU>, public-cwm-talk@w3.org, Robert Crowell <crowell@MIT.EDU>
Message-Id: <1139528911.12577.385.camel@dirk.w3.org>

On Thu, 2006-02-09 at 16:21 -0500, Tim Berners-Lee wrote:
> >>>   <- http://www.w3.org/2001/sw/DataAccess/rq23/parsers/
> ...I would like it in RDF, using the same
> context-free grammar ontology please, but any syntax out of RDF/XML or
> any subset of N3.

OK. I couldn't help working on that for much of today:

The .ttl looks like:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix : <http://www.w3.org/2001/sw/DataAccess/rq23/parsers/sparql#>.
@prefix g:
#@@ case insensitivity of 'BASE' and the like is not expressed.

:Query rdfs:label "Query"; rdf:value "1";
 rdfs:comment "[1]      Query     ::=           Prolog( SelectQuery |
ConstructQuery | DescribeQuery | AskQuery )";
 a g:NonTerminal;
  g:seq (
    [ g:alt (
     ) ]

:Prolog rdfs:label "Prolog"; rdf:value "2";
 rdfs:comment "[2]      Prolog    ::=           BaseDecl? PrefixDecl*";
 a g:NonTerminal;
  g:seq (
    [ g:opt
    [ g:star


I haven't done a conversion back to BNF from RDF; it should
be a simple --strings thingy or XSLT transformation. I don't
think I can argue to throw away the BNF and use the RDF as the
source; it's pretty unwieldy and verbose, even in turtle format.

(DAWG business:
There's the question of the full URI of terms like :Query
and :Prolog themselves. If this thing is to become part
of the SPARQL Recommendation, I guess their URIs will have
to be approved by the WG. I suppose a namespace outside /DataAccess/
and outside /TR/... somewhere in /2006/02/... like the SPARQL
protocol namespace, is best. )

I made up my own EBNF ontology because I couldn't figure out
the swap/grammar one; I suspect the terms match 1-1. I like
mine better. :) Let's switch, shall we? Perhaps: first one
to make a decent write-up wins?

I saw somebody... Bjoren H. maybe... ask that the BNF notation
section of the XML spec get published independently. Maybe
this would be the way to do it. I wrote a converter:


Anyway... so this .rdf version has not been checked against
the SPARQL test suite.

Yosi, do you think you could update the SPARQL parser you
put in cwm to be mechanically generated from sparql{.ttl,.rdf}
and try it against some of the tests? It would involve
compiling the :Terminal nodes to regexs, probably in python.

Jos, it might be fun to have euler derive proofs that strings
are in the language generated by this grammar.

I grabbed
and checked that in; as I understand it, that's the "truth"
that EricP and/or AndyS and/or Yosi work from.

I check that the .ttl doesn't have anything that goes beyond
RDF expressiveness like this:

connolly@dirk:~/w3ccvs/WWW/2001/sw/DataAccess/rq23$ make check-gram
python bnf2turtle.py parsers/sparql.bnf >parsers/sparql.ttl
python ../../../../2000/10/swap/cwm.py parsers/sparql.ttl --rdf
python ../../../../2000/10/swap/cwm.py parsers/sparql.ttl --n3 >,g1.n3
python ../../../../2000/10/swap/cwm.py parsers/sparql.rdf --n3 >,g2.n3
diff -u ,g1.n3 ,g2.n3
[[some diffs in comments about base URI;
is there a way to suppres those comments in N3 output?]]

Dan Connolly, W3C http://www.w3.org/People/Connolly/
D3C2 887B 0F92 6005 C541  0875 0F91 96DE 6E52 C29E
Received on Thursday, 9 February 2006 23:48:39 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:01:05 UTC