From 8d648dc8c075fc1cf8d89d74c1425cdeb47e8089 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Sun, 29 Jan 2023 16:39:35 +0800 Subject: refactor break loop keyword checking. --- spec/inputs/loops.yue | 24 ++++++++++++++++++- spec/outputs/5.1/loops.lua | 60 ++++++++++++++++++++++++++++++++++++++++++++++ spec/outputs/loops.lua | 41 +++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/inputs/loops.yue b/spec/inputs/loops.yue index 51eb10b..5cadbf0 100644 --- a/spec/inputs/loops.yue +++ b/spec/inputs/loops.yue @@ -173,4 +173,26 @@ do for thing in *xxx print thing - +do + for i = 1, 10 + repeat + with? tb + .a = 1 + continue if .b + do + if .c + break + until true + switch x + when 123 + break + else + continue + if y + continue + else + break + do do do + print i + continue + print "abc" diff --git a/spec/outputs/5.1/loops.lua b/spec/outputs/5.1/loops.lua index 85e9de8..6f0d072 100644 --- a/spec/outputs/5.1/loops.lua +++ b/spec/outputs/5.1/loops.lua @@ -382,3 +382,63 @@ do print(thing) end end +do + for i = 1, 10 do + local _continue_0 = false + repeat + repeat + local _cond_0 = false + local _continue_1 = false + repeat + do + local _with_0 = tb + if _with_0 ~= nil then + _with_0.a = 1 + if _with_0.b then + _cond_0 = true + _continue_1 = true + break + end + do + if _with_0.c then + break + end + end + end + end + _cond_0 = true + _continue_1 = true + until true + if not _continue_1 then + break + end + until _cond_0 + if 123 == x then + break + else + _continue_0 = true + break + end + if y then + _continue_0 = true + break + else + break + end + do + do + do + print(i) + _continue_0 = true + break + end + end + end + print("abc") + _continue_0 = true + until true + if not _continue_0 then + break + end + end +end diff --git a/spec/outputs/loops.lua b/spec/outputs/loops.lua index eeea15f..79ef789 100644 --- a/spec/outputs/loops.lua +++ b/spec/outputs/loops.lua @@ -294,3 +294,44 @@ do print(thing) end end +do + for i = 1, 10 do + repeat + do + local _with_0 = tb + if _with_0 ~= nil then + _with_0.a = 1 + if _with_0.b then + goto _continue_12 + end + do + if _with_0.c then + break + end + end + end + end + ::_continue_12:: + until true + if 123 == x then + break + else + goto _continue_11 + end + if y then + goto _continue_11 + else + break + end + do + do + do + print(i) + goto _continue_11 + end + end + end + print("abc") + ::_continue_11:: + end +end -- cgit v1.2.3-55-g6feb