 ### WhymL: break and continue

```Without an argument, break and continue refer to the innermost loop.
A label put over an expression sequence starting with a loop, can be
used as an optional argument for break and continue:

label L in
[ghost] ["tag"] [M.begin]
while true do
...
break L
...
done;
[...]
[end] [: unit]

In the square brackets are listed the constructions allowed between
the label declaration and the loop expression.```
parent 2f1058c9
 ... ... @@ -240,7 +240,6 @@ module NaturalMergesort variant { n - !first_run } label L in let lo = ref 0 in exception Break in try while !lo < n - 1 do invariant { 0 <= !lo <= n } invariant { !first_run at L <= !first_run <= n } ... ... @@ -249,7 +248,7 @@ module NaturalMergesort invariant { permut_all (a at L) a } variant { n - !lo } let mid = find_run a !lo in if mid = n then begin if !lo = 0 then return; raise Break end; if mid = n then begin if !lo = 0 then return; break end; let hi = find_run a mid in label M in merge_using tmp a !lo mid hi; ... ... @@ -258,7 +257,6 @@ module NaturalMergesort ghost if !lo = 0 then first_run := hi; lo := hi; done with Break -> () end done ... ...
 ... ... @@ -92,23 +92,23 @@ module Array (0 <= i < ofs2 \/ ofs2 + len <= i < length a) -> a[i] = old a[i] } ensures { forall i:int. ofs2 <= i < ofs2 + len -> a[i] = old a[ofs1 + i - ofs2] } = label Init in = if ofs1 <= ofs2 then (* from right to left *) for k = len - 1 downto 0 do invariant { forall i:int. (0 <= i <= ofs2 + k \/ ofs2 + len <= i < length a) -> a[i] = (a at Init)[i] } a[i] = (old a)[i] } invariant { forall i:int. ofs2 + k < i < ofs2 + len -> a[i] = (a at Init)[ofs1 + i - ofs2] } ofs2 + k < i < ofs2 + len -> a[i] = (old a)[ofs1 + i - ofs2] } a[ofs2 + k] <- a[ofs1 + k] done else (* from left to right *) for k = 0 to len - 1 do invariant { forall i:int. (0 <= i < ofs2 \/ ofs2 + k <= i < length a) -> a[i] = (a at Init)[i] } a[i] = (old a)[i] } invariant { forall i:int. ofs2 <= i < ofs2 + k -> a[i] = (a at Init)[ofs1 + i - ofs2] } ofs2 <= i < ofs2 + k -> a[i] = (old a)[ofs1 + i - ofs2] } a[ofs2 + k] <- a[ofs1 + k] done ... ...
 ... ... @@ -29,7 +29,7 @@ '("(\\*\\([^*)]\\([^*]\\|\\*[^)]\\)*\\)?\\*)" . font-lock-comment-face) ; '("{}\\|{[^|]\\([^}]*\\)}" . font-lock-type-face) `(,(why3-regexp-opt '("invariant" "variant" "diverges" "requires" "ensures" "pure" "returns" "raises" "reads" "writes" "assert" "assume" "check")) . font-lock-type-face) `(,(why3-regexp-opt '("use" "clone" "scope" "import" "export" "coinductive" "inductive" "external" "constant" "function" "predicate" "val" "exception" "axiom" "lemma" "goal" "type" "mutable" "abstract" "private" "any" "match" "let" "rec" "in" "if" "then" "else" "begin" "end" "while" "for" "to" "downto" "do" "done" "loop" "absurd" "ghost" "raise" "return" "try" "with" "theory" "uses" "module" "converter" "fun" "at" "old" "true" "false" "forall" "exists" "label" "by" "so" "meta")) . font-lock-keyword-face) `(,(why3-regexp-opt '("use" "clone" "scope" "import" "export" "coinductive" "inductive" "external" "constant" "function" "predicate" "val" "exception" "axiom" "lemma" "goal" "type" "mutable" "abstract" "private" "any" "match" "let" "rec" "in" "if" "then" "else" "begin" "end" "while" "for" "to" "downto" "do" "done" "loop" "absurd" "ghost" "raise" "return" "break" "continue" "try" "with" "theory" "uses" "module" "converter" "fun" "at" "old" "true" "false" "forall" "exists" "label" "by" "so" "meta")) . font-lock-keyword-face) ) "Minimal highlighting for Why3 mode") ... ...
 ... ... @@ -186,7 +186,9 @@ on linking described in file LICENSE. any begin break by continue do done downto ... ...
 ... ... @@ -5,8 +5,8 @@ \lstdefinelanguage{why3} { basicstyle=\ttfamily,% morekeywords={abstract,absurd,any,assert,assume,at,axiom,by,% check,clone,coinductive,constant,diverges,do,done,downto,% morekeywords={abstract,absurd,any,assert,assume,at,axiom,break,by,% check,clone,coinductive,constant,continue,diverges,do,done,downto,% else,end,ensures,exception,exists,export,false,for,forall,fun,% function,ghost,goal,if,import,in,inductive,invariant,label,lemma,% let,loop,match,meta,module,mutable,not,old,% ... ...
 ... ... @@ -91,7 +91,7 @@ syn keyword whyKeyword let meta syn keyword whyKeyword not predicate so syn keyword whyKeyword then type with syn keyword whyKeyword abstract any syn keyword whyKeyword abstract any break continue syn keyword whyKeyword exception fun ghost label syn keyword whyKeyword model mutable private syn keyword whyKeyword raise rec return val while ... ...