A lexical change (a breaking change, but trivial to fix)
Timon Gehr
timon.gehr at gmx.ch
Sat Jul 7 15:12:27 PDT 2012
On 07/07/2012 11:39 PM, Mehrdad wrote:
> This might sound silly,
+1.
> but how about if D stopped allowing 0..2 as a
> range, and instead just said "invalid floating-point number"?
>
> Fixing it en masse would be pretty trivial... just run a regex to replace
> "\b(\d+)\.\."
> with
> "\1 .. "
> and you're good to go.
>
> (Or if you want more accuracy, just take the compiler output and feed it
> back with a fix -- that would work too.)
>
> The benefit, though, is that now you can do maximal munch without
> worrying about this edge case... which sure makes it easier to make a
> lexer.
>
> Thoughts?
It does not make it easier to create a lexer, because this is not
actually an edge case worth explicitly testing for.
switch(input.front){
case '0'..'9': ...
case 'a'..'f', 'A'..'F': ...
case '.': if('0'>input[1]||input[1]>'9') break;
...
}
More information about the Digitalmars-d
mailing list