aboutsummaryrefslogtreecommitdiff
path: root/nomsu.lua
diff options
context:
space:
mode:
Diffstat (limited to 'nomsu.lua')
-rw-r--r--nomsu.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/nomsu.lua b/nomsu.lua
index 583843f..28bb36d 100644
--- a/nomsu.lua
+++ b/nomsu.lua
@@ -610,7 +610,11 @@ end)]]):format(concat(lua_bits, "\n"))
elseif "Number" == _exp_0 then
return repr(tree.value), nil
elseif "Var" == _exp_0 then
- return "vars[" .. tostring(repr(tree.value)) .. "]", nil
+ if tree.value:match("^[a-zA-Z_][a-zA-Z0-9_]*$") then
+ return "vars." .. tostring(tree.value), nil
+ else
+ return "vars[" .. tostring(repr(tree.value)) .. "]", nil
+ end
else
return self:error("Unknown/unimplemented thingy: " .. tostring(tree.type))
end