From 319c80af35b17c607bfe05b14af09afeb42d2abf Mon Sep 17 00:00:00 2001 From: OmarTawfik <15987992+OmarTawfik@users.noreply.github.com> Date: Sun, 11 Aug 2024 14:44:18 -0700 Subject: [PATCH] --- --- .../inputs/language/src/definition.rs | 18 +++--- .../src/generated/language/generated/mod.rs | 30 ++++----- .../src/generated/ast/generated/ast_types.ts | 64 +++++++++---------- .../outputs/spec/generated/grammar.ebnf | 16 ++--- .../public/06-yul/01-yul-statements.md | 2 +- 5 files changed, 66 insertions(+), 64 deletions(-) diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index f38c50b55c..7c72787883 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -4161,21 +4161,23 @@ codegen_language_macros::compile!(Language( Enum( name = YulStatement, variants = [ + // Variants that can be identified using the first token: EnumVariant(reference = YulBlock), + EnumVariant(reference = YulBreakStatement), + EnumVariant(reference = YulContinueStatement), + EnumVariant(reference = YulForStatement), EnumVariant(reference = YulFunctionDefinition), - EnumVariant(reference = YulVariableDeclarationStatement), - EnumVariant(reference = YulVariableAssignmentStatement), + EnumVariant(reference = YulIfStatement), + EnumVariant(reference = YulLabel, enabled = Till("0.5.0")), + EnumVariant(reference = YulLeaveStatement, enabled = From("0.6.0")), EnumVariant( reference = YulStackAssignmentStatement, enabled = Till("0.5.0") ), - EnumVariant(reference = YulIfStatement), - EnumVariant(reference = YulForStatement), EnumVariant(reference = YulSwitchStatement), - EnumVariant(reference = YulLeaveStatement, enabled = From("0.6.0")), - EnumVariant(reference = YulBreakStatement), - EnumVariant(reference = YulContinueStatement), - EnumVariant(reference = YulLabel, enabled = Till("0.5.0")), + // These variants are more complex, and require backtracking: + EnumVariant(reference = YulVariableDeclarationStatement), + EnumVariant(reference = YulVariableAssignmentStatement), EnumVariant(reference = YulExpression) ] ), diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/language/generated/mod.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/language/generated/mod.rs index 7ec6134007..f1c76e38e7 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/language/generated/mod.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/language/generated/mod.rs @@ -6840,34 +6840,34 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.yul_block(input); choice.consider(input, result)?; - let result = self.yul_function_definition(input); + let result = self.yul_break_statement(input); choice.consider(input, result)?; - let result = self.yul_variable_declaration_statement(input); + let result = self.yul_continue_statement(input); choice.consider(input, result)?; - let result = self.yul_variable_assignment_statement(input); + let result = self.yul_for_statement(input); + choice.consider(input, result)?; + let result = self.yul_function_definition(input); + choice.consider(input, result)?; + let result = self.yul_if_statement(input); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { - let result = self.yul_stack_assignment_statement(input); + let result = self.yul_label(input); choice.consider(input, result)?; } - let result = self.yul_if_statement(input); - choice.consider(input, result)?; - let result = self.yul_for_statement(input); - choice.consider(input, result)?; - let result = self.yul_switch_statement(input); - choice.consider(input, result)?; if self.version_is_at_least_0_6_0 { let result = self.yul_leave_statement(input); choice.consider(input, result)?; } - let result = self.yul_break_statement(input); - choice.consider(input, result)?; - let result = self.yul_continue_statement(input); - choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { - let result = self.yul_label(input); + let result = self.yul_stack_assignment_statement(input); choice.consider(input, result)?; } + let result = self.yul_switch_statement(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/npm/package/src/generated/ast/generated/ast_types.ts b/crates/solidity/outputs/npm/package/src/generated/ast/generated/ast_types.ts index 45ed5ddc2b..a58953204d 100644 --- a/crates/solidity/outputs/npm/package/src/generated/ast/generated/ast_types.ts +++ b/crates/solidity/outputs/npm/package/src/generated/ast/generated/ast_types.ts @@ -4883,45 +4883,45 @@ export class UnicodeStringLiteral { export class YulStatement { private readonly fetch: () => | YulBlock - | YulFunctionDefinition - | YulVariableDeclarationStatement - | YulVariableAssignmentStatement - | YulStackAssignmentStatement - | YulIfStatement - | YulForStatement - | YulSwitchStatement - | YulLeaveStatement | YulBreakStatement | YulContinueStatement + | YulForStatement + | YulFunctionDefinition + | YulIfStatement | YulLabel + | YulLeaveStatement + | YulStackAssignmentStatement + | YulSwitchStatement + | YulVariableDeclarationStatement + | YulVariableAssignmentStatement | YulExpression = once(() => { const variant = ast_internal.selectChoice(this.cst); switch (variant.kind) { case NonterminalKind.YulBlock: return new YulBlock(variant as NonterminalNode); - case NonterminalKind.YulFunctionDefinition: - return new YulFunctionDefinition(variant as NonterminalNode); - case NonterminalKind.YulVariableDeclarationStatement: - return new YulVariableDeclarationStatement(variant as NonterminalNode); - case NonterminalKind.YulVariableAssignmentStatement: - return new YulVariableAssignmentStatement(variant as NonterminalNode); - case NonterminalKind.YulStackAssignmentStatement: - return new YulStackAssignmentStatement(variant as NonterminalNode); - case NonterminalKind.YulIfStatement: - return new YulIfStatement(variant as NonterminalNode); - case NonterminalKind.YulForStatement: - return new YulForStatement(variant as NonterminalNode); - case NonterminalKind.YulSwitchStatement: - return new YulSwitchStatement(variant as NonterminalNode); - case NonterminalKind.YulLeaveStatement: - return new YulLeaveStatement(variant as NonterminalNode); case NonterminalKind.YulBreakStatement: return new YulBreakStatement(variant as NonterminalNode); case NonterminalKind.YulContinueStatement: return new YulContinueStatement(variant as NonterminalNode); + case NonterminalKind.YulForStatement: + return new YulForStatement(variant as NonterminalNode); + case NonterminalKind.YulFunctionDefinition: + return new YulFunctionDefinition(variant as NonterminalNode); + case NonterminalKind.YulIfStatement: + return new YulIfStatement(variant as NonterminalNode); case NonterminalKind.YulLabel: return new YulLabel(variant as NonterminalNode); + case NonterminalKind.YulLeaveStatement: + return new YulLeaveStatement(variant as NonterminalNode); + case NonterminalKind.YulStackAssignmentStatement: + return new YulStackAssignmentStatement(variant as NonterminalNode); + case NonterminalKind.YulSwitchStatement: + return new YulSwitchStatement(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); @@ -4936,17 +4936,17 @@ export class YulStatement { public get variant(): | YulBlock - | YulFunctionDefinition - | YulVariableDeclarationStatement - | YulVariableAssignmentStatement - | YulStackAssignmentStatement - | YulIfStatement - | YulForStatement - | YulSwitchStatement - | YulLeaveStatement | YulBreakStatement | YulContinueStatement + | YulForStatement + | YulFunctionDefinition + | YulIfStatement | YulLabel + | YulLeaveStatement + | YulStackAssignmentStatement + | YulSwitchStatement + | 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 ee5b7926ab..5b3f4b9815 100644 --- a/crates/solidity/outputs/spec/generated/grammar.ebnf +++ b/crates/solidity/outputs/spec/generated/grammar.ebnf @@ -1620,17 +1620,17 @@ YulBlock = (* open_brace: *) OPEN_BRACE YulStatements = (* item: *) YulStatement*; YulStatement = (* variant: *) YulBlock - | (* variant: *) YulFunctionDefinition - | (* variant: *) YulVariableDeclarationStatement - | (* variant: *) YulVariableAssignmentStatement - | (* 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: *) YulForStatement + | (* variant: *) YulFunctionDefinition + | (* variant: *) YulIfStatement | (* variant: *) YulLabel (* Deprecated in 0.5.0 *) + | (* variant: *) YulLeaveStatement (* Introduced in 0.6.0 *) + | (* variant: *) YulStackAssignmentStatement (* Deprecated in 0.5.0 *) + | (* variant: *) YulSwitchStatement + | (* 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 3023e54066..b07f800fb4 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 @@ ``` -
YulStatement = (* variant: *) YulBlock
| (* variant: *) YulFunctionDefinition
| (* variant: *) YulVariableDeclarationStatement
| (* variant: *) YulVariableAssignmentStatement
| (* 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: *) YulExpression;
+
YulStatement = (* variant: *) YulBlock
| (* variant: *) YulBreakStatement
| (* variant: *) YulContinueStatement
| (* variant: *) YulForStatement
| (* variant: *) YulFunctionDefinition
| (* variant: *) YulIfStatement
| (* variant: *) YulLabel (* Deprecated in 0.5.0 *)
| (* variant: *) YulLeaveStatement (* Introduced in 0.6.0 *)
| (* variant: *) YulStackAssignmentStatement (* Deprecated in 0.5.0 *)
| (* variant: *) YulSwitchStatement
| (* variant: *) YulVariableDeclarationStatement
| (* variant: *) YulVariableAssignmentStatement
| (* variant: *) YulExpression;
```{ .ebnf #YulFunctionDefinition }