feat: add null literal token and compiler support with keyword parsing and test cases

Introduce TOKEN_NULL to the token enum and register it as a prefix parse rule that emits CODE_NULL. Implement the null() compiler function to emit the null constant. Extend readName() to recognize the "null" keyword and map it to TOKEN_NULL. Add test files verifying null output, and that null, true, and false cannot be used as variable names.
This commit is contained in:
Bob Nystrom
2013-11-06 02:22:22 +00:00
parent 60d4c15be2
commit 5341bdcbb3
5 changed files with 13 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
var false = "value" // expect error
+1
View File
@@ -0,0 +1 @@
var null = "value" // expect error
+1
View File
@@ -0,0 +1 @@
var true = "value" // expect error
+1
View File
@@ -0,0 +1 @@
io.write(null) // expect: null