lua-users home
lua-l archive

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

why not '64'..s if 64 is hard coded ?!

2012/9/17, Roberto Ierusalimschy <>:
>> This string causes "malformed number" error:
>> print(64..'KB')
>> It seems that lexer does not know that two dots are never contained in
>> numerical constant.
>> IMHO, correct parsing of numerical constant should stop before
>> concatenation operator.
> Scanners usually know very little. They seldom do backtracking or know
> about grammar. Most of them operate on the "longest sequence" rule.  By
> this rule, the "correct parsing" of the string |64..'KB'| would be |64.|
> (a number), |.| (the dot operator), and |'KB'| (a literal string).
> That would give you an error anyway, only a different one.
> -- Roberto