Skip to content

6.1. Yul Statements#

Syntax#


YulBlock = (* open_brace: *) OPEN_BRACE
(* statements: *) YulStatements
(* close_brace: *) CLOSE_BRACE;

YulStatements = (* item: *) YulStatement*;

YulStatement = (* variant: *) YulBlock
| (* variant: *) YulFunctionDefinition
| (* variant: *) YulStackAssignmentStatement (* Deprecated in 0.5.0 *)
| (* variant: *) YulIfStatement
| (* variant: *) YulForStatement
| (* variant: *) YulSwitchStatement
| (* variant: *) YulLeaveStatement (* Introduced in 0.6.0 *)
| (* variant: *) YulBreakStatement
| (* variant: *) YulContinueStatement
| (* variant: *) YulLabel (* Deprecated in 0.5.0 *)
| (* variant: *) YulVariableDeclarationStatement
| (* variant: *) YulVariableAssignmentStatement
| (* variant: *) YulExpression;

YulFunctionDefinition = (* function_keyword: *) YUL_FUNCTION_KEYWORD
(* name: *) YUL_IDENTIFIER
(* parameters: *) YulParametersDeclaration
(* returns: *) YulReturnsDeclaration?
(* body: *) YulBlock;

YulParametersDeclaration = (* open_paren: *) OPEN_PAREN
(* parameters: *) YulParameters
(* close_paren: *) CLOSE_PAREN;

YulParameters = ((* item: *) YUL_IDENTIFIER ((* separator: *) COMMA (* item: *) YUL_IDENTIFIER)*)?;

YulReturnsDeclaration = (* minus_greater_than: *) MINUS_GREATER_THAN
(* variables: *) YulVariableNames;

YulVariableNames = (* item: *) YUL_IDENTIFIER ((* separator: *) COMMA (* item: *) YUL_IDENTIFIER)*;

YulVariableDeclarationStatement = (* let_keyword: *) YUL_LET_KEYWORD
(* variables: *) YulVariableNames
(* value: *) YulVariableDeclarationValue?;

YulVariableDeclarationValue = (* assignment: *) YulAssignmentOperator
(* expression: *) YulExpression;

YulVariableAssignmentStatement = (* variables: *) YulPaths
(* assignment: *) YulAssignmentOperator
(* expression: *) YulExpression;

YulAssignmentOperator = (* variant: *) COLON_EQUAL
| (* variant: *) YulColonAndEqual; (* Deprecated in 0.5.5 *)

(* Deprecated in 0.5.5 *)
YulColonAndEqual = (* colon: *) COLON
(* equal: *) EQUAL;

(* Deprecated in 0.5.0 *)
YulStackAssignmentStatement = (* assignment: *) YulStackAssignmentOperator
(* variable: *) YUL_IDENTIFIER;

(* Deprecated in 0.5.0 *)
YulStackAssignmentOperator = (* variant: *) EQUAL_COLON
| (* variant: *) YulEqualAndColon;

(* Deprecated in 0.5.0 *)
YulEqualAndColon = (* equal: *) EQUAL
(* colon: *) COLON;

YulIfStatement = (* if_keyword: *) YUL_IF_KEYWORD
(* condition: *) YulExpression
(* body: *) YulBlock;

YulForStatement = (* for_keyword: *) YUL_FOR_KEYWORD
(* initialization: *) YulBlock
(* condition: *) YulExpression
(* iterator: *) YulBlock
(* body: *) YulBlock;

YulSwitchStatement = (* switch_keyword: *) YUL_SWITCH_KEYWORD
(* expression: *) YulExpression
(* cases: *) YulSwitchCases;

YulSwitchCases = (* item: *) YulSwitchCase+;

YulSwitchCase = (* variant: *) YulDefaultCase
| (* variant: *) YulValueCase;

YulDefaultCase = (* default_keyword: *) YUL_DEFAULT_KEYWORD
(* body: *) YulBlock;

YulValueCase = (* case_keyword: *) YUL_CASE_KEYWORD
(* value: *) YulLiteral
(* body: *) YulBlock;

(* Introduced in 0.6.0 *)
YulLeaveStatement = (* leave_keyword: *) YUL_LEAVE_KEYWORD;

YulBreakStatement = (* break_keyword: *) YUL_BREAK_KEYWORD;

YulContinueStatement = (* continue_keyword: *) YUL_CONTINUE_KEYWORD;

(* Deprecated in 0.5.0 *)
YulLabel = (* label: *) YUL_IDENTIFIER
(* colon: *) COLON;

Documentation#

Note

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