feat: add hexadecimal literal support to lexer and compiler

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.
This commit is contained in:
Gavin Schulz
2015-01-25 06:07:23 +00:00
parent 3f0aceeffa
commit b2c6dfce8d
2 changed files with 59 additions and 14 deletions
+8
View File
@@ -0,0 +1,8 @@
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