lua-users home
lua-l archive

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


On 1/20/2012 1:05 AM, Alexandra Barros wrote:
Hi all,

I stumbled upon a weird behaviour in hexadecimal constants in Lua
5.2.0 (and LuaJIT 2.0.0-beta8).

When adding a hexadecimal number ending with E it gives a "malformed
number" error, unless I insert a blank space between E and the plus
sign. Looks like the lexer is tokenizing it as an invalid floating
point number. Tests follow...

print(0xE)
14
print(0xE+9)
stdin:1: malformed number near '0xE+9'
print(0xE +9)
23
print(0xA+9)
19

Sorry, I was hasty. :-P I agree that it is not a hex float.

This is a limitation of the lexer. It grabs a lot but test the kaboodle as one unit. Triggered by 'E', from llex.c:

  do {
    save_and_next(ls);
    if (check_next(ls, "EePp"))  /* exponent part? */
      check_next(ls, "+-");  /* optional exponent sign */
  } while (lislalnum(ls->current) || ls->current == '.');


Would be nice to have it fixed...

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia