ControlFlow
Important
All control flow constructs require a semicolon, ;, at the end of their blocks as of now.
Important
All control flow constructs have the capability of holding more statements within their blocks (Examples shown in Nested Statements sections)
If
**Note: No else, or else if… yet**
Grammar
<IF> <EXPR> <BLOCK>
Examples
Simple If Statement
if x == 4 {
...
};
Nested Statements
if x == 4 {
if y > x {
...
};
};
While
Grammar
<WHILE> <EXPR> <BLOCK>
Examples
Simple While Loop
while x > 4 {
x = x - 1;
};
Nested Statements
while x > 4 {
if x % 2 == 0 {
...
};
if x % 2 == 1 {
...
};
};
For (Not Implemented Yet)
Grammar
<FOR> <VAR>|<EXPR> ; <EXPR> ; <EXPR> <BLOCK>
Examples
Simple For Loop
for i: int = 0; i < 4; i = i + 1 {
};