diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-09-21 02:33:04 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-09-21 02:33:04 -0700 |
| commit | 5f2db8da0e99fca282265b232330f3f432b94373 (patch) | |
| tree | 5c27a1f958b55a15b0e35139165c885574d4fa3a /nomsu.moon | |
| parent | 371548150618d5b3501f388972077b5d035f7d8a (diff) | |
Everything fixed up and some reduced lua codespew too!
Diffstat (limited to 'nomsu.moon')
| -rwxr-xr-x | nomsu.moon | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -311,7 +311,7 @@ class NomsuCompiler error("Failed to compile generated code:\n#{code}\n\n#{err}") return (lua_thunk!)(self, vars or {}) - tree_to_lua: (tree, kind="Expression")=> + tree_to_lua: (tree)=> assert tree, "No tree provided." if not tree.type @error "Invalid tree: #{utils.repr(tree)}" @@ -319,8 +319,8 @@ class NomsuCompiler buffer = {} return_value = nil - to_lua = (t,kind)-> - ret = @tree_to_lua(t,kind) + to_lua = (t)-> + ret = @tree_to_lua(t) return ret add = (code)-> table.insert(buffer, code) @@ -462,10 +462,8 @@ class NomsuCompiler var_to_lua_identifier: (var)=> if var.type != "Var" @error("Tried to convert something that wasn't a Var into a lua identifier: it was not a Var, it was: "..label.type) - identifier = "var_" - for i=1,#var.value - identifier ..= ("%x")\format(string.byte(var.value, i)) - return identifier + "var"..(var.value\gsub "%W", (verboten)-> + if verboten == "_" then "__" else ("_%x")\format(verboten\byte!)) run_macro: (tree, kind="Expression")=> name = @fn_name_from_tree(tree) |
