From d30f6a397d274b0b942bdd2e2648b42538f1cbe2 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 14 Dec 2018 20:34:27 -0800 Subject: Fixed some bugs, including upgrade --upgrade-from=version not working. Also updated the README. --- nomsu_environment.moon | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'nomsu_environment.moon') diff --git a/nomsu_environment.moon b/nomsu_environment.moon index 5d26701..cc059b5 100644 --- a/nomsu_environment.moon +++ b/nomsu_environment.moon @@ -60,18 +60,20 @@ nomsu_environment = Importer{ compile: compile, _1_as_lua: compile, compile_error_at:compile_error, :_1_forked, :import_to_1_from, - _1_parsed: (nomsu_code)-> + _1_parsed: (nomsu_code, syntax_version)-> if type(nomsu_code) == 'string' filename = Files.spoof(nomsu_code) nomsu_code = NomsuCode\from(Source(filename, 1, #nomsu_code), nomsu_code) source = nomsu_code.source nomsu_code = tostring(nomsu_code) version = nomsu_code\match("^#![^\n]*nomsu[ ]+-V[ ]*([0-9.]+)") - syntax_version = version and tonumber(version\match("^[0-9]+")) or max_parser_version + if syntax_version + syntax_version = tonumber(syntax_version\match("^[0-9]+")) + syntax_version or= version and tonumber(version\match("^[0-9]+")) or max_parser_version parse = Parsers[syntax_version] or Parsers[max_parser_version] tree = parse(nomsu_code, source.filename) if tree.shebang - tree.version = tree.shebang\match("nomsu %-V[ ]*([%d.]*)") + tree.version or= tree.shebang\match("nomsu %-V[ ]*([%d.]*)") errs = {} find_errors = (t)-> if t.type == "Error" -- cgit v1.2.3