Re: Possible grammar problem with decimal numbers

* Thomas Visel <TVisel@algebraixdata.com> [2013-04-09 17:21+0000]
> Gentlemen,
> While verifying our implementation of Sparql, I have encountered what several suspected problems in the grammar.
> 
> 1st 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 was considered to be less of an annoyance than requiring whitespace between a number and the '.' at the end of a triple, e.g. the Turtle/SPARQL triple "<s> <p> 7. .".
You'll note that none of the numerics permit a trailing '.':

[146] INTEGER ::= [0-9]+
[147] DECIMAL ::= [0-9]* '.' [0-9]+
[148] DOUBLE  ::= [0-9]+ '.' [0-9]* EXPONENT | '.' ([0-9])+ EXPONENT | ([0-9])+ EXPONENT


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

DOUBLE is the numeric variant that is the most permissive. for the mantissa, it permits leading, trailing or no '.'. The latter two variants below can't serve as DECIMALs because one is an INTEGER and the other ends a triple with a ".".

valid DOUBLEs:  ".0E0" "0.0E0" "0E0" "0.E0"
valid DECIMALs: ".0"   "0.0"
valid INTEGERs:                "0"
illegal:                             "0."


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

-- 
-ericP

Received on Tuesday, 9 April 2013 19:28:55 UTC