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,8 +1,9 @@
var Module1 = "module".import_("Module1")
var Module2 = "module".import_("Module2")
var Module3 = "module".import_("Module3")
var Module4 = "module".import_("Module4")
var Module5 = "module".import_("Module5")
// TODO: Comma-separated list.
import "module" for Module1
import "module" for Module2
import "module" for Module3
import "module" for Module4
import "module" for Module5
// Only execute module body once:
// expect: ran module