aboutsummaryrefslogtreecommitdiff
path: root/nomsu_compiler.moon
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-09-26 13:58:29 -0700
committerBruce Hill <bruce@bruce-hill.com>2018-09-26 13:59:31 -0700
commit8a8940c9bcacfd8bcb6c724a383c75615acd3af8 (patch)
treeefbbe21e1c520b3c15a46a61ce66392a7b68389e /nomsu_compiler.moon
parentdcff9ecfcf0c3f81cc22bacd082472ea744c9070 (diff)
Fixes for actions with targets colliding with compiler actions, and lua
keywords as dict keys.
Diffstat (limited to 'nomsu_compiler.moon')
-rw-r--r--nomsu_compiler.moon9
1 files changed, 5 insertions, 4 deletions
diff --git a/nomsu_compiler.moon b/nomsu_compiler.moon
index 34c2ab0..e91db80 100644
--- a/nomsu_compiler.moon
+++ b/nomsu_compiler.moon
@@ -398,7 +398,8 @@ with NomsuCompiler
switch tree.type
when "Action"
stub = tree.stub
- if compile_action = compile_actions[stub]
+ compile_action = compile_actions[stub]
+ if compile_action and not tree.target
args = [arg for arg in *tree when type(arg) != "string"]
-- Force Lua to avoid tail call optimization for debugging purposes
-- TODO: use tail call?
@@ -551,9 +552,8 @@ with NomsuCompiler
unless value_lua.is_value
@compile_error tree[2],
"Can't use this as a dict value, since it's not an expression."
- -- TODO: support arbitrary words here, like operators and unicode
key_str = match(tostring(key_lua), [=[^["']([a-zA-Z_][a-zA-Z0-9_]*)['"]$]=])
- return if key_str
+ return if key_str and key_str\is_lua_id!
LuaCode tree.source, key_str,"=",value_lua
elseif sub(tostring(key_lua),1,1) == "["
-- NOTE: this *must* use a space after the [ to avoid freaking out
@@ -579,7 +579,8 @@ with NomsuCompiler
@compile_error key,
"Can't use this as an index, since it's not an expression."
key_lua_str = tostring(key_lua)
- if lua_id = match(key_lua_str, "^['\"]([a-zA-Z_][a-zA-Z0-9_]*)['\"]$")
+ lua_id = match(key_lua_str, "^['\"]([a-zA-Z_][a-zA-Z0-9_]*)['\"]$")
+ if lua_id and lua_id\is_lua_id!
lua\append ".#{lua_id}"
elseif sub(key_lua_str,1,1) == '['
-- NOTE: this *must* use a space after the [ to avoid freaking out