public static final class Stmt.While extends wybs.lang.SyntacticElement.Impl implements Stmt
WhileStmt ::= "while" Expression (where Expression)* ':' NewLine BlockAs an example:
function sum([int] xs) -> int:
int r = 0
int i = 0
while i < |xs| where i >= 0:
r = r + xs[i]
i = i + 1
return r
The optional where clause(s) are commonly referred to as the
"loop invariant". When multiple clauses are given, these are combined
using a conjunction. The combined invariant defines a condition which
must be true on every iteration of the loop.Stmt.Assert, Stmt.Assign, Stmt.Assume, Stmt.Break, Stmt.Case, Stmt.Continue, Stmt.Debug, Stmt.DoWhile, Stmt.Fail, Stmt.IfElse, Stmt.NamedBlock, Stmt.Return, Stmt.Skip, Stmt.Switch, Stmt.VariableDeclaration, Stmt.While| Modifier and Type | Field and Description |
|---|---|
ArrayList<Stmt> |
body |
Expr |
condition |
List<Expr> |
invariants |
| Constructor and Description |
|---|
While(Expr condition,
List<Expr> invariants,
Collection<Stmt> body,
wybs.lang.Attribute... attributes)
Construct a While statement from a given condition and body of
statements.
|
While(Expr condition,
List<Expr> invariants,
Collection<Stmt> body,
Collection<wybs.lang.Attribute> attributes)
Construct a While statement from a given condition and body of
statements.
|
public Expr condition
public While(Expr condition, List<Expr> invariants, Collection<Stmt> body, wybs.lang.Attribute... attributes)
condition - non-null expression.invariant - The loop invariant expression, which may be null (if no
invariant is given)body - non-null collection which contains zero or more
statements.attributes - public While(Expr condition, List<Expr> invariants, Collection<Stmt> body, Collection<wybs.lang.Attribute> attributes)
condition - non-null expression.invariant - The loop invariant expression, which may be null (if no
invariant is given)body - non-null collection which contains zero or more
statements.attributes - Copyright © 2017. All rights reserved.