Re: Possible grammar problem with decimal numbers

On 09/04/13 18:21, Thomas Visel wrote:
>
> Gentlemen,
>
> While verifying our implementation of Sparql, I have encountered what 
> several suspected problems in the grammar.
>
> 1^st Case:  The following production (in 
> http://www.w3.org/TR/sparql11-query/#rUnaryExpression) permits decimal 
> numbers of the following exemplary forms: ddd.d ddd.ddd   .ddd .  
> Decimals of the form ddd.  are not permitted.
>
> [147]
>
> 	
>
> DECIMAL
>
> 	
>
> ::=
>
> 	
>
> [0-9]* '.' [0-9]+
>
> If this was not the intended result, the right-hand side of the 
> production might better read as
>
> [0-9]* '.' [0-9]+ | [0-9] '.'
>
> The original motivation might be the conflicting use of a floating 
> number in the /object/ position of a triple, where a fraction-free 
> float's decimal point would conflict with the triple's closing AND '.' 
> mark.
>
> The implications of leaving [147] as-is is that /FILTER [?data > 
> 29.]/is not legal, a visible annoyance.
>

This is intentional.

Consider:

<subject> <predicate> 123.

It was decide that this be an integer then a dot for the end of triple. 
This aligns with Turtle.  It also aligns with prefix names where the 
trailing DOT was never legal.

<subject> <predicate> ns:x.y.

has DOT as end of triple, not part of the local name.  The local part is 
"x.y"

Given that DOT is end-of-triple as well, we have to have things one way 
or the other.

SPARQL-WG decided, along with RDF-WG, that the end-of-triple case was 
more important  and that the practice is seen in use (Freebase is an 
example where they is an assumption that DOT is end-of-triple when 
immediately after an integer). ".0" on decimals is sufficiently common 
and understood usage.

It flagged in last call.
http://www.w3.org/TR/2012/WD-sparql11-query-20120724/#grammar

[] is not legal for filters.

FILTER ( ?data > 29.0 )

This also aligns with the canonical representation in XSD:
http://www.w3.org/TR/xmlschema11-2/#f-fracDigitsMap

> 2^nd Case:  There is a slight inconsistency in treatment of DECIMAL 
> (per above) and DOUBLEs:
>
> |[148] |
>
> 	
>
> |DOUBLE|
>
> 	
>
> ::=
>
> 	
>
> |[0-9]+ '.' [0-9]* EXPONENT 
> <http://www.w3.org/TR/sparql11-query/#rEXPONENT> | '.' ([0-9])+ 
> EXPONENT <http://www.w3.org/TR/sparql11-query/#rEXPONENT> | ([0-9])+ 
> EXPONENT <http://www.w3.org/TR/sparql11-query/#rEXPONENT>|
>
> For single precision DECIMAL, the leading digit is optional.  For 
> DOUBLE, a leading digit is mandatory.  Is there a motivation for this 
> difference?
>

For double the leading zero is not mandatory - see the second clause of 
[148]
|
'.' ([0-9])+ EXPONENT <http://www.w3.org/TR/sparql11-query/#rEXPONENT>|

1e5
1.1e5
.1e5

are legal doubles.

(Decimal is xsd:decimal, which is arbitrary length - no limit or 
implication of precision)


You may find
http://www.sparql.org/query-validator.html

useful.  It is not endorsed by W3C but it is running the parser used to 
check and produce the HTML grammar in the final document.

     Andy

> My regards to the WG for taking 1.1 through to closure.
>
>
> Thomas A. Visel
>
> AlgebraixData, Inc.
>
> (512) 651-5834
>

Received on Tuesday, 9 April 2013 19:17:19 UTC