W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > April to June 2005

Fine tuning the rq23 grammar

From: Seaborne, Andy <andy.seaborne@hp.com>
Date: Tue, 26 Apr 2005 14:25:15 +0100
Message-ID: <426E413B.8050701@hp.com>
To: RDF Data Access Working Group <public-rdf-dawg@w3.org>

I have made some changes to fine tune the SPARQL grammar; rq23 has been updated. 
  This is about making it eaier to write queries - not changing the language 
meaning.


0/ These changes should not affect any query in the current WD.


1/ DOTs between group elements:

I have rearranged the rules to make DOT (i.e. the character ".") optional after 
a group or non-basic pattern.

SELECT *
WHERE
{ :x :p ?v
    OPTIONAL {:a :b ?b}
    OPTIONAL {:a :c ?c}
}

is now legal.  DOT after a "}" is optional.

SELECT *
WHERE
{ :x :p ?v .
    OPTIONAL {:a :b ?b} .
    OPTIONAL {:a :c ?c} .
}

DOTs between triple patterns are still necessary.

This makes multiline queries more natural - it complicates the grammar to
insist that blocks of multiple triple patterns (which don't need a trailind
dot) can't be adjacent which would allow two triple patterns to be used with a
DOT in between.

This applies to FILTER as well:

SELECT *
WHERE
{ :x :p ?v
    FILTER ?v < 3
    OPTIONAL {:a :c ?c}
}


2/ Turtle alignment - 1

Added long literals using """ or ''' for multiline quoting of strings.

This leaves open the problem (shared with Turtle and N3) about line endings as
they can be part of a string.


3/ Turtle alignment - 2

Allow trailing dots in QNames


4/ Query patterns

The query pattern is always a group.  A query can omit the outer most {}
if it uses the WHERE keyword.  This is special casing the top level of the
graph pattern and enforcing it must contain at least one item.

SELECT ?x
WHERE  ?x :y :z

is legal as is:

SELECT ?x
{ ?x :y :z }

and:

SELECT ?x
WHERE
{ ?x :y :z . ?x :y :z1 }

[[Strictly, the last one is a natural outcome.  It's a query with a group of
one element which is a group of two triple patterns. It can't be made illegal
without a special case.]]

SELECT ?x
WHERE

is not legal.  If there is no {}, it can't be empty.


5/ Variable names exclude "-" and "." to avoid problems with
    FILTER expressions.



I have checked in a test suite into tests/SyntaxFull (there are 71 currently).
ARQ should pass the tests and should fail illegal queries.

I am looking for more tests - please send example queris you woudl like to see 
in the test suite.




Steve - these tests have no results.  They all execute against an empty model.

They all look like:

      mf:entries
      (
        [  mf:name    "syntax-basic-01.rq" ;
           mf:action
               [ qt:query  <syntax-basic-01.rq> ;
                 qt:data   <empty.nt> ]
           # No result
        ]
        ...

Not sure if that is going to break anything.  An alternative is to define test
types (i use three types: query, syntax and serialization).

Also, 71 tests is a bit much for the HTML page.

	Andy
Received on Tuesday, 26 April 2005 13:25:42 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:23 GMT