Specifically matches only simple for loops.
Properties
forLoopSimple produces a record that contains the following properties:
| Name | Type | Description |
|---|---|---|
kind |
enum forLoopKind |
The kind of loop: always `simple`;
see forLoopKind
|
initializationStatement |
statement? |
The initialization clause of the for loop;
null if there is none
|
conditionExpression |
expression |
The condition that causes the loop to terminate |
conditionDeclaration |
declaration? |
If a variable is declared within the condition (second clause) of the for loop,
this property contains its name.
(This is seldom done; this property is null if no such variable is declared.)
|
updateStatement |
statement? |
The statement that updates the loop value; frequently something like i++.
This record is null if there is no such statement
|
bodyStatement |
statement |
The statement that the loop repeatedly executes.
Frequently this is a blockStatement.
|
Inherits properties from:
Example
The following code:
for ( int i = 0; i < 42; i++ ) {
doSomething(i);
};
... is matched by forLoopSimple, which sets the following properties:
-
.kindis assigned`simple`. -
.initializationStatementis set to theint i=0declaration. -
.conditionExpressionisi < 42. -
The
.conditionDeclarationisnull, because the condition doesn't declare anything. -
.updateStatementis the incrementi++. -
.bodyStatementis set to theblockStatementthat contains the function call.