From 08fef1c7698cff09689e9965d993931ca6081257 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 23 Oct 2023 10:19:42 +0800 Subject: fix chaining condition evaluation rules. --- spec/inputs/cond.yue | 22 ++++++ spec/outputs/cond.lua | 155 +++++++++++++++++++++++++++++++++++++++++- spec/outputs/unicode/cond.lua | 12 +++- 3 files changed, 185 insertions(+), 4 deletions(-) (limited to 'spec') diff --git a/spec/inputs/cond.yue b/spec/inputs/cond.yue index df7d78e..f5f42a8 100644 --- a/spec/inputs/cond.yue +++ b/spec/inputs/cond.yue @@ -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 diff --git a/spec/outputs/cond.lua b/spec/outputs/cond.lua index 651c14a..d7aae02 100644 --- a/spec/outputs/cond.lua +++ b/spec/outputs/cond.lua @@ -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 diff --git a/spec/outputs/unicode/cond.lua b/spec/outputs/unicode/cond.lua index 9a4ccb9..ed5d274 100644 --- a/spec/outputs/unicode/cond.lua +++ b/spec/outputs/unicode/cond.lua @@ -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 -- cgit v1.2.3-55-g6feb