feat: add bitwise NOT operator (~) with token, parser, and native implementation

Add TOKEN_TILDE token type and lexer support for the '~' character in the compiler. Implement the bitwise NOT operation as a native method on the Num class, operating on 32-bit unsigned integers. Include a new OPERATOR macro for prefix/infix operator grammar rules and add comprehensive test cases covering positive, negative, floating-point, and boundary values.
This commit is contained in:
Bob Nystrom
2013-12-05 06:09:31 +00:00
parent d076abc8b1
commit 071239aa35
4 changed files with 49 additions and 3 deletions
+9
View File
@@ -0,0 +1,9 @@
var a = "a"
var b = "b"
var c = "c"
// Assignment is right-associative.
a = b = c
io.write(a) // expect: c
io.write(b) // expect: c
io.write(c) // expect: c