lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hello all,

I was recently writing some syntax highlighting code for Lua, and
while trying to duplicate the behaviour of the standard Lua parser, I
noticed a curious behaviour. The first two of the following examples
are completely normal. The third is unexpected to me - according the
reference manual on numbers, "A numerical constant can be written with
an optional decimal part and an optional decimal exponent", so I would
expect it to be parsed like the first example, as the parser should
stop trying to match a number at the second decimal point. The fourth
example is included for completeness; it could in theory be parsed
like the second example, or as 1. followed by . and ""

> =1. ..""
> =1 ..""
> =1...""
stdin:1: malformed number near '1...'
> =1..""
stdin:1: malformed number near '1..'

Are there are reasons why the third example is parsed like it currently is?