Skip to content

4.3. Control Statements#

Syntax#


IfStatement = (* if_keyword: *) IF_KEYWORD
(* open_paren: *) OPEN_PAREN
(* condition: *) Expression
(* close_paren: *) CLOSE_PAREN
(* body: *) Statement
(* else_branch: *) ElseBranch?;

ElseBranch = (* else_keyword: *) ELSE_KEYWORD
(* body: *) Statement;

ForStatement = (* for_keyword: *) FOR_KEYWORD
(* open_paren: *) OPEN_PAREN
(* initialization: *) ForStatementInitialization
(* condition: *) ForStatementCondition
(* iterator: *) Expression?
(* close_paren: *) CLOSE_PAREN
(* body: *) Statement;

ForStatementInitialization = (* variant: *) TupleDeconstructionStatement
| (* variant: *) VariableDeclarationStatement
| (* variant: *) ExpressionStatement
| (* variant: *) SEMICOLON;

ForStatementCondition = (* variant: *) ExpressionStatement
| (* variant: *) SEMICOLON;

WhileStatement = (* while_keyword: *) WHILE_KEYWORD
(* open_paren: *) OPEN_PAREN
(* condition: *) Expression
(* close_paren: *) CLOSE_PAREN
(* body: *) Statement;

DoWhileStatement = (* do_keyword: *) DO_KEYWORD
(* body: *) Statement
(* while_keyword: *) WHILE_KEYWORD
(* open_paren: *) OPEN_PAREN
(* condition: *) Expression
(* close_paren: *) CLOSE_PAREN
(* semicolon: *) SEMICOLON;

ContinueStatement = (* continue_keyword: *) CONTINUE_KEYWORD
(* semicolon: *) SEMICOLON;

BreakStatement = (* break_keyword: *) BREAK_KEYWORD
(* semicolon: *) SEMICOLON;

ReturnStatement = (* return_keyword: *) RETURN_KEYWORD
(* expression: *) Expression?
(* semicolon: *) SEMICOLON;

(* Introduced in 0.4.21 *)
EmitStatement = (* emit_keyword: *) EMIT_KEYWORD
(* event: *) IdentifierPath
(* arguments: *) ArgumentsDeclaration
(* semicolon: *) SEMICOLON;

Documentation#

Note

This section is under construction. You are more than welcome to contribute suggestions to our GitHub repository.