diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-01-26 20:20:12 -0800 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-01-26 20:20:38 -0800 |
| commit | 90c56d31352a0eeccd382ef5921baf3af4971040 (patch) | |
| tree | 5167eafb5785c94b48458b18b0454222ca70c749 /nomsu.moon | |
| parent | d5aa4e52983712f9f4c5b23528d0c2dab12b0b33 (diff) | |
Added a ton of tests for virtually all the functionality. Helped me find
and fix a lot of latent problems.
Diffstat (limited to 'nomsu.moon')
| -rwxr-xr-x | nomsu.moon | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -29,6 +29,7 @@ do if type(i) == 'number' then return string.sub(@, i, i) elseif type(i) == 'table' then return string.sub(@, i[1], i[2]) else return string[i] + -- Can't use this because it breaks some LPEG stuff --STRING_METATABLE.__mul = (other)=> string.rep(@, other) -- TODO: @@ -39,6 +40,7 @@ do -- Add compiler options for optimization level (compile-fast vs. run-fast, etc.) -- Do a pass on all actions to enforce parameters-are-nouns heuristic -- Maybe do some sort of lazy definitions of actions that defer until they're used in code +-- Add a ((%x foo %y) where {x:"asdf", y:"fdsa"}) compile-time action for substitution lpeg.setmaxstack 10000 -- whoa {:P,:R,:V,:S,:Cg,:C,:Cp,:B,:Cmt} = lpeg @@ -223,6 +225,7 @@ class NomsuCompiler -- TODO: repair error("Not currently functional.", 0) + -- TODO: figure out whether indent/dedent should affect first line dedent: (code)=> unless code\find("\n") return code @@ -900,10 +903,11 @@ class NomsuCompiler insert concat_parts, lua.expr return concat(concat_parts) - -- TODO: fix how 'immediately' works with locals, e.g. "immediately: %x <- 5" @define_compile_action "immediately %block", get_line_no!, (_block)-> lua = nomsu\tree_to_lua(_block) lua_code = lua.statements or (lua.expr..";") + if lua.locals and #lua.locals > 0 + lua_code = "local #{concat lua.locals, ", "};\n#{lua_code}" nomsu\run_lua(lua_code) return statements:"if IMMEDIATE then\n#{lua_code}\nend", locals:lua.locals |
