134 - Yul Syntax
Yul parses comments, literals and identifiers in the same way as Solidity. Inside a code block, the following elements can be used:
-
Literals, i.e.
0x123
,42
or"abc"
(strings up to 32 characters) -
Calls to builtin functions, e.g. add(1, mload(0))
-
Variable declarations, e.g.
let x := 7
,let x := add(y, 3)
orlet x
(initial value of 0 is assigned) -
Identifiers (variables), e.g.
add(3, x)
-
Assignments, e.g.
x := add(y, 3)
-
Blocks where local variables are scoped inside, e.g.
{ let x := 3 { let y := add(x, 1) } }
-
if
statements, e.g.if lt(a, b) { sstore(0, 1) }
-
switch statements, e.g.
switch mload(0) case 0 { revert() } default { mstore(0, 1) }
-
for
loops, e.g.for { let i := 0} lt(i, 10) { i := add(i, 1) } { mstore(i, 7) }
-
Function definitions, e.g.
function f(a, b) -> c { c := add(a, b) }
- Literals & Calls
- Variable Declarations
- Assignments
- Scoping Blocks
- if/switch/for
- Function Definitions