- From: Seaborne, Andy <andy.seaborne@hp.com>
- Date: Sat, 24 Feb 2007 17:05:39 +0000
- To: 'RDF Data Access Working Group' <public-rdf-dawg@w3.org>
After updating the grammar from Souri's comments and suggestions, I also put in a change to move SPARQL closer to Turtle. In Turtle, the sign of a number (integer, decimal, double) is part of the token making up the number. A consequence of this is that white space between the sign and the digits is not permitted. http://www.dajobe.org/2004/01/turtle/#sec-grammar Legal Turtle -- :x :p +2 Illegal Turtle -- :x :p + 2 -- :x :p + 2 In SPARQL, it was the case that the grammar said in the parser: ('-'|'+') Number but that place accepts separating white space. To follow this in SPARQL, I have put in lexer tokens for signed numbers and removed the sign handling for literal objects in triple patterns. Details: As a consequence, the expression "1+2" is tokens "1" and "+2" whereas it was "1", "+" and "2". The AdditiveExpression rule is expanded to cover this situation and to be clearer there different tokens for signed positive and negative signed numbers (not strictly necessary) . A parser will need to generate add(1,+2). Unary minus/unary plus are unchanged as rules but the parse tree for 3 * -4 is now (in prefix notation): (* 3 -4) not (* 3 (- 4)) using unary minus. --3 is (- -3) [52] AdditiveExpression ::= MultiplicativeExpression ( '+' MultiplicativeExpression | '-' MultiplicativeExpression | NumericLiteralPositive | NumericLiteralNegative )* A minor side effect of this is that it makes the SPARQL extension to property paths easier: http://lists.w3.org/Archives/Public/public-rdf-dawg-comments/2007Jan/0001.html because ":C1 rdfs:subClassOf+ :C2" is now unambiguous whereas previously, the "+" could be the unary sign for a number at :C2. Brackets around the property path regex are no longer needed and "(:property)" is no longer a path of one unlike ":property" which is a predicate. It is a language change for triple patterns to be closer to Turtle. There is no language change for expressions but it works a little different. Andy PS FWIW - for quite some time, the SPARQL grammar did not allow a signed number in the object slot of a triple pattern. And no one commented on it, formally or informally!
Received on Saturday, 24 February 2007 17:05:52 UTC