diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 73648c1145..9fe81048ce 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -4178,9 +4178,9 @@ codegen_language_macros::compile!(Language( EnumVariant(reference = YulLeaveStatement, enabled = From("0.6.0")), EnumVariant(reference = YulBreakStatement), EnumVariant(reference = YulContinueStatement), + EnumVariant(reference = YulVariableAssignmentStatement), EnumVariant(reference = YulLabel, enabled = Till("0.5.0")), EnumVariant(reference = YulVariableDeclarationStatement), - EnumVariant(reference = YulVariableAssignmentStatement), EnumVariant(reference = YulExpression) ] ), diff --git a/crates/solidity/outputs/cargo/crate/src/generated/parser/generated/parser.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/generated/parser.rs index 79c09cc669..e887cdb596 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/parser/generated/parser.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/parser/generated/parser.rs @@ -6775,14 +6775,14 @@ impl Parser { choice.consider(input, result)?; let result = self.yul_continue_statement(input); choice.consider(input, result)?; + let result = self.yul_variable_assignment_statement(input); + choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { let result = self.yul_label(input); choice.consider(input, result)?; } let result = self.yul_variable_declaration_statement(input); choice.consider(input, result)?; - let result = self.yul_variable_assignment_statement(input); - choice.consider(input, result)?; let result = self.yul_expression(input); choice.consider(input, result)?; choice.finish(input) diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs index cf0c0ac6c6..80384be566 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs @@ -52,6 +52,7 @@ mod yul_function_call_expression; mod yul_label; mod yul_leave_statement; mod yul_stack_assignment_statement; +mod yul_statement; mod yul_statements; mod yul_variable_assignment_statement; mod yul_variable_declaration_statement; diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/yul_statement.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/yul_statement.rs new file mode 100644 index 0000000000..cc32ccff6a --- /dev/null +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/yul_statement.rs @@ -0,0 +1,15 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use anyhow::Result; + +use crate::cst_output::runner::run; + +#[test] +fn label() -> Result<()> { + run("YulStatement", "label") +} + +#[test] +fn var_assign_colon_and_equals() -> Result<()> { + run("YulStatement", "var_assign_colon_and_equals") +} diff --git a/crates/solidity/outputs/npm/package/src/generated/ast/generated/nodes.mts b/crates/solidity/outputs/npm/package/src/generated/ast/generated/nodes.mts index 767c47642f..ed4dceaa88 100644 --- a/crates/solidity/outputs/npm/package/src/generated/ast/generated/nodes.mts +++ b/crates/solidity/outputs/npm/package/src/generated/ast/generated/nodes.mts @@ -4936,9 +4936,9 @@ export class YulStatement { | YulLeaveStatement | YulBreakStatement | YulContinueStatement + | YulVariableAssignmentStatement | YulLabel | YulVariableDeclarationStatement - | YulVariableAssignmentStatement | YulExpression = once(() => { const variant = generated.ast.Selectors.choice(this.cst); @@ -4961,12 +4961,12 @@ export class YulStatement { return new YulBreakStatement(variant as NonterminalNode); case NonterminalKind.YulContinueStatement: return new YulContinueStatement(variant as NonterminalNode); + case NonterminalKind.YulVariableAssignmentStatement: + return new YulVariableAssignmentStatement(variant as NonterminalNode); case NonterminalKind.YulLabel: return new YulLabel(variant as NonterminalNode); case NonterminalKind.YulVariableDeclarationStatement: return new YulVariableDeclarationStatement(variant as NonterminalNode); - case NonterminalKind.YulVariableAssignmentStatement: - return new YulVariableAssignmentStatement(variant as NonterminalNode); case NonterminalKind.YulExpression: return new YulExpression(variant as NonterminalNode); @@ -4989,9 +4989,9 @@ export class YulStatement { | YulLeaveStatement | YulBreakStatement | YulContinueStatement + | YulVariableAssignmentStatement | YulLabel | YulVariableDeclarationStatement - | YulVariableAssignmentStatement | YulExpression { return this.fetch(); } diff --git a/crates/solidity/outputs/spec/generated/grammar.ebnf b/crates/solidity/outputs/spec/generated/grammar.ebnf index a1afbddb1d..e7f7fe9acf 100644 --- a/crates/solidity/outputs/spec/generated/grammar.ebnf +++ b/crates/solidity/outputs/spec/generated/grammar.ebnf @@ -1618,9 +1618,9 @@ YulStatement = (* variant: *) YulBlock | (* variant: *) YulLeaveStatement (* Introduced in 0.6.0 *) | (* variant: *) YulBreakStatement | (* variant: *) YulContinueStatement + | (* variant: *) YulVariableAssignmentStatement | (* variant: *) YulLabel (* Deprecated in 0.5.0 *) | (* variant: *) YulVariableDeclarationStatement - | (* variant: *) YulVariableAssignmentStatement | (* variant: *) YulExpression; YulFunctionDefinition = (* function_keyword: *) YUL_FUNCTION_KEYWORD diff --git a/crates/solidity/outputs/spec/generated/public/06-yul/01-yul-statements.md b/crates/solidity/outputs/spec/generated/public/06-yul/01-yul-statements.md index b01cd74607..a7563b9ef4 100644 --- a/crates/solidity/outputs/spec/generated/public/06-yul/01-yul-statements.md +++ b/crates/solidity/outputs/spec/generated/public/06-yul/01-yul-statements.md @@ -20,7 +20,7 @@ ``` -
+ ```{ .ebnf #YulFunctionDefinition } diff --git a/crates/solidity/testing/snapshots/cst_output/YulStatement/label/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/YulStatement/label/generated/0.4.11-success.yml new file mode 100644 index 0000000000..ff6fc56063 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/YulStatement/label/generated/0.4.11-success.yml @@ -0,0 +1,12 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ foo_label: │ 0..10 + +Errors: [] + +Tree: + - (YulStatement) ► (variant꞉ YulLabel): # "foo_label:\n" (0..11) + - (label꞉ YulIdentifier): "foo_label" # (0..9) + - (colon꞉ Colon): ":" # (9..10) + - (trailing_trivia꞉ EndOfLine): "\n" # (10..11) diff --git a/crates/solidity/testing/snapshots/cst_output/YulStatement/label/generated/0.5.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/YulStatement/label/generated/0.5.0-failure.yml new file mode 100644 index 0000000000..524b2a249e --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/YulStatement/label/generated/0.5.0-failure.yml @@ -0,0 +1,20 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ foo_label: │ 0..10 + +Errors: # 1 total + - > + Error: Expected OpenParen. + ╭─[crates/solidity/testing/snapshots/cst_output/YulStatement/label/input.sol:1:10] + │ + 1 │ foo_label: + │ ─┬ + │ ╰── Error occurred here. + ───╯ + +Tree: + - (YulStatement): # "foo_label:\n" (0..11) + - (variant꞉ YulExpression) ► (variant꞉ YulPath): # "foo_label" (0..9) + - (item꞉ YulIdentifier): "foo_label" # (0..9) + - (UNRECOGNIZED): ":\n" # (9..11) diff --git a/crates/solidity/testing/snapshots/cst_output/YulStatement/label/input.sol b/crates/solidity/testing/snapshots/cst_output/YulStatement/label/input.sol new file mode 100644 index 0000000000..61b0e76f7b --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/YulStatement/label/input.sol @@ -0,0 +1 @@ +foo_label: diff --git a/crates/solidity/testing/snapshots/cst_output/YulStatement/var_assign_colon_and_equals/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/YulStatement/var_assign_colon_and_equals/generated/0.4.11-success.yml new file mode 100644 index 0000000000..c11972f62e --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/YulStatement/var_assign_colon_and_equals/generated/0.4.11-success.yml @@ -0,0 +1,28 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ // Makes sure that `newB:` is not parsed as a label here, and that we continue parsing to get a whole assignment statement. │ 0..123 + 2 │ newB: = mload(0x80) │ 124..143 + +Errors: [] + +Tree: + - (YulStatement) ► (variant꞉ YulVariableAssignmentStatement): # "// Makes sure that `newB:` is not parsed as a labe..." (0..144) + - (variables꞉ YulPaths): # "// Makes sure that `newB:` is not parsed as a labe..." (0..128) + - (item꞉ YulPath): # "// Makes sure that `newB:` is not parsed as a labe..." (0..128) + - (leading_trivia꞉ SingleLineComment): "// Makes sure that `newB:` is not parsed as a labe..." # (0..123) + - (leading_trivia꞉ EndOfLine): "\n" # (123..124) + - (item꞉ YulIdentifier): "newB" # (124..128) + - (assignment꞉ YulAssignmentOperator) ► (variant꞉ YulColonAndEqual): # ": =" (128..131) + - (colon꞉ Colon): ":" # (128..129) + - (leading_trivia꞉ Whitespace): " " # (129..130) + - (equal꞉ Equal): "=" # (130..131) + - (expression꞉ YulExpression) ► (variant꞉ YulFunctionCallExpression): # " mload(0x80)\n" (131..144) + - (operand꞉ YulExpression) ► (variant꞉ YulBuiltInFunction): # " mload" (131..137) + - (leading_trivia꞉ Whitespace): " " # (131..132) + - (variant꞉ YulMLoadKeyword): "mload" # (132..137) + - (open_paren꞉ OpenParen): "(" # (137..138) + - (arguments꞉ YulArguments): # "0x80" (138..142) + - (item꞉ YulExpression) ► (variant꞉ YulLiteral) ► (variant꞉ YulHexLiteral): "0x80" # (138..142) + - (close_paren꞉ CloseParen): ")" # (142..143) + - (trailing_trivia꞉ EndOfLine): "\n" # (143..144) diff --git a/crates/solidity/testing/snapshots/cst_output/YulStatement/var_assign_colon_and_equals/generated/0.5.5-failure.yml b/crates/solidity/testing/snapshots/cst_output/YulStatement/var_assign_colon_and_equals/generated/0.5.5-failure.yml new file mode 100644 index 0000000000..791ca554a1 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/YulStatement/var_assign_colon_and_equals/generated/0.5.5-failure.yml @@ -0,0 +1,23 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ // Makes sure that `newB:` is not parsed as a label here, and that we continue parsing to get a whole assignment statement. │ 0..123 + 2 │ newB: = mload(0x80) │ 124..143 + +Errors: # 1 total + - > + Error: Expected OpenParen. + ╭─[crates/solidity/testing/snapshots/cst_output/YulStatement/var_assign_colon_and_equals/input.sol:2:5] + │ + 2 │ newB: = mload(0x80) + │ ────────┬─────── + │ ╰───────── Error occurred here. + ───╯ + +Tree: + - (YulStatement): # "// Makes sure that `newB:` is not parsed as a labe..." (0..144) + - (variant꞉ YulExpression) ► (variant꞉ YulPath): # "// Makes sure that `newB:` is not parsed as a labe..." (0..128) + - (leading_trivia꞉ SingleLineComment): "// Makes sure that `newB:` is not parsed as a labe..." # (0..123) + - (leading_trivia꞉ EndOfLine): "\n" # (123..124) + - (item꞉ YulIdentifier): "newB" # (124..128) + - (UNRECOGNIZED): ": = mload(0x80)\n" # (128..144) diff --git a/crates/solidity/testing/snapshots/cst_output/YulStatement/var_assign_colon_and_equals/input.sol b/crates/solidity/testing/snapshots/cst_output/YulStatement/var_assign_colon_and_equals/input.sol new file mode 100644 index 0000000000..17e9122e28 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/YulStatement/var_assign_colon_and_equals/input.sol @@ -0,0 +1,2 @@ +// Makes sure that `newB:` is not parsed as a label here, and that we continue parsing to get a whole assignment statement. +newB: = mload(0x80)