@@ -116,6 +116,34 @@ expand_elseif_assign = (ifstm) ->
116116
117117constructor_name = " new"
118118
119+ with_continue_listener = ( body) ->
120+ continue_name = nil
121+ {
122+ Run =>
123+ @listen " continue" , ->
124+ unless continue_name
125+ continue_name = NameProxy " continue"
126+ @put_name continue_name
127+ continue_name
128+
129+ build. group body
130+
131+ Run =>
132+ return unless continue_name
133+ @put_name continue_name, nil
134+ @splice ( lines) -> {
135+ { " assign" , { continue_name} , { " false" }}
136+ { " repeat" , " true" , {
137+ lines
138+ { " assign" , { continue_name} , { " true" }}
139+ }}
140+ { " if" , { " not" , continue_name} , {
141+ { " break" }
142+ }}
143+ }
144+ }
145+
146+
119147class Transformer
120148 new : ( @transformers ) =>
121149 @seen_nodes = setmetatable {} , __mode : " k"
@@ -346,7 +374,7 @@ Statement = Transformer {
346374 else
347375 { 1 , { " length" , list_name}}
348376
349- build. group {
377+ return build. group {
350378 build. assign_one list_name, list
351379 slice_var
352380 build[ " for" ] {
@@ -359,6 +387,16 @@ Statement = Transformer {
359387 }
360388 }
361389
390+ node. body = with_continue_listener node. body
391+
392+ while : ( node) =>
393+ smart_node node
394+ node. body = with_continue_listener node. body
395+
396+ for : ( node) =>
397+ smart_node node
398+ node. body = with_continue_listener node. body
399+
362400 switch : ( node, ret) =>
363401 _, exp, conds = unpack node
364402 exp_name = NameProxy " exp"
0 commit comments