diff --git a/crates/codegen/parser/generator/src/parser_definition.rs b/crates/codegen/parser/generator/src/parser_definition.rs index 3e2eee429d..bea7a2827b 100644 --- a/crates/codegen/parser/generator/src/parser_definition.rs +++ b/crates/codegen/parser/generator/src/parser_definition.rs @@ -70,12 +70,10 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { }) .collect::>(); quote! { - { - SequenceHelper::run(|mut seq| { - #(#parsers)* - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + #(#parsers)* + seq.finish() + }) } } } @@ -95,12 +93,10 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { }) .collect::>(); quote! { - { - ChoiceHelper::run(input, |mut choice, input| { - #(#parsers)* - choice.finish(input) - }) - } + ChoiceHelper::run(input, |mut choice, input| { + #(#parsers)* + choice.finish(input) + }) } } diff --git a/crates/codegen/parser/generator/src/precedence_parser_definition.rs b/crates/codegen/parser/generator/src/precedence_parser_definition.rs index adac7ec7ce..47c709b646 100644 --- a/crates/codegen/parser/generator/src/precedence_parser_definition.rs +++ b/crates/codegen/parser/generator/src/precedence_parser_definition.rs @@ -164,12 +164,10 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode .map(|parser| quote! { seq.elem(#parser)?; }) .collect::>(); quote! { - { - SequenceHelper::run(|mut seq| { - #(#parsers)* - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + #(#parsers)* + seq.finish() + }) } } @@ -187,12 +185,10 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode }) .collect::>(); quote! { - { - ChoiceHelper::run(input, |mut choice, input| { - #(#parsers)* - choice.finish(input) - }) - } + ChoiceHelper::run(input, |mut choice, input| { + #(#parsers)* + choice.finish(input) + }) } } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index 17b6da0b09..3079135e3c 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -240,37 +240,29 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn abi_coder_pragma(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ABICoderKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ABICoderKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.finish() + }) .with_kind(RuleKind::ABICoderPragma) } #[allow(unused_assignments, unused_parens)] fn address_type(&self, input: &mut ParserContext) -> ParserResult { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::AddressKeyword), - )?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword), - ))?; - seq.finish() - }) - }; - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - } + ChoiceHelper::run(input, |mut choice, input| { + let result = SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AddressKeyword))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword), + ))?; + seq.finish() + }); + choice.consider(input, result)?; + let result = self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword); + choice.consider(input, result)?; + choice.finish(input) + }) .with_kind(RuleKind::AddressType) } @@ -281,15 +273,13 @@ impl Language { let input = delim_guard.ctx(); seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; seq.elem( - OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.positional_arguments_list(input); - choice.consider(input, result)?; - let result = self.named_arguments_declaration(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }) + OptionalHelper::transform(ChoiceHelper::run(input, |mut choice, input| { + let result = self.positional_arguments_list(input); + choice.consider(input, result)?; + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + choice.finish(input) + })) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -358,37 +348,33 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn assembly_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AssemblyKeyword))?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral), - ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; - seq.elem( - self.assembly_flags_list(input) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; - seq.finish() - })))?; - seq.elem(self.yul_block(input))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AssemblyKeyword))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral), + ))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; + seq.elem( + self.assembly_flags_list(input) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; seq.finish() - }) - } + })))?; + seq.elem(self.yul_block(input))?; + seq.finish() + }) .with_kind(RuleKind::AssemblyStatement) } @@ -436,14 +422,12 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn catch_clause(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CatchKeyword))?; - seq.elem(OptionalHelper::transform(self.catch_clause_error(input)))?; - seq.elem(self.block(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CatchKeyword))?; + seq.elem(OptionalHelper::transform(self.catch_clause_error(input)))?; + seq.elem(self.block(input))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -453,15 +437,13 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn catch_clause_error(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { - { - SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - ))?; - seq.elem(self.parameters_declaration(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + ))?; + seq.elem(self.parameters_declaration(input))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -483,23 +465,18 @@ impl Language { if self.version_is_at_least_0_7_4 { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem(self.default_parse_token_with_trivia( - input, - TokenKind::ConstantKeyword, - ))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Equal), - )?; - seq.elem(self.expression(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::ConstantKeyword), + )?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Equal))?; + seq.elem(self.expression(input))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -522,22 +499,20 @@ impl Language { if self.version_is_at_least_0_4_22 { OneOrMoreHelper::run(input, |input| { if self.version_is_at_least_0_4_22 { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.modifier_invocation(input); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::InternalKeyword); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::PayableKeyword); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::PublicKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - } + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::InternalKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::PublicKeyword); + choice.consider(input, result)?; + choice.finish(input) + }) } else { ParserResult::disabled() } @@ -551,19 +526,17 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn constructor_definition(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_4_22 { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::ConstructorKeyword), - )?; - seq.elem(self.parameters_declaration(input))?; - seq.elem(OptionalHelper::transform( - self.constructor_attributes_list(input), - ))?; - seq.elem(self.block(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::ConstructorKeyword), + )?; + seq.elem(self.parameters_declaration(input))?; + seq.elem(OptionalHelper::transform( + self.constructor_attributes_list(input), + ))?; + seq.elem(self.block(input))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -591,40 +564,36 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn contract_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - if self.version_is_at_least_0_6_0 { - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::AbstractKeyword), - ))?; - } - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ContractKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(OptionalHelper::transform(self.inheritance_specifier(input)))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; - seq.elem( - OptionalHelper::transform(self.contract_members_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseBrace, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; - seq.finish() - }))?; + SequenceHelper::run(|mut seq| { + if self.version_is_at_least_0_6_0 { + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::AbstractKeyword), + ))?; + } + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ContractKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(OptionalHelper::transform(self.inheritance_specifier(input)))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; + seq.elem( + OptionalHelper::transform(self.contract_members_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseBrace, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; seq.finish() - }) - } + }))?; + seq.finish() + }) .with_kind(RuleKind::ContractDefinition) } @@ -651,15 +620,13 @@ impl Language { choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.fallback_function_definition(input); + choice.consider(input, result)?; + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + choice.finish(input) + }); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { @@ -682,58 +649,44 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn deconstruction_import(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; - seq.elem( - self.deconstruction_import_symbols_list(input) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseBrace, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; - seq.finish() - }))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FromKeyword))?; + SequenceHelper::run(|mut seq| { + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral), + self.deconstruction_import_symbols_list(input) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseBrace, + Self::default_delimiters(), + ), )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; seq.finish() - }) - } + }))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FromKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral))?; + seq.finish() + }) .with_kind(RuleKind::DeconstructionImport) } #[allow(unused_assignments, unused_parens)] fn deconstruction_import_symbol(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsKeyword))?; seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::AsKeyword), - )?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.finish() - }) - }))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .with_kind(RuleKind::DeconstructionImportSymbol) } @@ -752,16 +705,14 @@ impl Language { fn delete_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::DeleteKeyword), - )?; - seq.elem(self.expression(input))?; - seq.finish() - }) - } - .recover_until_with_nested_delims( + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::DeleteKeyword), + )?; + seq.elem(self.expression(input))?; + seq.finish() + }) + .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), |input| Lexer::leading_trivia(self, input), @@ -779,40 +730,32 @@ impl Language { fn do_while_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::DoKeyword))?; + seq.elem(self.statement(input))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::WhileKeyword))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::DoKeyword), + self.default_parse_token_with_trivia(input, TokenKind::OpenParen), )?; - seq.elem(self.statement(input))?; + seq.elem(self.expression(input).recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ))?; seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::WhileKeyword), + self.default_parse_token_with_trivia(input, TokenKind::CloseParen), )?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::OpenParen), - )?; - seq.elem(self.expression(input).recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::CloseParen), - )?; - seq.finish() - }))?; seq.finish() - }) - } + }))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -832,16 +775,14 @@ impl Language { if self.version_is_at_least_0_4_21 { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::EmitKeyword), - )?; - seq.elem(self.identifier_path(input))?; - seq.elem(self.arguments_declaration(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::EmitKeyword), + )?; + seq.elem(self.identifier_path(input))?; + seq.elem(self.arguments_declaration(input))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -879,54 +820,99 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn enum_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::EnumKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; - seq.elem( - OptionalHelper::transform(self.identifiers_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseBrace, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; - seq.finish() - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::EnumKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; + seq.elem( + OptionalHelper::transform(self.identifiers_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseBrace, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; seq.finish() - }) - } + }))?; + seq.finish() + }) .with_kind(RuleKind::EnumDefinition) } #[allow(unused_assignments, unused_parens)] fn error_definition(&self, input: &mut ParserContext) -> ParserResult { - if self . version_is_at_least_0_8_4 { SequenceHelper :: run (| mut seq | { seq . elem ({ SequenceHelper :: run (| mut seq | { seq . elem (self . default_parse_token_with_trivia (input , TokenKind :: ErrorKeyword)) ? ; seq . elem (self . default_parse_token_with_trivia (input , TokenKind :: Identifier)) ? ; seq . elem (SequenceHelper :: run (| mut seq | { let mut delim_guard = input . open_delim (TokenKind :: CloseParen) ; let input = delim_guard . ctx () ; seq . elem (self . default_parse_token_with_trivia (input , TokenKind :: OpenParen)) ? ; seq . elem (OptionalHelper :: transform (self . error_parameters_list (input)) . recover_until_with_nested_delims (input , | input | Lexer :: next_token :: < { LexicalContext :: Default as u8 } > (self , input) , | input | Lexer :: leading_trivia (self , input) , TokenKind :: CloseParen , Self :: default_delimiters () ,)) ? ; seq . elem (self . default_parse_token_with_trivia (input , TokenKind :: CloseParen)) ? ; seq . finish () })) ? ; seq . finish () }) } . recover_until_with_nested_delims (input , | input | Lexer :: next_token :: < { LexicalContext :: Default as u8 } > (self , input) , | input | Lexer :: leading_trivia (self , input) , TokenKind :: Semicolon , Self :: default_delimiters () ,)) ? ; seq . elem (self . default_parse_token_with_trivia (input , TokenKind :: Semicolon)) ? ; seq . finish () }) } else { ParserResult :: disabled () } . with_kind (RuleKind :: ErrorDefinition) + if self.version_is_at_least_0_8_4 { + SequenceHelper::run(|mut seq| { + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::ErrorKeyword), + )?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + )?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::OpenParen), + )?; + seq.elem( + OptionalHelper::transform(self.error_parameters_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>( + self, input, + ) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ), + )?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::CloseParen), + )?; + seq.finish() + }))?; + seq.finish() + }) + .recover_until_with_nested_delims( + input, + |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), + |input| Lexer::leading_trivia(self, input), + TokenKind::Semicolon, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Semicolon))?; + seq.finish() + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::ErrorDefinition) } #[allow(unused_assignments, unused_parens)] fn error_parameter(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_8_4 { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - ))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + ))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -952,48 +938,39 @@ impl Language { fn event_definition(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::EventKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::EventKeyword), + self.default_parse_token_with_trivia(input, TokenKind::OpenParen), )?; seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), + OptionalHelper::transform(self.event_parameters_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>( + self, input, + ) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ), + )?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::CloseParen), )?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::OpenParen), - )?; - seq.elem( - OptionalHelper::transform(self.event_parameters_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ), - )?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::CloseParen), - )?; - seq.finish() - }))?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia( - input, - TokenKind::AnonymousKeyword, - ), - ))?; seq.finish() - }) - } + }))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::AnonymousKeyword), + ))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -1010,18 +987,16 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn event_parameter(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::IndexedKeyword), - ))?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - ))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::IndexedKeyword), + ))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + ))?; + seq.finish() + }) .with_kind(RuleKind::EventParameter) } @@ -1038,32 +1013,28 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn experimental_pragma(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::ExperimentalKeyword), - )?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self - .default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::Identifier); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ExperimentalKeyword))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral); + choice.consider(input, result)?; + let result = self.default_parse_token_with_trivia(input, TokenKind::Identifier); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) .with_kind(RuleKind::ExperimentalPragma) } #[allow(unused_assignments, unused_parens)] fn expression(&self, input: &mut ParserContext) -> ParserResult { let parse_assignment_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_binary_operator(RuleKind::BinaryExpression, 1u8, 1u8 + 1, { + PrecedenceHelper::to_binary_operator( + RuleKind::BinaryExpression, + 1u8, + 1u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::Equal); choice.consider(input, result)?; @@ -1100,19 +1071,21 @@ impl Language { ); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let parse_conditional_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_postfix_operator(RuleKind::ConditionalExpression, 3u8, { + PrecedenceHelper::to_postfix_operator( + RuleKind::ConditionalExpression, + 3u8, SequenceHelper::run(|mut seq| { seq.elem(self.default_parse_token_with_trivia(input, TokenKind::QuestionMark))?; seq.elem(self.expression(input))?; seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Colon))?; seq.elem(self.expression(input))?; seq.finish() - }) - }) + }), + ) }; let parse_or_operator = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( @@ -1131,18 +1104,24 @@ impl Language { ) }; let parse_equality_comparison_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_binary_operator(RuleKind::BinaryExpression, 9u8, 9u8 + 1, { + PrecedenceHelper::to_binary_operator( + RuleKind::BinaryExpression, + 9u8, + 9u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::EqualEqual); choice.consider(input, result)?; let result = self.default_parse_token_with_trivia(input, TokenKind::BangEqual); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let parse_order_comparison_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_binary_operator(RuleKind::BinaryExpression, 11u8, 11u8 + 1, { + PrecedenceHelper::to_binary_operator( + RuleKind::BinaryExpression, + 11u8, + 11u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::LessThan); choice.consider(input, result)?; @@ -1156,8 +1135,8 @@ impl Language { self.default_parse_token_with_trivia(input, TokenKind::GreaterThanEqual); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let parse_bitwise_or_operator = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( @@ -1184,7 +1163,10 @@ impl Language { ) }; let parse_shift_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_binary_operator(RuleKind::BinaryExpression, 19u8, 19u8 + 1, { + PrecedenceHelper::to_binary_operator( + RuleKind::BinaryExpression, + 19u8, + 19u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::LessThanLessThan); @@ -1198,22 +1180,28 @@ impl Language { ); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let parse_add_sub_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_binary_operator(RuleKind::BinaryExpression, 21u8, 21u8 + 1, { + PrecedenceHelper::to_binary_operator( + RuleKind::BinaryExpression, + 21u8, + 21u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::Plus); choice.consider(input, result)?; let result = self.default_parse_token_with_trivia(input, TokenKind::Minus); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let parse_mul_div_mod_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_binary_operator(RuleKind::BinaryExpression, 23u8, 23u8 + 1, { + PrecedenceHelper::to_binary_operator( + RuleKind::BinaryExpression, + 23u8, + 23u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::Asterisk); choice.consider(input, result)?; @@ -1222,8 +1210,8 @@ impl Language { let result = self.default_parse_token_with_trivia(input, TokenKind::Percent); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let parse_exponentiation_operator_removed_from_0_6_0 = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( @@ -1242,18 +1230,22 @@ impl Language { ) }; let parse_unary_postfix_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_postfix_operator(RuleKind::UnaryPostfixExpression, 29u8, { + PrecedenceHelper::to_postfix_operator( + RuleKind::UnaryPostfixExpression, + 29u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::PlusPlus); choice.consider(input, result)?; let result = self.default_parse_token_with_trivia(input, TokenKind::MinusMinus); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let parse_unary_prefix_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_prefix_operator(RuleKind::UnaryPrefixExpression, 31u8, { + PrecedenceHelper::to_prefix_operator( + RuleKind::UnaryPrefixExpression, + 31u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::PlusPlus); choice.consider(input, result)?; @@ -1270,38 +1262,40 @@ impl Language { choice.consider(input, result)?; } choice.finish(input) - }) - }) + }), + ) }; let parse_function_call_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_postfix_operator(RuleKind::FunctionCallExpression, 33u8, { + PrecedenceHelper::to_postfix_operator( + RuleKind::FunctionCallExpression, + 33u8, SequenceHelper::run(|mut seq| { if self.version_is_at_least_0_6_2 { seq.elem(OptionalHelper::transform(self.function_call_options(input)))?; } seq.elem(self.arguments_declaration(input))?; seq.finish() - }) - }) + }), + ) }; let parse_member_access_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_postfix_operator(RuleKind::MemberAccessExpression, 35u8, { + PrecedenceHelper::to_postfix_operator( + RuleKind::MemberAccessExpression, + 35u8, SequenceHelper::run(|mut seq| { seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Period))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::Identifier); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::AddressKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::Identifier); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::AddressKeyword); + choice.consider(input, result)?; + choice.finish(input) + }))?; seq.finish() - }) - }) + }), + ) }; let parse_index_access_operator = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( @@ -1312,24 +1306,17 @@ impl Language { let input = delim_guard.ctx(); seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBracket))?; seq.elem( - { - SequenceHelper::run(|mut seq| { + SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform(self.expression(input)))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::Colon), + )?; seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia( - input, - TokenKind::Colon, - ))?; - seq.elem(OptionalHelper::transform( - self.expression(input), - ))?; - seq.finish() - }) - }))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| { @@ -1360,67 +1347,61 @@ impl Language { choice.consider(input, result)?; let result = self.array_expression(input); choice.consider(input, result)?; - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::TrueKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::FalseKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - }; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::TrueKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::FalseKeyword); + choice.consider(input, result)?; + choice.finish(input) + }); choice.consider(input, result)?; let result = self.numeric_expression(input); choice.consider(input, result)?; - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.hex_string_literals_list(input); - choice.consider(input, result)?; - let result = self.ascii_string_literals_list(input); + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.hex_string_literals_list(input); + choice.consider(input, result)?; + let result = self.ascii_string_literals_list(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_7_0 { + let result = self.unicode_string_literals_list(input); choice.consider(input, result)?; - if self.version_is_at_least_0_7_0 { - let result = self.unicode_string_literals_list(input); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }; + } + choice.finish(input) + }); choice.consider(input, result)?; - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::BoolKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::StringKeyword); - choice.consider(input, result)?; - let result = self.address_type(input); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::FixedBytesType); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::SignedIntegerType); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::UnsignedIntegerType); - choice.consider(input, result)?; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::BoolKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::StringKeyword); + choice.consider(input, result)?; + let result = self.address_type(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::FixedBytesType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::SignedIntegerType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::UnsignedIntegerType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::SignedFixedType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::UnsignedFixedType); + choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { let result = - self.default_parse_token_with_trivia(input, TokenKind::SignedFixedType); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::UnsignedFixedType); + self.default_parse_token_with_trivia(input, TokenKind::ByteKeyword); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = - self.default_parse_token_with_trivia(input, TokenKind::ByteKeyword); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }; + } + choice.finish(input) + }); choice.consider(input, result)?; let result = self.default_parse_token_with_trivia(input, TokenKind::Identifier); choice.consider(input, result)?; @@ -1534,30 +1515,28 @@ impl Language { if self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| { if self.version_is_at_least_0_6_0 { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.modifier_invocation(input); - choice.consider(input, result)?; - let result = self.override_specifier(input); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::ExternalKeyword); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::PayableKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::PureKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::ViewKeyword); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::VirtualKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - } + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::ExternalKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::PureKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::ViewKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::VirtualKeyword); + choice.consider(input, result)?; + choice.finish(input) + }) } else { ParserResult::disabled() } @@ -1571,29 +1550,22 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn fallback_function_definition(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::FallbackKeyword), - )?; - seq.elem(self.parameters_declaration(input))?; - seq.elem(OptionalHelper::transform( - self.fallback_function_attributes_list(input), - ))?; - seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::Semicolon); - choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FallbackKeyword))?; + seq.elem(self.parameters_declaration(input))?; + seq.elem(OptionalHelper::transform( + self.fallback_function_attributes_list(input), + ))?; + seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.default_parse_token_with_trivia(input, TokenKind::Semicolon); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -1602,73 +1574,55 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn for_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ForKeyword))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; - seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = - self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = - self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }; - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Semicolon, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Semicolon, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.finish() - }) - } - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; - seq.finish() - }))?; - seq.elem(self.statement(input))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ForKeyword))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.expression_statement(input); + choice.consider(input, result)?; + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + choice.finish(input) + }); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Semicolon); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.expression_statement(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Semicolon); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.elem(OptionalHelper::transform(self.expression(input)))?; + seq.finish() + }) + .recover_until_with_nested_delims( + input, + |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; seq.finish() - }) - } + }))?; + seq.elem(self.statement(input))?; + seq.finish() + }) .with_kind(RuleKind::ForStatement) } @@ -1714,77 +1668,63 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn function_call_options(&self, input: &mut ParserContext) -> ParserResult { - { - ChoiceHelper::run(input, |mut choice, input| { - if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { - let result = OneOrMoreHelper::run(input, |input| { - self.named_arguments_declaration(input) - }); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_0 { - let result = self.named_arguments_declaration(input); - choice.consider(input, result)?; - } - choice.finish(input) - }) - } - .with_kind(RuleKind::FunctionCallOptions) - } - - #[allow(unused_assignments, unused_parens)] - fn function_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FunctionKeyword))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::Identifier); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::FallbackKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::ReceiveKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.elem(self.parameters_declaration(input))?; - seq.elem(OptionalHelper::transform( - self.function_attributes_list(input), - ))?; - seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::Semicolon); - choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + ChoiceHelper::run(input, |mut choice, input| { + if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { + let result = + OneOrMoreHelper::run(input, |input| self.named_arguments_declaration(input)); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_8_0 { + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::FunctionCallOptions) + } + + #[allow(unused_assignments, unused_parens)] + fn function_definition(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FunctionKeyword))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.default_parse_token_with_trivia(input, TokenKind::Identifier); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::FallbackKeyword); + choice.consider(input, result)?; + let result = self.default_parse_token_with_trivia(input, TokenKind::ReceiveKeyword); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.elem(self.parameters_declaration(input))?; + seq.elem(OptionalHelper::transform( + self.function_attributes_list(input), + ))?; + seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.default_parse_token_with_trivia(input, TokenKind::Semicolon); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) .with_kind(RuleKind::FunctionDefinition) } #[allow(unused_assignments, unused_parens)] fn function_type(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FunctionKeyword))?; - seq.elem(self.parameters_declaration(input))?; - seq.elem(OptionalHelper::transform( - self.function_type_attributes_list(input), - ))?; - seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FunctionKeyword))?; + seq.elem(self.parameters_declaration(input))?; + seq.elem(OptionalHelper::transform( + self.function_type_attributes_list(input), + ))?; + seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; + seq.finish() + }) .with_kind(RuleKind::FunctionType) } @@ -1857,36 +1797,30 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn if_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::IfKeyword))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; - seq.elem(self.expression(input).recover_until_with_nested_delims( - input, - |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; - seq.finish() - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::IfKeyword))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; + seq.elem(self.expression(input).recover_until_with_nested_delims( + input, + |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; + seq.finish() + }))?; + seq.elem(self.statement(input))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ElseKeyword))?; seq.elem(self.statement(input))?; - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::ElseKeyword), - )?; - seq.elem(self.statement(input))?; - seq.finish() - }) - }))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .with_kind(RuleKind::IfStatement) } @@ -1894,25 +1828,21 @@ impl Language { fn import_directive(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::ImportKeyword), - )?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.path_import(input); - choice.consider(input, result)?; - let result = self.named_import(input); - choice.consider(input, result)?; - let result = self.deconstruction_import(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::ImportKeyword), + )?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.path_import(input); + choice.consider(input, result)?; + let result = self.named_import(input); + choice.consider(input, result)?; + let result = self.deconstruction_import(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -1929,25 +1859,21 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn inheritance_specifier(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::IsKeyword))?; - seq.elem(self.inheritance_types_list(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::IsKeyword))?; + seq.elem(self.inheritance_types_list(input))?; + seq.finish() + }) .with_kind(RuleKind::InheritanceSpecifier) } #[allow(unused_assignments, unused_parens)] fn inheritance_type(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.identifier_path(input))?; - seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.identifier_path(input))?; + seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; + seq.finish() + }) .with_kind(RuleKind::InheritanceType) } @@ -1964,35 +1890,31 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn interface_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::InterfaceKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(OptionalHelper::transform(self.inheritance_specifier(input)))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; - seq.elem( - OptionalHelper::transform(self.interface_members_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseBrace, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; - seq.finish() - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::InterfaceKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(OptionalHelper::transform(self.inheritance_specifier(input)))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; + seq.elem( + OptionalHelper::transform(self.interface_members_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseBrace, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; seq.finish() - }) - } + }))?; + seq.finish() + }) .with_kind(RuleKind::InterfaceDefinition) } @@ -2019,15 +1941,13 @@ impl Language { choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.fallback_function_definition(input); + choice.consider(input, result)?; + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + choice.finish(input) + }); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { @@ -2068,34 +1988,30 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn library_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::LibraryKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; - seq.elem( - OptionalHelper::transform(self.library_members_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseBrace, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; - seq.finish() - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::LibraryKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; + seq.elem( + OptionalHelper::transform(self.library_members_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseBrace, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; seq.finish() - }) - } + }))?; + seq.finish() + }) .with_kind(RuleKind::LibraryDefinition) } @@ -2122,15 +2038,13 @@ impl Language { choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.fallback_function_definition(input); + choice.consider(input, result)?; + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + choice.finish(input) + }); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { @@ -2153,127 +2067,101 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn mapping_key_type(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self - .default_parse_token_with_trivia(input, TokenKind::BoolKeyword); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::StringKeyword, - ); - choice.consider(input, result)?; - let result = self.address_type(input); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::FixedBytesType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::SignedIntegerType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::UnsignedIntegerType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::SignedFixedType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::UnsignedFixedType, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }; - choice.consider(input, result)?; - let result = self.identifier_path(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - if self.version_is_at_least_0_8_18 { - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - ))?; - } - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::BoolKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::StringKeyword); + choice.consider(input, result)?; + let result = self.address_type(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::FixedBytesType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::SignedIntegerType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::UnsignedIntegerType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::SignedFixedType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::UnsignedFixedType); + choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = + self.default_parse_token_with_trivia(input, TokenKind::ByteKeyword); + choice.consider(input, result)?; + } + choice.finish(input) + }); + choice.consider(input, result)?; + let result = self.identifier_path(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + if self.version_is_at_least_0_8_18 { + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + ))?; + } + seq.finish() + }) .with_kind(RuleKind::MappingKeyType) } #[allow(unused_assignments, unused_parens)] fn mapping_type(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::MappingKeyword))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; - seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem(self.mapping_key_type(input))?; - seq.elem(self.default_parse_token_with_trivia( - input, - TokenKind::EqualGreaterThan, - ))?; - seq.elem(self.mapping_value_type(input))?; - seq.finish() - }) - } - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; - seq.finish() - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::MappingKeyword))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(self.mapping_key_type(input))?; + seq.elem( + self.default_parse_token_with_trivia( + input, + TokenKind::EqualGreaterThan, + ), + )?; + seq.elem(self.mapping_value_type(input))?; + seq.finish() + }) + .recover_until_with_nested_delims( + input, + |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; seq.finish() - }) - } + }))?; + seq.finish() + }) .with_kind(RuleKind::MappingType) } #[allow(unused_assignments, unused_parens)] fn mapping_value_type(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - if self.version_is_at_least_0_8_18 { - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - ))?; - } - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + if self.version_is_at_least_0_8_18 { + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + ))?; + } + seq.finish() + }) .with_kind(RuleKind::MappingValueType) } @@ -2296,54 +2184,45 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn modifier_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ModifierKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(OptionalHelper::transform( - self.parameters_declaration(input), - ))?; - seq.elem(OptionalHelper::transform( - self.modifier_attributes_list(input), - ))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::Semicolon); - choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ModifierKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(OptionalHelper::transform( + self.parameters_declaration(input), + ))?; + seq.elem(OptionalHelper::transform( + self.modifier_attributes_list(input), + ))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.default_parse_token_with_trivia(input, TokenKind::Semicolon); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) .with_kind(RuleKind::ModifierDefinition) } #[allow(unused_assignments, unused_parens)] fn modifier_invocation(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.identifier_path(input))?; - seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.identifier_path(input))?; + seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; + seq.finish() + }) .with_kind(RuleKind::ModifierInvocation) } #[allow(unused_assignments, unused_parens)] fn named_argument(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Colon))?; - seq.elem(self.expression(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Colon))?; + seq.elem(self.expression(input))?; + seq.finish() + }) .with_kind(RuleKind::NamedArgument) } @@ -2382,262 +2261,209 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn named_import(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Asterisk))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FromKeyword))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral), - )?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Asterisk))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FromKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral))?; + seq.finish() + }) .with_kind(RuleKind::NamedImport) } #[allow(unused_assignments, unused_parens)] fn new_expression(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::NewKeyword))?; - seq.elem(self.type_name(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::NewKeyword))?; + seq.elem(self.type_name(input))?; + seq.finish() + }) .with_kind(RuleKind::NewExpression) } #[allow(unused_assignments, unused_parens)] fn numeric_expression(&self, input: &mut ParserContext) -> ParserResult { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::HexLiteral), - )?; - if !self.version_is_at_least_0_5_0 { - seq.elem(OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::DaysKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::EtherKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::HoursKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::MinutesKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::SecondsKeyword, - ); - choice.consider(input, result)?; + ChoiceHelper::run(input, |mut choice, input| { + let result = SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::HexLiteral))?; + if !self.version_is_at_least_0_5_0 { + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::DaysKeyword); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::EtherKeyword); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::HoursKeyword); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::MinutesKeyword); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::SecondsKeyword); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::WeeksKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::WeiKeyword); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.default_parse_token_with_trivia( + input, + TokenKind::YearsKeyword, + ); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_11 { + let result = self + .default_parse_token_with_trivia(input, TokenKind::GweiKeyword); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia( input, - TokenKind::WeeksKeyword, + TokenKind::FinneyKeyword, ); choice.consider(input, result)?; let result = self.default_parse_token_with_trivia( input, - TokenKind::WeiKeyword, + TokenKind::SzaboKeyword, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::YearsKeyword, - ); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_11 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::GweiKeyword, - ); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_7_0 { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::FinneyKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::SzaboKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - }; - choice.consider(input, result)?; - } choice.finish(input) - }) - }))?; - } - seq.finish() - }) - }; - choice.consider(input, result)?; - let result = { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::DecimalLiteral), - )?; - seq.elem(OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self - .default_parse_token_with_trivia(input, TokenKind::DaysKeyword); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::EtherKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::HoursKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::MinutesKeyword, - ); + }); choice.consider(input, result)?; + } + choice.finish(input) + }, + )))?; + } + seq.finish() + }); + choice.consider(input, result)?; + let result = SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::DecimalLiteral))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::DaysKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::EtherKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::HoursKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::MinutesKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::SecondsKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::WeeksKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::WeiKeyword); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self + .default_parse_token_with_trivia(input, TokenKind::YearsKeyword); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_11 { + let result = + self.default_parse_token_with_trivia(input, TokenKind::GweiKeyword); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia( input, - TokenKind::SecondsKeyword, + TokenKind::FinneyKeyword, ); choice.consider(input, result)?; let result = self.default_parse_token_with_trivia( input, - TokenKind::WeeksKeyword, + TokenKind::SzaboKeyword, ); choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::WeiKeyword); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::YearsKeyword, - ); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_11 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::GweiKeyword, - ); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_7_0 { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::FinneyKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::SzaboKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - }; - choice.consider(input, result)?; - } choice.finish(input) - }) - }))?; - seq.finish() - }) - }; - choice.consider(input, result)?; - choice.finish(input) - }) - } + }); + choice.consider(input, result)?; + } + choice.finish(input) + }, + )))?; + seq.finish() + }); + choice.consider(input, result)?; + choice.finish(input) + }) .with_kind(RuleKind::NumericExpression) } #[allow(unused_assignments, unused_parens)] fn override_specifier(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OverrideKeyword))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; - seq.elem( - OptionalHelper::transform(self.identifier_paths_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; - seq.finish() - })))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OverrideKeyword))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; + seq.elem( + OptionalHelper::transform(self.identifier_paths_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .with_kind(RuleKind::OverrideSpecifier) } - #[allow(unused_assignments, unused_parens)] - fn parameter(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem(OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::MemoryKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::StorageKeyword); - choice.consider(input, result)?; - if self.version_is_at_least_0_5_0 { - let result = self - .default_parse_token_with_trivia(input, TokenKind::CalldataKeyword); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }))?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - ))?; - seq.finish() - }) - } + #[allow(unused_assignments, unused_parens)] + fn parameter(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::MemoryKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::StorageKeyword); + choice.consider(input, result)?; + if self.version_is_at_least_0_5_0 { + let result = + self.default_parse_token_with_trivia(input, TokenKind::CalldataKeyword); + choice.consider(input, result)?; + } + choice.finish(input) + }, + )))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + ))?; + seq.finish() + }) .with_kind(RuleKind::Parameter) } @@ -2676,25 +2502,15 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn path_import(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral), - )?; - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::AsKeyword), - )?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.finish() - }) - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .with_kind(RuleKind::PathImport) } @@ -2713,25 +2529,21 @@ impl Language { fn pragma_directive(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::PragmaKeyword), - )?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.abi_coder_pragma(input); - choice.consider(input, result)?; - let result = self.experimental_pragma(input); - choice.consider(input, result)?; - let result = self.version_pragma(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::PragmaKeyword), + )?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.abi_coder_pragma(input); + choice.consider(input, result)?; + let result = self.experimental_pragma(input); + choice.consider(input, result)?; + let result = self.version_pragma(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -2751,24 +2563,22 @@ impl Language { if self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| { if self.version_is_at_least_0_6_0 { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.modifier_invocation(input); - choice.consider(input, result)?; - let result = self.override_specifier(input); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::ExternalKeyword); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::PayableKeyword); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::VirtualKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - } + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::ExternalKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::VirtualKeyword); + choice.consider(input, result)?; + choice.finish(input) + }) } else { ParserResult::disabled() } @@ -2782,28 +2592,21 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn receive_function_definition(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::ReceiveKeyword), - )?; - seq.elem(self.parameters_declaration(input))?; - seq.elem(OptionalHelper::transform( - self.receive_function_attributes_list(input), - ))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::Semicolon); - choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ReceiveKeyword))?; + seq.elem(self.parameters_declaration(input))?; + seq.elem(OptionalHelper::transform( + self.receive_function_attributes_list(input), + ))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.default_parse_token_with_trivia(input, TokenKind::Semicolon); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -2814,15 +2617,13 @@ impl Language { fn return_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::ReturnKeyword), - )?; - seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::ReturnKeyword), + )?; + seq.elem(OptionalHelper::transform(self.expression(input)))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -2839,13 +2640,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn returns_declaration(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ReturnsKeyword))?; - seq.elem(self.parameters_declaration(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ReturnsKeyword))?; + seq.elem(self.parameters_declaration(input))?; + seq.finish() + }) .with_kind(RuleKind::ReturnsDeclaration) } @@ -2853,16 +2652,14 @@ impl Language { fn revert_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::RevertKeyword), - )?; - seq.elem(OptionalHelper::transform(self.identifier_path(input)))?; - seq.elem(self.arguments_declaration(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::RevertKeyword), + )?; + seq.elem(OptionalHelper::transform(self.identifier_path(input)))?; + seq.elem(self.arguments_declaration(input))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -2879,15 +2676,13 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn source_unit(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform( - self.source_unit_members_list(input), - ))?; - seq.elem(OptionalHelper::transform(self.end_of_file_trivia(input)))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform( + self.source_unit_members_list(input), + ))?; + seq.elem(OptionalHelper::transform(self.end_of_file_trivia(input)))?; + seq.finish() + }) .with_kind(RuleKind::SourceUnit) } @@ -2906,15 +2701,13 @@ impl Language { let result = self.library_definition(input); choice.consider(input, result)?; if self.version_is_at_least_0_6_0 { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.struct_definition(input); + choice.consider(input, result)?; + let result = self.enum_definition(input); + choice.consider(input, result)?; + choice.finish(input) + }); choice.consider(input, result)?; } if self.version_is_at_least_0_7_1 { @@ -2974,27 +2767,19 @@ impl Language { fn state_variable_definition(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem(OptionalHelper::transform( - self.state_variable_attributes_list(input), - ))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Equal), - )?; - seq.elem(self.expression(input))?; - seq.finish() - }) - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem(OptionalHelper::transform( + self.state_variable_attributes_list(input), + ))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Equal))?; + seq.elem(self.expression(input))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -3011,106 +2796,96 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn statement(&self, input: &mut ParserContext) -> ParserResult { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }; + ChoiceHelper::run(input, |mut choice, input| { + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.expression_statement(input); choice.consider(input, result)?; - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); - choice.consider(input, result)?; - let result = self.break_statement(input); - choice.consider(input, result)?; - let result = self.delete_statement(input); - choice.consider(input, result)?; - let result = self.return_statement(input); - choice.consider(input, result)?; - let result = self.revert_statement(input); - choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }; + let result = self.variable_declaration_statement(input); choice.consider(input, result)?; - let result = self.assembly_statement(input); + let result = self.tuple_deconstruction_statement(input); choice.consider(input, result)?; - let result = self.block(input); + choice.finish(input) + }); + choice.consider(input, result)?; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.if_statement(input); choice.consider(input, result)?; - if self.version_is_at_least_0_8_0 { - let result = self.unchecked_block(input); + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + let result = self.revert_statement(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); choice.consider(input, result)?; } choice.finish(input) - }) - } - .with_kind(RuleKind::Statement) - } - - #[allow(unused_assignments, unused_parens)] - fn statements_list(&self, input: &mut ParserContext) -> ParserResult { - OneOrMoreHelper::run(input, |input| self.statement(input)) - .with_kind(RuleKind::StatementsList) - } - - #[allow(unused_assignments, unused_parens)] - fn struct_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::StructKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; - seq.elem( - OptionalHelper::transform(self.struct_members_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseBrace, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; - seq.finish() - }))?; + }); + choice.consider(input, result)?; + let result = self.assembly_statement(input); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_8_0 { + let result = self.unchecked_block(input); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::Statement) + } + + #[allow(unused_assignments, unused_parens)] + fn statements_list(&self, input: &mut ParserContext) -> ParserResult { + OneOrMoreHelper::run(input, |input| self.statement(input)) + .with_kind(RuleKind::StatementsList) + } + + #[allow(unused_assignments, unused_parens)] + fn struct_definition(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::StructKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; + seq.elem( + OptionalHelper::transform(self.struct_members_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseBrace, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; seq.finish() - }) - } + }))?; + seq.finish() + }) .with_kind(RuleKind::StructDefinition) } @@ -3118,15 +2893,11 @@ impl Language { fn struct_member(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -3174,34 +2945,30 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn trailing_trivia(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform( - self.default_parse_token(input, TokenKind::Whitespace), - ))?; - seq.elem(OptionalHelper::transform( - self.default_parse_token(input, TokenKind::SingleLineComment), - ))?; - seq.elem(self.default_parse_token(input, TokenKind::EndOfLine))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform( + self.default_parse_token(input, TokenKind::Whitespace), + ))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token(input, TokenKind::SingleLineComment), + ))?; + seq.elem(self.default_parse_token(input, TokenKind::EndOfLine))?; + seq.finish() + }) .with_kind(RuleKind::TrailingTrivia) } #[allow(unused_assignments, unused_parens)] fn try_statement(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::TryKeyword))?; - seq.elem(self.expression(input))?; - seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; - seq.elem(self.block(input))?; - seq.elem(self.catch_clauses_list(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::TryKeyword))?; + seq.elem(self.expression(input))?; + seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; + seq.elem(self.block(input))?; + seq.elem(self.catch_clauses_list(input))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -3212,38 +2979,36 @@ impl Language { fn tuple_deconstruction_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::OpenParen), - )?; - seq.elem( - OptionalHelper::transform(self.tuple_members_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ), - )?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::CloseParen), - )?; - seq.finish() - }))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Equal))?; - seq.elem(self.expression(input))?; + SequenceHelper::run(|mut seq| { + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::OpenParen), + )?; + seq.elem( + OptionalHelper::transform(self.tuple_members_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>( + self, input, + ) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ), + )?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::CloseParen), + )?; seq.finish() - }) - } + }))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Equal))?; + seq.elem(self.expression(input))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -3282,74 +3047,54 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn tuple_member(&self, input: &mut ParserContext) -> ParserResult { - OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem(OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::MemoryKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::StorageKeyword, - ); - choice.consider(input, result)?; - if self.version_is_at_least_0_5_0 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::CalldataKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.finish() - }) - }; - choice.consider(input, result)?; - let result = { - SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::MemoryKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::StorageKeyword, - ); - choice.consider(input, result)?; - if self.version_is_at_least_0_5_0 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::CalldataKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.finish() - }) - }; - choice.consider(input, result)?; - choice.finish(input) - }) - }) + OptionalHelper::transform(ChoiceHelper::run(input, |mut choice, input| { + let result = SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::MemoryKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::StorageKeyword); + choice.consider(input, result)?; + if self.version_is_at_least_0_5_0 { + let result = self + .default_parse_token_with_trivia(input, TokenKind::CalldataKeyword); + choice.consider(input, result)?; + } + choice.finish(input) + }, + )))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.finish() + }); + choice.consider(input, result)?; + let result = SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::MemoryKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::StorageKeyword); + choice.consider(input, result)?; + if self.version_is_at_least_0_5_0 { + let result = self + .default_parse_token_with_trivia(input, TokenKind::CalldataKeyword); + choice.consider(input, result)?; + } + choice.finish(input) + }, + )))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.finish() + }); + choice.consider(input, result)?; + choice.finish(input) + })) .with_kind(RuleKind::TupleMember) } @@ -3378,32 +3123,24 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn type_expression(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_5_3 { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::TypeKeyword))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::OpenParen), - )?; - seq.elem(self.type_name(input).recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::CloseParen), - )?; - seq.finish() - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::TypeKeyword))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; + seq.elem(self.type_name(input).recover_until_with_nested_delims( + input, + |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; seq.finish() - }) - } + }))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -3445,39 +3182,37 @@ impl Language { choice.consider(input, result)?; let result = self.mapping_type(input); choice.consider(input, result)?; - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::BoolKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::StringKeyword); - choice.consider(input, result)?; - let result = self.address_type(input); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::FixedBytesType); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::SignedIntegerType); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::UnsignedIntegerType); - choice.consider(input, result)?; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::BoolKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::StringKeyword); + choice.consider(input, result)?; + let result = self.address_type(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::FixedBytesType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::SignedIntegerType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::UnsignedIntegerType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::SignedFixedType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::UnsignedFixedType); + choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { let result = - self.default_parse_token_with_trivia(input, TokenKind::SignedFixedType); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::UnsignedFixedType); + self.default_parse_token_with_trivia(input, TokenKind::ByteKeyword); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = - self.default_parse_token_with_trivia(input, TokenKind::ByteKeyword); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }; + } + choice.finish(input) + }); choice.consider(input, result)?; let result = self.identifier_path(input); choice.consider(input, result)?; @@ -3510,15 +3245,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn unchecked_block(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_8_0 { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::UncheckedKeyword), - )?; - seq.elem(self.block(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::UncheckedKeyword))?; + seq.elem(self.block(input))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -3542,27 +3273,25 @@ impl Language { if !self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| { if !self.version_is_at_least_0_6_0 { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.modifier_invocation(input); - choice.consider(input, result)?; - let result = self.override_specifier(input); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::ExternalKeyword); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::PayableKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::PureKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::ViewKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - } + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::ExternalKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::PureKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::ViewKeyword); + choice.consider(input, result)?; + choice.finish(input) + }) } else { ParserResult::disabled() } @@ -3576,28 +3305,21 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn unnamed_function_definition(&self, input: &mut ParserContext) -> ParserResult { if !self.version_is_at_least_0_6_0 { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::FunctionKeyword), - )?; - seq.elem(self.parameters_declaration(input))?; - seq.elem(OptionalHelper::transform( - self.unnamed_function_attributes_list(input), - ))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::Semicolon); - choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FunctionKeyword))?; + seq.elem(self.parameters_declaration(input))?; + seq.elem(OptionalHelper::transform( + self.unnamed_function_attributes_list(input), + ))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.default_parse_token_with_trivia(input, TokenKind::Semicolon); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -3609,69 +3331,55 @@ impl Language { if self.version_is_at_least_0_8_8 { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::TypeKeyword), - )?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::IsKeyword), - )?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::BoolKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::StringKeyword, - ); - choice.consider(input, result)?; - let result = self.address_type(input); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::FixedBytesType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::SignedIntegerType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::UnsignedIntegerType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::SignedFixedType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::UnsignedFixedType, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::TypeKeyword), + )?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + )?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::IsKeyword), + )?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::BoolKeyword); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::StringKeyword); + choice.consider(input, result)?; + let result = self.address_type(input); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::FixedBytesType); + choice.consider(input, result)?; + let result = self.default_parse_token_with_trivia( + input, + TokenKind::SignedIntegerType, + ); + choice.consider(input, result)?; + let result = self.default_parse_token_with_trivia( + input, + TokenKind::UnsignedIntegerType, + ); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::SignedFixedType); + choice.consider(input, result)?; + let result = self.default_parse_token_with_trivia( + input, + TokenKind::UnsignedFixedType, + ); + choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self + .default_parse_token_with_trivia(input, TokenKind::ByteKeyword); + choice.consider(input, result)?; + } + choice.finish(input) + }))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -3693,39 +3401,29 @@ impl Language { fn using_directive(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::UsingKeyword), - )?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.using_directive_path(input); - choice.consider(input, result)?; - let result = self.using_directive_deconstruction(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::ForKeyword), - )?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self - .default_parse_token_with_trivia(input, TokenKind::Asterisk); - choice.consider(input, result)?; - let result = self.type_name(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::GlobalKeyword), - ))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::UsingKeyword))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.using_directive_path(input); + choice.consider(input, result)?; + let result = self.using_directive_deconstruction(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ForKeyword))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::Asterisk); + choice.consider(input, result)?; + let result = self.type_name(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::GlobalKeyword), + ))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -3770,154 +3468,116 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn using_directive_symbol(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.identifier_path(input))?; - if self.version_is_at_least_0_8_19 { - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::AsKeyword), - )?; - seq.elem(if self.version_is_at_least_0_8_19 { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Ampersand, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::Bar); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - } - } else { - ParserResult::disabled() - })?; - seq.finish() + SequenceHelper::run(|mut seq| { + seq.elem(self.identifier_path(input))?; + if self.version_is_at_least_0_8_19 { + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsKeyword))?; + seq.elem(if self.version_is_at_least_0_8_19 { + ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::Ampersand); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Asterisk); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::BangEqual); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Bar); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Caret); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::EqualEqual); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::GreaterThan); + choice.consider(input, result)?; + let result = self.default_parse_token_with_trivia( + input, + TokenKind::GreaterThanEqual, + ); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::LessThan); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::LessThanEqual); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Minus); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Percent); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Plus); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Slash); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Tilde); + choice.consider(input, result)?; + choice.finish(input) }) - }))?; - } - seq.finish() - }) - } + } else { + ParserResult::disabled() + })?; + seq.finish() + })))?; + } + seq.finish() + }) .with_kind(RuleKind::UsingDirectiveSymbol) } - #[allow(unused_assignments, unused_parens)] - fn using_directive_symbols_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<{ LexicalContext::Default as u8 }, Self>( - input, - |input| self.using_directive_symbol(input), - TokenKind::Comma, - self, - ) - .with_kind(RuleKind::UsingDirectiveSymbolsList) - } - - #[allow(unused_assignments, unused_parens)] - fn variable_declaration(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - if !self.version_is_at_least_0_5_0 { - let result = - self.default_parse_token_with_trivia(input, TokenKind::VarKeyword); - choice.consider(input, result)?; - } - let result = self.type_name(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.elem(OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::MemoryKeyword); - choice.consider(input, result)?; + #[allow(unused_assignments, unused_parens)] + fn using_directive_symbols_list(&self, input: &mut ParserContext) -> ParserResult { + SeparatedHelper::run::<{ LexicalContext::Default as u8 }, Self>( + input, + |input| self.using_directive_symbol(input), + TokenKind::Comma, + self, + ) + .with_kind(RuleKind::UsingDirectiveSymbolsList) + } + + #[allow(unused_assignments, unused_parens)] + fn variable_declaration(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + if !self.version_is_at_least_0_5_0 { + let result = self.default_parse_token_with_trivia(input, TokenKind::VarKeyword); + choice.consider(input, result)?; + } + let result = self.type_name(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::MemoryKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::StorageKeyword); + choice.consider(input, result)?; + if self.version_is_at_least_0_5_0 { let result = - self.default_parse_token_with_trivia(input, TokenKind::StorageKeyword); + self.default_parse_token_with_trivia(input, TokenKind::CalldataKeyword); choice.consider(input, result)?; - if self.version_is_at_least_0_5_0 { - let result = self - .default_parse_token_with_trivia(input, TokenKind::CalldataKeyword); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.finish() - }) - } + } + choice.finish(input) + }, + )))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.finish() + }) .with_kind(RuleKind::VariableDeclaration) } @@ -3925,21 +3585,15 @@ impl Language { fn variable_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem(self.variable_declaration(input))?; - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Equal), - )?; - seq.elem(self.expression(input))?; - seq.finish() - }) - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.variable_declaration(input))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Equal))?; + seq.elem(self.expression(input))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -3956,15 +3610,13 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn version_pragma(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.version_pragma_parse_token_with_trivia(input, TokenKind::SolidityKeyword), - )?; - seq.elem(self.version_pragma_expressions_list(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.version_pragma_parse_token_with_trivia(input, TokenKind::SolidityKeyword), + )?; + seq.elem(self.version_pragma_expressions_list(input))?; + seq.finish() + }) .with_kind(RuleKind::VersionPragma) } @@ -3987,7 +3639,9 @@ impl Language { ) }; let parse_version_pragma_unary_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_prefix_operator(RuleKind::VersionPragmaUnaryExpression, 5u8, { + PrecedenceHelper::to_prefix_operator( + RuleKind::VersionPragmaUnaryExpression, + 5u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.version_pragma_parse_token_with_trivia(input, TokenKind::Caret); @@ -4011,8 +3665,8 @@ impl Language { .version_pragma_parse_token_with_trivia(input, TokenKind::GreaterThanEqual); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let prefix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { @@ -4082,40 +3736,36 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn while_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::WhileKeyword))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; - seq.elem(self.expression(input).recover_until_with_nested_delims( - input, - |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; - seq.finish() - }))?; - seq.elem(self.statement(input))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::WhileKeyword))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; + seq.elem(self.expression(input).recover_until_with_nested_delims( + input, + |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; seq.finish() - }) - } + }))?; + seq.elem(self.statement(input))?; + seq.finish() + }) .with_kind(RuleKind::WhileStatement) } #[allow(unused_assignments, unused_parens)] fn yul_assignment_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.yul_identifier_paths_list(input))?; - seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::ColonEqual))?; - seq.elem(self.yul_expression(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.yul_identifier_paths_list(input))?; + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::ColonEqual))?; + seq.elem(self.yul_expression(input))?; + seq.finish() + }) .with_kind(RuleKind::YulAssignmentStatement) } @@ -4157,22 +3807,16 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::LetKeyword))?; - seq.elem(self.yul_identifier_paths_list(input))?; - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem( - self.yul_block_parse_token_with_trivia(input, TokenKind::ColonEqual), - )?; - seq.elem(self.yul_expression(input))?; - seq.finish() - }) - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::LetKeyword))?; + seq.elem(self.yul_identifier_paths_list(input))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::ColonEqual))?; + seq.elem(self.yul_expression(input))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .with_kind(RuleKind::YulDeclarationStatement) } @@ -4207,31 +3851,27 @@ impl Language { }; let primary_expression_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.yul_block_parse_token_with_trivia(input, TokenKind::TrueKeyword); - choice.consider(input, result)?; - let result = - self.yul_block_parse_token_with_trivia(input, TokenKind::FalseKeyword); - choice.consider(input, result)?; - let result = - self.yul_block_parse_token_with_trivia(input, TokenKind::YulHexLiteral); - choice.consider(input, result)?; - let result = self - .yul_block_parse_token_with_trivia(input, TokenKind::YulDecimalLiteral); - choice.consider(input, result)?; - let result = self - .yul_block_parse_token_with_trivia(input, TokenKind::HexStringLiteral); - choice.consider(input, result)?; - let result = self.yul_block_parse_token_with_trivia( - input, - TokenKind::AsciiStringLiteral, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - }; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::TrueKeyword); + choice.consider(input, result)?; + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::FalseKeyword); + choice.consider(input, result)?; + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::YulHexLiteral); + choice.consider(input, result)?; + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::YulDecimalLiteral); + choice.consider(input, result)?; + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::HexStringLiteral); + choice.consider(input, result)?; + let result = self + .yul_block_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral); + choice.consider(input, result)?; + choice.finish(input) + }); choice.consider(input, result)?; let result = self.yul_identifier_path(input); choice.consider(input, result)?; @@ -4274,35 +3914,29 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_for_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::ForKeyword))?; - seq.elem(self.yul_block(input))?; - seq.elem(self.yul_expression(input))?; - seq.elem(self.yul_block(input))?; - seq.elem(self.yul_block(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::ForKeyword))?; + seq.elem(self.yul_block(input))?; + seq.elem(self.yul_expression(input))?; + seq.elem(self.yul_block(input))?; + seq.elem(self.yul_block(input))?; + seq.finish() + }) .with_kind(RuleKind::YulForStatement) } #[allow(unused_assignments, unused_parens)] fn yul_function_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.yul_block_parse_token_with_trivia(input, TokenKind::FunctionKeyword), - )?; - seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::YulIdentifier))?; - seq.elem(self.yul_parameters_declaration(input))?; - seq.elem(OptionalHelper::transform( - self.yul_returns_declaration(input), - ))?; - seq.elem(self.yul_block(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::FunctionKeyword))?; + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::YulIdentifier))?; + seq.elem(self.yul_parameters_declaration(input))?; + seq.elem(OptionalHelper::transform( + self.yul_returns_declaration(input), + ))?; + seq.elem(self.yul_block(input))?; + seq.finish() + }) .with_kind(RuleKind::YulFunctionDefinition) } @@ -4341,14 +3975,12 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_if_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::IfKeyword))?; - seq.elem(self.yul_expression(input))?; - seq.elem(self.yul_block(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::IfKeyword))?; + seq.elem(self.yul_expression(input))?; + seq.elem(self.yul_block(input))?; + seq.finish() + }) .with_kind(RuleKind::YulIfStatement) } @@ -4388,49 +4020,43 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_returns_declaration(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.yul_block_parse_token_with_trivia(input, TokenKind::MinusGreaterThan), - )?; - seq.elem(self.yul_identifiers_list(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::MinusGreaterThan))?; + seq.elem(self.yul_identifiers_list(input))?; + seq.finish() + }) .with_kind(RuleKind::YulReturnsDeclaration) } #[allow(unused_assignments, unused_parens)] fn yul_statement(&self, input: &mut ParserContext) -> ParserResult { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.yul_block(input); - choice.consider(input, result)?; - let result = self.yul_function_definition(input); - choice.consider(input, result)?; - let result = self.yul_declaration_statement(input); - choice.consider(input, result)?; - let result = self.yul_assignment_statement(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); + ChoiceHelper::run(input, |mut choice, input| { + let result = self.yul_block(input); + choice.consider(input, result)?; + let result = self.yul_function_definition(input); + choice.consider(input, result)?; + let result = self.yul_declaration_statement(input); + choice.consider(input, result)?; + let result = self.yul_assignment_statement(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)?; + let result = self.yul_break_statement(input); + choice.consider(input, result)?; + let result = self.yul_continue_statement(input); + choice.consider(input, result)?; + let result = self.yul_expression(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)?; - let result = self.yul_expression(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)?; - } - choice.finish(input) - }) - } + } + choice.finish(input) + }) .with_kind(RuleKind::YulStatement) } @@ -4442,65 +4068,46 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_switch_case(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { + SequenceHelper::run(|mut seq| { + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::DefaultKeyword); + choice.consider(input, result)?; + let result = SequenceHelper::run(|mut seq| { + seq.elem( + self.yul_block_parse_token_with_trivia(input, TokenKind::CaseKeyword), + )?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::TrueKeyword); + choice.consider(input, result)?; + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::FalseKeyword); + choice.consider(input, result)?; + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::YulHexLiteral); + choice.consider(input, result)?; let result = self - .yul_block_parse_token_with_trivia(input, TokenKind::DefaultKeyword); + .yul_block_parse_token_with_trivia(input, TokenKind::YulDecimalLiteral); choice.consider(input, result)?; - let result = { - SequenceHelper::run(|mut seq| { - seq.elem(self.yul_block_parse_token_with_trivia( - input, - TokenKind::CaseKeyword, - ))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.yul_block_parse_token_with_trivia( - input, - TokenKind::TrueKeyword, - ); - choice.consider(input, result)?; - let result = self.yul_block_parse_token_with_trivia( - input, - TokenKind::FalseKeyword, - ); - choice.consider(input, result)?; - let result = self.yul_block_parse_token_with_trivia( - input, - TokenKind::YulHexLiteral, - ); - choice.consider(input, result)?; - let result = self.yul_block_parse_token_with_trivia( - input, - TokenKind::YulDecimalLiteral, - ); - choice.consider(input, result)?; - let result = self.yul_block_parse_token_with_trivia( - input, - TokenKind::HexStringLiteral, - ); - choice.consider(input, result)?; - let result = self.yul_block_parse_token_with_trivia( - input, - TokenKind::AsciiStringLiteral, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - }; + let result = self + .yul_block_parse_token_with_trivia(input, TokenKind::HexStringLiteral); + choice.consider(input, result)?; + let result = self.yul_block_parse_token_with_trivia( + input, + TokenKind::AsciiStringLiteral, + ); choice.consider(input, result)?; choice.finish(input) - }) - })?; - seq.elem(self.yul_block(input))?; - seq.finish() - }) - } + }))?; + seq.finish() + }); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.elem(self.yul_block(input))?; + seq.finish() + }) .with_kind(RuleKind::YulSwitchCase) } @@ -4512,14 +4119,12 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_switch_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::SwitchKeyword))?; - seq.elem(self.yul_expression(input))?; - seq.elem(self.yul_switch_cases_list(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::SwitchKeyword))?; + seq.elem(self.yul_expression(input))?; + seq.elem(self.yul_switch_cases_list(input))?; + seq.finish() + }) .with_kind(RuleKind::YulSwitchStatement) } diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index 17b6da0b09..3079135e3c 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -240,37 +240,29 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn abi_coder_pragma(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ABICoderKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ABICoderKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.finish() + }) .with_kind(RuleKind::ABICoderPragma) } #[allow(unused_assignments, unused_parens)] fn address_type(&self, input: &mut ParserContext) -> ParserResult { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::AddressKeyword), - )?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword), - ))?; - seq.finish() - }) - }; - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - } + ChoiceHelper::run(input, |mut choice, input| { + let result = SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AddressKeyword))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword), + ))?; + seq.finish() + }); + choice.consider(input, result)?; + let result = self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword); + choice.consider(input, result)?; + choice.finish(input) + }) .with_kind(RuleKind::AddressType) } @@ -281,15 +273,13 @@ impl Language { let input = delim_guard.ctx(); seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; seq.elem( - OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.positional_arguments_list(input); - choice.consider(input, result)?; - let result = self.named_arguments_declaration(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }) + OptionalHelper::transform(ChoiceHelper::run(input, |mut choice, input| { + let result = self.positional_arguments_list(input); + choice.consider(input, result)?; + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + choice.finish(input) + })) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -358,37 +348,33 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn assembly_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AssemblyKeyword))?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral), - ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; - seq.elem( - self.assembly_flags_list(input) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; - seq.finish() - })))?; - seq.elem(self.yul_block(input))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AssemblyKeyword))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral), + ))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; + seq.elem( + self.assembly_flags_list(input) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; seq.finish() - }) - } + })))?; + seq.elem(self.yul_block(input))?; + seq.finish() + }) .with_kind(RuleKind::AssemblyStatement) } @@ -436,14 +422,12 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn catch_clause(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CatchKeyword))?; - seq.elem(OptionalHelper::transform(self.catch_clause_error(input)))?; - seq.elem(self.block(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CatchKeyword))?; + seq.elem(OptionalHelper::transform(self.catch_clause_error(input)))?; + seq.elem(self.block(input))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -453,15 +437,13 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn catch_clause_error(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { - { - SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - ))?; - seq.elem(self.parameters_declaration(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + ))?; + seq.elem(self.parameters_declaration(input))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -483,23 +465,18 @@ impl Language { if self.version_is_at_least_0_7_4 { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem(self.default_parse_token_with_trivia( - input, - TokenKind::ConstantKeyword, - ))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Equal), - )?; - seq.elem(self.expression(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::ConstantKeyword), + )?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Equal))?; + seq.elem(self.expression(input))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -522,22 +499,20 @@ impl Language { if self.version_is_at_least_0_4_22 { OneOrMoreHelper::run(input, |input| { if self.version_is_at_least_0_4_22 { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.modifier_invocation(input); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::InternalKeyword); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::PayableKeyword); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::PublicKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - } + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::InternalKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::PublicKeyword); + choice.consider(input, result)?; + choice.finish(input) + }) } else { ParserResult::disabled() } @@ -551,19 +526,17 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn constructor_definition(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_4_22 { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::ConstructorKeyword), - )?; - seq.elem(self.parameters_declaration(input))?; - seq.elem(OptionalHelper::transform( - self.constructor_attributes_list(input), - ))?; - seq.elem(self.block(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::ConstructorKeyword), + )?; + seq.elem(self.parameters_declaration(input))?; + seq.elem(OptionalHelper::transform( + self.constructor_attributes_list(input), + ))?; + seq.elem(self.block(input))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -591,40 +564,36 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn contract_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - if self.version_is_at_least_0_6_0 { - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::AbstractKeyword), - ))?; - } - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ContractKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(OptionalHelper::transform(self.inheritance_specifier(input)))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; - seq.elem( - OptionalHelper::transform(self.contract_members_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseBrace, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; - seq.finish() - }))?; + SequenceHelper::run(|mut seq| { + if self.version_is_at_least_0_6_0 { + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::AbstractKeyword), + ))?; + } + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ContractKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(OptionalHelper::transform(self.inheritance_specifier(input)))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; + seq.elem( + OptionalHelper::transform(self.contract_members_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseBrace, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; seq.finish() - }) - } + }))?; + seq.finish() + }) .with_kind(RuleKind::ContractDefinition) } @@ -651,15 +620,13 @@ impl Language { choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.fallback_function_definition(input); + choice.consider(input, result)?; + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + choice.finish(input) + }); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { @@ -682,58 +649,44 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn deconstruction_import(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; - seq.elem( - self.deconstruction_import_symbols_list(input) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseBrace, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; - seq.finish() - }))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FromKeyword))?; + SequenceHelper::run(|mut seq| { + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral), + self.deconstruction_import_symbols_list(input) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseBrace, + Self::default_delimiters(), + ), )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; seq.finish() - }) - } + }))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FromKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral))?; + seq.finish() + }) .with_kind(RuleKind::DeconstructionImport) } #[allow(unused_assignments, unused_parens)] fn deconstruction_import_symbol(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsKeyword))?; seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::AsKeyword), - )?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.finish() - }) - }))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .with_kind(RuleKind::DeconstructionImportSymbol) } @@ -752,16 +705,14 @@ impl Language { fn delete_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::DeleteKeyword), - )?; - seq.elem(self.expression(input))?; - seq.finish() - }) - } - .recover_until_with_nested_delims( + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::DeleteKeyword), + )?; + seq.elem(self.expression(input))?; + seq.finish() + }) + .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), |input| Lexer::leading_trivia(self, input), @@ -779,40 +730,32 @@ impl Language { fn do_while_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::DoKeyword))?; + seq.elem(self.statement(input))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::WhileKeyword))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::DoKeyword), + self.default_parse_token_with_trivia(input, TokenKind::OpenParen), )?; - seq.elem(self.statement(input))?; + seq.elem(self.expression(input).recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ))?; seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::WhileKeyword), + self.default_parse_token_with_trivia(input, TokenKind::CloseParen), )?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::OpenParen), - )?; - seq.elem(self.expression(input).recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::CloseParen), - )?; - seq.finish() - }))?; seq.finish() - }) - } + }))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -832,16 +775,14 @@ impl Language { if self.version_is_at_least_0_4_21 { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::EmitKeyword), - )?; - seq.elem(self.identifier_path(input))?; - seq.elem(self.arguments_declaration(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::EmitKeyword), + )?; + seq.elem(self.identifier_path(input))?; + seq.elem(self.arguments_declaration(input))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -879,54 +820,99 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn enum_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::EnumKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; - seq.elem( - OptionalHelper::transform(self.identifiers_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseBrace, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; - seq.finish() - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::EnumKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; + seq.elem( + OptionalHelper::transform(self.identifiers_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseBrace, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; seq.finish() - }) - } + }))?; + seq.finish() + }) .with_kind(RuleKind::EnumDefinition) } #[allow(unused_assignments, unused_parens)] fn error_definition(&self, input: &mut ParserContext) -> ParserResult { - if self . version_is_at_least_0_8_4 { SequenceHelper :: run (| mut seq | { seq . elem ({ SequenceHelper :: run (| mut seq | { seq . elem (self . default_parse_token_with_trivia (input , TokenKind :: ErrorKeyword)) ? ; seq . elem (self . default_parse_token_with_trivia (input , TokenKind :: Identifier)) ? ; seq . elem (SequenceHelper :: run (| mut seq | { let mut delim_guard = input . open_delim (TokenKind :: CloseParen) ; let input = delim_guard . ctx () ; seq . elem (self . default_parse_token_with_trivia (input , TokenKind :: OpenParen)) ? ; seq . elem (OptionalHelper :: transform (self . error_parameters_list (input)) . recover_until_with_nested_delims (input , | input | Lexer :: next_token :: < { LexicalContext :: Default as u8 } > (self , input) , | input | Lexer :: leading_trivia (self , input) , TokenKind :: CloseParen , Self :: default_delimiters () ,)) ? ; seq . elem (self . default_parse_token_with_trivia (input , TokenKind :: CloseParen)) ? ; seq . finish () })) ? ; seq . finish () }) } . recover_until_with_nested_delims (input , | input | Lexer :: next_token :: < { LexicalContext :: Default as u8 } > (self , input) , | input | Lexer :: leading_trivia (self , input) , TokenKind :: Semicolon , Self :: default_delimiters () ,)) ? ; seq . elem (self . default_parse_token_with_trivia (input , TokenKind :: Semicolon)) ? ; seq . finish () }) } else { ParserResult :: disabled () } . with_kind (RuleKind :: ErrorDefinition) + if self.version_is_at_least_0_8_4 { + SequenceHelper::run(|mut seq| { + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::ErrorKeyword), + )?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + )?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::OpenParen), + )?; + seq.elem( + OptionalHelper::transform(self.error_parameters_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>( + self, input, + ) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ), + )?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::CloseParen), + )?; + seq.finish() + }))?; + seq.finish() + }) + .recover_until_with_nested_delims( + input, + |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), + |input| Lexer::leading_trivia(self, input), + TokenKind::Semicolon, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Semicolon))?; + seq.finish() + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::ErrorDefinition) } #[allow(unused_assignments, unused_parens)] fn error_parameter(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_8_4 { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - ))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + ))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -952,48 +938,39 @@ impl Language { fn event_definition(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::EventKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::EventKeyword), + self.default_parse_token_with_trivia(input, TokenKind::OpenParen), )?; seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), + OptionalHelper::transform(self.event_parameters_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>( + self, input, + ) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ), + )?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::CloseParen), )?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::OpenParen), - )?; - seq.elem( - OptionalHelper::transform(self.event_parameters_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ), - )?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::CloseParen), - )?; - seq.finish() - }))?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia( - input, - TokenKind::AnonymousKeyword, - ), - ))?; seq.finish() - }) - } + }))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::AnonymousKeyword), + ))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -1010,18 +987,16 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn event_parameter(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::IndexedKeyword), - ))?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - ))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::IndexedKeyword), + ))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + ))?; + seq.finish() + }) .with_kind(RuleKind::EventParameter) } @@ -1038,32 +1013,28 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn experimental_pragma(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::ExperimentalKeyword), - )?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self - .default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::Identifier); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ExperimentalKeyword))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral); + choice.consider(input, result)?; + let result = self.default_parse_token_with_trivia(input, TokenKind::Identifier); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) .with_kind(RuleKind::ExperimentalPragma) } #[allow(unused_assignments, unused_parens)] fn expression(&self, input: &mut ParserContext) -> ParserResult { let parse_assignment_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_binary_operator(RuleKind::BinaryExpression, 1u8, 1u8 + 1, { + PrecedenceHelper::to_binary_operator( + RuleKind::BinaryExpression, + 1u8, + 1u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::Equal); choice.consider(input, result)?; @@ -1100,19 +1071,21 @@ impl Language { ); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let parse_conditional_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_postfix_operator(RuleKind::ConditionalExpression, 3u8, { + PrecedenceHelper::to_postfix_operator( + RuleKind::ConditionalExpression, + 3u8, SequenceHelper::run(|mut seq| { seq.elem(self.default_parse_token_with_trivia(input, TokenKind::QuestionMark))?; seq.elem(self.expression(input))?; seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Colon))?; seq.elem(self.expression(input))?; seq.finish() - }) - }) + }), + ) }; let parse_or_operator = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( @@ -1131,18 +1104,24 @@ impl Language { ) }; let parse_equality_comparison_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_binary_operator(RuleKind::BinaryExpression, 9u8, 9u8 + 1, { + PrecedenceHelper::to_binary_operator( + RuleKind::BinaryExpression, + 9u8, + 9u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::EqualEqual); choice.consider(input, result)?; let result = self.default_parse_token_with_trivia(input, TokenKind::BangEqual); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let parse_order_comparison_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_binary_operator(RuleKind::BinaryExpression, 11u8, 11u8 + 1, { + PrecedenceHelper::to_binary_operator( + RuleKind::BinaryExpression, + 11u8, + 11u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::LessThan); choice.consider(input, result)?; @@ -1156,8 +1135,8 @@ impl Language { self.default_parse_token_with_trivia(input, TokenKind::GreaterThanEqual); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let parse_bitwise_or_operator = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( @@ -1184,7 +1163,10 @@ impl Language { ) }; let parse_shift_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_binary_operator(RuleKind::BinaryExpression, 19u8, 19u8 + 1, { + PrecedenceHelper::to_binary_operator( + RuleKind::BinaryExpression, + 19u8, + 19u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::LessThanLessThan); @@ -1198,22 +1180,28 @@ impl Language { ); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let parse_add_sub_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_binary_operator(RuleKind::BinaryExpression, 21u8, 21u8 + 1, { + PrecedenceHelper::to_binary_operator( + RuleKind::BinaryExpression, + 21u8, + 21u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::Plus); choice.consider(input, result)?; let result = self.default_parse_token_with_trivia(input, TokenKind::Minus); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let parse_mul_div_mod_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_binary_operator(RuleKind::BinaryExpression, 23u8, 23u8 + 1, { + PrecedenceHelper::to_binary_operator( + RuleKind::BinaryExpression, + 23u8, + 23u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::Asterisk); choice.consider(input, result)?; @@ -1222,8 +1210,8 @@ impl Language { let result = self.default_parse_token_with_trivia(input, TokenKind::Percent); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let parse_exponentiation_operator_removed_from_0_6_0 = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( @@ -1242,18 +1230,22 @@ impl Language { ) }; let parse_unary_postfix_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_postfix_operator(RuleKind::UnaryPostfixExpression, 29u8, { + PrecedenceHelper::to_postfix_operator( + RuleKind::UnaryPostfixExpression, + 29u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::PlusPlus); choice.consider(input, result)?; let result = self.default_parse_token_with_trivia(input, TokenKind::MinusMinus); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let parse_unary_prefix_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_prefix_operator(RuleKind::UnaryPrefixExpression, 31u8, { + PrecedenceHelper::to_prefix_operator( + RuleKind::UnaryPrefixExpression, + 31u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia(input, TokenKind::PlusPlus); choice.consider(input, result)?; @@ -1270,38 +1262,40 @@ impl Language { choice.consider(input, result)?; } choice.finish(input) - }) - }) + }), + ) }; let parse_function_call_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_postfix_operator(RuleKind::FunctionCallExpression, 33u8, { + PrecedenceHelper::to_postfix_operator( + RuleKind::FunctionCallExpression, + 33u8, SequenceHelper::run(|mut seq| { if self.version_is_at_least_0_6_2 { seq.elem(OptionalHelper::transform(self.function_call_options(input)))?; } seq.elem(self.arguments_declaration(input))?; seq.finish() - }) - }) + }), + ) }; let parse_member_access_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_postfix_operator(RuleKind::MemberAccessExpression, 35u8, { + PrecedenceHelper::to_postfix_operator( + RuleKind::MemberAccessExpression, + 35u8, SequenceHelper::run(|mut seq| { seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Period))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::Identifier); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::AddressKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::Identifier); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::AddressKeyword); + choice.consider(input, result)?; + choice.finish(input) + }))?; seq.finish() - }) - }) + }), + ) }; let parse_index_access_operator = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( @@ -1312,24 +1306,17 @@ impl Language { let input = delim_guard.ctx(); seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBracket))?; seq.elem( - { - SequenceHelper::run(|mut seq| { + SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform(self.expression(input)))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::Colon), + )?; seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia( - input, - TokenKind::Colon, - ))?; - seq.elem(OptionalHelper::transform( - self.expression(input), - ))?; - seq.finish() - }) - }))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| { @@ -1360,67 +1347,61 @@ impl Language { choice.consider(input, result)?; let result = self.array_expression(input); choice.consider(input, result)?; - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::TrueKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::FalseKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - }; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::TrueKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::FalseKeyword); + choice.consider(input, result)?; + choice.finish(input) + }); choice.consider(input, result)?; let result = self.numeric_expression(input); choice.consider(input, result)?; - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.hex_string_literals_list(input); - choice.consider(input, result)?; - let result = self.ascii_string_literals_list(input); + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.hex_string_literals_list(input); + choice.consider(input, result)?; + let result = self.ascii_string_literals_list(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_7_0 { + let result = self.unicode_string_literals_list(input); choice.consider(input, result)?; - if self.version_is_at_least_0_7_0 { - let result = self.unicode_string_literals_list(input); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }; + } + choice.finish(input) + }); choice.consider(input, result)?; - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::BoolKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::StringKeyword); - choice.consider(input, result)?; - let result = self.address_type(input); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::FixedBytesType); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::SignedIntegerType); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::UnsignedIntegerType); - choice.consider(input, result)?; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::BoolKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::StringKeyword); + choice.consider(input, result)?; + let result = self.address_type(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::FixedBytesType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::SignedIntegerType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::UnsignedIntegerType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::SignedFixedType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::UnsignedFixedType); + choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { let result = - self.default_parse_token_with_trivia(input, TokenKind::SignedFixedType); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::UnsignedFixedType); + self.default_parse_token_with_trivia(input, TokenKind::ByteKeyword); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = - self.default_parse_token_with_trivia(input, TokenKind::ByteKeyword); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }; + } + choice.finish(input) + }); choice.consider(input, result)?; let result = self.default_parse_token_with_trivia(input, TokenKind::Identifier); choice.consider(input, result)?; @@ -1534,30 +1515,28 @@ impl Language { if self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| { if self.version_is_at_least_0_6_0 { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.modifier_invocation(input); - choice.consider(input, result)?; - let result = self.override_specifier(input); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::ExternalKeyword); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::PayableKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::PureKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::ViewKeyword); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::VirtualKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - } + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::ExternalKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::PureKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::ViewKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::VirtualKeyword); + choice.consider(input, result)?; + choice.finish(input) + }) } else { ParserResult::disabled() } @@ -1571,29 +1550,22 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn fallback_function_definition(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::FallbackKeyword), - )?; - seq.elem(self.parameters_declaration(input))?; - seq.elem(OptionalHelper::transform( - self.fallback_function_attributes_list(input), - ))?; - seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::Semicolon); - choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FallbackKeyword))?; + seq.elem(self.parameters_declaration(input))?; + seq.elem(OptionalHelper::transform( + self.fallback_function_attributes_list(input), + ))?; + seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.default_parse_token_with_trivia(input, TokenKind::Semicolon); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -1602,73 +1574,55 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn for_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ForKeyword))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; - seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = - self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = - self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }; - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Semicolon, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Semicolon, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.finish() - }) - } - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; - seq.finish() - }))?; - seq.elem(self.statement(input))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ForKeyword))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.expression_statement(input); + choice.consider(input, result)?; + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + choice.finish(input) + }); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Semicolon); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.expression_statement(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Semicolon); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.elem(OptionalHelper::transform(self.expression(input)))?; + seq.finish() + }) + .recover_until_with_nested_delims( + input, + |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; seq.finish() - }) - } + }))?; + seq.elem(self.statement(input))?; + seq.finish() + }) .with_kind(RuleKind::ForStatement) } @@ -1714,77 +1668,63 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn function_call_options(&self, input: &mut ParserContext) -> ParserResult { - { - ChoiceHelper::run(input, |mut choice, input| { - if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { - let result = OneOrMoreHelper::run(input, |input| { - self.named_arguments_declaration(input) - }); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_0 { - let result = self.named_arguments_declaration(input); - choice.consider(input, result)?; - } - choice.finish(input) - }) - } - .with_kind(RuleKind::FunctionCallOptions) - } - - #[allow(unused_assignments, unused_parens)] - fn function_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FunctionKeyword))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::Identifier); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::FallbackKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::ReceiveKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.elem(self.parameters_declaration(input))?; - seq.elem(OptionalHelper::transform( - self.function_attributes_list(input), - ))?; - seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::Semicolon); - choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + ChoiceHelper::run(input, |mut choice, input| { + if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { + let result = + OneOrMoreHelper::run(input, |input| self.named_arguments_declaration(input)); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_8_0 { + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::FunctionCallOptions) + } + + #[allow(unused_assignments, unused_parens)] + fn function_definition(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FunctionKeyword))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.default_parse_token_with_trivia(input, TokenKind::Identifier); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::FallbackKeyword); + choice.consider(input, result)?; + let result = self.default_parse_token_with_trivia(input, TokenKind::ReceiveKeyword); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.elem(self.parameters_declaration(input))?; + seq.elem(OptionalHelper::transform( + self.function_attributes_list(input), + ))?; + seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.default_parse_token_with_trivia(input, TokenKind::Semicolon); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) .with_kind(RuleKind::FunctionDefinition) } #[allow(unused_assignments, unused_parens)] fn function_type(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FunctionKeyword))?; - seq.elem(self.parameters_declaration(input))?; - seq.elem(OptionalHelper::transform( - self.function_type_attributes_list(input), - ))?; - seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FunctionKeyword))?; + seq.elem(self.parameters_declaration(input))?; + seq.elem(OptionalHelper::transform( + self.function_type_attributes_list(input), + ))?; + seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; + seq.finish() + }) .with_kind(RuleKind::FunctionType) } @@ -1857,36 +1797,30 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn if_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::IfKeyword))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; - seq.elem(self.expression(input).recover_until_with_nested_delims( - input, - |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; - seq.finish() - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::IfKeyword))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; + seq.elem(self.expression(input).recover_until_with_nested_delims( + input, + |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; + seq.finish() + }))?; + seq.elem(self.statement(input))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ElseKeyword))?; seq.elem(self.statement(input))?; - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::ElseKeyword), - )?; - seq.elem(self.statement(input))?; - seq.finish() - }) - }))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .with_kind(RuleKind::IfStatement) } @@ -1894,25 +1828,21 @@ impl Language { fn import_directive(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::ImportKeyword), - )?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.path_import(input); - choice.consider(input, result)?; - let result = self.named_import(input); - choice.consider(input, result)?; - let result = self.deconstruction_import(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::ImportKeyword), + )?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.path_import(input); + choice.consider(input, result)?; + let result = self.named_import(input); + choice.consider(input, result)?; + let result = self.deconstruction_import(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -1929,25 +1859,21 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn inheritance_specifier(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::IsKeyword))?; - seq.elem(self.inheritance_types_list(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::IsKeyword))?; + seq.elem(self.inheritance_types_list(input))?; + seq.finish() + }) .with_kind(RuleKind::InheritanceSpecifier) } #[allow(unused_assignments, unused_parens)] fn inheritance_type(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.identifier_path(input))?; - seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.identifier_path(input))?; + seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; + seq.finish() + }) .with_kind(RuleKind::InheritanceType) } @@ -1964,35 +1890,31 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn interface_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::InterfaceKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(OptionalHelper::transform(self.inheritance_specifier(input)))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; - seq.elem( - OptionalHelper::transform(self.interface_members_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseBrace, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; - seq.finish() - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::InterfaceKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(OptionalHelper::transform(self.inheritance_specifier(input)))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; + seq.elem( + OptionalHelper::transform(self.interface_members_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseBrace, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; seq.finish() - }) - } + }))?; + seq.finish() + }) .with_kind(RuleKind::InterfaceDefinition) } @@ -2019,15 +1941,13 @@ impl Language { choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.fallback_function_definition(input); + choice.consider(input, result)?; + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + choice.finish(input) + }); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { @@ -2068,34 +1988,30 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn library_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::LibraryKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; - seq.elem( - OptionalHelper::transform(self.library_members_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseBrace, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; - seq.finish() - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::LibraryKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; + seq.elem( + OptionalHelper::transform(self.library_members_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseBrace, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; seq.finish() - }) - } + }))?; + seq.finish() + }) .with_kind(RuleKind::LibraryDefinition) } @@ -2122,15 +2038,13 @@ impl Language { choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.fallback_function_definition(input); + choice.consider(input, result)?; + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + choice.finish(input) + }); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { @@ -2153,127 +2067,101 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn mapping_key_type(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self - .default_parse_token_with_trivia(input, TokenKind::BoolKeyword); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::StringKeyword, - ); - choice.consider(input, result)?; - let result = self.address_type(input); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::FixedBytesType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::SignedIntegerType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::UnsignedIntegerType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::SignedFixedType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::UnsignedFixedType, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }; - choice.consider(input, result)?; - let result = self.identifier_path(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - if self.version_is_at_least_0_8_18 { - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - ))?; - } - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::BoolKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::StringKeyword); + choice.consider(input, result)?; + let result = self.address_type(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::FixedBytesType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::SignedIntegerType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::UnsignedIntegerType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::SignedFixedType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::UnsignedFixedType); + choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = + self.default_parse_token_with_trivia(input, TokenKind::ByteKeyword); + choice.consider(input, result)?; + } + choice.finish(input) + }); + choice.consider(input, result)?; + let result = self.identifier_path(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + if self.version_is_at_least_0_8_18 { + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + ))?; + } + seq.finish() + }) .with_kind(RuleKind::MappingKeyType) } #[allow(unused_assignments, unused_parens)] fn mapping_type(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::MappingKeyword))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; - seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem(self.mapping_key_type(input))?; - seq.elem(self.default_parse_token_with_trivia( - input, - TokenKind::EqualGreaterThan, - ))?; - seq.elem(self.mapping_value_type(input))?; - seq.finish() - }) - } - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; - seq.finish() - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::MappingKeyword))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(self.mapping_key_type(input))?; + seq.elem( + self.default_parse_token_with_trivia( + input, + TokenKind::EqualGreaterThan, + ), + )?; + seq.elem(self.mapping_value_type(input))?; + seq.finish() + }) + .recover_until_with_nested_delims( + input, + |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; seq.finish() - }) - } + }))?; + seq.finish() + }) .with_kind(RuleKind::MappingType) } #[allow(unused_assignments, unused_parens)] fn mapping_value_type(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - if self.version_is_at_least_0_8_18 { - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - ))?; - } - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + if self.version_is_at_least_0_8_18 { + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + ))?; + } + seq.finish() + }) .with_kind(RuleKind::MappingValueType) } @@ -2296,54 +2184,45 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn modifier_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ModifierKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(OptionalHelper::transform( - self.parameters_declaration(input), - ))?; - seq.elem(OptionalHelper::transform( - self.modifier_attributes_list(input), - ))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::Semicolon); - choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ModifierKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(OptionalHelper::transform( + self.parameters_declaration(input), + ))?; + seq.elem(OptionalHelper::transform( + self.modifier_attributes_list(input), + ))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.default_parse_token_with_trivia(input, TokenKind::Semicolon); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) .with_kind(RuleKind::ModifierDefinition) } #[allow(unused_assignments, unused_parens)] fn modifier_invocation(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.identifier_path(input))?; - seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.identifier_path(input))?; + seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; + seq.finish() + }) .with_kind(RuleKind::ModifierInvocation) } #[allow(unused_assignments, unused_parens)] fn named_argument(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Colon))?; - seq.elem(self.expression(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Colon))?; + seq.elem(self.expression(input))?; + seq.finish() + }) .with_kind(RuleKind::NamedArgument) } @@ -2382,262 +2261,209 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn named_import(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Asterisk))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FromKeyword))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral), - )?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Asterisk))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FromKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral))?; + seq.finish() + }) .with_kind(RuleKind::NamedImport) } #[allow(unused_assignments, unused_parens)] fn new_expression(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::NewKeyword))?; - seq.elem(self.type_name(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::NewKeyword))?; + seq.elem(self.type_name(input))?; + seq.finish() + }) .with_kind(RuleKind::NewExpression) } #[allow(unused_assignments, unused_parens)] fn numeric_expression(&self, input: &mut ParserContext) -> ParserResult { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::HexLiteral), - )?; - if !self.version_is_at_least_0_5_0 { - seq.elem(OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::DaysKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::EtherKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::HoursKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::MinutesKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::SecondsKeyword, - ); - choice.consider(input, result)?; + ChoiceHelper::run(input, |mut choice, input| { + let result = SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::HexLiteral))?; + if !self.version_is_at_least_0_5_0 { + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::DaysKeyword); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::EtherKeyword); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::HoursKeyword); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::MinutesKeyword); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::SecondsKeyword); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::WeeksKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::WeiKeyword); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.default_parse_token_with_trivia( + input, + TokenKind::YearsKeyword, + ); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_11 { + let result = self + .default_parse_token_with_trivia(input, TokenKind::GweiKeyword); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia( input, - TokenKind::WeeksKeyword, + TokenKind::FinneyKeyword, ); choice.consider(input, result)?; let result = self.default_parse_token_with_trivia( input, - TokenKind::WeiKeyword, + TokenKind::SzaboKeyword, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::YearsKeyword, - ); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_11 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::GweiKeyword, - ); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_7_0 { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::FinneyKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::SzaboKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - }; - choice.consider(input, result)?; - } choice.finish(input) - }) - }))?; - } - seq.finish() - }) - }; - choice.consider(input, result)?; - let result = { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::DecimalLiteral), - )?; - seq.elem(OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self - .default_parse_token_with_trivia(input, TokenKind::DaysKeyword); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::EtherKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::HoursKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::MinutesKeyword, - ); + }); choice.consider(input, result)?; + } + choice.finish(input) + }, + )))?; + } + seq.finish() + }); + choice.consider(input, result)?; + let result = SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::DecimalLiteral))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::DaysKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::EtherKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::HoursKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::MinutesKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::SecondsKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::WeeksKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::WeiKeyword); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self + .default_parse_token_with_trivia(input, TokenKind::YearsKeyword); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_11 { + let result = + self.default_parse_token_with_trivia(input, TokenKind::GweiKeyword); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = ChoiceHelper::run(input, |mut choice, input| { let result = self.default_parse_token_with_trivia( input, - TokenKind::SecondsKeyword, + TokenKind::FinneyKeyword, ); choice.consider(input, result)?; let result = self.default_parse_token_with_trivia( input, - TokenKind::WeeksKeyword, + TokenKind::SzaboKeyword, ); choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::WeiKeyword); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::YearsKeyword, - ); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_11 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::GweiKeyword, - ); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_7_0 { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::FinneyKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::SzaboKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - }; - choice.consider(input, result)?; - } choice.finish(input) - }) - }))?; - seq.finish() - }) - }; - choice.consider(input, result)?; - choice.finish(input) - }) - } + }); + choice.consider(input, result)?; + } + choice.finish(input) + }, + )))?; + seq.finish() + }); + choice.consider(input, result)?; + choice.finish(input) + }) .with_kind(RuleKind::NumericExpression) } #[allow(unused_assignments, unused_parens)] fn override_specifier(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OverrideKeyword))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; - seq.elem( - OptionalHelper::transform(self.identifier_paths_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; - seq.finish() - })))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OverrideKeyword))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; + seq.elem( + OptionalHelper::transform(self.identifier_paths_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .with_kind(RuleKind::OverrideSpecifier) } - #[allow(unused_assignments, unused_parens)] - fn parameter(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem(OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::MemoryKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::StorageKeyword); - choice.consider(input, result)?; - if self.version_is_at_least_0_5_0 { - let result = self - .default_parse_token_with_trivia(input, TokenKind::CalldataKeyword); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }))?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - ))?; - seq.finish() - }) - } + #[allow(unused_assignments, unused_parens)] + fn parameter(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::MemoryKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::StorageKeyword); + choice.consider(input, result)?; + if self.version_is_at_least_0_5_0 { + let result = + self.default_parse_token_with_trivia(input, TokenKind::CalldataKeyword); + choice.consider(input, result)?; + } + choice.finish(input) + }, + )))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + ))?; + seq.finish() + }) .with_kind(RuleKind::Parameter) } @@ -2676,25 +2502,15 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn path_import(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral), - )?; - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::AsKeyword), - )?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.finish() - }) - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .with_kind(RuleKind::PathImport) } @@ -2713,25 +2529,21 @@ impl Language { fn pragma_directive(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::PragmaKeyword), - )?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.abi_coder_pragma(input); - choice.consider(input, result)?; - let result = self.experimental_pragma(input); - choice.consider(input, result)?; - let result = self.version_pragma(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::PragmaKeyword), + )?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.abi_coder_pragma(input); + choice.consider(input, result)?; + let result = self.experimental_pragma(input); + choice.consider(input, result)?; + let result = self.version_pragma(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -2751,24 +2563,22 @@ impl Language { if self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| { if self.version_is_at_least_0_6_0 { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.modifier_invocation(input); - choice.consider(input, result)?; - let result = self.override_specifier(input); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::ExternalKeyword); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::PayableKeyword); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::VirtualKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - } + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::ExternalKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::VirtualKeyword); + choice.consider(input, result)?; + choice.finish(input) + }) } else { ParserResult::disabled() } @@ -2782,28 +2592,21 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn receive_function_definition(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::ReceiveKeyword), - )?; - seq.elem(self.parameters_declaration(input))?; - seq.elem(OptionalHelper::transform( - self.receive_function_attributes_list(input), - ))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::Semicolon); - choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ReceiveKeyword))?; + seq.elem(self.parameters_declaration(input))?; + seq.elem(OptionalHelper::transform( + self.receive_function_attributes_list(input), + ))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.default_parse_token_with_trivia(input, TokenKind::Semicolon); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -2814,15 +2617,13 @@ impl Language { fn return_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::ReturnKeyword), - )?; - seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::ReturnKeyword), + )?; + seq.elem(OptionalHelper::transform(self.expression(input)))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -2839,13 +2640,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn returns_declaration(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ReturnsKeyword))?; - seq.elem(self.parameters_declaration(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ReturnsKeyword))?; + seq.elem(self.parameters_declaration(input))?; + seq.finish() + }) .with_kind(RuleKind::ReturnsDeclaration) } @@ -2853,16 +2652,14 @@ impl Language { fn revert_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::RevertKeyword), - )?; - seq.elem(OptionalHelper::transform(self.identifier_path(input)))?; - seq.elem(self.arguments_declaration(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::RevertKeyword), + )?; + seq.elem(OptionalHelper::transform(self.identifier_path(input)))?; + seq.elem(self.arguments_declaration(input))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -2879,15 +2676,13 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn source_unit(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform( - self.source_unit_members_list(input), - ))?; - seq.elem(OptionalHelper::transform(self.end_of_file_trivia(input)))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform( + self.source_unit_members_list(input), + ))?; + seq.elem(OptionalHelper::transform(self.end_of_file_trivia(input)))?; + seq.finish() + }) .with_kind(RuleKind::SourceUnit) } @@ -2906,15 +2701,13 @@ impl Language { let result = self.library_definition(input); choice.consider(input, result)?; if self.version_is_at_least_0_6_0 { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.struct_definition(input); + choice.consider(input, result)?; + let result = self.enum_definition(input); + choice.consider(input, result)?; + choice.finish(input) + }); choice.consider(input, result)?; } if self.version_is_at_least_0_7_1 { @@ -2974,27 +2767,19 @@ impl Language { fn state_variable_definition(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem(OptionalHelper::transform( - self.state_variable_attributes_list(input), - ))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Equal), - )?; - seq.elem(self.expression(input))?; - seq.finish() - }) - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem(OptionalHelper::transform( + self.state_variable_attributes_list(input), + ))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Equal))?; + seq.elem(self.expression(input))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -3011,106 +2796,96 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn statement(&self, input: &mut ParserContext) -> ParserResult { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }) - }; + ChoiceHelper::run(input, |mut choice, input| { + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.expression_statement(input); choice.consider(input, result)?; - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); - choice.consider(input, result)?; - let result = self.break_statement(input); - choice.consider(input, result)?; - let result = self.delete_statement(input); - choice.consider(input, result)?; - let result = self.return_statement(input); - choice.consider(input, result)?; - let result = self.revert_statement(input); - choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }; + let result = self.variable_declaration_statement(input); choice.consider(input, result)?; - let result = self.assembly_statement(input); + let result = self.tuple_deconstruction_statement(input); choice.consider(input, result)?; - let result = self.block(input); + choice.finish(input) + }); + choice.consider(input, result)?; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = self.if_statement(input); choice.consider(input, result)?; - if self.version_is_at_least_0_8_0 { - let result = self.unchecked_block(input); + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + let result = self.revert_statement(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); choice.consider(input, result)?; } choice.finish(input) - }) - } - .with_kind(RuleKind::Statement) - } - - #[allow(unused_assignments, unused_parens)] - fn statements_list(&self, input: &mut ParserContext) -> ParserResult { - OneOrMoreHelper::run(input, |input| self.statement(input)) - .with_kind(RuleKind::StatementsList) - } - - #[allow(unused_assignments, unused_parens)] - fn struct_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::StructKeyword))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBrace); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; - seq.elem( - OptionalHelper::transform(self.struct_members_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseBrace, - Self::default_delimiters(), - ), - )?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; - seq.finish() - }))?; + }); + choice.consider(input, result)?; + let result = self.assembly_statement(input); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_8_0 { + let result = self.unchecked_block(input); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::Statement) + } + + #[allow(unused_assignments, unused_parens)] + fn statements_list(&self, input: &mut ParserContext) -> ParserResult { + OneOrMoreHelper::run(input, |input| self.statement(input)) + .with_kind(RuleKind::StatementsList) + } + + #[allow(unused_assignments, unused_parens)] + fn struct_definition(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::StructKeyword))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenBrace))?; + seq.elem( + OptionalHelper::transform(self.struct_members_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseBrace, + Self::default_delimiters(), + ), + )?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseBrace))?; seq.finish() - }) - } + }))?; + seq.finish() + }) .with_kind(RuleKind::StructDefinition) } @@ -3118,15 +2893,11 @@ impl Language { fn struct_member(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -3174,34 +2945,30 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn trailing_trivia(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform( - self.default_parse_token(input, TokenKind::Whitespace), - ))?; - seq.elem(OptionalHelper::transform( - self.default_parse_token(input, TokenKind::SingleLineComment), - ))?; - seq.elem(self.default_parse_token(input, TokenKind::EndOfLine))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform( + self.default_parse_token(input, TokenKind::Whitespace), + ))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token(input, TokenKind::SingleLineComment), + ))?; + seq.elem(self.default_parse_token(input, TokenKind::EndOfLine))?; + seq.finish() + }) .with_kind(RuleKind::TrailingTrivia) } #[allow(unused_assignments, unused_parens)] fn try_statement(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::TryKeyword))?; - seq.elem(self.expression(input))?; - seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; - seq.elem(self.block(input))?; - seq.elem(self.catch_clauses_list(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::TryKeyword))?; + seq.elem(self.expression(input))?; + seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; + seq.elem(self.block(input))?; + seq.elem(self.catch_clauses_list(input))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -3212,38 +2979,36 @@ impl Language { fn tuple_deconstruction_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::OpenParen), - )?; - seq.elem( - OptionalHelper::transform(self.tuple_members_list(input)) - .recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>( - self, input, - ) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ), - )?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::CloseParen), - )?; - seq.finish() - }))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Equal))?; - seq.elem(self.expression(input))?; + SequenceHelper::run(|mut seq| { + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::OpenParen), + )?; + seq.elem( + OptionalHelper::transform(self.tuple_members_list(input)) + .recover_until_with_nested_delims( + input, + |input| { + Lexer::next_token::<{ LexicalContext::Default as u8 }>( + self, input, + ) + }, + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ), + )?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::CloseParen), + )?; seq.finish() - }) - } + }))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Equal))?; + seq.elem(self.expression(input))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -3282,74 +3047,54 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn tuple_member(&self, input: &mut ParserContext) -> ParserResult { - OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = { - SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem(OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::MemoryKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::StorageKeyword, - ); - choice.consider(input, result)?; - if self.version_is_at_least_0_5_0 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::CalldataKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.finish() - }) - }; - choice.consider(input, result)?; - let result = { - SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::MemoryKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::StorageKeyword, - ); - choice.consider(input, result)?; - if self.version_is_at_least_0_5_0 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::CalldataKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.finish() - }) - }; - choice.consider(input, result)?; - choice.finish(input) - }) - }) + OptionalHelper::transform(ChoiceHelper::run(input, |mut choice, input| { + let result = SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::MemoryKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::StorageKeyword); + choice.consider(input, result)?; + if self.version_is_at_least_0_5_0 { + let result = self + .default_parse_token_with_trivia(input, TokenKind::CalldataKeyword); + choice.consider(input, result)?; + } + choice.finish(input) + }, + )))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.finish() + }); + choice.consider(input, result)?; + let result = SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::MemoryKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::StorageKeyword); + choice.consider(input, result)?; + if self.version_is_at_least_0_5_0 { + let result = self + .default_parse_token_with_trivia(input, TokenKind::CalldataKeyword); + choice.consider(input, result)?; + } + choice.finish(input) + }, + )))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.finish() + }); + choice.consider(input, result)?; + choice.finish(input) + })) .with_kind(RuleKind::TupleMember) } @@ -3378,32 +3123,24 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn type_expression(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_5_3 { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::TypeKeyword))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::OpenParen), - )?; - seq.elem(self.type_name(input).recover_until_with_nested_delims( - input, - |input| { - Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input) - }, - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ))?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::CloseParen), - )?; - seq.finish() - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::TypeKeyword))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; + seq.elem(self.type_name(input).recover_until_with_nested_delims( + input, + |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; seq.finish() - }) - } + }))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -3445,39 +3182,37 @@ impl Language { choice.consider(input, result)?; let result = self.mapping_type(input); choice.consider(input, result)?; - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::BoolKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::StringKeyword); - choice.consider(input, result)?; - let result = self.address_type(input); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::FixedBytesType); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::SignedIntegerType); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::UnsignedIntegerType); - choice.consider(input, result)?; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::BoolKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::StringKeyword); + choice.consider(input, result)?; + let result = self.address_type(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::FixedBytesType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::SignedIntegerType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::UnsignedIntegerType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::SignedFixedType); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::UnsignedFixedType); + choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { let result = - self.default_parse_token_with_trivia(input, TokenKind::SignedFixedType); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::UnsignedFixedType); + self.default_parse_token_with_trivia(input, TokenKind::ByteKeyword); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = - self.default_parse_token_with_trivia(input, TokenKind::ByteKeyword); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }; + } + choice.finish(input) + }); choice.consider(input, result)?; let result = self.identifier_path(input); choice.consider(input, result)?; @@ -3510,15 +3245,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn unchecked_block(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_8_0 { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::UncheckedKeyword), - )?; - seq.elem(self.block(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::UncheckedKeyword))?; + seq.elem(self.block(input))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -3542,27 +3273,25 @@ impl Language { if !self.version_is_at_least_0_6_0 { OneOrMoreHelper::run(input, |input| { if !self.version_is_at_least_0_6_0 { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.modifier_invocation(input); - choice.consider(input, result)?; - let result = self.override_specifier(input); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::ExternalKeyword); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::PayableKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::PureKeyword); - choice.consider(input, result)?; - let result = - self.default_parse_token_with_trivia(input, TokenKind::ViewKeyword); - choice.consider(input, result)?; - choice.finish(input) - }) - } + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(input); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::ExternalKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::PayableKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::PureKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::ViewKeyword); + choice.consider(input, result)?; + choice.finish(input) + }) } else { ParserResult::disabled() } @@ -3576,28 +3305,21 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn unnamed_function_definition(&self, input: &mut ParserContext) -> ParserResult { if !self.version_is_at_least_0_6_0 { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::FunctionKeyword), - )?; - seq.elem(self.parameters_declaration(input))?; - seq.elem(OptionalHelper::transform( - self.unnamed_function_attributes_list(input), - ))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::Semicolon); - choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::FunctionKeyword))?; + seq.elem(self.parameters_declaration(input))?; + seq.elem(OptionalHelper::transform( + self.unnamed_function_attributes_list(input), + ))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.default_parse_token_with_trivia(input, TokenKind::Semicolon); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.finish() + }) } else { ParserResult::disabled() } @@ -3609,69 +3331,55 @@ impl Language { if self.version_is_at_least_0_8_8 { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::TypeKeyword), - )?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Identifier), - )?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::IsKeyword), - )?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::BoolKeyword, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::StringKeyword, - ); - choice.consider(input, result)?; - let result = self.address_type(input); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::FixedBytesType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::SignedIntegerType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::UnsignedIntegerType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::SignedFixedType, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::UnsignedFixedType, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }) - })?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::TypeKeyword), + )?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::Identifier), + )?; + seq.elem( + self.default_parse_token_with_trivia(input, TokenKind::IsKeyword), + )?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::BoolKeyword); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::StringKeyword); + choice.consider(input, result)?; + let result = self.address_type(input); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::FixedBytesType); + choice.consider(input, result)?; + let result = self.default_parse_token_with_trivia( + input, + TokenKind::SignedIntegerType, + ); + choice.consider(input, result)?; + let result = self.default_parse_token_with_trivia( + input, + TokenKind::UnsignedIntegerType, + ); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::SignedFixedType); + choice.consider(input, result)?; + let result = self.default_parse_token_with_trivia( + input, + TokenKind::UnsignedFixedType, + ); + choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self + .default_parse_token_with_trivia(input, TokenKind::ByteKeyword); + choice.consider(input, result)?; + } + choice.finish(input) + }))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -3693,39 +3401,29 @@ impl Language { fn using_directive(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::UsingKeyword), - )?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.using_directive_path(input); - choice.consider(input, result)?; - let result = self.using_directive_deconstruction(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::ForKeyword), - )?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self - .default_parse_token_with_trivia(input, TokenKind::Asterisk); - choice.consider(input, result)?; - let result = self.type_name(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.elem(OptionalHelper::transform( - self.default_parse_token_with_trivia(input, TokenKind::GlobalKeyword), - ))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::UsingKeyword))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.using_directive_path(input); + choice.consider(input, result)?; + let result = self.using_directive_deconstruction(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::ForKeyword))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::Asterisk); + choice.consider(input, result)?; + let result = self.type_name(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.elem(OptionalHelper::transform( + self.default_parse_token_with_trivia(input, TokenKind::GlobalKeyword), + ))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -3770,154 +3468,116 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn using_directive_symbol(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.identifier_path(input))?; - if self.version_is_at_least_0_8_19 { - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::AsKeyword), - )?; - seq.elem(if self.version_is_at_least_0_8_19 { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Ampersand, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - let result = self - .default_parse_token_with_trivia(input, TokenKind::Bar); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.default_parse_token_with_trivia( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - } - } else { - ParserResult::disabled() - })?; - seq.finish() + SequenceHelper::run(|mut seq| { + seq.elem(self.identifier_path(input))?; + if self.version_is_at_least_0_8_19 { + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::AsKeyword))?; + seq.elem(if self.version_is_at_least_0_8_19 { + ChoiceHelper::run(input, |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::Ampersand); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Asterisk); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::BangEqual); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Bar); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Caret); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::EqualEqual); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::GreaterThan); + choice.consider(input, result)?; + let result = self.default_parse_token_with_trivia( + input, + TokenKind::GreaterThanEqual, + ); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::LessThan); + choice.consider(input, result)?; + let result = self + .default_parse_token_with_trivia(input, TokenKind::LessThanEqual); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Minus); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Percent); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Plus); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Slash); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::Tilde); + choice.consider(input, result)?; + choice.finish(input) }) - }))?; - } - seq.finish() - }) - } + } else { + ParserResult::disabled() + })?; + seq.finish() + })))?; + } + seq.finish() + }) .with_kind(RuleKind::UsingDirectiveSymbol) } - #[allow(unused_assignments, unused_parens)] - fn using_directive_symbols_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<{ LexicalContext::Default as u8 }, Self>( - input, - |input| self.using_directive_symbol(input), - TokenKind::Comma, - self, - ) - .with_kind(RuleKind::UsingDirectiveSymbolsList) - } - - #[allow(unused_assignments, unused_parens)] - fn variable_declaration(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - if !self.version_is_at_least_0_5_0 { - let result = - self.default_parse_token_with_trivia(input, TokenKind::VarKeyword); - choice.consider(input, result)?; - } - let result = self.type_name(input); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.elem(OptionalHelper::transform({ - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.default_parse_token_with_trivia(input, TokenKind::MemoryKeyword); - choice.consider(input, result)?; + #[allow(unused_assignments, unused_parens)] + fn using_directive_symbols_list(&self, input: &mut ParserContext) -> ParserResult { + SeparatedHelper::run::<{ LexicalContext::Default as u8 }, Self>( + input, + |input| self.using_directive_symbol(input), + TokenKind::Comma, + self, + ) + .with_kind(RuleKind::UsingDirectiveSymbolsList) + } + + #[allow(unused_assignments, unused_parens)] + fn variable_declaration(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + if !self.version_is_at_least_0_5_0 { + let result = self.default_parse_token_with_trivia(input, TokenKind::VarKeyword); + choice.consider(input, result)?; + } + let result = self.type_name(input); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = + self.default_parse_token_with_trivia(input, TokenKind::MemoryKeyword); + choice.consider(input, result)?; + let result = + self.default_parse_token_with_trivia(input, TokenKind::StorageKeyword); + choice.consider(input, result)?; + if self.version_is_at_least_0_5_0 { let result = - self.default_parse_token_with_trivia(input, TokenKind::StorageKeyword); + self.default_parse_token_with_trivia(input, TokenKind::CalldataKeyword); choice.consider(input, result)?; - if self.version_is_at_least_0_5_0 { - let result = self - .default_parse_token_with_trivia(input, TokenKind::CalldataKeyword); - choice.consider(input, result)?; - } - choice.finish(input) - }) - }))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; - seq.finish() - }) - } + } + choice.finish(input) + }, + )))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Identifier))?; + seq.finish() + }) .with_kind(RuleKind::VariableDeclaration) } @@ -3925,21 +3585,15 @@ impl Language { fn variable_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - { - SequenceHelper::run(|mut seq| { - seq.elem(self.variable_declaration(input))?; - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem( - self.default_parse_token_with_trivia(input, TokenKind::Equal), - )?; - seq.elem(self.expression(input))?; - seq.finish() - }) - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.variable_declaration(input))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::Equal))?; + seq.elem(self.expression(input))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .recover_until_with_nested_delims( input, |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), @@ -3956,15 +3610,13 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn version_pragma(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.version_pragma_parse_token_with_trivia(input, TokenKind::SolidityKeyword), - )?; - seq.elem(self.version_pragma_expressions_list(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem( + self.version_pragma_parse_token_with_trivia(input, TokenKind::SolidityKeyword), + )?; + seq.elem(self.version_pragma_expressions_list(input))?; + seq.finish() + }) .with_kind(RuleKind::VersionPragma) } @@ -3987,7 +3639,9 @@ impl Language { ) }; let parse_version_pragma_unary_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_prefix_operator(RuleKind::VersionPragmaUnaryExpression, 5u8, { + PrecedenceHelper::to_prefix_operator( + RuleKind::VersionPragmaUnaryExpression, + 5u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.version_pragma_parse_token_with_trivia(input, TokenKind::Caret); @@ -4011,8 +3665,8 @@ impl Language { .version_pragma_parse_token_with_trivia(input, TokenKind::GreaterThanEqual); choice.consider(input, result)?; choice.finish(input) - }) - }) + }), + ) }; let prefix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { @@ -4082,40 +3736,36 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn while_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::WhileKeyword))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; - seq.elem(self.expression(input).recover_until_with_nested_delims( - input, - |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), - |input| Lexer::leading_trivia(self, input), - TokenKind::CloseParen, - Self::default_delimiters(), - ))?; - seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; - seq.finish() - }))?; - seq.elem(self.statement(input))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::WhileKeyword))?; + seq.elem(SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::OpenParen))?; + seq.elem(self.expression(input).recover_until_with_nested_delims( + input, + |input| Lexer::next_token::<{ LexicalContext::Default as u8 }>(self, input), + |input| Lexer::leading_trivia(self, input), + TokenKind::CloseParen, + Self::default_delimiters(), + ))?; + seq.elem(self.default_parse_token_with_trivia(input, TokenKind::CloseParen))?; seq.finish() - }) - } + }))?; + seq.elem(self.statement(input))?; + seq.finish() + }) .with_kind(RuleKind::WhileStatement) } #[allow(unused_assignments, unused_parens)] fn yul_assignment_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.yul_identifier_paths_list(input))?; - seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::ColonEqual))?; - seq.elem(self.yul_expression(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.yul_identifier_paths_list(input))?; + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::ColonEqual))?; + seq.elem(self.yul_expression(input))?; + seq.finish() + }) .with_kind(RuleKind::YulAssignmentStatement) } @@ -4157,22 +3807,16 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::LetKeyword))?; - seq.elem(self.yul_identifier_paths_list(input))?; - seq.elem(OptionalHelper::transform({ - SequenceHelper::run(|mut seq| { - seq.elem( - self.yul_block_parse_token_with_trivia(input, TokenKind::ColonEqual), - )?; - seq.elem(self.yul_expression(input))?; - seq.finish() - }) - }))?; + SequenceHelper::run(|mut seq| { + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::LetKeyword))?; + seq.elem(self.yul_identifier_paths_list(input))?; + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::ColonEqual))?; + seq.elem(self.yul_expression(input))?; seq.finish() - }) - } + })))?; + seq.finish() + }) .with_kind(RuleKind::YulDeclarationStatement) } @@ -4207,31 +3851,27 @@ impl Language { }; let primary_expression_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = { - ChoiceHelper::run(input, |mut choice, input| { - let result = - self.yul_block_parse_token_with_trivia(input, TokenKind::TrueKeyword); - choice.consider(input, result)?; - let result = - self.yul_block_parse_token_with_trivia(input, TokenKind::FalseKeyword); - choice.consider(input, result)?; - let result = - self.yul_block_parse_token_with_trivia(input, TokenKind::YulHexLiteral); - choice.consider(input, result)?; - let result = self - .yul_block_parse_token_with_trivia(input, TokenKind::YulDecimalLiteral); - choice.consider(input, result)?; - let result = self - .yul_block_parse_token_with_trivia(input, TokenKind::HexStringLiteral); - choice.consider(input, result)?; - let result = self.yul_block_parse_token_with_trivia( - input, - TokenKind::AsciiStringLiteral, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - }; + let result = ChoiceHelper::run(input, |mut choice, input| { + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::TrueKeyword); + choice.consider(input, result)?; + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::FalseKeyword); + choice.consider(input, result)?; + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::YulHexLiteral); + choice.consider(input, result)?; + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::YulDecimalLiteral); + choice.consider(input, result)?; + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::HexStringLiteral); + choice.consider(input, result)?; + let result = self + .yul_block_parse_token_with_trivia(input, TokenKind::AsciiStringLiteral); + choice.consider(input, result)?; + choice.finish(input) + }); choice.consider(input, result)?; let result = self.yul_identifier_path(input); choice.consider(input, result)?; @@ -4274,35 +3914,29 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_for_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::ForKeyword))?; - seq.elem(self.yul_block(input))?; - seq.elem(self.yul_expression(input))?; - seq.elem(self.yul_block(input))?; - seq.elem(self.yul_block(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::ForKeyword))?; + seq.elem(self.yul_block(input))?; + seq.elem(self.yul_expression(input))?; + seq.elem(self.yul_block(input))?; + seq.elem(self.yul_block(input))?; + seq.finish() + }) .with_kind(RuleKind::YulForStatement) } #[allow(unused_assignments, unused_parens)] fn yul_function_definition(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.yul_block_parse_token_with_trivia(input, TokenKind::FunctionKeyword), - )?; - seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::YulIdentifier))?; - seq.elem(self.yul_parameters_declaration(input))?; - seq.elem(OptionalHelper::transform( - self.yul_returns_declaration(input), - ))?; - seq.elem(self.yul_block(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::FunctionKeyword))?; + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::YulIdentifier))?; + seq.elem(self.yul_parameters_declaration(input))?; + seq.elem(OptionalHelper::transform( + self.yul_returns_declaration(input), + ))?; + seq.elem(self.yul_block(input))?; + seq.finish() + }) .with_kind(RuleKind::YulFunctionDefinition) } @@ -4341,14 +3975,12 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_if_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::IfKeyword))?; - seq.elem(self.yul_expression(input))?; - seq.elem(self.yul_block(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::IfKeyword))?; + seq.elem(self.yul_expression(input))?; + seq.elem(self.yul_block(input))?; + seq.finish() + }) .with_kind(RuleKind::YulIfStatement) } @@ -4388,49 +4020,43 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_returns_declaration(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem( - self.yul_block_parse_token_with_trivia(input, TokenKind::MinusGreaterThan), - )?; - seq.elem(self.yul_identifiers_list(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::MinusGreaterThan))?; + seq.elem(self.yul_identifiers_list(input))?; + seq.finish() + }) .with_kind(RuleKind::YulReturnsDeclaration) } #[allow(unused_assignments, unused_parens)] fn yul_statement(&self, input: &mut ParserContext) -> ParserResult { - { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.yul_block(input); - choice.consider(input, result)?; - let result = self.yul_function_definition(input); - choice.consider(input, result)?; - let result = self.yul_declaration_statement(input); - choice.consider(input, result)?; - let result = self.yul_assignment_statement(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); + ChoiceHelper::run(input, |mut choice, input| { + let result = self.yul_block(input); + choice.consider(input, result)?; + let result = self.yul_function_definition(input); + choice.consider(input, result)?; + let result = self.yul_declaration_statement(input); + choice.consider(input, result)?; + let result = self.yul_assignment_statement(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)?; + let result = self.yul_break_statement(input); + choice.consider(input, result)?; + let result = self.yul_continue_statement(input); + choice.consider(input, result)?; + let result = self.yul_expression(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)?; - let result = self.yul_expression(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)?; - } - choice.finish(input) - }) - } + } + choice.finish(input) + }) .with_kind(RuleKind::YulStatement) } @@ -4442,65 +4068,46 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_switch_case(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { + SequenceHelper::run(|mut seq| { + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::DefaultKeyword); + choice.consider(input, result)?; + let result = SequenceHelper::run(|mut seq| { + seq.elem( + self.yul_block_parse_token_with_trivia(input, TokenKind::CaseKeyword), + )?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::TrueKeyword); + choice.consider(input, result)?; + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::FalseKeyword); + choice.consider(input, result)?; + let result = + self.yul_block_parse_token_with_trivia(input, TokenKind::YulHexLiteral); + choice.consider(input, result)?; let result = self - .yul_block_parse_token_with_trivia(input, TokenKind::DefaultKeyword); + .yul_block_parse_token_with_trivia(input, TokenKind::YulDecimalLiteral); choice.consider(input, result)?; - let result = { - SequenceHelper::run(|mut seq| { - seq.elem(self.yul_block_parse_token_with_trivia( - input, - TokenKind::CaseKeyword, - ))?; - seq.elem({ - ChoiceHelper::run(input, |mut choice, input| { - let result = self.yul_block_parse_token_with_trivia( - input, - TokenKind::TrueKeyword, - ); - choice.consider(input, result)?; - let result = self.yul_block_parse_token_with_trivia( - input, - TokenKind::FalseKeyword, - ); - choice.consider(input, result)?; - let result = self.yul_block_parse_token_with_trivia( - input, - TokenKind::YulHexLiteral, - ); - choice.consider(input, result)?; - let result = self.yul_block_parse_token_with_trivia( - input, - TokenKind::YulDecimalLiteral, - ); - choice.consider(input, result)?; - let result = self.yul_block_parse_token_with_trivia( - input, - TokenKind::HexStringLiteral, - ); - choice.consider(input, result)?; - let result = self.yul_block_parse_token_with_trivia( - input, - TokenKind::AsciiStringLiteral, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - })?; - seq.finish() - }) - }; + let result = self + .yul_block_parse_token_with_trivia(input, TokenKind::HexStringLiteral); + choice.consider(input, result)?; + let result = self.yul_block_parse_token_with_trivia( + input, + TokenKind::AsciiStringLiteral, + ); choice.consider(input, result)?; choice.finish(input) - }) - })?; - seq.elem(self.yul_block(input))?; - seq.finish() - }) - } + }))?; + seq.finish() + }); + choice.consider(input, result)?; + choice.finish(input) + }))?; + seq.elem(self.yul_block(input))?; + seq.finish() + }) .with_kind(RuleKind::YulSwitchCase) } @@ -4512,14 +4119,12 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_switch_statement(&self, input: &mut ParserContext) -> ParserResult { - { - SequenceHelper::run(|mut seq| { - seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::SwitchKeyword))?; - seq.elem(self.yul_expression(input))?; - seq.elem(self.yul_switch_cases_list(input))?; - seq.finish() - }) - } + SequenceHelper::run(|mut seq| { + seq.elem(self.yul_block_parse_token_with_trivia(input, TokenKind::SwitchKeyword))?; + seq.elem(self.yul_expression(input))?; + seq.elem(self.yul_switch_cases_list(input))?; + seq.finish() + }) .with_kind(RuleKind::YulSwitchStatement) }