diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-10-13 18:14:18 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-10-13 18:14:18 -0700 |
| commit | 56f014a4884d7df387ff2ffa34fa95f1cc8b1f16 (patch) | |
| tree | 8b0f081c704c692bb134e9d4d856bd87c1492504 /nomsu.lua | |
| parent | e82a8286b66175739b294a0797658a9370004e5a (diff) | |
Improved code generation by changing vars["x"] to vars.x for allowed lua
var names.
Diffstat (limited to 'nomsu.lua')
| -rw-r--r-- | nomsu.lua | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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 |
