feat: add import keyword token and parser support with updated test syntax

Add TOKEN_IMPORT to the token enum and wire it into the keyword parser in readName(). Refactor string literal parsing by extracting stringConstant() helper that returns the constant index, allowing the new import parser to reuse it. Update all module test files to replace the old .import_() method calls with the new import "module" for Var syntax, and add new error test cases for missing string and missing for clause after import.
This commit is contained in:
Bob Nystrom
2015-02-15 00:46:00 +00:00
parent 91efd0d0cc
commit ea958deeef
16 changed files with 74 additions and 27 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
// nontest
IO.print("a")
var Shared = "shared".import_("Shared")
import "shared" for Shared
var A = "a " + Shared
IO.print("a done")
+1 -1
View File
@@ -1,5 +1,5 @@
// nontest
IO.print("b")
var Shared = "shared".import_("Shared")
import "shared" for Shared
var B = "b " + Shared
IO.print("b done")
+2 -2
View File
@@ -1,5 +1,5 @@
var A = "a".import_("A")
var B = "b".import_("B")
import "a" for A
import "b" for B
// Shared module should only run once:
// expect: a