Re: number parsing question
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: number parsing question
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: 2010年4月30日 10:55:04 -0300
> isn't '-' part of the Number terminal?
No.
> I don't think it is handled as an unary minus opcode applied on the absolute value described by the following digits.
It is. But Lua does constant folding and the unary minus opcode disappears.
Try luac -l -p - on
a = -34
a = - 34
a = -(34)
a = -(30+4)
All four lines generate the same bytecode:
LOADK 0 -2 ; -34
SETGLOBAL 0 -1 ; a