Add TOKEN_HEXADECIMAL token type and isHexDigit helper function to lexer. Modify readNumber to detect 'x' prefix after '0' and lex hex digits. Implement emitNumericConstant for hex values in compiler. Add test file test/number/hex_literals.wren verifying basic hex parsing, arithmetic, type checks, and negative hex literals.
8 lines
211 B
Plaintext
8 lines
211 B
Plaintext
var x = 0xFF
|
|
|
|
IO.print(x) // expect: 255
|
|
IO.print(x + 1) // expect: 256
|
|
IO.print(x == 255) // expect: true
|
|
IO.print(0x09 is Num) // expect: true
|
|
IO.print(x is Num) // expect: true
|
|
IO.print(-0xFF) // expect: -255 |