Cleanup of unnecessary parens in generated lua code for math operations.
This commit is contained in:
parent
e64a91b8ba
commit
36ead4d82b
@ -132,11 +132,6 @@ immediately
|
|||||||
|
|
||||||
immediately
|
immediately
|
||||||
# Math Operators
|
# Math Operators
|
||||||
compile [%x + %y] to: Lua value "(\(%x as lua expr) + \(%y as lua expr))"
|
|
||||||
compile [%x - %y] to: Lua value "(\(%x as lua expr) - \(%y as lua expr))"
|
|
||||||
compile [%x * %y] to: Lua value "(\(%x as lua expr) * \(%y as lua expr))"
|
|
||||||
compile [%x / %y] to: Lua value "(\(%x as lua expr) / \(%y as lua expr))"
|
|
||||||
compile [%x ^ %y] to: Lua value "(\(%x as lua expr) ^ \(%y as lua expr))"
|
|
||||||
compile [%x wrapped around %y, %x mod %y] to: Lua value "(\(%x as lua expr) % \(%y as lua expr))"
|
compile [%x wrapped around %y, %x mod %y] to: Lua value "(\(%x as lua expr) % \(%y as lua expr))"
|
||||||
|
|
||||||
# 3-part chained comparisons
|
# 3-part chained comparisons
|
||||||
|
@ -203,13 +203,15 @@ Tree("Action", {
|
|||||||
local src = tok.source:get_text()
|
local src = tok.source:get_text()
|
||||||
error("non-expression value inside math expression: " .. tostring(colored.yellow(src)))
|
error("non-expression value inside math expression: " .. tostring(colored.yellow(src)))
|
||||||
end
|
end
|
||||||
|
if tok.type == "Action" then
|
||||||
|
tok_lua:parenthesize()
|
||||||
|
end
|
||||||
lua:append(tok_lua)
|
lua:append(tok_lua)
|
||||||
end
|
end
|
||||||
if i < #self.value then
|
if i < #self.value then
|
||||||
lua:append(" ")
|
lua:append(" ")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
lua:parenthesize()
|
|
||||||
return lua
|
return lua
|
||||||
end
|
end
|
||||||
local args = { }
|
local args = { }
|
||||||
|
@ -132,10 +132,11 @@ Tree "Action",
|
|||||||
unless tok_lua.is_value
|
unless tok_lua.is_value
|
||||||
src = tok.source\get_text!
|
src = tok.source\get_text!
|
||||||
error("non-expression value inside math expression: #{colored.yellow src}")
|
error("non-expression value inside math expression: #{colored.yellow src}")
|
||||||
|
if tok.type == "Action"
|
||||||
|
tok_lua\parenthesize!
|
||||||
lua\append tok_lua
|
lua\append tok_lua
|
||||||
if i < #@value
|
if i < #@value
|
||||||
lua\append " "
|
lua\append " "
|
||||||
lua\parenthesize!
|
|
||||||
return lua
|
return lua
|
||||||
|
|
||||||
args = {}
|
args = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user