The rules for minilang statements contain sequential, optional and repeating elements.
statement | → | if‑statement | while‑statement | return‑statement | compound‑statement | construction‑statement | assignment‑statement |
if‑statement | → | if ( expression ) statement ( else statement )? |
while‑statement | → | while ( expression ) statement |
return‑statement | → | return expression ? |
compound‑statement | → | { statement * } |
construction‑statement | → | type identifier = expression ; |
assignment‑statement | → | identifier = expression ; |
The Statement rule delegates parsing to other rules.
In the IfStatement rule there are elements with a postfix ! operator. They are elements that are mandatory, in other words are expected to be present unconditionally after seeing the if token. If not, an immediate error is generated for them.
The else -part of the if -statement is optional. This denoted by the question mark.
The var keyword is used for declaring local variables for a rule.
Zero or more occurrences of an expression is denoted by the kleene-star symbol * .