Improved code generation by changing vars["x"] to vars.x for allowed lua
var names.
This commit is contained in:
parent
e82a8286b6
commit
56f014a488
@ -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
|
||||
|
@ -461,7 +461,10 @@ end)]])\format(concat(lua_bits, "\n"))
|
||||
return repr(tree.value), nil
|
||||
|
||||
when "Var"
|
||||
return "vars[#{repr tree.value}]", nil
|
||||
if tree.value\match("^[a-zA-Z_][a-zA-Z0-9_]*$")
|
||||
return "vars.#{tree.value}", nil
|
||||
else
|
||||
return "vars[#{repr tree.value}]", nil
|
||||
|
||||
else
|
||||
@error("Unknown/unimplemented thingy: #{tree.type}")
|
||||
|
Loading…
Reference in New Issue
Block a user