Re: [svgwg] Number grammar adjusted (#816)

I totally agree on the point that the type of syntax is not very clear. This should be clarified, maybe I will look into this.

To get further into this specific problem. It is actually way more complicating than I originally thought.

> ```
> number ::= [0-9]+ ("." [0-9]*)?
> ```
This grammar and the one I suggested would not work, since it needs to support basically 3 different formats also with an possible extension. Furthermore, the after the point there needs to be one or more digits in your grammar, otherwise we wouldn't be able to (when adding the other formats) distinguish between parsing "5.2" to _5.0_ and _0.2_ or parsing it _5.2_.

The three different formats are:
- Plain integers _1_, _2_, _42_, etc.
- Plain floating point numbers _1.0_, _42.24_, _123.456_, etc.
- Unopend floating point numbers _.5_, _.1_, _.42_, etc. This is also explained in this piece of text from just below the syntax:
> Similarly, for the string "M 0.6.5", the first coordinate of the "moveto" consumes the characters "0.6" and stops upon encountering the second decimal point because the production of a "coordinate" only allows one decimal point. The result is that the first coordinate will be "0.6" and the second coordinate will be ".5".

The extension which I forgot is found in `0.12e10`. I don't know how the concensus is on this extension, but it is supported in most major browsers.

A syntax which would take all of this into account would then look like:
```
number ::= ( ([0-9]+ ("." [0-9]+)?) | ("." [0-9]+) ) exponent_extension?
exponent_extension ::= ("e" | "E") [0-9]+
```

Or alternatively you could write it like this:
```
number ::= ( ([0-9]+ float_ext?) | float_ext ) exponent_ext?
float_ext ::= "." [0-9]+
exponent_ext ::= ("e" | "E") [0-9]+
```
Personally I think this makes it way more readable.

This syntax leads to supporting all different formats and allows for unambiguous interpretation within the standard when parsing.

As said please don't close this PR just yet as I will look into making the syntax type less confusing.

-- 
GitHub Notification of comment by coastalwhite
Please view or discuss this issue at https://github.com/w3c/svgwg/pull/816#issuecomment-739248317 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Saturday, 5 December 2020 13:02:43 UTC