Skip to content

Commit

Permalink
fix chaining condition evaluation rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
pigpigyyy committed Oct 23, 2023
1 parent 0ecd527 commit 08fef1c
Show file tree
Hide file tree
Showing 4 changed files with 349 additions and 105 deletions.
22 changes: 22 additions & 0 deletions spec/inputs/cond.yue
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,28 @@ do

evaluation = v(1) > v(2) <= v(3)

do
a = v(1) < v(2) < v(3) < v(4)
a = x and y or v(1) < v(2) < v(3) < v(4)
a = v(1) < v(2) < v(3) < v(4) or x and y
a = x and y or v(1) < v(2) < v(3) < v(4) or w and z

a = v(1) < v(2) < v(3) and b < v(4) < v(5) < v(6)
a = x and y or v(1) < v(2) < v(3) and b < v(4) < v(5) < v(6)
a = v(1) < v(2) < v(3) and b < v(4) < v(5) < v(6) or x and y
a = x and y or v(1) < v(2) < v(3) and b < v(4) < v(5) < v(6) or w and z

local v1, v2, v3, v4, v5, v6
a = v1 < v2 < v3 < v4
a = x and y or v1 < v2 < v3 < v4
a = v1 < v2 < v3 < v4 or x and y
a = x and y or v1 < v2 < v3 < v4 or w and z

a = v1 < v2 < v3 and b < v4 < v5 < v6
a = x and y or v1 < v2 < v3 and b < v4 < v5 < v6
a = v1 < v2 < v3 and b < v4 < v5 < v6 or x and y
a = x and y or v1 < v2 < v3 and b < v4 < v5 < v6 or w and z

nil


Expand Down
155 changes: 153 additions & 2 deletions spec/outputs/cond.lua
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,162 @@ do
local evaluation
do
local _cond_0 = v(2)
evaluation = v(1) < _cond_0 and _cond_0 <= v(3)
if not (v(1) < _cond_0) then
evaluation = false
else
evaluation = _cond_0 <= v(3)
end
end
do
local _cond_0 = v(2)
if not (v(1) > _cond_0) then
evaluation = false
else
evaluation = _cond_0 <= v(3)
end
end
end
do
do
local _cond_0 = v(2)
evaluation = v(1) > _cond_0 and _cond_0 <= v(3)
if not (v(1) < _cond_0) then
a = false
else
local _cond_1 = v(3)
if not (_cond_0 < _cond_1) then
a = false
else
a = _cond_1 < v(4)
end
end
end
a = x and y or (function()
local _cond_0 = v(2)
if not (v(1) < _cond_0) then
return false
else
local _cond_1 = v(3)
if not (_cond_0 < _cond_1) then
return false
else
return _cond_1 < v(4)
end
end
end)()
a = (function()
local _cond_0 = v(2)
if not (v(1) < _cond_0) then
return false
else
local _cond_1 = v(3)
if not (_cond_0 < _cond_1) then
return false
else
return _cond_1 < v(4)
end
end
end)() or x and y
a = x and y or (function()
local _cond_0 = v(2)
if not (v(1) < _cond_0) then
return false
else
local _cond_1 = v(3)
if not (_cond_0 < _cond_1) then
return false
else
return _cond_1 < v(4)
end
end
end)() or w and z
a = (function()
local _cond_0 = v(2)
if not (v(1) < _cond_0) then
return false
else
return _cond_0 < v(3)
end
end)() and (function()
local _cond_0 = v(4)
if not (b < _cond_0) then
return false
else
local _cond_1 = v(5)
if not (_cond_0 < _cond_1) then
return false
else
return _cond_1 < v(6)
end
end
end)()
a = x and y or (function()
local _cond_0 = v(2)
if not (v(1) < _cond_0) then
return false
else
return _cond_0 < v(3)
end
end)() and (function()
local _cond_0 = v(4)
if not (b < _cond_0) then
return false
else
local _cond_1 = v(5)
if not (_cond_0 < _cond_1) then
return false
else
return _cond_1 < v(6)
end
end
end)()
a = (function()
local _cond_0 = v(2)
if not (v(1) < _cond_0) then
return false
else
return _cond_0 < v(3)
end
end)() and (function()
local _cond_0 = v(4)
if not (b < _cond_0) then
return false
else
local _cond_1 = v(5)
if not (_cond_0 < _cond_1) then
return false
else
return _cond_1 < v(6)
end
end
end)() or x and y
a = x and y or (function()
local _cond_0 = v(2)
if not (v(1) < _cond_0) then
return false
else
return _cond_0 < v(3)
end
end)() and (function()
local _cond_0 = v(4)
if not (b < _cond_0) then
return false
else
local _cond_1 = v(5)
if not (_cond_0 < _cond_1) then
return false
else
return _cond_1 < v(6)
end
end
end)() or w and z
local v1, v2, v3, v4, v5, v6
a = v1 < v2 and v2 < v3 and v3 < v4
a = x and y or v1 < v2 and v2 < v3 and v3 < v4
a = v1 < v2 and v2 < v3 and v3 < v4 or x and y
a = x and y or v1 < v2 and v2 < v3 and v3 < v4 or w and z
a = v1 < v2 and v2 < v3 and b < v4 and v4 < v5 and v5 < v6
a = x and y or v1 < v2 and v2 < v3 and b < v4 and v4 < v5 and v5 < v6
a = v1 < v2 and v2 < v3 and b < v4 and v4 < v5 and v5 < v6 or x and y
a = x and y or v1 < v2 and v2 < v3 and b < v4 and v4 < v5 and v5 < v6 or w and z
end
return nil
12 changes: 10 additions & 2 deletions spec/outputs/unicode/cond.lua
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,19 @@ do
local _u6c42_u503c
do
local _cond_0 = _u503c(2)
_u6c42_u503c = _u503c(1) < _cond_0 and _cond_0 <= _u503c(3)
if not (_u503c(1) < _cond_0) then
_u6c42_u503c = false
else
_u6c42_u503c = _cond_0 <= _u503c(3)
end
end
do
local _cond_0 = _u503c(2)
_u6c42_u503c = _u503c(1) > _cond_0 and _cond_0 <= _u503c(3)
if not (_u503c(1) > _cond_0) then
_u6c42_u503c = false
else
_u6c42_u503c = _cond_0 <= _u503c(3)
end
end
end
return nil
Loading

0 comments on commit 08fef1c

Please sign in to comment.