From 1f1468b1717837b8c642b2b315506ba8dfaaf42f Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 6 Dec 2023 17:38:39 +0100 Subject: [PATCH 01/17] Remove ProductionKind in favor of RuleKind --- .../parser/generator/src/code_generator.rs | 4 - .../runtime/src/templates/kinds.rs.jinja2 | 20 - .../runtime/src/templates/language.rs.jinja2 | 14 +- .../cargo/crate/src/generated/kinds.rs | 203 --------- .../cargo/crate/src/generated/language.rs | 423 ++++++++---------- .../solidity/outputs/cargo/crate/src/main.rs | 4 +- .../cargo/tests/src/cst_output/runner.rs | 6 +- .../tests/src/doc_examples/cursor_api.rs | 10 +- .../tests/src/doc_examples/simple_contract.rs | 4 +- .../outputs/npm/crate/src/generated/kinds.rs | 203 --------- .../npm/crate/src/generated/language.rs | 423 ++++++++---------- .../npm/package/src/generated/index.d.ts | 191 +------- .../outputs/npm/package/src/kinds/index.ts | 3 - .../tests/src/doc-examples/simple-contract.ts | 4 +- .../outputs/npm/tests/src/tests/cst-cursor.ts | 4 +- .../outputs/npm/tests/src/tests/cst-output.ts | 10 +- .../outputs/npm/tests/src/tests/errors.ts | 4 +- .../outputs/npm/tests/src/tests/public-api.ts | 6 +- crates/solidity/testing/sanctuary/src/main.rs | 4 +- .../utils/src/node_extensions/tests.rs | 4 +- .../testing/utils/src/version_pragmas/mod.rs | 4 +- .../public/user-guide/npm-package/index.md | 6 +- 22 files changed, 436 insertions(+), 1118 deletions(-) diff --git a/crates/codegen/parser/generator/src/code_generator.rs b/crates/codegen/parser/generator/src/code_generator.rs index 0ea95c30d3..fc00871b3e 100644 --- a/crates/codegen/parser/generator/src/code_generator.rs +++ b/crates/codegen/parser/generator/src/code_generator.rs @@ -28,7 +28,6 @@ pub struct CodeGenerator { rule_kinds: BTreeSet<&'static str>, token_kinds: BTreeSet<&'static str>, - production_kinds: BTreeSet<&'static str>, trivia_kinds: BTreeSet<&'static str>, top_level_scanner_names: BTreeSet<&'static str>, @@ -217,7 +216,6 @@ impl GrammarVisitor for CodeGenerator { fn trivia_parser_definition_enter(&mut self, parser: &TriviaParserDefinitionRef) { self.set_current_context(parser.context()); - self.production_kinds.insert(parser.name()); self.rule_kinds.insert(parser.name()); self.trivia_kinds.insert(parser.name()); self.parser_functions.push(( @@ -235,7 +233,6 @@ impl GrammarVisitor for CodeGenerator { // Have to set this regardless so that we can collect referenced scanners self.set_current_context(parser.context()); if !parser.is_inline() { - self.production_kinds.insert(parser.name()); self.rule_kinds.insert(parser.name()); let code = parser.to_parser_code(); self.parser_functions.push(( @@ -251,7 +248,6 @@ impl GrammarVisitor for CodeGenerator { fn precedence_parser_definition_enter(&mut self, parser: &PrecedenceParserDefinitionRef) { self.set_current_context(parser.context()); - self.production_kinds.insert(parser.name()); self.rule_kinds.insert(parser.name()); for (_, _, name, _) in &parser.node().operators { self.rule_kinds.insert(name); diff --git a/crates/codegen/parser/runtime/src/templates/kinds.rs.jinja2 b/crates/codegen/parser/runtime/src/templates/kinds.rs.jinja2 index 7ba6bd338d..bf76aa9318 100644 --- a/crates/codegen/parser/runtime/src/templates/kinds.rs.jinja2 +++ b/crates/codegen/parser/runtime/src/templates/kinds.rs.jinja2 @@ -1,26 +1,6 @@ #[cfg(feature = "slang_napi_interfaces")] use {napi::bindgen_prelude::*, napi_derive::napi}; -#[derive( - Debug, - Eq, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, -)] -#[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] -#[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum ProductionKind { - {%- for variant in code.production_kinds -%} - {# variant.documentation | indent(prefix = "/// ", first = true, blank = true) #} - {{ variant }}, - {%- endfor -%} -} - #[derive( Debug, Eq, diff --git a/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 b/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 index 9615655d9b..2d2c383f14 100644 --- a/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 +++ b/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 @@ -7,7 +7,7 @@ use {napi::bindgen_prelude::*, napi_derive::napi}; use semver::Version; use super::{ - kinds::{RuleKind, TokenKind, ProductionKind, IsLexicalContext, LexicalContextType}, + kinds::{RuleKind, TokenKind, IsLexicalContext, LexicalContextType}, lexer::Lexer, parse_output::ParseOutput, support::{ @@ -99,11 +99,13 @@ impl Language { } } - pub fn parse(&self, production_kind: ProductionKind, input: &str) -> ParseOutput { - match production_kind { + pub fn parse(&self, kind: RuleKind, input: &str) -> ParseOutput { + match kind { {%- for function in code.parser_functions -%} - ProductionKind::{{ function.0 }} => Self::{{ function.0 | snake_case }}.parse(self, input), + RuleKind::{{ function.0 }} => Self::{{ function.0 | snake_case }}.parse(self, input), {%- endfor -%} + // TODO(#638): Expose parsing individual operators + _ => unimplemented!("Parsing individual precedence operators is not supported at the moment") } } } @@ -220,10 +222,10 @@ impl Language { #[napi(js_name = "parse", ts_return_type = "parse_output.ParseOutput")] pub fn parse_napi( &self, - #[napi(ts_arg_type = "kinds.ProductionKind")] production_kind: ProductionKind, + #[napi(ts_arg_type = "kinds.RuleKind")] kind: RuleKind, input: String ) -> NAPIParseOutput { - self.parse(production_kind, input.as_str()).into() + self.parse(kind, input.as_str()).into() } } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs index f87c025206..185edf3e86 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs @@ -3,209 +3,6 @@ #[cfg(feature = "slang_napi_interfaces")] use {napi::bindgen_prelude::*, napi_derive::napi}; -#[derive( - Debug, - Eq, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, -)] -#[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] -#[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum ProductionKind { - ABICoderPragma, - AddressType, - ArgumentsDeclaration, - ArrayExpression, - ArrayValues, - AsciiStringLiterals, - AssemblyFlags, - AssemblyFlagsDeclaration, - AssemblyStatement, - Block, - BreakStatement, - CatchClause, - CatchClauseError, - CatchClauses, - ConstantDefinition, - ConstructorAttribute, - ConstructorAttributes, - ConstructorDefinition, - ContinueStatement, - ContractDefinition, - ContractMember, - ContractMembers, - DecimalNumberExpression, - DeleteStatement, - DoWhileStatement, - ElementaryType, - ElseBranch, - EmitStatement, - EndOfFileTrivia, - EnumDefinition, - EnumMembers, - ErrorDefinition, - ErrorParameter, - ErrorParameters, - ErrorParametersDeclaration, - EventDefinition, - EventParameter, - EventParameters, - EventParametersDeclaration, - ExperimentalFeature, - ExperimentalPragma, - Expression, - ExpressionStatement, - FallbackFunctionAttribute, - FallbackFunctionAttributes, - FallbackFunctionDefinition, - ForStatement, - ForStatementCondition, - ForStatementInitialization, - FunctionAttribute, - FunctionAttributes, - FunctionBody, - FunctionCallOptions, - FunctionDefinition, - FunctionName, - FunctionType, - FunctionTypeAttribute, - FunctionTypeAttributes, - HexNumberExpression, - HexStringLiterals, - IdentifierPath, - IfStatement, - ImportAlias, - ImportClause, - ImportDeconstruction, - ImportDeconstructionSymbol, - ImportDeconstructionSymbols, - ImportDirective, - IndexAccessEnd, - InheritanceSpecifier, - InheritanceType, - InheritanceTypes, - InterfaceDefinition, - InterfaceMembers, - LeadingTrivia, - LibraryDefinition, - LibraryMembers, - MappingKey, - MappingKeyType, - MappingType, - MappingValue, - MemberAccess, - ModifierAttribute, - ModifierAttributes, - ModifierDefinition, - ModifierInvocation, - NamedArgument, - NamedArgumentGroup, - NamedArgumentGroups, - NamedArguments, - NamedArgumentsDeclaration, - NamedImport, - NewExpression, - NumberUnit, - OverridePaths, - OverridePathsDeclaration, - OverrideSpecifier, - Parameter, - Parameters, - ParametersDeclaration, - PathImport, - PositionalArguments, - PositionalArgumentsDeclaration, - Pragma, - PragmaDirective, - ReceiveFunctionAttribute, - ReceiveFunctionAttributes, - ReceiveFunctionDefinition, - ReturnStatement, - ReturnsDeclaration, - RevertStatement, - SourceUnit, - SourceUnitMember, - SourceUnitMembers, - StateVariableAttribute, - StateVariableAttributes, - StateVariableDefinition, - StateVariableDefinitionValue, - Statement, - Statements, - StorageLocation, - StringExpression, - StructDefinition, - StructMember, - StructMembers, - ThrowStatement, - TrailingTrivia, - TryStatement, - TupleDeconstructionElement, - TupleDeconstructionElements, - TupleDeconstructionStatement, - TupleExpression, - TupleMember, - TupleValue, - TupleValues, - TypeExpression, - TypeName, - TypedTupleMember, - UncheckedBlock, - UnicodeStringLiterals, - UnnamedFunctionAttribute, - UnnamedFunctionAttributes, - UnnamedFunctionDefinition, - UntypedTupleMember, - UserDefinedValueTypeDefinition, - UsingAlias, - UsingClause, - UsingDeconstruction, - UsingDeconstructionSymbol, - UsingDeconstructionSymbols, - UsingDirective, - UsingOperator, - UsingTarget, - VariableDeclarationStatement, - VariableDeclarationType, - VariableDeclarationValue, - VersionPragma, - VersionPragmaExpression, - VersionPragmaExpressions, - VersionPragmaSpecifier, - WhileStatement, - YulArguments, - YulAssignmentStatement, - YulBlock, - YulBreakStatement, - YulContinueStatement, - YulDefaultCase, - YulExpression, - YulForStatement, - YulFunctionDefinition, - YulIdentifierPath, - YulIdentifierPaths, - YulIfStatement, - YulLeaveStatement, - YulLiteral, - YulParameters, - YulParametersDeclaration, - YulReturnVariables, - YulReturnsDeclaration, - YulStatement, - YulStatements, - YulSwitchCase, - YulSwitchCases, - YulSwitchStatement, - YulValueCase, - YulVariableDeclarationStatement, - YulVariableDeclarationValue, -} - #[derive( Debug, Eq, diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index 4c862493a2..d67c0e8aff 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -15,7 +15,7 @@ use {napi::bindgen_prelude::*, napi_derive::napi}; use semver::Version; use super::{ - kinds::{IsLexicalContext, LexicalContextType, ProductionKind, RuleKind, TokenKind}, + kinds::{IsLexicalContext, LexicalContextType, RuleKind, TokenKind}, lexer::Lexer, parse_output::ParseOutput, support::{ @@ -8427,291 +8427,260 @@ impl Language { } } - pub fn parse(&self, production_kind: ProductionKind, input: &str) -> ParseOutput { - match production_kind { - ProductionKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), - ProductionKind::AddressType => Self::address_type.parse(self, input), - ProductionKind::ArgumentsDeclaration => Self::arguments_declaration.parse(self, input), - ProductionKind::ArrayExpression => Self::array_expression.parse(self, input), - ProductionKind::ArrayValues => Self::array_values.parse(self, input), - ProductionKind::AsciiStringLiterals => Self::ascii_string_literals.parse(self, input), - ProductionKind::AssemblyFlags => Self::assembly_flags.parse(self, input), - ProductionKind::AssemblyFlagsDeclaration => { + pub fn parse(&self, kind: RuleKind, input: &str) -> ParseOutput { + match kind { + RuleKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), + RuleKind::AddressType => Self::address_type.parse(self, input), + RuleKind::ArgumentsDeclaration => Self::arguments_declaration.parse(self, input), + RuleKind::ArrayExpression => Self::array_expression.parse(self, input), + RuleKind::ArrayValues => Self::array_values.parse(self, input), + RuleKind::AsciiStringLiterals => Self::ascii_string_literals.parse(self, input), + RuleKind::AssemblyFlags => Self::assembly_flags.parse(self, input), + RuleKind::AssemblyFlagsDeclaration => { Self::assembly_flags_declaration.parse(self, input) } - ProductionKind::AssemblyStatement => Self::assembly_statement.parse(self, input), - ProductionKind::Block => Self::block.parse(self, input), - ProductionKind::BreakStatement => Self::break_statement.parse(self, input), - ProductionKind::CatchClause => Self::catch_clause.parse(self, input), - ProductionKind::CatchClauseError => Self::catch_clause_error.parse(self, input), - ProductionKind::CatchClauses => Self::catch_clauses.parse(self, input), - ProductionKind::ConstantDefinition => Self::constant_definition.parse(self, input), - ProductionKind::ConstructorAttribute => Self::constructor_attribute.parse(self, input), - ProductionKind::ConstructorAttributes => { - Self::constructor_attributes.parse(self, input) - } - ProductionKind::ConstructorDefinition => { - Self::constructor_definition.parse(self, input) - } - ProductionKind::ContinueStatement => Self::continue_statement.parse(self, input), - ProductionKind::ContractDefinition => Self::contract_definition.parse(self, input), - ProductionKind::ContractMember => Self::contract_member.parse(self, input), - ProductionKind::ContractMembers => Self::contract_members.parse(self, input), - ProductionKind::DecimalNumberExpression => { - Self::decimal_number_expression.parse(self, input) - } - ProductionKind::DeleteStatement => Self::delete_statement.parse(self, input), - ProductionKind::DoWhileStatement => Self::do_while_statement.parse(self, input), - ProductionKind::ElementaryType => Self::elementary_type.parse(self, input), - ProductionKind::ElseBranch => Self::else_branch.parse(self, input), - ProductionKind::EmitStatement => Self::emit_statement.parse(self, input), - ProductionKind::EndOfFileTrivia => Self::end_of_file_trivia.parse(self, input), - ProductionKind::EnumDefinition => Self::enum_definition.parse(self, input), - ProductionKind::EnumMembers => Self::enum_members.parse(self, input), - ProductionKind::ErrorDefinition => Self::error_definition.parse(self, input), - ProductionKind::ErrorParameter => Self::error_parameter.parse(self, input), - ProductionKind::ErrorParameters => Self::error_parameters.parse(self, input), - ProductionKind::ErrorParametersDeclaration => { + RuleKind::AssemblyStatement => Self::assembly_statement.parse(self, input), + RuleKind::Block => Self::block.parse(self, input), + RuleKind::BreakStatement => Self::break_statement.parse(self, input), + RuleKind::CatchClause => Self::catch_clause.parse(self, input), + RuleKind::CatchClauseError => Self::catch_clause_error.parse(self, input), + RuleKind::CatchClauses => Self::catch_clauses.parse(self, input), + RuleKind::ConstantDefinition => Self::constant_definition.parse(self, input), + RuleKind::ConstructorAttribute => Self::constructor_attribute.parse(self, input), + RuleKind::ConstructorAttributes => Self::constructor_attributes.parse(self, input), + RuleKind::ConstructorDefinition => Self::constructor_definition.parse(self, input), + RuleKind::ContinueStatement => Self::continue_statement.parse(self, input), + RuleKind::ContractDefinition => Self::contract_definition.parse(self, input), + RuleKind::ContractMember => Self::contract_member.parse(self, input), + RuleKind::ContractMembers => Self::contract_members.parse(self, input), + RuleKind::DecimalNumberExpression => Self::decimal_number_expression.parse(self, input), + RuleKind::DeleteStatement => Self::delete_statement.parse(self, input), + RuleKind::DoWhileStatement => Self::do_while_statement.parse(self, input), + RuleKind::ElementaryType => Self::elementary_type.parse(self, input), + RuleKind::ElseBranch => Self::else_branch.parse(self, input), + RuleKind::EmitStatement => Self::emit_statement.parse(self, input), + RuleKind::EndOfFileTrivia => Self::end_of_file_trivia.parse(self, input), + RuleKind::EnumDefinition => Self::enum_definition.parse(self, input), + RuleKind::EnumMembers => Self::enum_members.parse(self, input), + RuleKind::ErrorDefinition => Self::error_definition.parse(self, input), + RuleKind::ErrorParameter => Self::error_parameter.parse(self, input), + RuleKind::ErrorParameters => Self::error_parameters.parse(self, input), + RuleKind::ErrorParametersDeclaration => { Self::error_parameters_declaration.parse(self, input) } - ProductionKind::EventDefinition => Self::event_definition.parse(self, input), - ProductionKind::EventParameter => Self::event_parameter.parse(self, input), - ProductionKind::EventParameters => Self::event_parameters.parse(self, input), - ProductionKind::EventParametersDeclaration => { + RuleKind::EventDefinition => Self::event_definition.parse(self, input), + RuleKind::EventParameter => Self::event_parameter.parse(self, input), + RuleKind::EventParameters => Self::event_parameters.parse(self, input), + RuleKind::EventParametersDeclaration => { Self::event_parameters_declaration.parse(self, input) } - ProductionKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), - ProductionKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), - ProductionKind::Expression => Self::expression.parse(self, input), - ProductionKind::ExpressionStatement => Self::expression_statement.parse(self, input), - ProductionKind::FallbackFunctionAttribute => { + RuleKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), + RuleKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), + RuleKind::Expression => Self::expression.parse(self, input), + RuleKind::ExpressionStatement => Self::expression_statement.parse(self, input), + RuleKind::FallbackFunctionAttribute => { Self::fallback_function_attribute.parse(self, input) } - ProductionKind::FallbackFunctionAttributes => { + RuleKind::FallbackFunctionAttributes => { Self::fallback_function_attributes.parse(self, input) } - ProductionKind::FallbackFunctionDefinition => { + RuleKind::FallbackFunctionDefinition => { Self::fallback_function_definition.parse(self, input) } - ProductionKind::ForStatement => Self::for_statement.parse(self, input), - ProductionKind::ForStatementCondition => { - Self::for_statement_condition.parse(self, input) - } - ProductionKind::ForStatementInitialization => { + RuleKind::ForStatement => Self::for_statement.parse(self, input), + RuleKind::ForStatementCondition => Self::for_statement_condition.parse(self, input), + RuleKind::ForStatementInitialization => { Self::for_statement_initialization.parse(self, input) } - ProductionKind::FunctionAttribute => Self::function_attribute.parse(self, input), - ProductionKind::FunctionAttributes => Self::function_attributes.parse(self, input), - ProductionKind::FunctionBody => Self::function_body.parse(self, input), - ProductionKind::FunctionCallOptions => Self::function_call_options.parse(self, input), - ProductionKind::FunctionDefinition => Self::function_definition.parse(self, input), - ProductionKind::FunctionName => Self::function_name.parse(self, input), - ProductionKind::FunctionType => Self::function_type.parse(self, input), - ProductionKind::FunctionTypeAttribute => { - Self::function_type_attribute.parse(self, input) - } - ProductionKind::FunctionTypeAttributes => { - Self::function_type_attributes.parse(self, input) - } - ProductionKind::HexNumberExpression => Self::hex_number_expression.parse(self, input), - ProductionKind::HexStringLiterals => Self::hex_string_literals.parse(self, input), - ProductionKind::IdentifierPath => Self::identifier_path.parse(self, input), - ProductionKind::IfStatement => Self::if_statement.parse(self, input), - ProductionKind::ImportAlias => Self::import_alias.parse(self, input), - ProductionKind::ImportClause => Self::import_clause.parse(self, input), - ProductionKind::ImportDeconstruction => Self::import_deconstruction.parse(self, input), - ProductionKind::ImportDeconstructionSymbol => { + RuleKind::FunctionAttribute => Self::function_attribute.parse(self, input), + RuleKind::FunctionAttributes => Self::function_attributes.parse(self, input), + RuleKind::FunctionBody => Self::function_body.parse(self, input), + RuleKind::FunctionCallOptions => Self::function_call_options.parse(self, input), + RuleKind::FunctionDefinition => Self::function_definition.parse(self, input), + RuleKind::FunctionName => Self::function_name.parse(self, input), + RuleKind::FunctionType => Self::function_type.parse(self, input), + RuleKind::FunctionTypeAttribute => Self::function_type_attribute.parse(self, input), + RuleKind::FunctionTypeAttributes => Self::function_type_attributes.parse(self, input), + RuleKind::HexNumberExpression => Self::hex_number_expression.parse(self, input), + RuleKind::HexStringLiterals => Self::hex_string_literals.parse(self, input), + RuleKind::IdentifierPath => Self::identifier_path.parse(self, input), + RuleKind::IfStatement => Self::if_statement.parse(self, input), + RuleKind::ImportAlias => Self::import_alias.parse(self, input), + RuleKind::ImportClause => Self::import_clause.parse(self, input), + RuleKind::ImportDeconstruction => Self::import_deconstruction.parse(self, input), + RuleKind::ImportDeconstructionSymbol => { Self::import_deconstruction_symbol.parse(self, input) } - ProductionKind::ImportDeconstructionSymbols => { + RuleKind::ImportDeconstructionSymbols => { Self::import_deconstruction_symbols.parse(self, input) } - ProductionKind::ImportDirective => Self::import_directive.parse(self, input), - ProductionKind::IndexAccessEnd => Self::index_access_end.parse(self, input), - ProductionKind::InheritanceSpecifier => Self::inheritance_specifier.parse(self, input), - ProductionKind::InheritanceType => Self::inheritance_type.parse(self, input), - ProductionKind::InheritanceTypes => Self::inheritance_types.parse(self, input), - ProductionKind::InterfaceDefinition => Self::interface_definition.parse(self, input), - ProductionKind::InterfaceMembers => Self::interface_members.parse(self, input), - ProductionKind::LeadingTrivia => Self::leading_trivia.parse(self, input), - ProductionKind::LibraryDefinition => Self::library_definition.parse(self, input), - ProductionKind::LibraryMembers => Self::library_members.parse(self, input), - ProductionKind::MappingKey => Self::mapping_key.parse(self, input), - ProductionKind::MappingKeyType => Self::mapping_key_type.parse(self, input), - ProductionKind::MappingType => Self::mapping_type.parse(self, input), - ProductionKind::MappingValue => Self::mapping_value.parse(self, input), - ProductionKind::MemberAccess => Self::member_access.parse(self, input), - ProductionKind::ModifierAttribute => Self::modifier_attribute.parse(self, input), - ProductionKind::ModifierAttributes => Self::modifier_attributes.parse(self, input), - ProductionKind::ModifierDefinition => Self::modifier_definition.parse(self, input), - ProductionKind::ModifierInvocation => Self::modifier_invocation.parse(self, input), - ProductionKind::NamedArgument => Self::named_argument.parse(self, input), - ProductionKind::NamedArgumentGroup => Self::named_argument_group.parse(self, input), - ProductionKind::NamedArgumentGroups => Self::named_argument_groups.parse(self, input), - ProductionKind::NamedArguments => Self::named_arguments.parse(self, input), - ProductionKind::NamedArgumentsDeclaration => { + RuleKind::ImportDirective => Self::import_directive.parse(self, input), + RuleKind::IndexAccessEnd => Self::index_access_end.parse(self, input), + RuleKind::InheritanceSpecifier => Self::inheritance_specifier.parse(self, input), + RuleKind::InheritanceType => Self::inheritance_type.parse(self, input), + RuleKind::InheritanceTypes => Self::inheritance_types.parse(self, input), + RuleKind::InterfaceDefinition => Self::interface_definition.parse(self, input), + RuleKind::InterfaceMembers => Self::interface_members.parse(self, input), + RuleKind::LeadingTrivia => Self::leading_trivia.parse(self, input), + RuleKind::LibraryDefinition => Self::library_definition.parse(self, input), + RuleKind::LibraryMembers => Self::library_members.parse(self, input), + RuleKind::MappingKey => Self::mapping_key.parse(self, input), + RuleKind::MappingKeyType => Self::mapping_key_type.parse(self, input), + RuleKind::MappingType => Self::mapping_type.parse(self, input), + RuleKind::MappingValue => Self::mapping_value.parse(self, input), + RuleKind::MemberAccess => Self::member_access.parse(self, input), + RuleKind::ModifierAttribute => Self::modifier_attribute.parse(self, input), + RuleKind::ModifierAttributes => Self::modifier_attributes.parse(self, input), + RuleKind::ModifierDefinition => Self::modifier_definition.parse(self, input), + RuleKind::ModifierInvocation => Self::modifier_invocation.parse(self, input), + RuleKind::NamedArgument => Self::named_argument.parse(self, input), + RuleKind::NamedArgumentGroup => Self::named_argument_group.parse(self, input), + RuleKind::NamedArgumentGroups => Self::named_argument_groups.parse(self, input), + RuleKind::NamedArguments => Self::named_arguments.parse(self, input), + RuleKind::NamedArgumentsDeclaration => { Self::named_arguments_declaration.parse(self, input) } - ProductionKind::NamedImport => Self::named_import.parse(self, input), - ProductionKind::NewExpression => Self::new_expression.parse(self, input), - ProductionKind::NumberUnit => Self::number_unit.parse(self, input), - ProductionKind::OverridePaths => Self::override_paths.parse(self, input), - ProductionKind::OverridePathsDeclaration => { + RuleKind::NamedImport => Self::named_import.parse(self, input), + RuleKind::NewExpression => Self::new_expression.parse(self, input), + RuleKind::NumberUnit => Self::number_unit.parse(self, input), + RuleKind::OverridePaths => Self::override_paths.parse(self, input), + RuleKind::OverridePathsDeclaration => { Self::override_paths_declaration.parse(self, input) } - ProductionKind::OverrideSpecifier => Self::override_specifier.parse(self, input), - ProductionKind::Parameter => Self::parameter.parse(self, input), - ProductionKind::Parameters => Self::parameters.parse(self, input), - ProductionKind::ParametersDeclaration => { - Self::parameters_declaration.parse(self, input) - } - ProductionKind::PathImport => Self::path_import.parse(self, input), - ProductionKind::PositionalArguments => Self::positional_arguments.parse(self, input), - ProductionKind::PositionalArgumentsDeclaration => { + RuleKind::OverrideSpecifier => Self::override_specifier.parse(self, input), + RuleKind::Parameter => Self::parameter.parse(self, input), + RuleKind::Parameters => Self::parameters.parse(self, input), + RuleKind::ParametersDeclaration => Self::parameters_declaration.parse(self, input), + RuleKind::PathImport => Self::path_import.parse(self, input), + RuleKind::PositionalArguments => Self::positional_arguments.parse(self, input), + RuleKind::PositionalArgumentsDeclaration => { Self::positional_arguments_declaration.parse(self, input) } - ProductionKind::Pragma => Self::pragma.parse(self, input), - ProductionKind::PragmaDirective => Self::pragma_directive.parse(self, input), - ProductionKind::ReceiveFunctionAttribute => { + RuleKind::Pragma => Self::pragma.parse(self, input), + RuleKind::PragmaDirective => Self::pragma_directive.parse(self, input), + RuleKind::ReceiveFunctionAttribute => { Self::receive_function_attribute.parse(self, input) } - ProductionKind::ReceiveFunctionAttributes => { + RuleKind::ReceiveFunctionAttributes => { Self::receive_function_attributes.parse(self, input) } - ProductionKind::ReceiveFunctionDefinition => { + RuleKind::ReceiveFunctionDefinition => { Self::receive_function_definition.parse(self, input) } - ProductionKind::ReturnStatement => Self::return_statement.parse(self, input), - ProductionKind::ReturnsDeclaration => Self::returns_declaration.parse(self, input), - ProductionKind::RevertStatement => Self::revert_statement.parse(self, input), - ProductionKind::SourceUnit => Self::source_unit.parse(self, input), - ProductionKind::SourceUnitMember => Self::source_unit_member.parse(self, input), - ProductionKind::SourceUnitMembers => Self::source_unit_members.parse(self, input), - ProductionKind::StateVariableAttribute => { - Self::state_variable_attribute.parse(self, input) - } - ProductionKind::StateVariableAttributes => { - Self::state_variable_attributes.parse(self, input) - } - ProductionKind::StateVariableDefinition => { - Self::state_variable_definition.parse(self, input) - } - ProductionKind::StateVariableDefinitionValue => { + RuleKind::ReturnStatement => Self::return_statement.parse(self, input), + RuleKind::ReturnsDeclaration => Self::returns_declaration.parse(self, input), + RuleKind::RevertStatement => Self::revert_statement.parse(self, input), + RuleKind::SourceUnit => Self::source_unit.parse(self, input), + RuleKind::SourceUnitMember => Self::source_unit_member.parse(self, input), + RuleKind::SourceUnitMembers => Self::source_unit_members.parse(self, input), + RuleKind::StateVariableAttribute => Self::state_variable_attribute.parse(self, input), + RuleKind::StateVariableAttributes => Self::state_variable_attributes.parse(self, input), + RuleKind::StateVariableDefinition => Self::state_variable_definition.parse(self, input), + RuleKind::StateVariableDefinitionValue => { Self::state_variable_definition_value.parse(self, input) } - ProductionKind::Statement => Self::statement.parse(self, input), - ProductionKind::Statements => Self::statements.parse(self, input), - ProductionKind::StorageLocation => Self::storage_location.parse(self, input), - ProductionKind::StringExpression => Self::string_expression.parse(self, input), - ProductionKind::StructDefinition => Self::struct_definition.parse(self, input), - ProductionKind::StructMember => Self::struct_member.parse(self, input), - ProductionKind::StructMembers => Self::struct_members.parse(self, input), - ProductionKind::ThrowStatement => Self::throw_statement.parse(self, input), - ProductionKind::TrailingTrivia => Self::trailing_trivia.parse(self, input), - ProductionKind::TryStatement => Self::try_statement.parse(self, input), - ProductionKind::TupleDeconstructionElement => { + RuleKind::Statement => Self::statement.parse(self, input), + RuleKind::Statements => Self::statements.parse(self, input), + RuleKind::StorageLocation => Self::storage_location.parse(self, input), + RuleKind::StringExpression => Self::string_expression.parse(self, input), + RuleKind::StructDefinition => Self::struct_definition.parse(self, input), + RuleKind::StructMember => Self::struct_member.parse(self, input), + RuleKind::StructMembers => Self::struct_members.parse(self, input), + RuleKind::ThrowStatement => Self::throw_statement.parse(self, input), + RuleKind::TrailingTrivia => Self::trailing_trivia.parse(self, input), + RuleKind::TryStatement => Self::try_statement.parse(self, input), + RuleKind::TupleDeconstructionElement => { Self::tuple_deconstruction_element.parse(self, input) } - ProductionKind::TupleDeconstructionElements => { + RuleKind::TupleDeconstructionElements => { Self::tuple_deconstruction_elements.parse(self, input) } - ProductionKind::TupleDeconstructionStatement => { + RuleKind::TupleDeconstructionStatement => { Self::tuple_deconstruction_statement.parse(self, input) } - ProductionKind::TupleExpression => Self::tuple_expression.parse(self, input), - ProductionKind::TupleMember => Self::tuple_member.parse(self, input), - ProductionKind::TupleValue => Self::tuple_value.parse(self, input), - ProductionKind::TupleValues => Self::tuple_values.parse(self, input), - ProductionKind::TypeExpression => Self::type_expression.parse(self, input), - ProductionKind::TypeName => Self::type_name.parse(self, input), - ProductionKind::TypedTupleMember => Self::typed_tuple_member.parse(self, input), - ProductionKind::UncheckedBlock => Self::unchecked_block.parse(self, input), - ProductionKind::UnicodeStringLiterals => { - Self::unicode_string_literals.parse(self, input) - } - ProductionKind::UnnamedFunctionAttribute => { + RuleKind::TupleExpression => Self::tuple_expression.parse(self, input), + RuleKind::TupleMember => Self::tuple_member.parse(self, input), + RuleKind::TupleValue => Self::tuple_value.parse(self, input), + RuleKind::TupleValues => Self::tuple_values.parse(self, input), + RuleKind::TypeExpression => Self::type_expression.parse(self, input), + RuleKind::TypeName => Self::type_name.parse(self, input), + RuleKind::TypedTupleMember => Self::typed_tuple_member.parse(self, input), + RuleKind::UncheckedBlock => Self::unchecked_block.parse(self, input), + RuleKind::UnicodeStringLiterals => Self::unicode_string_literals.parse(self, input), + RuleKind::UnnamedFunctionAttribute => { Self::unnamed_function_attribute.parse(self, input) } - ProductionKind::UnnamedFunctionAttributes => { + RuleKind::UnnamedFunctionAttributes => { Self::unnamed_function_attributes.parse(self, input) } - ProductionKind::UnnamedFunctionDefinition => { + RuleKind::UnnamedFunctionDefinition => { Self::unnamed_function_definition.parse(self, input) } - ProductionKind::UntypedTupleMember => Self::untyped_tuple_member.parse(self, input), - ProductionKind::UserDefinedValueTypeDefinition => { + RuleKind::UntypedTupleMember => Self::untyped_tuple_member.parse(self, input), + RuleKind::UserDefinedValueTypeDefinition => { Self::user_defined_value_type_definition.parse(self, input) } - ProductionKind::UsingAlias => Self::using_alias.parse(self, input), - ProductionKind::UsingClause => Self::using_clause.parse(self, input), - ProductionKind::UsingDeconstruction => Self::using_deconstruction.parse(self, input), - ProductionKind::UsingDeconstructionSymbol => { + RuleKind::UsingAlias => Self::using_alias.parse(self, input), + RuleKind::UsingClause => Self::using_clause.parse(self, input), + RuleKind::UsingDeconstruction => Self::using_deconstruction.parse(self, input), + RuleKind::UsingDeconstructionSymbol => { Self::using_deconstruction_symbol.parse(self, input) } - ProductionKind::UsingDeconstructionSymbols => { + RuleKind::UsingDeconstructionSymbols => { Self::using_deconstruction_symbols.parse(self, input) } - ProductionKind::UsingDirective => Self::using_directive.parse(self, input), - ProductionKind::UsingOperator => Self::using_operator.parse(self, input), - ProductionKind::UsingTarget => Self::using_target.parse(self, input), - ProductionKind::VariableDeclarationStatement => { + RuleKind::UsingDirective => Self::using_directive.parse(self, input), + RuleKind::UsingOperator => Self::using_operator.parse(self, input), + RuleKind::UsingTarget => Self::using_target.parse(self, input), + RuleKind::VariableDeclarationStatement => { Self::variable_declaration_statement.parse(self, input) } - ProductionKind::VariableDeclarationType => { - Self::variable_declaration_type.parse(self, input) - } - ProductionKind::VariableDeclarationValue => { + RuleKind::VariableDeclarationType => Self::variable_declaration_type.parse(self, input), + RuleKind::VariableDeclarationValue => { Self::variable_declaration_value.parse(self, input) } - ProductionKind::VersionPragma => Self::version_pragma.parse(self, input), - ProductionKind::VersionPragmaExpression => { - Self::version_pragma_expression.parse(self, input) - } - ProductionKind::VersionPragmaExpressions => { + RuleKind::VersionPragma => Self::version_pragma.parse(self, input), + RuleKind::VersionPragmaExpression => Self::version_pragma_expression.parse(self, input), + RuleKind::VersionPragmaExpressions => { Self::version_pragma_expressions.parse(self, input) } - ProductionKind::VersionPragmaSpecifier => { - Self::version_pragma_specifier.parse(self, input) - } - ProductionKind::WhileStatement => Self::while_statement.parse(self, input), - ProductionKind::YulArguments => Self::yul_arguments.parse(self, input), - ProductionKind::YulAssignmentStatement => { - Self::yul_assignment_statement.parse(self, input) - } - ProductionKind::YulBlock => Self::yul_block.parse(self, input), - ProductionKind::YulBreakStatement => Self::yul_break_statement.parse(self, input), - ProductionKind::YulContinueStatement => Self::yul_continue_statement.parse(self, input), - ProductionKind::YulDefaultCase => Self::yul_default_case.parse(self, input), - ProductionKind::YulExpression => Self::yul_expression.parse(self, input), - ProductionKind::YulForStatement => Self::yul_for_statement.parse(self, input), - ProductionKind::YulFunctionDefinition => { - Self::yul_function_definition.parse(self, input) - } - ProductionKind::YulIdentifierPath => Self::yul_identifier_path.parse(self, input), - ProductionKind::YulIdentifierPaths => Self::yul_identifier_paths.parse(self, input), - ProductionKind::YulIfStatement => Self::yul_if_statement.parse(self, input), - ProductionKind::YulLeaveStatement => Self::yul_leave_statement.parse(self, input), - ProductionKind::YulLiteral => Self::yul_literal.parse(self, input), - ProductionKind::YulParameters => Self::yul_parameters.parse(self, input), - ProductionKind::YulParametersDeclaration => { + RuleKind::VersionPragmaSpecifier => Self::version_pragma_specifier.parse(self, input), + RuleKind::WhileStatement => Self::while_statement.parse(self, input), + RuleKind::YulArguments => Self::yul_arguments.parse(self, input), + RuleKind::YulAssignmentStatement => Self::yul_assignment_statement.parse(self, input), + RuleKind::YulBlock => Self::yul_block.parse(self, input), + RuleKind::YulBreakStatement => Self::yul_break_statement.parse(self, input), + RuleKind::YulContinueStatement => Self::yul_continue_statement.parse(self, input), + RuleKind::YulDefaultCase => Self::yul_default_case.parse(self, input), + RuleKind::YulExpression => Self::yul_expression.parse(self, input), + RuleKind::YulForStatement => Self::yul_for_statement.parse(self, input), + RuleKind::YulFunctionDefinition => Self::yul_function_definition.parse(self, input), + RuleKind::YulIdentifierPath => Self::yul_identifier_path.parse(self, input), + RuleKind::YulIdentifierPaths => Self::yul_identifier_paths.parse(self, input), + RuleKind::YulIfStatement => Self::yul_if_statement.parse(self, input), + RuleKind::YulLeaveStatement => Self::yul_leave_statement.parse(self, input), + RuleKind::YulLiteral => Self::yul_literal.parse(self, input), + RuleKind::YulParameters => Self::yul_parameters.parse(self, input), + RuleKind::YulParametersDeclaration => { Self::yul_parameters_declaration.parse(self, input) } - ProductionKind::YulReturnVariables => Self::yul_return_variables.parse(self, input), - ProductionKind::YulReturnsDeclaration => { - Self::yul_returns_declaration.parse(self, input) - } - ProductionKind::YulStatement => Self::yul_statement.parse(self, input), - ProductionKind::YulStatements => Self::yul_statements.parse(self, input), - ProductionKind::YulSwitchCase => Self::yul_switch_case.parse(self, input), - ProductionKind::YulSwitchCases => Self::yul_switch_cases.parse(self, input), - ProductionKind::YulSwitchStatement => Self::yul_switch_statement.parse(self, input), - ProductionKind::YulValueCase => Self::yul_value_case.parse(self, input), - ProductionKind::YulVariableDeclarationStatement => { + RuleKind::YulReturnVariables => Self::yul_return_variables.parse(self, input), + RuleKind::YulReturnsDeclaration => Self::yul_returns_declaration.parse(self, input), + RuleKind::YulStatement => Self::yul_statement.parse(self, input), + RuleKind::YulStatements => Self::yul_statements.parse(self, input), + RuleKind::YulSwitchCase => Self::yul_switch_case.parse(self, input), + RuleKind::YulSwitchCases => Self::yul_switch_cases.parse(self, input), + RuleKind::YulSwitchStatement => Self::yul_switch_statement.parse(self, input), + RuleKind::YulValueCase => Self::yul_value_case.parse(self, input), + RuleKind::YulVariableDeclarationStatement => { Self::yul_variable_declaration_statement.parse(self, input) } - ProductionKind::YulVariableDeclarationValue => { + RuleKind::YulVariableDeclarationValue => { Self::yul_variable_declaration_value.parse(self, input) - } + } // TODO(#638): Expose parsing individual operators + _ => unimplemented!( + "Parsing individual precedence operators is not supported at the moment" + ), } } } @@ -10963,9 +10932,9 @@ impl Language { #[napi(js_name = "parse", ts_return_type = "parse_output.ParseOutput")] pub fn parse_napi( &self, - #[napi(ts_arg_type = "kinds.ProductionKind")] production_kind: ProductionKind, + #[napi(ts_arg_type = "kinds.RuleKind")] kind: RuleKind, input: String, ) -> NAPIParseOutput { - self.parse(production_kind, input.as_str()).into() + self.parse(kind, input.as_str()).into() } } diff --git a/crates/solidity/outputs/cargo/crate/src/main.rs b/crates/solidity/outputs/cargo/crate/src/main.rs index 54d31402e2..1b6f94a5c7 100644 --- a/crates/solidity/outputs/cargo/crate/src/main.rs +++ b/crates/solidity/outputs/cargo/crate/src/main.rs @@ -3,7 +3,7 @@ use std::{fs, path::PathBuf, process::ExitCode}; use anyhow::{Context, Result}; use clap::{Parser as ClapParser, Subcommand}; use semver::Version; -use slang_solidity::{kinds::ProductionKind, language::Language}; +use slang_solidity::{kinds::RuleKind, language::Language}; // Below are dependencies used by the API `lib.rs`, but not the CLI "main.rs". // However, we need to add a fake usage to suppress Cargo warnings about unused dependencies. @@ -59,7 +59,7 @@ fn execute_parse_command(file_path_string: &str, version: Version, json: bool) - let input = fs::read_to_string(file_path)?; let language = Language::new(version)?; - let output = language.parse(ProductionKind::SourceUnit, &input); + let output = language.parse(RuleKind::SourceUnit, &input); let errors = output.errors(); for error in errors { diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs index 12386de627..dc1c2ed6d2 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use anyhow::Result; use infra_utils::{cargo::CargoWorkspace, codegen::Codegen, paths::PathExtensions}; -use slang_solidity::{kinds::ProductionKind, language::Language}; +use slang_solidity::{kinds::RuleKind, language::Language}; use solidity_testing_utils::cst_snapshots::CstSnapshots; use strum_macros::Display; @@ -31,10 +31,10 @@ pub fn run(parser_name: &str, test_name: &str) -> Result<()> { let mut last_output = None; for version in VERSION_BREAKS { - let production_kind = ProductionKind::from_str(parser_name) + let rule_kind = RuleKind::from_str(parser_name) .unwrap_or_else(|_| panic!("No such parser: {parser_name}")); - let output = Language::new(version.clone())?.parse(production_kind, &source); + let output = Language::new(version.clone())?.parse(rule_kind, &source); let output = match last_output { // Skip this version if it produces the same output. diff --git a/crates/solidity/outputs/cargo/tests/src/doc_examples/cursor_api.rs b/crates/solidity/outputs/cargo/tests/src/doc_examples/cursor_api.rs index 67d1639b06..4f6f432dfe 100644 --- a/crates/solidity/outputs/cargo/tests/src/doc_examples/cursor_api.rs +++ b/crates/solidity/outputs/cargo/tests/src/doc_examples/cursor_api.rs @@ -2,7 +2,7 @@ use anyhow::Result; use semver::Version; use slang_solidity::{ - kinds::{ProductionKind, RuleKind, TokenKind}, + kinds::{RuleKind, TokenKind}, language::Language, }; @@ -15,7 +15,7 @@ const SOURCE: &str = " #[test] fn using_cursor_api() -> Result<()> { let language = Language::new(Version::parse("0.8.0")?)?; - let parse_output = language.parse(ProductionKind::SourceUnit, SOURCE); + let parse_output = language.parse(RuleKind::SourceUnit, SOURCE); let mut contract_names = Vec::new(); let mut cursor = parse_output.create_tree_cursor(); @@ -38,7 +38,7 @@ fn using_cursor_api() -> Result<()> { #[test] fn using_spawn() -> Result<()> { let language = Language::new(Version::parse("0.8.0")?)?; - let parse_output = language.parse(ProductionKind::SourceUnit, SOURCE); + let parse_output = language.parse(RuleKind::SourceUnit, SOURCE); let mut contract_names = Vec::new(); let mut cursor = parse_output.create_tree_cursor(); @@ -62,7 +62,7 @@ fn using_spawn() -> Result<()> { #[test] fn using_iter() -> Result<()> { let language = Language::new(Version::parse("0.8.0")?)?; - let parse_output = language.parse(ProductionKind::SourceUnit, SOURCE); + let parse_output = language.parse(RuleKind::SourceUnit, SOURCE); let mut contract_names = Vec::new(); let mut cursor = parse_output.create_tree_cursor(); @@ -87,7 +87,7 @@ fn using_iter() -> Result<()> { #[test] fn using_iter_combinators() -> Result<()> { let language = Language::new(Version::parse("0.8.0")?)?; - let parse_output = language.parse(ProductionKind::SourceUnit, SOURCE); + let parse_output = language.parse(RuleKind::SourceUnit, SOURCE); let contract_names: Vec<_> = parse_output .create_tree_cursor() diff --git a/crates/solidity/outputs/cargo/tests/src/doc_examples/simple_contract.rs b/crates/solidity/outputs/cargo/tests/src/doc_examples/simple_contract.rs index bdf1db4a34..5a8f4d7612 100644 --- a/crates/solidity/outputs/cargo/tests/src/doc_examples/simple_contract.rs +++ b/crates/solidity/outputs/cargo/tests/src/doc_examples/simple_contract.rs @@ -3,14 +3,14 @@ use semver::Version; use slang_solidity::{ cst::Node, - kinds::{ProductionKind, RuleKind, TokenKind}, + kinds::{RuleKind, TokenKind}, language::Language, }; #[test] fn simple_contract() -> Result<()> { let language = Language::new(Version::parse("0.8.0")?)?; - let parse_output = language.parse(ProductionKind::ContractDefinition, "contract Foo {}"); + let parse_output = language.parse(RuleKind::ContractDefinition, "contract Foo {}"); let parse_tree = parse_output.tree(); let rule = parse_tree diff --git a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs index f87c025206..185edf3e86 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs @@ -3,209 +3,6 @@ #[cfg(feature = "slang_napi_interfaces")] use {napi::bindgen_prelude::*, napi_derive::napi}; -#[derive( - Debug, - Eq, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, -)] -#[cfg_attr(feature = "slang_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "kinds"))] -#[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] -pub enum ProductionKind { - ABICoderPragma, - AddressType, - ArgumentsDeclaration, - ArrayExpression, - ArrayValues, - AsciiStringLiterals, - AssemblyFlags, - AssemblyFlagsDeclaration, - AssemblyStatement, - Block, - BreakStatement, - CatchClause, - CatchClauseError, - CatchClauses, - ConstantDefinition, - ConstructorAttribute, - ConstructorAttributes, - ConstructorDefinition, - ContinueStatement, - ContractDefinition, - ContractMember, - ContractMembers, - DecimalNumberExpression, - DeleteStatement, - DoWhileStatement, - ElementaryType, - ElseBranch, - EmitStatement, - EndOfFileTrivia, - EnumDefinition, - EnumMembers, - ErrorDefinition, - ErrorParameter, - ErrorParameters, - ErrorParametersDeclaration, - EventDefinition, - EventParameter, - EventParameters, - EventParametersDeclaration, - ExperimentalFeature, - ExperimentalPragma, - Expression, - ExpressionStatement, - FallbackFunctionAttribute, - FallbackFunctionAttributes, - FallbackFunctionDefinition, - ForStatement, - ForStatementCondition, - ForStatementInitialization, - FunctionAttribute, - FunctionAttributes, - FunctionBody, - FunctionCallOptions, - FunctionDefinition, - FunctionName, - FunctionType, - FunctionTypeAttribute, - FunctionTypeAttributes, - HexNumberExpression, - HexStringLiterals, - IdentifierPath, - IfStatement, - ImportAlias, - ImportClause, - ImportDeconstruction, - ImportDeconstructionSymbol, - ImportDeconstructionSymbols, - ImportDirective, - IndexAccessEnd, - InheritanceSpecifier, - InheritanceType, - InheritanceTypes, - InterfaceDefinition, - InterfaceMembers, - LeadingTrivia, - LibraryDefinition, - LibraryMembers, - MappingKey, - MappingKeyType, - MappingType, - MappingValue, - MemberAccess, - ModifierAttribute, - ModifierAttributes, - ModifierDefinition, - ModifierInvocation, - NamedArgument, - NamedArgumentGroup, - NamedArgumentGroups, - NamedArguments, - NamedArgumentsDeclaration, - NamedImport, - NewExpression, - NumberUnit, - OverridePaths, - OverridePathsDeclaration, - OverrideSpecifier, - Parameter, - Parameters, - ParametersDeclaration, - PathImport, - PositionalArguments, - PositionalArgumentsDeclaration, - Pragma, - PragmaDirective, - ReceiveFunctionAttribute, - ReceiveFunctionAttributes, - ReceiveFunctionDefinition, - ReturnStatement, - ReturnsDeclaration, - RevertStatement, - SourceUnit, - SourceUnitMember, - SourceUnitMembers, - StateVariableAttribute, - StateVariableAttributes, - StateVariableDefinition, - StateVariableDefinitionValue, - Statement, - Statements, - StorageLocation, - StringExpression, - StructDefinition, - StructMember, - StructMembers, - ThrowStatement, - TrailingTrivia, - TryStatement, - TupleDeconstructionElement, - TupleDeconstructionElements, - TupleDeconstructionStatement, - TupleExpression, - TupleMember, - TupleValue, - TupleValues, - TypeExpression, - TypeName, - TypedTupleMember, - UncheckedBlock, - UnicodeStringLiterals, - UnnamedFunctionAttribute, - UnnamedFunctionAttributes, - UnnamedFunctionDefinition, - UntypedTupleMember, - UserDefinedValueTypeDefinition, - UsingAlias, - UsingClause, - UsingDeconstruction, - UsingDeconstructionSymbol, - UsingDeconstructionSymbols, - UsingDirective, - UsingOperator, - UsingTarget, - VariableDeclarationStatement, - VariableDeclarationType, - VariableDeclarationValue, - VersionPragma, - VersionPragmaExpression, - VersionPragmaExpressions, - VersionPragmaSpecifier, - WhileStatement, - YulArguments, - YulAssignmentStatement, - YulBlock, - YulBreakStatement, - YulContinueStatement, - YulDefaultCase, - YulExpression, - YulForStatement, - YulFunctionDefinition, - YulIdentifierPath, - YulIdentifierPaths, - YulIfStatement, - YulLeaveStatement, - YulLiteral, - YulParameters, - YulParametersDeclaration, - YulReturnVariables, - YulReturnsDeclaration, - YulStatement, - YulStatements, - YulSwitchCase, - YulSwitchCases, - YulSwitchStatement, - YulValueCase, - YulVariableDeclarationStatement, - YulVariableDeclarationValue, -} - #[derive( Debug, Eq, diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index 4c862493a2..d67c0e8aff 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -15,7 +15,7 @@ use {napi::bindgen_prelude::*, napi_derive::napi}; use semver::Version; use super::{ - kinds::{IsLexicalContext, LexicalContextType, ProductionKind, RuleKind, TokenKind}, + kinds::{IsLexicalContext, LexicalContextType, RuleKind, TokenKind}, lexer::Lexer, parse_output::ParseOutput, support::{ @@ -8427,291 +8427,260 @@ impl Language { } } - pub fn parse(&self, production_kind: ProductionKind, input: &str) -> ParseOutput { - match production_kind { - ProductionKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), - ProductionKind::AddressType => Self::address_type.parse(self, input), - ProductionKind::ArgumentsDeclaration => Self::arguments_declaration.parse(self, input), - ProductionKind::ArrayExpression => Self::array_expression.parse(self, input), - ProductionKind::ArrayValues => Self::array_values.parse(self, input), - ProductionKind::AsciiStringLiterals => Self::ascii_string_literals.parse(self, input), - ProductionKind::AssemblyFlags => Self::assembly_flags.parse(self, input), - ProductionKind::AssemblyFlagsDeclaration => { + pub fn parse(&self, kind: RuleKind, input: &str) -> ParseOutput { + match kind { + RuleKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), + RuleKind::AddressType => Self::address_type.parse(self, input), + RuleKind::ArgumentsDeclaration => Self::arguments_declaration.parse(self, input), + RuleKind::ArrayExpression => Self::array_expression.parse(self, input), + RuleKind::ArrayValues => Self::array_values.parse(self, input), + RuleKind::AsciiStringLiterals => Self::ascii_string_literals.parse(self, input), + RuleKind::AssemblyFlags => Self::assembly_flags.parse(self, input), + RuleKind::AssemblyFlagsDeclaration => { Self::assembly_flags_declaration.parse(self, input) } - ProductionKind::AssemblyStatement => Self::assembly_statement.parse(self, input), - ProductionKind::Block => Self::block.parse(self, input), - ProductionKind::BreakStatement => Self::break_statement.parse(self, input), - ProductionKind::CatchClause => Self::catch_clause.parse(self, input), - ProductionKind::CatchClauseError => Self::catch_clause_error.parse(self, input), - ProductionKind::CatchClauses => Self::catch_clauses.parse(self, input), - ProductionKind::ConstantDefinition => Self::constant_definition.parse(self, input), - ProductionKind::ConstructorAttribute => Self::constructor_attribute.parse(self, input), - ProductionKind::ConstructorAttributes => { - Self::constructor_attributes.parse(self, input) - } - ProductionKind::ConstructorDefinition => { - Self::constructor_definition.parse(self, input) - } - ProductionKind::ContinueStatement => Self::continue_statement.parse(self, input), - ProductionKind::ContractDefinition => Self::contract_definition.parse(self, input), - ProductionKind::ContractMember => Self::contract_member.parse(self, input), - ProductionKind::ContractMembers => Self::contract_members.parse(self, input), - ProductionKind::DecimalNumberExpression => { - Self::decimal_number_expression.parse(self, input) - } - ProductionKind::DeleteStatement => Self::delete_statement.parse(self, input), - ProductionKind::DoWhileStatement => Self::do_while_statement.parse(self, input), - ProductionKind::ElementaryType => Self::elementary_type.parse(self, input), - ProductionKind::ElseBranch => Self::else_branch.parse(self, input), - ProductionKind::EmitStatement => Self::emit_statement.parse(self, input), - ProductionKind::EndOfFileTrivia => Self::end_of_file_trivia.parse(self, input), - ProductionKind::EnumDefinition => Self::enum_definition.parse(self, input), - ProductionKind::EnumMembers => Self::enum_members.parse(self, input), - ProductionKind::ErrorDefinition => Self::error_definition.parse(self, input), - ProductionKind::ErrorParameter => Self::error_parameter.parse(self, input), - ProductionKind::ErrorParameters => Self::error_parameters.parse(self, input), - ProductionKind::ErrorParametersDeclaration => { + RuleKind::AssemblyStatement => Self::assembly_statement.parse(self, input), + RuleKind::Block => Self::block.parse(self, input), + RuleKind::BreakStatement => Self::break_statement.parse(self, input), + RuleKind::CatchClause => Self::catch_clause.parse(self, input), + RuleKind::CatchClauseError => Self::catch_clause_error.parse(self, input), + RuleKind::CatchClauses => Self::catch_clauses.parse(self, input), + RuleKind::ConstantDefinition => Self::constant_definition.parse(self, input), + RuleKind::ConstructorAttribute => Self::constructor_attribute.parse(self, input), + RuleKind::ConstructorAttributes => Self::constructor_attributes.parse(self, input), + RuleKind::ConstructorDefinition => Self::constructor_definition.parse(self, input), + RuleKind::ContinueStatement => Self::continue_statement.parse(self, input), + RuleKind::ContractDefinition => Self::contract_definition.parse(self, input), + RuleKind::ContractMember => Self::contract_member.parse(self, input), + RuleKind::ContractMembers => Self::contract_members.parse(self, input), + RuleKind::DecimalNumberExpression => Self::decimal_number_expression.parse(self, input), + RuleKind::DeleteStatement => Self::delete_statement.parse(self, input), + RuleKind::DoWhileStatement => Self::do_while_statement.parse(self, input), + RuleKind::ElementaryType => Self::elementary_type.parse(self, input), + RuleKind::ElseBranch => Self::else_branch.parse(self, input), + RuleKind::EmitStatement => Self::emit_statement.parse(self, input), + RuleKind::EndOfFileTrivia => Self::end_of_file_trivia.parse(self, input), + RuleKind::EnumDefinition => Self::enum_definition.parse(self, input), + RuleKind::EnumMembers => Self::enum_members.parse(self, input), + RuleKind::ErrorDefinition => Self::error_definition.parse(self, input), + RuleKind::ErrorParameter => Self::error_parameter.parse(self, input), + RuleKind::ErrorParameters => Self::error_parameters.parse(self, input), + RuleKind::ErrorParametersDeclaration => { Self::error_parameters_declaration.parse(self, input) } - ProductionKind::EventDefinition => Self::event_definition.parse(self, input), - ProductionKind::EventParameter => Self::event_parameter.parse(self, input), - ProductionKind::EventParameters => Self::event_parameters.parse(self, input), - ProductionKind::EventParametersDeclaration => { + RuleKind::EventDefinition => Self::event_definition.parse(self, input), + RuleKind::EventParameter => Self::event_parameter.parse(self, input), + RuleKind::EventParameters => Self::event_parameters.parse(self, input), + RuleKind::EventParametersDeclaration => { Self::event_parameters_declaration.parse(self, input) } - ProductionKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), - ProductionKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), - ProductionKind::Expression => Self::expression.parse(self, input), - ProductionKind::ExpressionStatement => Self::expression_statement.parse(self, input), - ProductionKind::FallbackFunctionAttribute => { + RuleKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), + RuleKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), + RuleKind::Expression => Self::expression.parse(self, input), + RuleKind::ExpressionStatement => Self::expression_statement.parse(self, input), + RuleKind::FallbackFunctionAttribute => { Self::fallback_function_attribute.parse(self, input) } - ProductionKind::FallbackFunctionAttributes => { + RuleKind::FallbackFunctionAttributes => { Self::fallback_function_attributes.parse(self, input) } - ProductionKind::FallbackFunctionDefinition => { + RuleKind::FallbackFunctionDefinition => { Self::fallback_function_definition.parse(self, input) } - ProductionKind::ForStatement => Self::for_statement.parse(self, input), - ProductionKind::ForStatementCondition => { - Self::for_statement_condition.parse(self, input) - } - ProductionKind::ForStatementInitialization => { + RuleKind::ForStatement => Self::for_statement.parse(self, input), + RuleKind::ForStatementCondition => Self::for_statement_condition.parse(self, input), + RuleKind::ForStatementInitialization => { Self::for_statement_initialization.parse(self, input) } - ProductionKind::FunctionAttribute => Self::function_attribute.parse(self, input), - ProductionKind::FunctionAttributes => Self::function_attributes.parse(self, input), - ProductionKind::FunctionBody => Self::function_body.parse(self, input), - ProductionKind::FunctionCallOptions => Self::function_call_options.parse(self, input), - ProductionKind::FunctionDefinition => Self::function_definition.parse(self, input), - ProductionKind::FunctionName => Self::function_name.parse(self, input), - ProductionKind::FunctionType => Self::function_type.parse(self, input), - ProductionKind::FunctionTypeAttribute => { - Self::function_type_attribute.parse(self, input) - } - ProductionKind::FunctionTypeAttributes => { - Self::function_type_attributes.parse(self, input) - } - ProductionKind::HexNumberExpression => Self::hex_number_expression.parse(self, input), - ProductionKind::HexStringLiterals => Self::hex_string_literals.parse(self, input), - ProductionKind::IdentifierPath => Self::identifier_path.parse(self, input), - ProductionKind::IfStatement => Self::if_statement.parse(self, input), - ProductionKind::ImportAlias => Self::import_alias.parse(self, input), - ProductionKind::ImportClause => Self::import_clause.parse(self, input), - ProductionKind::ImportDeconstruction => Self::import_deconstruction.parse(self, input), - ProductionKind::ImportDeconstructionSymbol => { + RuleKind::FunctionAttribute => Self::function_attribute.parse(self, input), + RuleKind::FunctionAttributes => Self::function_attributes.parse(self, input), + RuleKind::FunctionBody => Self::function_body.parse(self, input), + RuleKind::FunctionCallOptions => Self::function_call_options.parse(self, input), + RuleKind::FunctionDefinition => Self::function_definition.parse(self, input), + RuleKind::FunctionName => Self::function_name.parse(self, input), + RuleKind::FunctionType => Self::function_type.parse(self, input), + RuleKind::FunctionTypeAttribute => Self::function_type_attribute.parse(self, input), + RuleKind::FunctionTypeAttributes => Self::function_type_attributes.parse(self, input), + RuleKind::HexNumberExpression => Self::hex_number_expression.parse(self, input), + RuleKind::HexStringLiterals => Self::hex_string_literals.parse(self, input), + RuleKind::IdentifierPath => Self::identifier_path.parse(self, input), + RuleKind::IfStatement => Self::if_statement.parse(self, input), + RuleKind::ImportAlias => Self::import_alias.parse(self, input), + RuleKind::ImportClause => Self::import_clause.parse(self, input), + RuleKind::ImportDeconstruction => Self::import_deconstruction.parse(self, input), + RuleKind::ImportDeconstructionSymbol => { Self::import_deconstruction_symbol.parse(self, input) } - ProductionKind::ImportDeconstructionSymbols => { + RuleKind::ImportDeconstructionSymbols => { Self::import_deconstruction_symbols.parse(self, input) } - ProductionKind::ImportDirective => Self::import_directive.parse(self, input), - ProductionKind::IndexAccessEnd => Self::index_access_end.parse(self, input), - ProductionKind::InheritanceSpecifier => Self::inheritance_specifier.parse(self, input), - ProductionKind::InheritanceType => Self::inheritance_type.parse(self, input), - ProductionKind::InheritanceTypes => Self::inheritance_types.parse(self, input), - ProductionKind::InterfaceDefinition => Self::interface_definition.parse(self, input), - ProductionKind::InterfaceMembers => Self::interface_members.parse(self, input), - ProductionKind::LeadingTrivia => Self::leading_trivia.parse(self, input), - ProductionKind::LibraryDefinition => Self::library_definition.parse(self, input), - ProductionKind::LibraryMembers => Self::library_members.parse(self, input), - ProductionKind::MappingKey => Self::mapping_key.parse(self, input), - ProductionKind::MappingKeyType => Self::mapping_key_type.parse(self, input), - ProductionKind::MappingType => Self::mapping_type.parse(self, input), - ProductionKind::MappingValue => Self::mapping_value.parse(self, input), - ProductionKind::MemberAccess => Self::member_access.parse(self, input), - ProductionKind::ModifierAttribute => Self::modifier_attribute.parse(self, input), - ProductionKind::ModifierAttributes => Self::modifier_attributes.parse(self, input), - ProductionKind::ModifierDefinition => Self::modifier_definition.parse(self, input), - ProductionKind::ModifierInvocation => Self::modifier_invocation.parse(self, input), - ProductionKind::NamedArgument => Self::named_argument.parse(self, input), - ProductionKind::NamedArgumentGroup => Self::named_argument_group.parse(self, input), - ProductionKind::NamedArgumentGroups => Self::named_argument_groups.parse(self, input), - ProductionKind::NamedArguments => Self::named_arguments.parse(self, input), - ProductionKind::NamedArgumentsDeclaration => { + RuleKind::ImportDirective => Self::import_directive.parse(self, input), + RuleKind::IndexAccessEnd => Self::index_access_end.parse(self, input), + RuleKind::InheritanceSpecifier => Self::inheritance_specifier.parse(self, input), + RuleKind::InheritanceType => Self::inheritance_type.parse(self, input), + RuleKind::InheritanceTypes => Self::inheritance_types.parse(self, input), + RuleKind::InterfaceDefinition => Self::interface_definition.parse(self, input), + RuleKind::InterfaceMembers => Self::interface_members.parse(self, input), + RuleKind::LeadingTrivia => Self::leading_trivia.parse(self, input), + RuleKind::LibraryDefinition => Self::library_definition.parse(self, input), + RuleKind::LibraryMembers => Self::library_members.parse(self, input), + RuleKind::MappingKey => Self::mapping_key.parse(self, input), + RuleKind::MappingKeyType => Self::mapping_key_type.parse(self, input), + RuleKind::MappingType => Self::mapping_type.parse(self, input), + RuleKind::MappingValue => Self::mapping_value.parse(self, input), + RuleKind::MemberAccess => Self::member_access.parse(self, input), + RuleKind::ModifierAttribute => Self::modifier_attribute.parse(self, input), + RuleKind::ModifierAttributes => Self::modifier_attributes.parse(self, input), + RuleKind::ModifierDefinition => Self::modifier_definition.parse(self, input), + RuleKind::ModifierInvocation => Self::modifier_invocation.parse(self, input), + RuleKind::NamedArgument => Self::named_argument.parse(self, input), + RuleKind::NamedArgumentGroup => Self::named_argument_group.parse(self, input), + RuleKind::NamedArgumentGroups => Self::named_argument_groups.parse(self, input), + RuleKind::NamedArguments => Self::named_arguments.parse(self, input), + RuleKind::NamedArgumentsDeclaration => { Self::named_arguments_declaration.parse(self, input) } - ProductionKind::NamedImport => Self::named_import.parse(self, input), - ProductionKind::NewExpression => Self::new_expression.parse(self, input), - ProductionKind::NumberUnit => Self::number_unit.parse(self, input), - ProductionKind::OverridePaths => Self::override_paths.parse(self, input), - ProductionKind::OverridePathsDeclaration => { + RuleKind::NamedImport => Self::named_import.parse(self, input), + RuleKind::NewExpression => Self::new_expression.parse(self, input), + RuleKind::NumberUnit => Self::number_unit.parse(self, input), + RuleKind::OverridePaths => Self::override_paths.parse(self, input), + RuleKind::OverridePathsDeclaration => { Self::override_paths_declaration.parse(self, input) } - ProductionKind::OverrideSpecifier => Self::override_specifier.parse(self, input), - ProductionKind::Parameter => Self::parameter.parse(self, input), - ProductionKind::Parameters => Self::parameters.parse(self, input), - ProductionKind::ParametersDeclaration => { - Self::parameters_declaration.parse(self, input) - } - ProductionKind::PathImport => Self::path_import.parse(self, input), - ProductionKind::PositionalArguments => Self::positional_arguments.parse(self, input), - ProductionKind::PositionalArgumentsDeclaration => { + RuleKind::OverrideSpecifier => Self::override_specifier.parse(self, input), + RuleKind::Parameter => Self::parameter.parse(self, input), + RuleKind::Parameters => Self::parameters.parse(self, input), + RuleKind::ParametersDeclaration => Self::parameters_declaration.parse(self, input), + RuleKind::PathImport => Self::path_import.parse(self, input), + RuleKind::PositionalArguments => Self::positional_arguments.parse(self, input), + RuleKind::PositionalArgumentsDeclaration => { Self::positional_arguments_declaration.parse(self, input) } - ProductionKind::Pragma => Self::pragma.parse(self, input), - ProductionKind::PragmaDirective => Self::pragma_directive.parse(self, input), - ProductionKind::ReceiveFunctionAttribute => { + RuleKind::Pragma => Self::pragma.parse(self, input), + RuleKind::PragmaDirective => Self::pragma_directive.parse(self, input), + RuleKind::ReceiveFunctionAttribute => { Self::receive_function_attribute.parse(self, input) } - ProductionKind::ReceiveFunctionAttributes => { + RuleKind::ReceiveFunctionAttributes => { Self::receive_function_attributes.parse(self, input) } - ProductionKind::ReceiveFunctionDefinition => { + RuleKind::ReceiveFunctionDefinition => { Self::receive_function_definition.parse(self, input) } - ProductionKind::ReturnStatement => Self::return_statement.parse(self, input), - ProductionKind::ReturnsDeclaration => Self::returns_declaration.parse(self, input), - ProductionKind::RevertStatement => Self::revert_statement.parse(self, input), - ProductionKind::SourceUnit => Self::source_unit.parse(self, input), - ProductionKind::SourceUnitMember => Self::source_unit_member.parse(self, input), - ProductionKind::SourceUnitMembers => Self::source_unit_members.parse(self, input), - ProductionKind::StateVariableAttribute => { - Self::state_variable_attribute.parse(self, input) - } - ProductionKind::StateVariableAttributes => { - Self::state_variable_attributes.parse(self, input) - } - ProductionKind::StateVariableDefinition => { - Self::state_variable_definition.parse(self, input) - } - ProductionKind::StateVariableDefinitionValue => { + RuleKind::ReturnStatement => Self::return_statement.parse(self, input), + RuleKind::ReturnsDeclaration => Self::returns_declaration.parse(self, input), + RuleKind::RevertStatement => Self::revert_statement.parse(self, input), + RuleKind::SourceUnit => Self::source_unit.parse(self, input), + RuleKind::SourceUnitMember => Self::source_unit_member.parse(self, input), + RuleKind::SourceUnitMembers => Self::source_unit_members.parse(self, input), + RuleKind::StateVariableAttribute => Self::state_variable_attribute.parse(self, input), + RuleKind::StateVariableAttributes => Self::state_variable_attributes.parse(self, input), + RuleKind::StateVariableDefinition => Self::state_variable_definition.parse(self, input), + RuleKind::StateVariableDefinitionValue => { Self::state_variable_definition_value.parse(self, input) } - ProductionKind::Statement => Self::statement.parse(self, input), - ProductionKind::Statements => Self::statements.parse(self, input), - ProductionKind::StorageLocation => Self::storage_location.parse(self, input), - ProductionKind::StringExpression => Self::string_expression.parse(self, input), - ProductionKind::StructDefinition => Self::struct_definition.parse(self, input), - ProductionKind::StructMember => Self::struct_member.parse(self, input), - ProductionKind::StructMembers => Self::struct_members.parse(self, input), - ProductionKind::ThrowStatement => Self::throw_statement.parse(self, input), - ProductionKind::TrailingTrivia => Self::trailing_trivia.parse(self, input), - ProductionKind::TryStatement => Self::try_statement.parse(self, input), - ProductionKind::TupleDeconstructionElement => { + RuleKind::Statement => Self::statement.parse(self, input), + RuleKind::Statements => Self::statements.parse(self, input), + RuleKind::StorageLocation => Self::storage_location.parse(self, input), + RuleKind::StringExpression => Self::string_expression.parse(self, input), + RuleKind::StructDefinition => Self::struct_definition.parse(self, input), + RuleKind::StructMember => Self::struct_member.parse(self, input), + RuleKind::StructMembers => Self::struct_members.parse(self, input), + RuleKind::ThrowStatement => Self::throw_statement.parse(self, input), + RuleKind::TrailingTrivia => Self::trailing_trivia.parse(self, input), + RuleKind::TryStatement => Self::try_statement.parse(self, input), + RuleKind::TupleDeconstructionElement => { Self::tuple_deconstruction_element.parse(self, input) } - ProductionKind::TupleDeconstructionElements => { + RuleKind::TupleDeconstructionElements => { Self::tuple_deconstruction_elements.parse(self, input) } - ProductionKind::TupleDeconstructionStatement => { + RuleKind::TupleDeconstructionStatement => { Self::tuple_deconstruction_statement.parse(self, input) } - ProductionKind::TupleExpression => Self::tuple_expression.parse(self, input), - ProductionKind::TupleMember => Self::tuple_member.parse(self, input), - ProductionKind::TupleValue => Self::tuple_value.parse(self, input), - ProductionKind::TupleValues => Self::tuple_values.parse(self, input), - ProductionKind::TypeExpression => Self::type_expression.parse(self, input), - ProductionKind::TypeName => Self::type_name.parse(self, input), - ProductionKind::TypedTupleMember => Self::typed_tuple_member.parse(self, input), - ProductionKind::UncheckedBlock => Self::unchecked_block.parse(self, input), - ProductionKind::UnicodeStringLiterals => { - Self::unicode_string_literals.parse(self, input) - } - ProductionKind::UnnamedFunctionAttribute => { + RuleKind::TupleExpression => Self::tuple_expression.parse(self, input), + RuleKind::TupleMember => Self::tuple_member.parse(self, input), + RuleKind::TupleValue => Self::tuple_value.parse(self, input), + RuleKind::TupleValues => Self::tuple_values.parse(self, input), + RuleKind::TypeExpression => Self::type_expression.parse(self, input), + RuleKind::TypeName => Self::type_name.parse(self, input), + RuleKind::TypedTupleMember => Self::typed_tuple_member.parse(self, input), + RuleKind::UncheckedBlock => Self::unchecked_block.parse(self, input), + RuleKind::UnicodeStringLiterals => Self::unicode_string_literals.parse(self, input), + RuleKind::UnnamedFunctionAttribute => { Self::unnamed_function_attribute.parse(self, input) } - ProductionKind::UnnamedFunctionAttributes => { + RuleKind::UnnamedFunctionAttributes => { Self::unnamed_function_attributes.parse(self, input) } - ProductionKind::UnnamedFunctionDefinition => { + RuleKind::UnnamedFunctionDefinition => { Self::unnamed_function_definition.parse(self, input) } - ProductionKind::UntypedTupleMember => Self::untyped_tuple_member.parse(self, input), - ProductionKind::UserDefinedValueTypeDefinition => { + RuleKind::UntypedTupleMember => Self::untyped_tuple_member.parse(self, input), + RuleKind::UserDefinedValueTypeDefinition => { Self::user_defined_value_type_definition.parse(self, input) } - ProductionKind::UsingAlias => Self::using_alias.parse(self, input), - ProductionKind::UsingClause => Self::using_clause.parse(self, input), - ProductionKind::UsingDeconstruction => Self::using_deconstruction.parse(self, input), - ProductionKind::UsingDeconstructionSymbol => { + RuleKind::UsingAlias => Self::using_alias.parse(self, input), + RuleKind::UsingClause => Self::using_clause.parse(self, input), + RuleKind::UsingDeconstruction => Self::using_deconstruction.parse(self, input), + RuleKind::UsingDeconstructionSymbol => { Self::using_deconstruction_symbol.parse(self, input) } - ProductionKind::UsingDeconstructionSymbols => { + RuleKind::UsingDeconstructionSymbols => { Self::using_deconstruction_symbols.parse(self, input) } - ProductionKind::UsingDirective => Self::using_directive.parse(self, input), - ProductionKind::UsingOperator => Self::using_operator.parse(self, input), - ProductionKind::UsingTarget => Self::using_target.parse(self, input), - ProductionKind::VariableDeclarationStatement => { + RuleKind::UsingDirective => Self::using_directive.parse(self, input), + RuleKind::UsingOperator => Self::using_operator.parse(self, input), + RuleKind::UsingTarget => Self::using_target.parse(self, input), + RuleKind::VariableDeclarationStatement => { Self::variable_declaration_statement.parse(self, input) } - ProductionKind::VariableDeclarationType => { - Self::variable_declaration_type.parse(self, input) - } - ProductionKind::VariableDeclarationValue => { + RuleKind::VariableDeclarationType => Self::variable_declaration_type.parse(self, input), + RuleKind::VariableDeclarationValue => { Self::variable_declaration_value.parse(self, input) } - ProductionKind::VersionPragma => Self::version_pragma.parse(self, input), - ProductionKind::VersionPragmaExpression => { - Self::version_pragma_expression.parse(self, input) - } - ProductionKind::VersionPragmaExpressions => { + RuleKind::VersionPragma => Self::version_pragma.parse(self, input), + RuleKind::VersionPragmaExpression => Self::version_pragma_expression.parse(self, input), + RuleKind::VersionPragmaExpressions => { Self::version_pragma_expressions.parse(self, input) } - ProductionKind::VersionPragmaSpecifier => { - Self::version_pragma_specifier.parse(self, input) - } - ProductionKind::WhileStatement => Self::while_statement.parse(self, input), - ProductionKind::YulArguments => Self::yul_arguments.parse(self, input), - ProductionKind::YulAssignmentStatement => { - Self::yul_assignment_statement.parse(self, input) - } - ProductionKind::YulBlock => Self::yul_block.parse(self, input), - ProductionKind::YulBreakStatement => Self::yul_break_statement.parse(self, input), - ProductionKind::YulContinueStatement => Self::yul_continue_statement.parse(self, input), - ProductionKind::YulDefaultCase => Self::yul_default_case.parse(self, input), - ProductionKind::YulExpression => Self::yul_expression.parse(self, input), - ProductionKind::YulForStatement => Self::yul_for_statement.parse(self, input), - ProductionKind::YulFunctionDefinition => { - Self::yul_function_definition.parse(self, input) - } - ProductionKind::YulIdentifierPath => Self::yul_identifier_path.parse(self, input), - ProductionKind::YulIdentifierPaths => Self::yul_identifier_paths.parse(self, input), - ProductionKind::YulIfStatement => Self::yul_if_statement.parse(self, input), - ProductionKind::YulLeaveStatement => Self::yul_leave_statement.parse(self, input), - ProductionKind::YulLiteral => Self::yul_literal.parse(self, input), - ProductionKind::YulParameters => Self::yul_parameters.parse(self, input), - ProductionKind::YulParametersDeclaration => { + RuleKind::VersionPragmaSpecifier => Self::version_pragma_specifier.parse(self, input), + RuleKind::WhileStatement => Self::while_statement.parse(self, input), + RuleKind::YulArguments => Self::yul_arguments.parse(self, input), + RuleKind::YulAssignmentStatement => Self::yul_assignment_statement.parse(self, input), + RuleKind::YulBlock => Self::yul_block.parse(self, input), + RuleKind::YulBreakStatement => Self::yul_break_statement.parse(self, input), + RuleKind::YulContinueStatement => Self::yul_continue_statement.parse(self, input), + RuleKind::YulDefaultCase => Self::yul_default_case.parse(self, input), + RuleKind::YulExpression => Self::yul_expression.parse(self, input), + RuleKind::YulForStatement => Self::yul_for_statement.parse(self, input), + RuleKind::YulFunctionDefinition => Self::yul_function_definition.parse(self, input), + RuleKind::YulIdentifierPath => Self::yul_identifier_path.parse(self, input), + RuleKind::YulIdentifierPaths => Self::yul_identifier_paths.parse(self, input), + RuleKind::YulIfStatement => Self::yul_if_statement.parse(self, input), + RuleKind::YulLeaveStatement => Self::yul_leave_statement.parse(self, input), + RuleKind::YulLiteral => Self::yul_literal.parse(self, input), + RuleKind::YulParameters => Self::yul_parameters.parse(self, input), + RuleKind::YulParametersDeclaration => { Self::yul_parameters_declaration.parse(self, input) } - ProductionKind::YulReturnVariables => Self::yul_return_variables.parse(self, input), - ProductionKind::YulReturnsDeclaration => { - Self::yul_returns_declaration.parse(self, input) - } - ProductionKind::YulStatement => Self::yul_statement.parse(self, input), - ProductionKind::YulStatements => Self::yul_statements.parse(self, input), - ProductionKind::YulSwitchCase => Self::yul_switch_case.parse(self, input), - ProductionKind::YulSwitchCases => Self::yul_switch_cases.parse(self, input), - ProductionKind::YulSwitchStatement => Self::yul_switch_statement.parse(self, input), - ProductionKind::YulValueCase => Self::yul_value_case.parse(self, input), - ProductionKind::YulVariableDeclarationStatement => { + RuleKind::YulReturnVariables => Self::yul_return_variables.parse(self, input), + RuleKind::YulReturnsDeclaration => Self::yul_returns_declaration.parse(self, input), + RuleKind::YulStatement => Self::yul_statement.parse(self, input), + RuleKind::YulStatements => Self::yul_statements.parse(self, input), + RuleKind::YulSwitchCase => Self::yul_switch_case.parse(self, input), + RuleKind::YulSwitchCases => Self::yul_switch_cases.parse(self, input), + RuleKind::YulSwitchStatement => Self::yul_switch_statement.parse(self, input), + RuleKind::YulValueCase => Self::yul_value_case.parse(self, input), + RuleKind::YulVariableDeclarationStatement => { Self::yul_variable_declaration_statement.parse(self, input) } - ProductionKind::YulVariableDeclarationValue => { + RuleKind::YulVariableDeclarationValue => { Self::yul_variable_declaration_value.parse(self, input) - } + } // TODO(#638): Expose parsing individual operators + _ => unimplemented!( + "Parsing individual precedence operators is not supported at the moment" + ), } } } @@ -10963,9 +10932,9 @@ impl Language { #[napi(js_name = "parse", ts_return_type = "parse_output.ParseOutput")] pub fn parse_napi( &self, - #[napi(ts_arg_type = "kinds.ProductionKind")] production_kind: ProductionKind, + #[napi(ts_arg_type = "kinds.RuleKind")] kind: RuleKind, input: String, ) -> NAPIParseOutput { - self.parse(production_kind, input.as_str()).into() + self.parse(kind, input.as_str()).into() } } diff --git a/crates/solidity/outputs/npm/package/src/generated/index.d.ts b/crates/solidity/outputs/npm/package/src/generated/index.d.ts index 563bc2caa8..50b7549c1a 100644 --- a/crates/solidity/outputs/npm/package/src/generated/index.d.ts +++ b/crates/solidity/outputs/npm/package/src/generated/index.d.ts @@ -9,195 +9,6 @@ /* auto-generated by NAPI-RS */ export namespace kinds { - export enum ProductionKind { - ABICoderPragma = "ABICoderPragma", - AddressType = "AddressType", - ArgumentsDeclaration = "ArgumentsDeclaration", - ArrayExpression = "ArrayExpression", - ArrayValues = "ArrayValues", - AsciiStringLiterals = "AsciiStringLiterals", - AssemblyFlags = "AssemblyFlags", - AssemblyFlagsDeclaration = "AssemblyFlagsDeclaration", - AssemblyStatement = "AssemblyStatement", - Block = "Block", - BreakStatement = "BreakStatement", - CatchClause = "CatchClause", - CatchClauseError = "CatchClauseError", - CatchClauses = "CatchClauses", - ConstantDefinition = "ConstantDefinition", - ConstructorAttribute = "ConstructorAttribute", - ConstructorAttributes = "ConstructorAttributes", - ConstructorDefinition = "ConstructorDefinition", - ContinueStatement = "ContinueStatement", - ContractDefinition = "ContractDefinition", - ContractMember = "ContractMember", - ContractMembers = "ContractMembers", - DecimalNumberExpression = "DecimalNumberExpression", - DeleteStatement = "DeleteStatement", - DoWhileStatement = "DoWhileStatement", - ElementaryType = "ElementaryType", - ElseBranch = "ElseBranch", - EmitStatement = "EmitStatement", - EndOfFileTrivia = "EndOfFileTrivia", - EnumDefinition = "EnumDefinition", - EnumMembers = "EnumMembers", - ErrorDefinition = "ErrorDefinition", - ErrorParameter = "ErrorParameter", - ErrorParameters = "ErrorParameters", - ErrorParametersDeclaration = "ErrorParametersDeclaration", - EventDefinition = "EventDefinition", - EventParameter = "EventParameter", - EventParameters = "EventParameters", - EventParametersDeclaration = "EventParametersDeclaration", - ExperimentalFeature = "ExperimentalFeature", - ExperimentalPragma = "ExperimentalPragma", - Expression = "Expression", - ExpressionStatement = "ExpressionStatement", - FallbackFunctionAttribute = "FallbackFunctionAttribute", - FallbackFunctionAttributes = "FallbackFunctionAttributes", - FallbackFunctionDefinition = "FallbackFunctionDefinition", - ForStatement = "ForStatement", - ForStatementCondition = "ForStatementCondition", - ForStatementInitialization = "ForStatementInitialization", - FunctionAttribute = "FunctionAttribute", - FunctionAttributes = "FunctionAttributes", - FunctionBody = "FunctionBody", - FunctionCallOptions = "FunctionCallOptions", - FunctionDefinition = "FunctionDefinition", - FunctionName = "FunctionName", - FunctionType = "FunctionType", - FunctionTypeAttribute = "FunctionTypeAttribute", - FunctionTypeAttributes = "FunctionTypeAttributes", - HexNumberExpression = "HexNumberExpression", - HexStringLiterals = "HexStringLiterals", - IdentifierPath = "IdentifierPath", - IfStatement = "IfStatement", - ImportAlias = "ImportAlias", - ImportClause = "ImportClause", - ImportDeconstruction = "ImportDeconstruction", - ImportDeconstructionSymbol = "ImportDeconstructionSymbol", - ImportDeconstructionSymbols = "ImportDeconstructionSymbols", - ImportDirective = "ImportDirective", - IndexAccessEnd = "IndexAccessEnd", - InheritanceSpecifier = "InheritanceSpecifier", - InheritanceType = "InheritanceType", - InheritanceTypes = "InheritanceTypes", - InterfaceDefinition = "InterfaceDefinition", - InterfaceMembers = "InterfaceMembers", - LeadingTrivia = "LeadingTrivia", - LibraryDefinition = "LibraryDefinition", - LibraryMembers = "LibraryMembers", - MappingKey = "MappingKey", - MappingKeyType = "MappingKeyType", - MappingType = "MappingType", - MappingValue = "MappingValue", - MemberAccess = "MemberAccess", - ModifierAttribute = "ModifierAttribute", - ModifierAttributes = "ModifierAttributes", - ModifierDefinition = "ModifierDefinition", - ModifierInvocation = "ModifierInvocation", - NamedArgument = "NamedArgument", - NamedArgumentGroup = "NamedArgumentGroup", - NamedArgumentGroups = "NamedArgumentGroups", - NamedArguments = "NamedArguments", - NamedArgumentsDeclaration = "NamedArgumentsDeclaration", - NamedImport = "NamedImport", - NewExpression = "NewExpression", - NumberUnit = "NumberUnit", - OverridePaths = "OverridePaths", - OverridePathsDeclaration = "OverridePathsDeclaration", - OverrideSpecifier = "OverrideSpecifier", - Parameter = "Parameter", - Parameters = "Parameters", - ParametersDeclaration = "ParametersDeclaration", - PathImport = "PathImport", - PositionalArguments = "PositionalArguments", - PositionalArgumentsDeclaration = "PositionalArgumentsDeclaration", - Pragma = "Pragma", - PragmaDirective = "PragmaDirective", - ReceiveFunctionAttribute = "ReceiveFunctionAttribute", - ReceiveFunctionAttributes = "ReceiveFunctionAttributes", - ReceiveFunctionDefinition = "ReceiveFunctionDefinition", - ReturnStatement = "ReturnStatement", - ReturnsDeclaration = "ReturnsDeclaration", - RevertStatement = "RevertStatement", - SourceUnit = "SourceUnit", - SourceUnitMember = "SourceUnitMember", - SourceUnitMembers = "SourceUnitMembers", - StateVariableAttribute = "StateVariableAttribute", - StateVariableAttributes = "StateVariableAttributes", - StateVariableDefinition = "StateVariableDefinition", - StateVariableDefinitionValue = "StateVariableDefinitionValue", - Statement = "Statement", - Statements = "Statements", - StorageLocation = "StorageLocation", - StringExpression = "StringExpression", - StructDefinition = "StructDefinition", - StructMember = "StructMember", - StructMembers = "StructMembers", - ThrowStatement = "ThrowStatement", - TrailingTrivia = "TrailingTrivia", - TryStatement = "TryStatement", - TupleDeconstructionElement = "TupleDeconstructionElement", - TupleDeconstructionElements = "TupleDeconstructionElements", - TupleDeconstructionStatement = "TupleDeconstructionStatement", - TupleExpression = "TupleExpression", - TupleMember = "TupleMember", - TupleValue = "TupleValue", - TupleValues = "TupleValues", - TypeExpression = "TypeExpression", - TypeName = "TypeName", - TypedTupleMember = "TypedTupleMember", - UncheckedBlock = "UncheckedBlock", - UnicodeStringLiterals = "UnicodeStringLiterals", - UnnamedFunctionAttribute = "UnnamedFunctionAttribute", - UnnamedFunctionAttributes = "UnnamedFunctionAttributes", - UnnamedFunctionDefinition = "UnnamedFunctionDefinition", - UntypedTupleMember = "UntypedTupleMember", - UserDefinedValueTypeDefinition = "UserDefinedValueTypeDefinition", - UsingAlias = "UsingAlias", - UsingClause = "UsingClause", - UsingDeconstruction = "UsingDeconstruction", - UsingDeconstructionSymbol = "UsingDeconstructionSymbol", - UsingDeconstructionSymbols = "UsingDeconstructionSymbols", - UsingDirective = "UsingDirective", - UsingOperator = "UsingOperator", - UsingTarget = "UsingTarget", - VariableDeclarationStatement = "VariableDeclarationStatement", - VariableDeclarationType = "VariableDeclarationType", - VariableDeclarationValue = "VariableDeclarationValue", - VersionPragma = "VersionPragma", - VersionPragmaExpression = "VersionPragmaExpression", - VersionPragmaExpressions = "VersionPragmaExpressions", - VersionPragmaSpecifier = "VersionPragmaSpecifier", - WhileStatement = "WhileStatement", - YulArguments = "YulArguments", - YulAssignmentStatement = "YulAssignmentStatement", - YulBlock = "YulBlock", - YulBreakStatement = "YulBreakStatement", - YulContinueStatement = "YulContinueStatement", - YulDefaultCase = "YulDefaultCase", - YulExpression = "YulExpression", - YulForStatement = "YulForStatement", - YulFunctionDefinition = "YulFunctionDefinition", - YulIdentifierPath = "YulIdentifierPath", - YulIdentifierPaths = "YulIdentifierPaths", - YulIfStatement = "YulIfStatement", - YulLeaveStatement = "YulLeaveStatement", - YulLiteral = "YulLiteral", - YulParameters = "YulParameters", - YulParametersDeclaration = "YulParametersDeclaration", - YulReturnVariables = "YulReturnVariables", - YulReturnsDeclaration = "YulReturnsDeclaration", - YulStatement = "YulStatement", - YulStatements = "YulStatements", - YulSwitchCase = "YulSwitchCase", - YulSwitchCases = "YulSwitchCases", - YulSwitchStatement = "YulSwitchStatement", - YulValueCase = "YulValueCase", - YulVariableDeclarationStatement = "YulVariableDeclarationStatement", - YulVariableDeclarationValue = "YulVariableDeclarationValue", - } export enum RuleKind { ABICoderPragma = "ABICoderPragma", AddressType = "AddressType", @@ -697,7 +508,7 @@ export namespace language { get version(): string; static supportedVersions(): Array; scan(lexicalContext: LexicalContext, input: string): kinds.TokenKind | null; - parse(productionKind: kinds.ProductionKind, input: string): parse_output.ParseOutput; + parse(kind: kinds.RuleKind, input: string): parse_output.ParseOutput; } } export namespace cst { diff --git a/crates/solidity/outputs/npm/package/src/kinds/index.ts b/crates/solidity/outputs/npm/package/src/kinds/index.ts index 6ac7e61c7f..24d203adb0 100644 --- a/crates/solidity/outputs/npm/package/src/kinds/index.ts +++ b/crates/solidity/outputs/npm/package/src/kinds/index.ts @@ -1,8 +1,5 @@ import * as generated from "../generated"; -export const ProductionKind = generated.kinds.ProductionKind; -export type ProductionKind = generated.kinds.ProductionKind; - export const RuleKind = generated.kinds.RuleKind; export type RuleKind = generated.kinds.RuleKind; diff --git a/crates/solidity/outputs/npm/tests/src/doc-examples/simple-contract.ts b/crates/solidity/outputs/npm/tests/src/doc-examples/simple-contract.ts index 4a0c29eabf..3fe7208c3b 100644 --- a/crates/solidity/outputs/npm/tests/src/doc-examples/simple-contract.ts +++ b/crates/solidity/outputs/npm/tests/src/doc-examples/simple-contract.ts @@ -1,10 +1,10 @@ import { Language } from "@nomicfoundation/slang/language"; import { RuleNode, TokenNode } from "@nomicfoundation/slang/cst"; -import { ProductionKind, RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; +import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; test("simple contract", () => { const language = new Language("0.8.0"); - const parseOutput = language.parse(ProductionKind.ContractDefinition, "contract Foo {}"); + const parseOutput = language.parse(RuleKind.ContractDefinition, "contract Foo {}"); const parseTree = parseOutput.tree() as RuleNode; expect(parseTree.kind).toEqual(RuleKind.ContractDefinition); diff --git a/crates/solidity/outputs/npm/tests/src/tests/cst-cursor.ts b/crates/solidity/outputs/npm/tests/src/tests/cst-cursor.ts index f4795d81e5..cf9803f2c0 100644 --- a/crates/solidity/outputs/npm/tests/src/tests/cst-cursor.ts +++ b/crates/solidity/outputs/npm/tests/src/tests/cst-cursor.ts @@ -1,5 +1,5 @@ import { Language } from "@nomicfoundation/slang/language"; -import { ProductionKind, RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; +import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; import { Cursor } from "@nomicfoundation/slang/cursor"; import { expectRule, expectToken } from "../utils/cst-helpers"; @@ -7,7 +7,7 @@ test("use cursor", () => { const source = "int256 constant z = 1 + 2;"; const language = new Language("0.8.1"); - const parseOutput = language.parse(ProductionKind.SourceUnit, source); + const parseOutput = language.parse(RuleKind.SourceUnit, source); const cursor: Cursor = parseOutput.createTreeCursor(); expectRule(cursor.node(), RuleKind.SourceUnit); diff --git a/crates/solidity/outputs/npm/tests/src/tests/cst-output.ts b/crates/solidity/outputs/npm/tests/src/tests/cst-output.ts index 9c65995592..de42cfc6c1 100644 --- a/crates/solidity/outputs/npm/tests/src/tests/cst-output.ts +++ b/crates/solidity/outputs/npm/tests/src/tests/cst-output.ts @@ -1,12 +1,12 @@ import { Language } from "@nomicfoundation/slang/language"; -import { ProductionKind, RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; +import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; import { expectRule, expectToken } from "../utils/cst-helpers"; test("parse token", () => { const source = "5_286_981"; const language = new Language("0.8.1"); - const parseTree = language.parse(ProductionKind.DecimalNumberExpression, source).tree(); + const parseTree = language.parse(RuleKind.DecimalNumberExpression, source).tree(); expectRule(parseTree, RuleKind.DecimalNumberExpression); const children = parseTree.children(); @@ -19,7 +19,7 @@ test("parse rule", () => { const source = "int256 constant z = 1**2**3;"; const language = new Language("0.8.1"); - const parseTree = language.parse(ProductionKind.SourceUnit, source).tree(); + const parseTree = language.parse(RuleKind.SourceUnit, source).tree(); expectRule(parseTree, RuleKind.SourceUnit); const children = parseTree.children(); @@ -32,7 +32,7 @@ test("trivial cursor access", () => { const source = "int256 constant z = 1**2**3;"; const language = new Language("0.8.1"); - const parseOutput = language.parse(ProductionKind.SourceUnit, source); + const parseOutput = language.parse(RuleKind.SourceUnit, source); const node = parseOutput.createTreeCursor().node(); expectRule(node, RuleKind.SourceUnit); @@ -44,7 +44,7 @@ test("calculate unicode characters text length", () => { const source = `unicode"some 😁 emoji"`; const language = new Language("0.8.1"); - const parseTree = language.parse(ProductionKind.UnicodeStringLiterals, source).tree(); + const parseTree = language.parse(RuleKind.UnicodeStringLiterals, source).tree(); expectRule(parseTree, RuleKind.UnicodeStringLiterals); expect(parseTree.textLength).toEqual({ diff --git a/crates/solidity/outputs/npm/tests/src/tests/errors.ts b/crates/solidity/outputs/npm/tests/src/tests/errors.ts index 02f07a84db..afadec9043 100644 --- a/crates/solidity/outputs/npm/tests/src/tests/errors.ts +++ b/crates/solidity/outputs/npm/tests/src/tests/errors.ts @@ -1,11 +1,11 @@ import { Language } from "@nomicfoundation/slang/language"; -import { ProductionKind } from "@nomicfoundation/slang/kinds"; +import { RuleKind } from "@nomicfoundation/slang/kinds"; test("render error reports", () => { const source = "int256 constant"; const language = new Language("0.8.1"); - const errors = language.parse(ProductionKind.SourceUnit, source).errors(); + const errors = language.parse(RuleKind.SourceUnit, source).errors(); expect(errors).toHaveLength(1); const report = errors[0]!.toErrorReport("test.sol", source, /* withColor */ false); diff --git a/crates/solidity/outputs/npm/tests/src/tests/public-api.ts b/crates/solidity/outputs/npm/tests/src/tests/public-api.ts index a33aa90d40..45616b0afa 100644 --- a/crates/solidity/outputs/npm/tests/src/tests/public-api.ts +++ b/crates/solidity/outputs/npm/tests/src/tests/public-api.ts @@ -1,14 +1,14 @@ import * as slang from "@nomicfoundation/slang"; -import { ProductionKind, RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; +import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; test("use namespace imports of the API", () => { - expect(slang.kinds.ProductionKind.SourceUnit).toEqual("SourceUnit"); + expect(slang.kinds.RuleKind.SourceUnit).toEqual("SourceUnit"); expect(slang.kinds.RuleKind.ContractDefinition).toEqual("ContractDefinition"); expect(slang.kinds.TokenKind.IfKeyword).toEqual("IfKeyword"); }); test("use nested imports of the API", () => { - expect(ProductionKind.SourceUnit).toEqual("SourceUnit"); + expect(RuleKind.SourceUnit).toEqual("SourceUnit"); expect(RuleKind.ContractDefinition).toEqual("ContractDefinition"); expect(TokenKind.IfKeyword).toEqual("IfKeyword"); }); diff --git a/crates/solidity/testing/sanctuary/src/main.rs b/crates/solidity/testing/sanctuary/src/main.rs index 8686223481..c190e089ee 100644 --- a/crates/solidity/testing/sanctuary/src/main.rs +++ b/crates/solidity/testing/sanctuary/src/main.rs @@ -7,7 +7,7 @@ use anyhow::Result; use infra_utils::paths::PathExtensions; use rayon::prelude::{IntoParallelRefIterator, ParallelIterator}; use semver::Version; -use slang_solidity::{kinds::ProductionKind, language::Language}; +use slang_solidity::{kinds::RuleKind, language::Language}; use solidity_language::SolidityDefinition; use solidity_testing_utils::version_pragmas::extract_version_pragmas; @@ -95,7 +95,7 @@ fn process_source_file( } let language = Language::new(version.to_owned())?; - let output = language.parse(ProductionKind::SourceUnit, source); + let output = language.parse(RuleKind::SourceUnit, source); reporter.report_test_result(source_id, source, version, &output); } diff --git a/crates/solidity/testing/utils/src/node_extensions/tests.rs b/crates/solidity/testing/utils/src/node_extensions/tests.rs index ce99a6e227..c4dc6072f2 100644 --- a/crates/solidity/testing/utils/src/node_extensions/tests.rs +++ b/crates/solidity/testing/utils/src/node_extensions/tests.rs @@ -1,6 +1,6 @@ use anyhow::Result; use semver::Version; -use slang_solidity::{kinds::ProductionKind, language::Language}; +use slang_solidity::{kinds::RuleKind, language::Language}; use crate::node_extensions::NodeExtensions; @@ -14,7 +14,7 @@ fn extract_non_trivia() -> Result<()> { )"; let language = Language::new(Version::parse("0.8.0")?)?; - let output = language.parse(ProductionKind::Expression, source); + let output = language.parse(RuleKind::Expression, source); assert_eq!(output.errors().len(), 0); diff --git a/crates/solidity/testing/utils/src/version_pragmas/mod.rs b/crates/solidity/testing/utils/src/version_pragmas/mod.rs index ea9b722b2f..b770c68e32 100644 --- a/crates/solidity/testing/utils/src/version_pragmas/mod.rs +++ b/crates/solidity/testing/utils/src/version_pragmas/mod.rs @@ -7,7 +7,7 @@ use anyhow::{bail, ensure, Context, Result}; use semver::{Comparator, Op, Version}; use slang_solidity::{ cst::Node, - kinds::{ProductionKind, RuleKind, TokenKind}, + kinds::{RuleKind, TokenKind}, language::Language, }; @@ -18,7 +18,7 @@ pub fn extract_version_pragmas( latest_version: &Version, ) -> Result> { let language = &Language::new(latest_version.to_owned())?; - let output = language.parse(ProductionKind::SourceUnit, source); + let output = language.parse(RuleKind::SourceUnit, source); let mut pragmas = vec![]; let mut cursor = output.create_tree_cursor(); diff --git a/documentation/public/user-guide/npm-package/index.md b/documentation/public/user-guide/npm-package/index.md index f67f631887..0c80271ae9 100644 --- a/documentation/public/user-guide/npm-package/index.md +++ b/documentation/public/user-guide/npm-package/index.md @@ -16,9 +16,9 @@ The API is initialized with a language version to create a `Language` object. Specifying the correct version is important, as it will affect the grammar used to parse inputs. You can then use it to parse different inputs belonging to that version. -Each `parse()` operation accepts the input source code, and a `ProductionKind` variant. -This allows callers to parse entire source files (`ProductionKind.SourceUnit`), individual contracts (`ProductionKind.ContractDefinition`), -methods (`ProductionKind.FunctionDefinition`), or any other syntax nodes. +Each `parse()` operation accepts the input source code, and a `RuleKind` variant. +This allows callers to parse entire source files (`RuleKind.SourceUnit`), individual contracts (`RuleKind.ContractDefinition`), +methods (`RuleKind.FunctionDefinition`), or any other syntax nodes. The resulting `ParseOutput` object will contain syntax errors (if any), and the parse tree corresponding to the input source code. You can then iterate over the resulting children, and assert that they match the expected syntax nodes: From 1bbb2d5055cd1c11429c59ab495dd4b0167f6a63 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 6 Dec 2023 17:58:08 +0100 Subject: [PATCH 02/17] Remove PrecedenceExpression::rule_name in favor of using its name This introduced individual rule kinds per each precedence expression and we lose the grouping rules such as BinaryExpression. Not sure how desirable they were in the first place but it seems better and easier to handle specific expressions rather than using grouping rule kinds like before. --- .../src/compiler/analysis/references.rs | 6 +- .../src/model/non_terminals/precedence.rs | 3 - .../duplicate_expression_name/test.rs | 6 +- .../duplicate_expression_name/test.stderr | 2 +- .../inputs/language/src/definition.rs | 23 ---- .../solidity/inputs/language/src/grammar.rs | 3 +- .../cargo/crate/src/generated/kinds.rs | 22 +++- .../cargo/crate/src/generated/language.rs | 100 +++++++++--------- .../outputs/npm/crate/src/generated/kinds.rs | 22 +++- .../npm/crate/src/generated/language.rs | 100 +++++++++--------- .../npm/package/src/generated/index.d.ts | 22 +++- .../outputs/npm/tests/src/tests/cst-cursor.ts | 2 +- .../unchecked/generated/0.8.0-success.yml | 2 +- .../generated/0.4.11-failure.yml | 2 +- .../generated/0.6.2-success.yml | 2 +- .../generated/0.8.0-success.yml | 2 +- .../generated/0.4.11-success.yml | 4 +- .../generated/0.4.11-failure.yml | 2 +- .../generated/0.4.21-failure.yml | 2 +- .../generated/0.5.0-failure.yml | 2 +- .../generated/0.5.3-failure.yml | 2 +- .../generated/0.6.0-failure.yml | 2 +- .../generated/0.7.0-failure.yml | 2 +- .../generated/0.8.0-failure.yml | 2 +- .../generated/0.8.4-failure.yml | 2 +- .../add_mul/generated/0.4.11-success.yml | 6 +- .../generated/0.4.11-success.yml | 2 +- .../generated/0.4.11-success.yml | 4 +- .../generated/0.4.11-success.yml | 18 ++-- .../generated/0.4.11-success.yml | 4 +- .../generated/0.6.0-success.yml | 4 +- .../generated/0.4.11-failure.yml | 2 +- .../generated/0.8.0-failure.yml | 2 +- .../generated/0.4.11-success.yml | 4 +- .../generated/0.4.11-success.yml | 2 +- .../generated/0.4.11-success.yml | 2 +- .../prefix_minus/generated/0.4.11-success.yml | 2 +- .../prefix_plus/generated/0.4.11-success.yml | 2 +- .../generated/0.4.11-failure.yml | 4 +- .../SafeMath/generated/0.8.0-success.yml | 4 +- .../generated/0.4.11-failure.yml | 2 +- .../generated/0.8.13-success.yml | 2 +- .../generated/0.4.11-success.yml | 26 ++--- .../generated/0.4.11-failure.yml | 4 +- .../alternatives/generated/0.4.11-success.yml | 6 +- .../generated/0.4.11-success.yml | 2 +- .../generated/0.4.11-success.yml | 2 +- .../generated/0.4.11-success.yml | 6 +- .../ranges/generated/0.4.11-success.yml | 2 +- .../testing/utils/src/version_pragmas/mod.rs | 66 ++++++------ 50 files changed, 263 insertions(+), 256 deletions(-) diff --git a/crates/codegen/language/definition/src/compiler/analysis/references.rs b/crates/codegen/language/definition/src/compiler/analysis/references.rs index 287f85a034..395829f921 100644 --- a/crates/codegen/language/definition/src/compiler/analysis/references.rs +++ b/crates/codegen/language/definition/src/compiler/analysis/references.rs @@ -169,11 +169,7 @@ fn check_precedence( let enablement = update_enablement(analysis, enablement, enabled); for precedence_expression in precedence_expressions { - let SpannedPrecedenceExpression { - name: _, - rule_name: _, - operators, - } = precedence_expression; + let SpannedPrecedenceExpression { name: _, operators } = precedence_expression; for operator in operators { let SpannedPrecedenceOperator { diff --git a/crates/codegen/language/definition/src/model/non_terminals/precedence.rs b/crates/codegen/language/definition/src/model/non_terminals/precedence.rs index eb4c2ec702..f06d0716b0 100644 --- a/crates/codegen/language/definition/src/model/non_terminals/precedence.rs +++ b/crates/codegen/language/definition/src/model/non_terminals/precedence.rs @@ -19,9 +19,6 @@ pub struct PrecedenceItem { pub struct PrecedenceExpression { pub name: Identifier, - // TODO(#638): Remove this, once we adapt the DSL v1 codegen model to the new v2 definition. - pub rule_name: Identifier, - pub operators: Vec, } diff --git a/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.rs b/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.rs index 1e5c9f00d6..657ba4785c 100644 --- a/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.rs +++ b/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.rs @@ -14,9 +14,9 @@ codegen_language_macros::compile!(Language( Precedence( name = Bar, precedence_expressions = [ - PrecedenceExpression(name = Expression1, rule_name = X, operators = []), - PrecedenceExpression(name = Expression2, rule_name = X, operators = []), - PrecedenceExpression(name = Expression1, rule_name = X, operators = []) + PrecedenceExpression(name = Expression1, operators = []), + PrecedenceExpression(name = Expression2, operators = []), + PrecedenceExpression(name = Expression1, operators = []) ], primary_expressions = [PrimaryExpression(reference = Baz)] ), diff --git a/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.stderr b/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.stderr index b9f2da2b43..6d6b1ea841 100644 --- a/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.stderr +++ b/crates/codegen/language/tests/src/fail/definitions/duplicate_expression_name/test.stderr @@ -1,5 +1,5 @@ error: An expression with the name 'Expression1' already exists. --> src/fail/definitions/duplicate_expression_name/test.rs:19:53 | -19 | PrecedenceExpression(name = Expression1, rule_name = X, operators = []) +19 | PrecedenceExpression(name = Expression1, operators = []) | ^^^^^^^^^^^ diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 141ed6081e..69061efdde 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -126,7 +126,6 @@ codegen_language_macros::compile!(Language( precedence_expressions = [ PrecedenceExpression( name = VersionPragmaOrExpression, - rule_name = VersionPragmaBinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(BarBar)) @@ -134,7 +133,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = VersionPragmaRangeExpression, - rule_name = VersionPragmaBinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Minus)) @@ -142,7 +140,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = VersionPragmaPrefixExpression, - rule_name = VersionPragmaUnaryExpression, operators = [ PrecedenceOperator( model = Prefix, @@ -2549,7 +2546,6 @@ codegen_language_macros::compile!(Language( name = TypeName, precedence_expressions = [PrecedenceExpression( name = ArrayTypeName, - rule_name = ArrayTypeName, operators = [PrecedenceOperator( model = Postfix, error_recovery = FieldsErrorRecovery( @@ -3040,7 +3036,6 @@ codegen_language_macros::compile!(Language( precedence_expressions = [ PrecedenceExpression( name = AssignmentExpression, - rule_name = BinaryExpression, operators = [ PrecedenceOperator( model = BinaryLeftAssociative, @@ -3096,7 +3091,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = ConditionalExpression, - rule_name = ConditionalExpression, operators = [PrecedenceOperator( model = Postfix, fields = ( @@ -3109,7 +3103,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = OrExpression, - rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(BarBar)) @@ -3117,7 +3110,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = AndExpression, - rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(AmpersandAmpersand)) @@ -3125,7 +3117,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = EqualityExpression, - rule_name = BinaryExpression, operators = [ PrecedenceOperator( model = BinaryLeftAssociative, @@ -3139,7 +3130,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = ComparisonExpression, - rule_name = BinaryExpression, operators = [ PrecedenceOperator( model = BinaryLeftAssociative, @@ -3161,7 +3151,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = BitwiseOrExpression, - rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Bar)) @@ -3169,7 +3158,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = BitwiseXorExpression, - rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Caret)) @@ -3177,7 +3165,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = BitwiseAndExpression, - rule_name = BinaryExpression, operators = [PrecedenceOperator( model = BinaryLeftAssociative, fields = (operator = Required(Ampersand)) @@ -3185,7 +3172,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = ShiftExpression, - rule_name = BinaryExpression, operators = [ PrecedenceOperator( model = BinaryLeftAssociative, @@ -3204,7 +3190,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = AdditiveExpression, - rule_name = BinaryExpression, operators = [ PrecedenceOperator( model = BinaryLeftAssociative, @@ -3218,7 +3203,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = MultiplicativeExpression, - rule_name = BinaryExpression, operators = [ PrecedenceOperator( model = BinaryLeftAssociative, @@ -3236,7 +3220,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = ExponentiationExpression, - rule_name = BinaryExpression, operators = [ // Before '0.6.0', it was left-associative: PrecedenceOperator( @@ -3254,7 +3237,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = PostfixExpression, - rule_name = UnaryPostfixExpression, operators = [ PrecedenceOperator( model = Postfix, @@ -3268,7 +3250,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = PrefixExpression, - rule_name = UnaryPrefixExpression, operators = [ PrecedenceOperator( model = Prefix, @@ -3299,7 +3280,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = FunctionCallExpression, - rule_name = FunctionCallExpression, operators = [PrecedenceOperator( model = Postfix, fields = ( @@ -3313,7 +3293,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = MemberAccessExpression, - rule_name = MemberAccessExpression, operators = [PrecedenceOperator( model = Postfix, fields = ( @@ -3324,7 +3303,6 @@ codegen_language_macros::compile!(Language( ), PrecedenceExpression( name = IndexAccessExpression, - rule_name = IndexAccessExpression, operators = [PrecedenceOperator( model = Postfix, error_recovery = FieldsErrorRecovery( @@ -4059,7 +4037,6 @@ codegen_language_macros::compile!(Language( name = YulExpression, precedence_expressions = [PrecedenceExpression( name = YulFunctionCallExpression, - rule_name = YulFunctionCallExpression, operators = [PrecedenceOperator( model = Postfix, error_recovery = FieldsErrorRecovery( diff --git a/crates/solidity/inputs/language/src/grammar.rs b/crates/solidity/inputs/language/src/grammar.rs index 2c8208206c..41f09dd252 100644 --- a/crates/solidity/inputs/language/src/grammar.rs +++ b/crates/solidity/inputs/language/src/grammar.rs @@ -752,7 +752,6 @@ fn resolve_precedence( let thunk = Rc::new(NamedParserThunk { name: name.to_string().leak(), context: lex_ctx, - // The operators are inlined but should be exposed under grouping `rule_name` below is_inline: true, def: OnceCell::new(), }); @@ -768,7 +767,7 @@ fn resolve_precedence( op.enabled.clone().map(enabled_to_range).unwrap_or_default(), model_to_enum(op.model), // TODO: Don't leak - expr.rule_name.to_string().leak() as &_, + name.to_string().leak() as &_, thunk.clone() as Rc, )); } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs index 185edf3e86..5fd9016364 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs @@ -18,7 +18,9 @@ use {napi::bindgen_prelude::*, napi_derive::napi}; #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] pub enum RuleKind { ABICoderPragma, + AdditiveExpression, AddressType, + AndExpression, ArgumentsDeclaration, ArrayExpression, ArrayTypeName, @@ -27,12 +29,16 @@ pub enum RuleKind { AssemblyFlags, AssemblyFlagsDeclaration, AssemblyStatement, - BinaryExpression, + AssignmentExpression, + BitwiseAndExpression, + BitwiseOrExpression, + BitwiseXorExpression, Block, BreakStatement, CatchClause, CatchClauseError, CatchClauses, + ComparisonExpression, ConditionalExpression, ConstantDefinition, ConstructorAttribute, @@ -51,6 +57,7 @@ pub enum RuleKind { EndOfFileTrivia, EnumDefinition, EnumMembers, + EqualityExpression, ErrorDefinition, ErrorParameter, ErrorParameters, @@ -61,6 +68,7 @@ pub enum RuleKind { EventParametersDeclaration, ExperimentalFeature, ExperimentalPragma, + ExponentiationExpression, Expression, ExpressionStatement, FallbackFunctionAttribute, @@ -109,6 +117,7 @@ pub enum RuleKind { ModifierAttributes, ModifierDefinition, ModifierInvocation, + MultiplicativeExpression, NamedArgument, NamedArgumentGroup, NamedArgumentGroups, @@ -117,6 +126,7 @@ pub enum RuleKind { NamedImport, NewExpression, NumberUnit, + OrExpression, OverridePaths, OverridePathsDeclaration, OverrideSpecifier, @@ -126,14 +136,17 @@ pub enum RuleKind { PathImport, PositionalArguments, PositionalArgumentsDeclaration, + PostfixExpression, Pragma, PragmaDirective, + PrefixExpression, ReceiveFunctionAttribute, ReceiveFunctionAttributes, ReceiveFunctionDefinition, ReturnStatement, ReturnsDeclaration, RevertStatement, + ShiftExpression, SourceUnit, SourceUnitMember, SourceUnitMembers, @@ -161,8 +174,6 @@ pub enum RuleKind { TypeExpression, TypeName, TypedTupleMember, - UnaryPostfixExpression, - UnaryPrefixExpression, UncheckedBlock, UnicodeStringLiterals, UnnamedFunctionAttribute, @@ -182,11 +193,12 @@ pub enum RuleKind { VariableDeclarationType, VariableDeclarationValue, VersionPragma, - VersionPragmaBinaryExpression, VersionPragmaExpression, VersionPragmaExpressions, + VersionPragmaOrExpression, + VersionPragmaPrefixExpression, + VersionPragmaRangeExpression, VersionPragmaSpecifier, - VersionPragmaUnaryExpression, WhileStatement, YulArguments, YulAssignmentStatement, diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index d67c0e8aff..2ae97aafbd 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -1185,7 +1185,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 1u8, 1u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1256,7 +1256,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 3u8, 3u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1327,7 +1327,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 5u8, 5u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1398,7 +1398,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 7u8, 7u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1469,7 +1469,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 9u8, 9u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1540,7 +1540,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 11u8, 11u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1611,7 +1611,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 13u8, 13u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1682,7 +1682,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 15u8, 15u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1753,7 +1753,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 17u8, 17u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1824,7 +1824,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 19u8, 19u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1895,7 +1895,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 21u8, 21u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1966,7 +1966,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 23u8, 23u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2057,7 +2057,7 @@ impl Language { #[allow(unused_variables)] let parse_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::OrExpression, 27u8, 27u8 + 1, self.parse_token_with_trivia::( @@ -2069,7 +2069,7 @@ impl Language { #[allow(unused_variables)] let parse_and_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AndExpression, 29u8, 29u8 + 1, self.parse_token_with_trivia::( @@ -2081,7 +2081,7 @@ impl Language { #[allow(unused_variables)] let parse_equality_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::EqualityExpression, 31u8, 31u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2102,7 +2102,7 @@ impl Language { #[allow(unused_variables)] let parse_equality_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::EqualityExpression, 33u8, 33u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2123,7 +2123,7 @@ impl Language { #[allow(unused_variables)] let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ComparisonExpression, 35u8, 35u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2154,7 +2154,7 @@ impl Language { #[allow(unused_variables)] let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ComparisonExpression, 37u8, 37u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2185,7 +2185,7 @@ impl Language { #[allow(unused_variables)] let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ComparisonExpression, 39u8, 39u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2216,7 +2216,7 @@ impl Language { #[allow(unused_variables)] let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ComparisonExpression, 41u8, 41u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2247,7 +2247,7 @@ impl Language { #[allow(unused_variables)] let parse_bitwise_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::BitwiseOrExpression, 43u8, 43u8 + 1, self.parse_token_with_trivia::(input, TokenKind::Bar), @@ -2256,7 +2256,7 @@ impl Language { #[allow(unused_variables)] let parse_bitwise_xor_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::BitwiseXorExpression, 45u8, 45u8 + 1, self.parse_token_with_trivia::( @@ -2268,7 +2268,7 @@ impl Language { #[allow(unused_variables)] let parse_bitwise_and_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::BitwiseAndExpression, 47u8, 47u8 + 1, self.parse_token_with_trivia::( @@ -2280,7 +2280,7 @@ impl Language { #[allow(unused_variables)] let parse_shift_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ShiftExpression, 49u8, 49u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2306,7 +2306,7 @@ impl Language { #[allow(unused_variables)] let parse_shift_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ShiftExpression, 51u8, 51u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2332,7 +2332,7 @@ impl Language { #[allow(unused_variables)] let parse_shift_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ShiftExpression, 53u8, 53u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2358,7 +2358,7 @@ impl Language { #[allow(unused_variables)] let parse_additive_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AdditiveExpression, 55u8, 55u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2379,7 +2379,7 @@ impl Language { #[allow(unused_variables)] let parse_additive_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AdditiveExpression, 57u8, 57u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2400,7 +2400,7 @@ impl Language { #[allow(unused_variables)] let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::MultiplicativeExpression, 59u8, 59u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2426,7 +2426,7 @@ impl Language { #[allow(unused_variables)] let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::MultiplicativeExpression, 61u8, 61u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2452,7 +2452,7 @@ impl Language { #[allow(unused_variables)] let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::MultiplicativeExpression, 63u8, 63u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2478,7 +2478,7 @@ impl Language { #[allow(unused_variables)] let parse_exponentiation_expression_removed_from_0_6_0 = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ExponentiationExpression, 65u8, 65u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2505,7 +2505,7 @@ impl Language { '_, >| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ExponentiationExpression, 67u8 + 1, 67u8, ChoiceHelper::run(input, |mut choice, input| { @@ -2530,7 +2530,7 @@ impl Language { #[allow(unused_variables)] let parse_postfix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - RuleKind::UnaryPostfixExpression, + RuleKind::PostfixExpression, 69u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -2550,7 +2550,7 @@ impl Language { #[allow(unused_variables)] let parse_postfix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - RuleKind::UnaryPostfixExpression, + RuleKind::PostfixExpression, 71u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -2570,7 +2570,7 @@ impl Language { #[allow(unused_variables)] let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, + RuleKind::PrefixExpression, 73u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -2612,7 +2612,7 @@ impl Language { #[allow(unused_variables)] let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, + RuleKind::PrefixExpression, 75u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -2654,7 +2654,7 @@ impl Language { #[allow(unused_variables)] let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, + RuleKind::PrefixExpression, 77u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -2696,7 +2696,7 @@ impl Language { #[allow(unused_variables)] let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, + RuleKind::PrefixExpression, 79u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -2738,7 +2738,7 @@ impl Language { #[allow(unused_variables)] let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, + RuleKind::PrefixExpression, 81u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -2780,7 +2780,7 @@ impl Language { #[allow(unused_variables)] let parse_prefix_expression_removed_from_0_5_0 = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, + RuleKind::PrefixExpression, 83u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -5603,7 +5603,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::VersionPragmaBinaryExpression, + RuleKind::VersionPragmaOrExpression, 1u8, 1u8 + 1, self.parse_token_with_trivia::( @@ -5615,7 +5615,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_range_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::VersionPragmaBinaryExpression, + RuleKind::VersionPragmaRangeExpression, 3u8, 3u8 + 1, self.parse_token_with_trivia::(input, TokenKind::Minus), @@ -5624,7 +5624,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, + RuleKind::VersionPragmaPrefixExpression, 5u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -5669,7 +5669,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, + RuleKind::VersionPragmaPrefixExpression, 7u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -5714,7 +5714,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, + RuleKind::VersionPragmaPrefixExpression, 9u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -5759,7 +5759,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, + RuleKind::VersionPragmaPrefixExpression, 11u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -5804,7 +5804,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, + RuleKind::VersionPragmaPrefixExpression, 13u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -5849,7 +5849,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, + RuleKind::VersionPragmaPrefixExpression, 15u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -5894,7 +5894,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, + RuleKind::VersionPragmaPrefixExpression, 17u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( diff --git a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs index 185edf3e86..5fd9016364 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs @@ -18,7 +18,9 @@ use {napi::bindgen_prelude::*, napi_derive::napi}; #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] pub enum RuleKind { ABICoderPragma, + AdditiveExpression, AddressType, + AndExpression, ArgumentsDeclaration, ArrayExpression, ArrayTypeName, @@ -27,12 +29,16 @@ pub enum RuleKind { AssemblyFlags, AssemblyFlagsDeclaration, AssemblyStatement, - BinaryExpression, + AssignmentExpression, + BitwiseAndExpression, + BitwiseOrExpression, + BitwiseXorExpression, Block, BreakStatement, CatchClause, CatchClauseError, CatchClauses, + ComparisonExpression, ConditionalExpression, ConstantDefinition, ConstructorAttribute, @@ -51,6 +57,7 @@ pub enum RuleKind { EndOfFileTrivia, EnumDefinition, EnumMembers, + EqualityExpression, ErrorDefinition, ErrorParameter, ErrorParameters, @@ -61,6 +68,7 @@ pub enum RuleKind { EventParametersDeclaration, ExperimentalFeature, ExperimentalPragma, + ExponentiationExpression, Expression, ExpressionStatement, FallbackFunctionAttribute, @@ -109,6 +117,7 @@ pub enum RuleKind { ModifierAttributes, ModifierDefinition, ModifierInvocation, + MultiplicativeExpression, NamedArgument, NamedArgumentGroup, NamedArgumentGroups, @@ -117,6 +126,7 @@ pub enum RuleKind { NamedImport, NewExpression, NumberUnit, + OrExpression, OverridePaths, OverridePathsDeclaration, OverrideSpecifier, @@ -126,14 +136,17 @@ pub enum RuleKind { PathImport, PositionalArguments, PositionalArgumentsDeclaration, + PostfixExpression, Pragma, PragmaDirective, + PrefixExpression, ReceiveFunctionAttribute, ReceiveFunctionAttributes, ReceiveFunctionDefinition, ReturnStatement, ReturnsDeclaration, RevertStatement, + ShiftExpression, SourceUnit, SourceUnitMember, SourceUnitMembers, @@ -161,8 +174,6 @@ pub enum RuleKind { TypeExpression, TypeName, TypedTupleMember, - UnaryPostfixExpression, - UnaryPrefixExpression, UncheckedBlock, UnicodeStringLiterals, UnnamedFunctionAttribute, @@ -182,11 +193,12 @@ pub enum RuleKind { VariableDeclarationType, VariableDeclarationValue, VersionPragma, - VersionPragmaBinaryExpression, VersionPragmaExpression, VersionPragmaExpressions, + VersionPragmaOrExpression, + VersionPragmaPrefixExpression, + VersionPragmaRangeExpression, VersionPragmaSpecifier, - VersionPragmaUnaryExpression, WhileStatement, YulArguments, YulAssignmentStatement, diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index d67c0e8aff..2ae97aafbd 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -1185,7 +1185,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 1u8, 1u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1256,7 +1256,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 3u8, 3u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1327,7 +1327,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 5u8, 5u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1398,7 +1398,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 7u8, 7u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1469,7 +1469,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 9u8, 9u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1540,7 +1540,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 11u8, 11u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1611,7 +1611,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 13u8, 13u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1682,7 +1682,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 15u8, 15u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1753,7 +1753,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 17u8, 17u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1824,7 +1824,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 19u8, 19u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1895,7 +1895,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 21u8, 21u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -1966,7 +1966,7 @@ impl Language { #[allow(unused_variables)] let parse_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AssignmentExpression, 23u8, 23u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2057,7 +2057,7 @@ impl Language { #[allow(unused_variables)] let parse_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::OrExpression, 27u8, 27u8 + 1, self.parse_token_with_trivia::( @@ -2069,7 +2069,7 @@ impl Language { #[allow(unused_variables)] let parse_and_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AndExpression, 29u8, 29u8 + 1, self.parse_token_with_trivia::( @@ -2081,7 +2081,7 @@ impl Language { #[allow(unused_variables)] let parse_equality_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::EqualityExpression, 31u8, 31u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2102,7 +2102,7 @@ impl Language { #[allow(unused_variables)] let parse_equality_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::EqualityExpression, 33u8, 33u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2123,7 +2123,7 @@ impl Language { #[allow(unused_variables)] let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ComparisonExpression, 35u8, 35u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2154,7 +2154,7 @@ impl Language { #[allow(unused_variables)] let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ComparisonExpression, 37u8, 37u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2185,7 +2185,7 @@ impl Language { #[allow(unused_variables)] let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ComparisonExpression, 39u8, 39u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2216,7 +2216,7 @@ impl Language { #[allow(unused_variables)] let parse_comparison_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ComparisonExpression, 41u8, 41u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2247,7 +2247,7 @@ impl Language { #[allow(unused_variables)] let parse_bitwise_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::BitwiseOrExpression, 43u8, 43u8 + 1, self.parse_token_with_trivia::(input, TokenKind::Bar), @@ -2256,7 +2256,7 @@ impl Language { #[allow(unused_variables)] let parse_bitwise_xor_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::BitwiseXorExpression, 45u8, 45u8 + 1, self.parse_token_with_trivia::( @@ -2268,7 +2268,7 @@ impl Language { #[allow(unused_variables)] let parse_bitwise_and_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::BitwiseAndExpression, 47u8, 47u8 + 1, self.parse_token_with_trivia::( @@ -2280,7 +2280,7 @@ impl Language { #[allow(unused_variables)] let parse_shift_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ShiftExpression, 49u8, 49u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2306,7 +2306,7 @@ impl Language { #[allow(unused_variables)] let parse_shift_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ShiftExpression, 51u8, 51u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2332,7 +2332,7 @@ impl Language { #[allow(unused_variables)] let parse_shift_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ShiftExpression, 53u8, 53u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2358,7 +2358,7 @@ impl Language { #[allow(unused_variables)] let parse_additive_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AdditiveExpression, 55u8, 55u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2379,7 +2379,7 @@ impl Language { #[allow(unused_variables)] let parse_additive_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::AdditiveExpression, 57u8, 57u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2400,7 +2400,7 @@ impl Language { #[allow(unused_variables)] let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::MultiplicativeExpression, 59u8, 59u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2426,7 +2426,7 @@ impl Language { #[allow(unused_variables)] let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::MultiplicativeExpression, 61u8, 61u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2452,7 +2452,7 @@ impl Language { #[allow(unused_variables)] let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::MultiplicativeExpression, 63u8, 63u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2478,7 +2478,7 @@ impl Language { #[allow(unused_variables)] let parse_exponentiation_expression_removed_from_0_6_0 = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ExponentiationExpression, 65u8, 65u8 + 1, ChoiceHelper::run(input, |mut choice, input| { @@ -2505,7 +2505,7 @@ impl Language { '_, >| { PrecedenceHelper::to_binary_operator( - RuleKind::BinaryExpression, + RuleKind::ExponentiationExpression, 67u8 + 1, 67u8, ChoiceHelper::run(input, |mut choice, input| { @@ -2530,7 +2530,7 @@ impl Language { #[allow(unused_variables)] let parse_postfix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - RuleKind::UnaryPostfixExpression, + RuleKind::PostfixExpression, 69u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -2550,7 +2550,7 @@ impl Language { #[allow(unused_variables)] let parse_postfix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( - RuleKind::UnaryPostfixExpression, + RuleKind::PostfixExpression, 71u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -2570,7 +2570,7 @@ impl Language { #[allow(unused_variables)] let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, + RuleKind::PrefixExpression, 73u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -2612,7 +2612,7 @@ impl Language { #[allow(unused_variables)] let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, + RuleKind::PrefixExpression, 75u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -2654,7 +2654,7 @@ impl Language { #[allow(unused_variables)] let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, + RuleKind::PrefixExpression, 77u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -2696,7 +2696,7 @@ impl Language { #[allow(unused_variables)] let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, + RuleKind::PrefixExpression, 79u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -2738,7 +2738,7 @@ impl Language { #[allow(unused_variables)] let parse_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, + RuleKind::PrefixExpression, 81u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -2780,7 +2780,7 @@ impl Language { #[allow(unused_variables)] let parse_prefix_expression_removed_from_0_5_0 = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::UnaryPrefixExpression, + RuleKind::PrefixExpression, 83u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -5603,7 +5603,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_or_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::VersionPragmaBinaryExpression, + RuleKind::VersionPragmaOrExpression, 1u8, 1u8 + 1, self.parse_token_with_trivia::( @@ -5615,7 +5615,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_range_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::VersionPragmaBinaryExpression, + RuleKind::VersionPragmaRangeExpression, 3u8, 3u8 + 1, self.parse_token_with_trivia::(input, TokenKind::Minus), @@ -5624,7 +5624,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, + RuleKind::VersionPragmaPrefixExpression, 5u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -5669,7 +5669,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, + RuleKind::VersionPragmaPrefixExpression, 7u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -5714,7 +5714,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, + RuleKind::VersionPragmaPrefixExpression, 9u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -5759,7 +5759,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, + RuleKind::VersionPragmaPrefixExpression, 11u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -5804,7 +5804,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, + RuleKind::VersionPragmaPrefixExpression, 13u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -5849,7 +5849,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, + RuleKind::VersionPragmaPrefixExpression, 15u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( @@ -5894,7 +5894,7 @@ impl Language { #[allow(unused_variables)] let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaUnaryExpression, + RuleKind::VersionPragmaPrefixExpression, 17u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( diff --git a/crates/solidity/outputs/npm/package/src/generated/index.d.ts b/crates/solidity/outputs/npm/package/src/generated/index.d.ts index 50b7549c1a..93b799da0b 100644 --- a/crates/solidity/outputs/npm/package/src/generated/index.d.ts +++ b/crates/solidity/outputs/npm/package/src/generated/index.d.ts @@ -11,7 +11,9 @@ export namespace kinds { export enum RuleKind { ABICoderPragma = "ABICoderPragma", + AdditiveExpression = "AdditiveExpression", AddressType = "AddressType", + AndExpression = "AndExpression", ArgumentsDeclaration = "ArgumentsDeclaration", ArrayExpression = "ArrayExpression", ArrayTypeName = "ArrayTypeName", @@ -20,12 +22,16 @@ export namespace kinds { AssemblyFlags = "AssemblyFlags", AssemblyFlagsDeclaration = "AssemblyFlagsDeclaration", AssemblyStatement = "AssemblyStatement", - BinaryExpression = "BinaryExpression", + AssignmentExpression = "AssignmentExpression", + BitwiseAndExpression = "BitwiseAndExpression", + BitwiseOrExpression = "BitwiseOrExpression", + BitwiseXorExpression = "BitwiseXorExpression", Block = "Block", BreakStatement = "BreakStatement", CatchClause = "CatchClause", CatchClauseError = "CatchClauseError", CatchClauses = "CatchClauses", + ComparisonExpression = "ComparisonExpression", ConditionalExpression = "ConditionalExpression", ConstantDefinition = "ConstantDefinition", ConstructorAttribute = "ConstructorAttribute", @@ -44,6 +50,7 @@ export namespace kinds { EndOfFileTrivia = "EndOfFileTrivia", EnumDefinition = "EnumDefinition", EnumMembers = "EnumMembers", + EqualityExpression = "EqualityExpression", ErrorDefinition = "ErrorDefinition", ErrorParameter = "ErrorParameter", ErrorParameters = "ErrorParameters", @@ -54,6 +61,7 @@ export namespace kinds { EventParametersDeclaration = "EventParametersDeclaration", ExperimentalFeature = "ExperimentalFeature", ExperimentalPragma = "ExperimentalPragma", + ExponentiationExpression = "ExponentiationExpression", Expression = "Expression", ExpressionStatement = "ExpressionStatement", FallbackFunctionAttribute = "FallbackFunctionAttribute", @@ -102,6 +110,7 @@ export namespace kinds { ModifierAttributes = "ModifierAttributes", ModifierDefinition = "ModifierDefinition", ModifierInvocation = "ModifierInvocation", + MultiplicativeExpression = "MultiplicativeExpression", NamedArgument = "NamedArgument", NamedArgumentGroup = "NamedArgumentGroup", NamedArgumentGroups = "NamedArgumentGroups", @@ -110,6 +119,7 @@ export namespace kinds { NamedImport = "NamedImport", NewExpression = "NewExpression", NumberUnit = "NumberUnit", + OrExpression = "OrExpression", OverridePaths = "OverridePaths", OverridePathsDeclaration = "OverridePathsDeclaration", OverrideSpecifier = "OverrideSpecifier", @@ -119,14 +129,17 @@ export namespace kinds { PathImport = "PathImport", PositionalArguments = "PositionalArguments", PositionalArgumentsDeclaration = "PositionalArgumentsDeclaration", + PostfixExpression = "PostfixExpression", Pragma = "Pragma", PragmaDirective = "PragmaDirective", + PrefixExpression = "PrefixExpression", ReceiveFunctionAttribute = "ReceiveFunctionAttribute", ReceiveFunctionAttributes = "ReceiveFunctionAttributes", ReceiveFunctionDefinition = "ReceiveFunctionDefinition", ReturnStatement = "ReturnStatement", ReturnsDeclaration = "ReturnsDeclaration", RevertStatement = "RevertStatement", + ShiftExpression = "ShiftExpression", SourceUnit = "SourceUnit", SourceUnitMember = "SourceUnitMember", SourceUnitMembers = "SourceUnitMembers", @@ -154,8 +167,6 @@ export namespace kinds { TypeExpression = "TypeExpression", TypeName = "TypeName", TypedTupleMember = "TypedTupleMember", - UnaryPostfixExpression = "UnaryPostfixExpression", - UnaryPrefixExpression = "UnaryPrefixExpression", UncheckedBlock = "UncheckedBlock", UnicodeStringLiterals = "UnicodeStringLiterals", UnnamedFunctionAttribute = "UnnamedFunctionAttribute", @@ -175,11 +186,12 @@ export namespace kinds { VariableDeclarationType = "VariableDeclarationType", VariableDeclarationValue = "VariableDeclarationValue", VersionPragma = "VersionPragma", - VersionPragmaBinaryExpression = "VersionPragmaBinaryExpression", VersionPragmaExpression = "VersionPragmaExpression", VersionPragmaExpressions = "VersionPragmaExpressions", + VersionPragmaOrExpression = "VersionPragmaOrExpression", + VersionPragmaPrefixExpression = "VersionPragmaPrefixExpression", + VersionPragmaRangeExpression = "VersionPragmaRangeExpression", VersionPragmaSpecifier = "VersionPragmaSpecifier", - VersionPragmaUnaryExpression = "VersionPragmaUnaryExpression", WhileStatement = "WhileStatement", YulArguments = "YulArguments", YulAssignmentStatement = "YulAssignmentStatement", diff --git a/crates/solidity/outputs/npm/tests/src/tests/cst-cursor.ts b/crates/solidity/outputs/npm/tests/src/tests/cst-cursor.ts index cf9803f2c0..58a2fb06b3 100644 --- a/crates/solidity/outputs/npm/tests/src/tests/cst-cursor.ts +++ b/crates/solidity/outputs/npm/tests/src/tests/cst-cursor.ts @@ -61,7 +61,7 @@ test("use cursor", () => { expectRule(cursor.node(), RuleKind.Expression); expect(cursor.goToNext()).toBe(true); - expectRule(cursor.node(), RuleKind.BinaryExpression); + expectRule(cursor.node(), RuleKind.AdditiveExpression); expect(cursor.goToNext()).toBe(true); expectRule(cursor.node(), RuleKind.Expression); diff --git a/crates/solidity/testing/snapshots/cst_output/Block/unchecked/generated/0.8.0-success.yml b/crates/solidity/testing/snapshots/cst_output/Block/unchecked/generated/0.8.0-success.yml index e54c525bb5..33c20a7cfc 100644 --- a/crates/solidity/testing/snapshots/cst_output/Block/unchecked/generated/0.8.0-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Block/unchecked/generated/0.8.0-success.yml @@ -18,7 +18,7 @@ Tree: - Statement (Rule): # 13..20 " x = 1;" - ExpressionStatement (Rule): # 13..20 " x = 1;" - Expression (Rule): # 13..19 " x = 1" - - BinaryExpression (Rule): # 13..19 " x = 1" + - AssignmentExpression (Rule): # 13..19 " x = 1" - Expression (Rule): # 13..15 " x" - Identifier (Token): "x" # 14..15 - Equal (Token): "=" # 16..17 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.4.11-failure.yml index 97082d571d..eb7915e42d 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.4.11-failure.yml @@ -69,7 +69,7 @@ Tree: - OpenParen (Token): "(" # 133..134 - PositionalArguments (Rule): # 134..198 'address(this).balance >= amount, "Address: insuffi...' - Expression (Rule): # 134..165 "address(this).balance >= amount" - - BinaryExpression (Rule): # 134..165 "address(this).balance >= amount" + - ComparisonExpression (Rule): # 134..165 "address(this).balance >= amount" - Expression (Rule): # 134..155 "address(this).balance" - MemberAccessExpression (Rule): # 134..155 "address(this).balance" - Expression (Rule): # 134..147 "address(this)" diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.6.2-success.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.6.2-success.yml index 1bba7d9ec3..e5d9dbf4ca 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.6.2-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.6.2-success.yml @@ -61,7 +61,7 @@ Tree: - OpenParen (Token): "(" # 133..134 - PositionalArguments (Rule): # 134..198 'address(this).balance >= amount, "Address: insuffi...' - Expression (Rule): # 134..165 "address(this).balance >= amount" - - BinaryExpression (Rule): # 134..165 "address(this).balance >= amount" + - ComparisonExpression (Rule): # 134..165 "address(this).balance >= amount" - Expression (Rule): # 134..155 "address(this).balance" - MemberAccessExpression (Rule): # 134..155 "address(this).balance" - Expression (Rule): # 134..147 "address(this)" diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.8.0-success.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.8.0-success.yml index f51fff9e96..aaf9eff1e8 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.8.0-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.8.0-success.yml @@ -61,7 +61,7 @@ Tree: - OpenParen (Token): "(" # 133..134 - PositionalArguments (Rule): # 134..198 'address(this).balance >= amount, "Address: insuffi...' - Expression (Rule): # 134..165 "address(this).balance >= amount" - - BinaryExpression (Rule): # 134..165 "address(this).balance >= amount" + - ComparisonExpression (Rule): # 134..165 "address(this).balance >= amount" - Expression (Rule): # 134..155 "address(this).balance" - MemberAccessExpression (Rule): # 134..155 "address(this).balance" - Expression (Rule): # 134..147 "address(this)" diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/local_expression/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/local_expression/generated/0.4.11-success.yml index f3dd2450ae..f53ce61cc1 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/local_expression/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/local_expression/generated/0.4.11-success.yml @@ -31,13 +31,13 @@ Tree: - VariableDeclarationValue (Rule): # 26..38 " = 1 + 2 * 3" - Equal (Token): "=" # 27..28 - Expression (Rule): # 28..38 " 1 + 2 * 3" - - BinaryExpression (Rule): # 28..38 " 1 + 2 * 3" + - AdditiveExpression (Rule): # 28..38 " 1 + 2 * 3" - Expression (Rule): # 28..30 " 1" - DecimalNumberExpression (Rule): # 28..30 " 1" - DecimalLiteral (Token): "1" # 29..30 - Plus (Token): "+" # 31..32 - Expression (Rule): # 32..38 " 2 * 3" - - BinaryExpression (Rule): # 32..38 " 2 * 3" + - MultiplicativeExpression (Rule): # 32..38 " 2 * 3" - Expression (Rule): # 32..34 " 2" - DecimalNumberExpression (Rule): # 32..34 " 2" - DecimalLiteral (Token): "2" # 33..34 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.11-failure.yml index cd3cf512d1..c8e6501e7e 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.11-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.21-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.21-failure.yml index afd17fa0ed..383bf63366 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.21-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.4.21-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.0-failure.yml index bd1f4c2e2d..c99b4ac7db 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.0-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.3-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.3-failure.yml index c492dce64f..689d1fcc3f 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.3-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.5.3-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.6.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.6.0-failure.yml index 143d3fcf3b..7619f3e5aa 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.6.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.6.0-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.7.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.7.0-failure.yml index 07aa14ec80..2e6a45acd9 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.7.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.7.0-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.0-failure.yml index 56729fe767..45fe6dc70c 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.0-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.4-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.4-failure.yml index 922c4458f3..f459533ed9 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.4-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/mismatched_delimiter/generated/0.8.4-failure.yml @@ -62,7 +62,7 @@ Tree: - TupleValues (Rule): # 58..63 "1 + 2" - TupleValue (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" + - AdditiveExpression (Rule): # 58..63 "1 + 2" - Expression (Rule): # 58..59 "1" - DecimalNumberExpression (Rule): # 58..59 "1" - DecimalLiteral (Token): "1" # 58..59 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/add_mul/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/add_mul/generated/0.4.11-success.yml index aee0045a2f..922a084e86 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/add_mul/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/add_mul/generated/0.4.11-success.yml @@ -7,9 +7,9 @@ Errors: [] Tree: - Expression (Rule): # 0..13 "a * b + c * d" - - BinaryExpression (Rule): # 0..13 "a * b + c * d" + - AdditiveExpression (Rule): # 0..13 "a * b + c * d" - Expression (Rule): # 0..5 "a * b" - - BinaryExpression (Rule): # 0..5 "a * b" + - MultiplicativeExpression (Rule): # 0..5 "a * b" - Expression (Rule): # 0..1 "a" - Identifier (Token): "a" # 0..1 - Asterisk (Token): "*" # 2..3 @@ -17,7 +17,7 @@ Tree: - Identifier (Token): "b" # 4..5 - Plus (Token): "+" # 6..7 - Expression (Rule): # 7..13 " c * d" - - BinaryExpression (Rule): # 7..13 " c * d" + - MultiplicativeExpression (Rule): # 7..13 " c * d" - Expression (Rule): # 7..9 " c" - Identifier (Token): "c" # 8..9 - Asterisk (Token): "*" # 10..11 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/generated/0.4.11-success.yml index 3b021353bc..20cb05a4e4 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/generated/0.4.11-success.yml @@ -14,7 +14,7 @@ Tree: - TupleValues (Rule): # 1..11 "foo == bar" - TupleValue (Rule): # 1..11 "foo == bar" - Expression (Rule): # 1..11 "foo == bar" - - BinaryExpression (Rule): # 1..11 "foo == bar" + - EqualityExpression (Rule): # 1..11 "foo == bar" - Expression (Rule): # 1..4 "foo" - Identifier (Token): "foo" # 1..4 - EqualEqual (Token): "==" # 5..7 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/generated/0.4.11-success.yml index 7420172850..49401a18b8 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/generated/0.4.11-success.yml @@ -17,7 +17,7 @@ Tree: - TupleValues (Rule): # 7..12 "a + b" - TupleValue (Rule): # 7..12 "a + b" - Expression (Rule): # 7..12 "a + b" - - BinaryExpression (Rule): # 7..12 "a + b" + - AdditiveExpression (Rule): # 7..12 "a + b" - Expression (Rule): # 7..8 "a" - Identifier (Token): "a" # 7..8 - Plus (Token): "+" # 9..10 @@ -31,7 +31,7 @@ Tree: - TupleValues (Rule): # 17..22 "c + d" - TupleValue (Rule): # 17..22 "c + d" - Expression (Rule): # 17..22 "c + d" - - BinaryExpression (Rule): # 17..22 "c + d" + - AdditiveExpression (Rule): # 17..22 "c + d" - Expression (Rule): # 17..18 "c" - Identifier (Token): "c" # 17..18 - Plus (Token): "+" # 19..20 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/generated/0.4.11-success.yml index aec8fe9d28..2280896669 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/generated/0.4.11-success.yml @@ -14,7 +14,7 @@ Tree: - Expression (Rule): # 5..40 " a == b ? a + b * c : a + b * c + d" - ConditionalExpression (Rule): # 5..40 " a == b ? a + b * c : a + b * c + d" - Expression (Rule): # 5..12 " a == b" - - BinaryExpression (Rule): # 5..12 " a == b" + - EqualityExpression (Rule): # 5..12 " a == b" - Expression (Rule): # 5..7 " a" - Identifier (Token): "a" # 6..7 - EqualEqual (Token): "==" # 8..10 @@ -22,12 +22,12 @@ Tree: - Identifier (Token): "b" # 11..12 - QuestionMark (Token): "?" # 13..14 - Expression (Rule): # 14..24 " a + b * c" - - BinaryExpression (Rule): # 14..24 " a + b * c" + - AdditiveExpression (Rule): # 14..24 " a + b * c" - Expression (Rule): # 14..16 " a" - Identifier (Token): "a" # 15..16 - Plus (Token): "+" # 17..18 - Expression (Rule): # 18..24 " b * c" - - BinaryExpression (Rule): # 18..24 " b * c" + - MultiplicativeExpression (Rule): # 18..24 " b * c" - Expression (Rule): # 18..20 " b" - Identifier (Token): "b" # 19..20 - Asterisk (Token): "*" # 21..22 @@ -35,14 +35,14 @@ Tree: - Identifier (Token): "c" # 23..24 - Colon (Token): ":" # 25..26 - Expression (Rule): # 26..40 " a + b * c + d" - - BinaryExpression (Rule): # 26..40 " a + b * c + d" + - AdditiveExpression (Rule): # 26..40 " a + b * c + d" - Expression (Rule): # 26..36 " a + b * c" - - BinaryExpression (Rule): # 26..36 " a + b * c" + - AdditiveExpression (Rule): # 26..36 " a + b * c" - Expression (Rule): # 26..28 " a" - Identifier (Token): "a" # 27..28 - Plus (Token): "+" # 29..30 - Expression (Rule): # 30..36 " b * c" - - BinaryExpression (Rule): # 30..36 " b * c" + - MultiplicativeExpression (Rule): # 30..36 " b * c" - Expression (Rule): # 30..32 " b" - Identifier (Token): "b" # 31..32 - Asterisk (Token): "*" # 33..34 @@ -55,13 +55,13 @@ Tree: - Expression (Rule): # 42..63 " !bar ? e + f : g + h" - ConditionalExpression (Rule): # 42..63 " !bar ? e + f : g + h" - Expression (Rule): # 42..47 " !bar" - - UnaryPrefixExpression (Rule): # 42..47 " !bar" + - PrefixExpression (Rule): # 42..47 " !bar" - Bang (Token): "!" # 43..44 - Expression (Rule): # 44..47 "bar" - Identifier (Token): "bar" # 44..47 - QuestionMark (Token): "?" # 48..49 - Expression (Rule): # 49..55 " e + f" - - BinaryExpression (Rule): # 49..55 " e + f" + - AdditiveExpression (Rule): # 49..55 " e + f" - Expression (Rule): # 49..51 " e" - Identifier (Token): "e" # 50..51 - Plus (Token): "+" # 52..53 @@ -69,7 +69,7 @@ Tree: - Identifier (Token): "f" # 54..55 - Colon (Token): ":" # 56..57 - Expression (Rule): # 57..63 " g + h" - - BinaryExpression (Rule): # 57..63 " g + h" + - AdditiveExpression (Rule): # 57..63 " g + h" - Expression (Rule): # 57..59 " g" - Identifier (Token): "g" # 58..59 - Plus (Token): "+" # 60..61 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.4.11-success.yml index cbb412d261..92a1e7aea6 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.4.11-success.yml @@ -7,9 +7,9 @@ Errors: [] Tree: - Expression (Rule): # 0..12 "x ** y ** z\n" - - BinaryExpression (Rule): # 0..12 "x ** y ** z\n" + - ExponentiationExpression (Rule): # 0..12 "x ** y ** z\n" - Expression (Rule): # 0..6 "x ** y" - - BinaryExpression (Rule): # 0..6 "x ** y" + - ExponentiationExpression (Rule): # 0..6 "x ** y" - Expression (Rule): # 0..1 "x" - Identifier (Token): "x" # 0..1 - AsteriskAsterisk (Token): "**" # 2..4 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.6.0-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.6.0-success.yml index 7013645345..facdfcccd0 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.6.0-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.6.0-success.yml @@ -7,12 +7,12 @@ Errors: [] Tree: - Expression (Rule): # 0..12 "x ** y ** z\n" - - BinaryExpression (Rule): # 0..12 "x ** y ** z\n" + - ExponentiationExpression (Rule): # 0..12 "x ** y ** z\n" - Expression (Rule): # 0..1 "x" - Identifier (Token): "x" # 0..1 - AsteriskAsterisk (Token): "**" # 2..4 - Expression (Rule): # 4..12 " y ** z\n" - - BinaryExpression (Rule): # 4..12 " y ** z\n" + - ExponentiationExpression (Rule): # 4..12 " y ** z\n" - Expression (Rule): # 4..6 " y" - Identifier (Token): "y" # 5..6 - AsteriskAsterisk (Token): "**" # 7..9 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.4.11-failure.yml index 6ba8946815..587426dcdd 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.4.11-failure.yml @@ -17,7 +17,7 @@ Tree: - Expression (Rule): # 0..8 "2 * new\n" - DecimalNumberExpression (Rule): # 0..1 "2" - DecimalLiteral (Token): "2" # 0..1 - - BinaryExpression (Rule): # 1..3 " *" + - MultiplicativeExpression (Rule): # 1..3 " *" - Asterisk (Token): "*" # 2..3 - NewExpression (Rule): # 3..8 " new\n" - NewKeyword (Token): "new" # 4..7 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.8.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.8.0-failure.yml index cfab07a5ed..b2d55fbc61 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.8.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/incomplete_operand/generated/0.8.0-failure.yml @@ -17,7 +17,7 @@ Tree: - Expression (Rule): # 0..8 "2 * new\n" - DecimalNumberExpression (Rule): # 0..1 "2" - DecimalLiteral (Token): "2" # 0..1 - - BinaryExpression (Rule): # 1..3 " *" + - MultiplicativeExpression (Rule): # 1..3 " *" - Asterisk (Token): "*" # 2..3 - NewExpression (Rule): # 3..8 " new\n" - NewKeyword (Token): "new" # 4..7 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/overlapping_operators/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/overlapping_operators/generated/0.4.11-success.yml index 0c0a5b4824..f93c60cb07 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/overlapping_operators/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/overlapping_operators/generated/0.4.11-success.yml @@ -7,9 +7,9 @@ Errors: [] Tree: - Expression (Rule): # 0..10 "a & b && c" - - BinaryExpression (Rule): # 0..10 "a & b && c" + - AndExpression (Rule): # 0..10 "a & b && c" - Expression (Rule): # 0..5 "a & b" - - BinaryExpression (Rule): # 0..5 "a & b" + - BitwiseAndExpression (Rule): # 0..5 "a & b" - Expression (Rule): # 0..1 "a" - Identifier (Token): "a" # 0..1 - Ampersand (Token): "&" # 2..3 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/postfix_decrement/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/postfix_decrement/generated/0.4.11-success.yml index f4b6083343..5509dded67 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/postfix_decrement/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/postfix_decrement/generated/0.4.11-success.yml @@ -7,7 +7,7 @@ Errors: [] Tree: - Expression (Rule): # 0..5 "foo--" - - UnaryPostfixExpression (Rule): # 0..5 "foo--" + - PostfixExpression (Rule): # 0..5 "foo--" - Expression (Rule): # 0..3 "foo" - Identifier (Token): "foo" # 0..3 - MinusMinus (Token): "--" # 3..5 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/prefix_decrement/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/prefix_decrement/generated/0.4.11-success.yml index d1f1d2e7c0..31cc07c850 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/prefix_decrement/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/prefix_decrement/generated/0.4.11-success.yml @@ -7,7 +7,7 @@ Errors: [] Tree: - Expression (Rule): # 0..5 "--foo" - - UnaryPrefixExpression (Rule): # 0..5 "--foo" + - PrefixExpression (Rule): # 0..5 "--foo" - MinusMinus (Token): "--" # 0..2 - Expression (Rule): # 2..5 "foo" - Identifier (Token): "foo" # 2..5 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/prefix_minus/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/prefix_minus/generated/0.4.11-success.yml index 37c36f3ce0..0e1234045d 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/prefix_minus/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/prefix_minus/generated/0.4.11-success.yml @@ -7,7 +7,7 @@ Errors: [] Tree: - Expression (Rule): # 0..4 "-foo" - - UnaryPrefixExpression (Rule): # 0..4 "-foo" + - PrefixExpression (Rule): # 0..4 "-foo" - Minus (Token): "-" # 0..1 - Expression (Rule): # 1..4 "foo" - Identifier (Token): "foo" # 1..4 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/prefix_plus/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/prefix_plus/generated/0.4.11-success.yml index 1687596b40..2e4d204281 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/prefix_plus/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/prefix_plus/generated/0.4.11-success.yml @@ -7,7 +7,7 @@ Errors: [] Tree: - Expression (Rule): # 0..4 "+foo" - - UnaryPrefixExpression (Rule): # 0..4 "+foo" + - PrefixExpression (Rule): # 0..4 "+foo" - Plus (Token): "+" # 0..1 - Expression (Rule): # 1..4 "foo" - Identifier (Token): "foo" # 1..4 diff --git a/crates/solidity/testing/snapshots/cst_output/ReturnStatement/invalid_terminator/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/ReturnStatement/invalid_terminator/generated/0.4.11-failure.yml index f43ed89169..7cd5253828 100644 --- a/crates/solidity/testing/snapshots/cst_output/ReturnStatement/invalid_terminator/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ReturnStatement/invalid_terminator/generated/0.4.11-failure.yml @@ -20,12 +20,12 @@ Tree: - ReturnStatement (Rule): # 0..38 "return a + 2 * some invalid tokens\n\n;\n" - ReturnKeyword (Token): "return" # 0..6 - Expression (Rule): # 6..19 " a + 2 * some" - - BinaryExpression (Rule): # 6..19 " a + 2 * some" + - AdditiveExpression (Rule): # 6..19 " a + 2 * some" - Expression (Rule): # 6..8 " a" - Identifier (Token): "a" # 7..8 - Plus (Token): "+" # 9..10 - Expression (Rule): # 10..19 " 2 * some" - - BinaryExpression (Rule): # 10..19 " 2 * some" + - MultiplicativeExpression (Rule): # 10..19 " 2 * some" - Expression (Rule): # 10..12 " 2" - DecimalNumberExpression (Rule): # 10..12 " 2" - DecimalLiteral (Token): "2" # 11..12 diff --git a/crates/solidity/testing/snapshots/cst_output/SourceUnit/SafeMath/generated/0.8.0-success.yml b/crates/solidity/testing/snapshots/cst_output/SourceUnit/SafeMath/generated/0.8.0-success.yml index c49ace0c34..a96a945288 100644 --- a/crates/solidity/testing/snapshots/cst_output/SourceUnit/SafeMath/generated/0.8.0-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/SourceUnit/SafeMath/generated/0.8.0-success.yml @@ -82,7 +82,7 @@ Tree: - VariableDeclarationValue (Rule): # 130..138 " = a + b" - Equal (Token): "=" # 131..132 - Expression (Rule): # 132..138 " a + b" - - BinaryExpression (Rule): # 132..138 " a + b" + - AdditiveExpression (Rule): # 132..138 " a + b" - Expression (Rule): # 132..134 " a" - Identifier (Token): "a" # 133..134 - Plus (Token): "+" # 135..136 @@ -94,7 +94,7 @@ Tree: - IfKeyword (Token): "if" # 146..148 - OpenParen (Token): "(" # 149..150 - Expression (Rule): # 150..155 "c < a" - - BinaryExpression (Rule): # 150..155 "c < a" + - ComparisonExpression (Rule): # 150..155 "c < a" - Expression (Rule): # 150..151 "c" - Identifier (Token): "c" # 150..151 - LessThan (Token): "<" # 152..153 diff --git a/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.4.11-failure.yml index d4a72b3797..94fb5672b2 100644 --- a/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.4.11-failure.yml @@ -50,7 +50,7 @@ Tree: - SolidityKeyword (Token): "solidity" # 39..47 - VersionPragmaExpressions (Rule): # 47..54 " ^0.8.0" - VersionPragmaExpression (Rule): # 47..54 " ^0.8.0" - - VersionPragmaUnaryExpression (Rule): # 47..54 " ^0.8.0" + - VersionPragmaPrefixExpression (Rule): # 47..54 " ^0.8.0" - Caret (Token): "^" # 48..49 - VersionPragmaExpression (Rule): # 49..54 "0.8.0" - VersionPragmaSpecifier (Rule): # 49..54 "0.8.0" diff --git a/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.8.13-success.yml b/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.8.13-success.yml index 0ef1dc5c7c..52650ac05b 100644 --- a/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.8.13-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/SourceUnit/using_directive/generated/0.8.13-success.yml @@ -40,7 +40,7 @@ Tree: - SolidityKeyword (Token): "solidity" # 39..47 - VersionPragmaExpressions (Rule): # 47..54 " ^0.8.0" - VersionPragmaExpression (Rule): # 47..54 " ^0.8.0" - - VersionPragmaUnaryExpression (Rule): # 47..54 " ^0.8.0" + - VersionPragmaPrefixExpression (Rule): # 47..54 " ^0.8.0" - Caret (Token): "^" # 48..49 - VersionPragmaExpression (Rule): # 49..54 "0.8.0" - VersionPragmaSpecifier (Rule): # 49..54 "0.8.0" diff --git a/crates/solidity/testing/snapshots/cst_output/Statements/compound_tokens/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Statements/compound_tokens/generated/0.4.11-success.yml index 018534db86..b6242d4ca7 100644 --- a/crates/solidity/testing/snapshots/cst_output/Statements/compound_tokens/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Statements/compound_tokens/generated/0.4.11-success.yml @@ -22,7 +22,7 @@ Tree: - Statement (Rule): # 0..8 "a && b;\n" - ExpressionStatement (Rule): # 0..8 "a && b;\n" - Expression (Rule): # 0..6 "a && b" - - BinaryExpression (Rule): # 0..6 "a && b" + - AndExpression (Rule): # 0..6 "a && b" - Expression (Rule): # 0..1 "a" - Identifier (Token): "a" # 0..1 - AmpersandAmpersand (Token): "&&" # 2..4 @@ -32,7 +32,7 @@ Tree: - Statement (Rule): # 8..16 "a &= b;\n" - ExpressionStatement (Rule): # 8..16 "a &= b;\n" - Expression (Rule): # 8..14 "a &= b" - - BinaryExpression (Rule): # 8..14 "a &= b" + - AssignmentExpression (Rule): # 8..14 "a &= b" - Expression (Rule): # 8..9 "a" - Identifier (Token): "a" # 8..9 - AmpersandEqual (Token): "&=" # 10..12 @@ -42,7 +42,7 @@ Tree: - Statement (Rule): # 16..24 "a || b;\n" - ExpressionStatement (Rule): # 16..24 "a || b;\n" - Expression (Rule): # 16..22 "a || b" - - BinaryExpression (Rule): # 16..22 "a || b" + - OrExpression (Rule): # 16..22 "a || b" - Expression (Rule): # 16..17 "a" - Identifier (Token): "a" # 16..17 - BarBar (Token): "||" # 18..20 @@ -52,7 +52,7 @@ Tree: - Statement (Rule): # 24..32 "a |= b;\n" - ExpressionStatement (Rule): # 24..32 "a |= b;\n" - Expression (Rule): # 24..30 "a |= b" - - BinaryExpression (Rule): # 24..30 "a |= b" + - AssignmentExpression (Rule): # 24..30 "a |= b" - Expression (Rule): # 24..25 "a" - Identifier (Token): "a" # 24..25 - BarEqual (Token): "|=" # 26..28 @@ -62,7 +62,7 @@ Tree: - Statement (Rule): # 32..39 "a / b;\n" - ExpressionStatement (Rule): # 32..39 "a / b;\n" - Expression (Rule): # 32..37 "a / b" - - BinaryExpression (Rule): # 32..37 "a / b" + - MultiplicativeExpression (Rule): # 32..37 "a / b" - Expression (Rule): # 32..33 "a" - Identifier (Token): "a" # 32..33 - Slash (Token): "/" # 34..35 @@ -72,7 +72,7 @@ Tree: - Statement (Rule): # 39..47 "a /= b;\n" - ExpressionStatement (Rule): # 39..47 "a /= b;\n" - Expression (Rule): # 39..45 "a /= b" - - BinaryExpression (Rule): # 39..45 "a /= b" + - AssignmentExpression (Rule): # 39..45 "a /= b" - Expression (Rule): # 39..40 "a" - Identifier (Token): "a" # 39..40 - SlashEqual (Token): "/=" # 41..43 @@ -82,7 +82,7 @@ Tree: - Statement (Rule): # 47..54 "a > b;\n" - ExpressionStatement (Rule): # 47..54 "a > b;\n" - Expression (Rule): # 47..52 "a > b" - - BinaryExpression (Rule): # 47..52 "a > b" + - ComparisonExpression (Rule): # 47..52 "a > b" - Expression (Rule): # 47..48 "a" - Identifier (Token): "a" # 47..48 - GreaterThan (Token): ">" # 49..50 @@ -92,7 +92,7 @@ Tree: - Statement (Rule): # 54..62 "a >= b;\n" - ExpressionStatement (Rule): # 54..62 "a >= b;\n" - Expression (Rule): # 54..60 "a >= b" - - BinaryExpression (Rule): # 54..60 "a >= b" + - ComparisonExpression (Rule): # 54..60 "a >= b" - Expression (Rule): # 54..55 "a" - Identifier (Token): "a" # 54..55 - GreaterThanEqual (Token): ">=" # 56..58 @@ -102,7 +102,7 @@ Tree: - Statement (Rule): # 62..70 "a >> b;\n" - ExpressionStatement (Rule): # 62..70 "a >> b;\n" - Expression (Rule): # 62..68 "a >> b" - - BinaryExpression (Rule): # 62..68 "a >> b" + - ShiftExpression (Rule): # 62..68 "a >> b" - Expression (Rule): # 62..63 "a" - Identifier (Token): "a" # 62..63 - GreaterThanGreaterThan (Token): ">>" # 64..66 @@ -112,7 +112,7 @@ Tree: - Statement (Rule): # 70..79 "a >>= b;\n" - ExpressionStatement (Rule): # 70..79 "a >>= b;\n" - Expression (Rule): # 70..77 "a >>= b" - - BinaryExpression (Rule): # 70..77 "a >>= b" + - AssignmentExpression (Rule): # 70..77 "a >>= b" - Expression (Rule): # 70..71 "a" - Identifier (Token): "a" # 70..71 - GreaterThanGreaterThanEqual (Token): ">>=" # 72..75 @@ -122,7 +122,7 @@ Tree: - Statement (Rule): # 79..89 "a >>>= b;\n" - ExpressionStatement (Rule): # 79..89 "a >>>= b;\n" - Expression (Rule): # 79..87 "a >>>= b" - - BinaryExpression (Rule): # 79..87 "a >>>= b" + - AssignmentExpression (Rule): # 79..87 "a >>>= b" - Expression (Rule): # 79..80 "a" - Identifier (Token): "a" # 79..80 - GreaterThanGreaterThanGreaterThanEqual (Token): ">>>=" # 81..85 @@ -132,7 +132,7 @@ Tree: - Statement (Rule): # 89..97 "a << b;\n" - ExpressionStatement (Rule): # 89..97 "a << b;\n" - Expression (Rule): # 89..95 "a << b" - - BinaryExpression (Rule): # 89..95 "a << b" + - ShiftExpression (Rule): # 89..95 "a << b" - Expression (Rule): # 89..90 "a" - Identifier (Token): "a" # 89..90 - LessThanLessThan (Token): "<<" # 91..93 @@ -142,7 +142,7 @@ Tree: - Statement (Rule): # 97..106 "a <<= b;\n" - ExpressionStatement (Rule): # 97..106 "a <<= b;\n" - Expression (Rule): # 97..104 "a <<= b" - - BinaryExpression (Rule): # 97..104 "a <<= b" + - AssignmentExpression (Rule): # 97..104 "a <<= b" - Expression (Rule): # 97..98 "a" - Identifier (Token): "a" # 97..98 - LessThanLessThanEqual (Token): "<<=" # 99..102 diff --git a/crates/solidity/testing/snapshots/cst_output/Statements/invalid_termination/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/Statements/invalid_termination/generated/0.4.11-failure.yml index 04dc3166d6..d832940c95 100644 --- a/crates/solidity/testing/snapshots/cst_output/Statements/invalid_termination/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/Statements/invalid_termination/generated/0.4.11-failure.yml @@ -37,7 +37,7 @@ Tree: - Statement (Rule): # 18..25 " 1 * 2;" - ExpressionStatement (Rule): # 18..25 " 1 * 2;" - Expression (Rule): # 18..24 " 1 * 2" - - BinaryExpression (Rule): # 18..24 " 1 * 2" + - MultiplicativeExpression (Rule): # 18..24 " 1 * 2" - Expression (Rule): # 18..20 " 1" - DecimalNumberExpression (Rule): # 18..20 " 1" - DecimalLiteral (Token): "1" # 19..20 @@ -49,7 +49,7 @@ Tree: - Statement (Rule): # 25..40 " 3 * b invalid;" - ExpressionStatement (Rule): # 25..40 " 3 * b invalid;" - Expression (Rule): # 25..31 " 3 * b" - - BinaryExpression (Rule): # 25..31 " 3 * b" + - MultiplicativeExpression (Rule): # 25..31 " 3 * b" - Expression (Rule): # 25..27 " 3" - DecimalNumberExpression (Rule): # 25..27 " 3" - DecimalLiteral (Token): "3" # 26..27 diff --git a/crates/solidity/testing/snapshots/cst_output/VersionPragma/alternatives/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/VersionPragma/alternatives/generated/0.4.11-success.yml index 85def026b9..8a9404d094 100644 --- a/crates/solidity/testing/snapshots/cst_output/VersionPragma/alternatives/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/VersionPragma/alternatives/generated/0.4.11-success.yml @@ -10,9 +10,9 @@ Tree: - SolidityKeyword (Token): "solidity" # 0..8 - VersionPragmaExpressions (Rule): # 8..33 " 0.5.0 || 0.6.0 || ^0.7.0" - VersionPragmaExpression (Rule): # 8..33 " 0.5.0 || 0.6.0 || ^0.7.0" - - VersionPragmaBinaryExpression (Rule): # 8..33 " 0.5.0 || 0.6.0 || ^0.7.0" + - VersionPragmaOrExpression (Rule): # 8..33 " 0.5.0 || 0.6.0 || ^0.7.0" - VersionPragmaExpression (Rule): # 8..23 " 0.5.0 || 0.6.0" - - VersionPragmaBinaryExpression (Rule): # 8..23 " 0.5.0 || 0.6.0" + - VersionPragmaOrExpression (Rule): # 8..23 " 0.5.0 || 0.6.0" - VersionPragmaExpression (Rule): # 8..14 " 0.5.0" - VersionPragmaSpecifier (Rule): # 8..14 " 0.5.0" - VersionPragmaValue (Token): "0" # 9..10 @@ -30,7 +30,7 @@ Tree: - VersionPragmaValue (Token): "0" # 22..23 - BarBar (Token): "||" # 24..26 - VersionPragmaExpression (Rule): # 26..33 " ^0.7.0" - - VersionPragmaUnaryExpression (Rule): # 26..33 " ^0.7.0" + - VersionPragmaPrefixExpression (Rule): # 26..33 " ^0.7.0" - Caret (Token): "^" # 27..28 - VersionPragmaExpression (Rule): # 28..33 "0.7.0" - VersionPragmaSpecifier (Rule): # 28..33 "0.7.0" diff --git a/crates/solidity/testing/snapshots/cst_output/VersionPragma/equal_operator/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/VersionPragma/equal_operator/generated/0.4.11-success.yml index 32b8a78c30..1c20d236e5 100644 --- a/crates/solidity/testing/snapshots/cst_output/VersionPragma/equal_operator/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/VersionPragma/equal_operator/generated/0.4.11-success.yml @@ -10,7 +10,7 @@ Tree: - SolidityKeyword (Token): "solidity" # 0..8 - VersionPragmaExpressions (Rule): # 8..15 " =0.8.0" - VersionPragmaExpression (Rule): # 8..15 " =0.8.0" - - VersionPragmaUnaryExpression (Rule): # 8..15 " =0.8.0" + - VersionPragmaPrefixExpression (Rule): # 8..15 " =0.8.0" - Equal (Token): "=" # 9..10 - VersionPragmaExpression (Rule): # 10..15 "0.8.0" - VersionPragmaSpecifier (Rule): # 10..15 "0.8.0" diff --git a/crates/solidity/testing/snapshots/cst_output/VersionPragma/less_than_operator/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/VersionPragma/less_than_operator/generated/0.4.11-success.yml index 5029c2e26d..277be9828f 100644 --- a/crates/solidity/testing/snapshots/cst_output/VersionPragma/less_than_operator/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/VersionPragma/less_than_operator/generated/0.4.11-success.yml @@ -10,7 +10,7 @@ Tree: - SolidityKeyword (Token): "solidity" # 0..8 - VersionPragmaExpressions (Rule): # 8..15 " <1.0.0" - VersionPragmaExpression (Rule): # 8..15 " <1.0.0" - - VersionPragmaUnaryExpression (Rule): # 8..15 " <1.0.0" + - VersionPragmaPrefixExpression (Rule): # 8..15 " <1.0.0" - LessThan (Token): "<" # 9..10 - VersionPragmaExpression (Rule): # 10..15 "1.0.0" - VersionPragmaSpecifier (Rule): # 10..15 "1.0.0" diff --git a/crates/solidity/testing/snapshots/cst_output/VersionPragma/nested_expressions/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/VersionPragma/nested_expressions/generated/0.4.11-success.yml index f2ac65f9d2..62c639dc9c 100644 --- a/crates/solidity/testing/snapshots/cst_output/VersionPragma/nested_expressions/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/VersionPragma/nested_expressions/generated/0.4.11-success.yml @@ -10,9 +10,9 @@ Tree: - SolidityKeyword (Token): "solidity" # 0..8 - VersionPragmaExpressions (Rule): # 8..30 " ^1.0.0 || 2.0.0-3.0.0" - VersionPragmaExpression (Rule): # 8..30 " ^1.0.0 || 2.0.0-3.0.0" - - VersionPragmaBinaryExpression (Rule): # 8..30 " ^1.0.0 || 2.0.0-3.0.0" + - VersionPragmaOrExpression (Rule): # 8..30 " ^1.0.0 || 2.0.0-3.0.0" - VersionPragmaExpression (Rule): # 8..15 " ^1.0.0" - - VersionPragmaUnaryExpression (Rule): # 8..15 " ^1.0.0" + - VersionPragmaPrefixExpression (Rule): # 8..15 " ^1.0.0" - Caret (Token): "^" # 9..10 - VersionPragmaExpression (Rule): # 10..15 "1.0.0" - VersionPragmaSpecifier (Rule): # 10..15 "1.0.0" @@ -23,7 +23,7 @@ Tree: - VersionPragmaValue (Token): "0" # 14..15 - BarBar (Token): "||" # 16..18 - VersionPragmaExpression (Rule): # 18..30 " 2.0.0-3.0.0" - - VersionPragmaBinaryExpression (Rule): # 18..30 " 2.0.0-3.0.0" + - VersionPragmaRangeExpression (Rule): # 18..30 " 2.0.0-3.0.0" - VersionPragmaExpression (Rule): # 18..24 " 2.0.0" - VersionPragmaSpecifier (Rule): # 18..24 " 2.0.0" - VersionPragmaValue (Token): "2" # 19..20 diff --git a/crates/solidity/testing/snapshots/cst_output/VersionPragma/ranges/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/VersionPragma/ranges/generated/0.4.11-success.yml index 2d3f769d55..d78f22fd12 100644 --- a/crates/solidity/testing/snapshots/cst_output/VersionPragma/ranges/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/VersionPragma/ranges/generated/0.4.11-success.yml @@ -10,7 +10,7 @@ Tree: - SolidityKeyword (Token): "solidity" # 0..8 - VersionPragmaExpressions (Rule): # 8..22 " 0.6.0 - 0.7.0" - VersionPragmaExpression (Rule): # 8..22 " 0.6.0 - 0.7.0" - - VersionPragmaBinaryExpression (Rule): # 8..22 " 0.6.0 - 0.7.0" + - VersionPragmaRangeExpression (Rule): # 8..22 " 0.6.0 - 0.7.0" - VersionPragmaExpression (Rule): # 8..14 " 0.6.0" - VersionPragmaSpecifier (Rule): # 8..14 " 0.6.0" - VersionPragmaValue (Token): "0" # 9..10 diff --git a/crates/solidity/testing/utils/src/version_pragmas/mod.rs b/crates/solidity/testing/utils/src/version_pragmas/mod.rs index b770c68e32..a974e5eab9 100644 --- a/crates/solidity/testing/utils/src/version_pragmas/mod.rs +++ b/crates/solidity/testing/utils/src/version_pragmas/mod.rs @@ -68,41 +68,43 @@ fn extract_pragma(expression_node: &Node) -> Result { .collect(); match inner_expression.kind { - RuleKind::VersionPragmaBinaryExpression => match &inner_children[..] { - [left, operator, right] => { - let Node::Token(operator) = operator else { - bail!("Expected rule: {operator:?}"); - }; - - match operator.kind { - TokenKind::BarBar => { - let left = extract_pragma(left)?; - let right = extract_pragma(right)?; - - Ok(VersionPragma::or(left, right)) + RuleKind::VersionPragmaOrExpression | RuleKind::VersionPragmaRangeExpression => { + match &inner_children[..] { + [left, operator, right] => { + let Node::Token(operator) = operator else { + bail!("Expected rule: {operator:?}"); + }; + + match operator.kind { + TokenKind::BarBar => { + let left = extract_pragma(left)?; + let right = extract_pragma(right)?; + + Ok(VersionPragma::or(left, right)) + } + TokenKind::Minus => { + let mut left = extract_pragma(left)?.comparator()?; + let mut right = extract_pragma(right)?.comparator()?; + + // Simulate solc bug: + // https://github.com/ethereum/solidity/issues/13920 + left.op = Op::GreaterEq; + right.op = Op::LessEq; + + Ok(VersionPragma::and( + VersionPragma::single(left), + VersionPragma::single(right), + )) + } + + _ => bail!("Unexpected operator: {operator:?}"), } - TokenKind::Minus => { - let mut left = extract_pragma(left)?.comparator()?; - let mut right = extract_pragma(right)?.comparator()?; - - // Simulate solc bug: - // https://github.com/ethereum/solidity/issues/13920 - left.op = Op::GreaterEq; - right.op = Op::LessEq; - - Ok(VersionPragma::and( - VersionPragma::single(left), - VersionPragma::single(right), - )) - } - - _ => bail!("Unexpected operator: {operator:?}"), } - } - _ => bail!("Expected 3 children: {inner_expression:?}"), - }, - RuleKind::VersionPragmaUnaryExpression => { + _ => bail!("Expected 3 children: {inner_expression:?}"), + } + } + RuleKind::VersionPragmaPrefixExpression => { let value = inner_expression.extract_non_trivia(); let comparator = Comparator::from_str(&value)?; From b3e7c169e1acb7b41f1e2e07638939691fb9e40f Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 6 Dec 2023 18:16:52 +0100 Subject: [PATCH 03/17] refactor: Move `disambiguating_name_suffix` to precedence-related code Since it's the only place it's used and it's a small helper. --- .../parser/generator/src/parser_definition.rs | 12 ------------ .../generator/src/precedence_parser_definition.rs | 13 ++++++++++++- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/crates/codegen/parser/generator/src/parser_definition.rs b/crates/codegen/parser/generator/src/parser_definition.rs index 8fd5fd02f0..fd2af06c76 100644 --- a/crates/codegen/parser/generator/src/parser_definition.rs +++ b/crates/codegen/parser/generator/src/parser_definition.rs @@ -260,7 +260,6 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { pub trait VersionQualityRangeVecExtensions { fn wrap_code(&self, if_true: TokenStream, if_false: Option) -> TokenStream; - fn disambiguating_name_suffix(&self) -> String; } impl VersionQualityRangeVecExtensions for Vec { @@ -283,15 +282,4 @@ impl VersionQualityRangeVecExtensions for Vec { quote! { if #(#flags)&&* { #if_true } #else_part } } } - - fn disambiguating_name_suffix(&self) -> String { - let mut suffix = String::new(); - for vqr in self { - suffix.push('_'); - suffix.push_str(&vqr.quality.to_string().to_lowercase()); - suffix.push_str("_from_"); - suffix.push_str(&vqr.from.to_string().replace('.', "_")); - } - suffix - } } diff --git a/crates/codegen/parser/generator/src/precedence_parser_definition.rs b/crates/codegen/parser/generator/src/precedence_parser_definition.rs index d97e68e3f9..317be945ed 100644 --- a/crates/codegen/parser/generator/src/precedence_parser_definition.rs +++ b/crates/codegen/parser/generator/src/precedence_parser_definition.rs @@ -95,7 +95,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode let closure_name = format_ident!( // Make a name that won't conflict with the parsers we define below "parse_{name}{version_tag}", - version_tag = version_quality_ranges.disambiguating_name_suffix(), + version_tag = disambiguating_name_suffix(version_quality_ranges), name = operator_definition.name().to_snake_case() ); @@ -256,3 +256,14 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode } } } + +fn disambiguating_name_suffix(ranges: &[VersionQualityRange]) -> String { + let mut suffix = String::new(); + for vqr in ranges { + suffix.push('_'); + suffix.push_str(&vqr.quality.to_string().to_lowercase()); + suffix.push_str("_from_"); + suffix.push_str(&vqr.from.to_string().replace('.', "_")); + } + suffix +} From f877ec6176822b864f8f24243e6b69899136d202 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 6 Dec 2023 18:23:50 +0100 Subject: [PATCH 04/17] refactor: Simplify redundant `Option`-wrapping in precedence codegen --- .../src/precedence_parser_definition.rs | 22 ++++--------------- .../runtime/src/support/precedence_helper.rs | 9 ++------ .../cargo/crate/src/generated/language.rs | 8 +++---- .../generated/support/precedence_helper.rs | 9 ++------ .../npm/crate/src/generated/language.rs | 8 +++---- .../generated/support/precedence_helper.rs | 9 ++------ 6 files changed, 18 insertions(+), 47 deletions(-) diff --git a/crates/codegen/parser/generator/src/precedence_parser_definition.rs b/crates/codegen/parser/generator/src/precedence_parser_definition.rs index 317be945ed..dc522fdcdb 100644 --- a/crates/codegen/parser/generator/src/precedence_parser_definition.rs +++ b/crates/codegen/parser/generator/src/precedence_parser_definition.rs @@ -17,17 +17,13 @@ impl PrecedenceParserDefinitionExtensions for PrecedenceParserDefinitionRef { fn to_parser_code(&self) -> TokenStream { self.node().to_parser_code( self.context(), - Some(format_ident!("{name}", name = self.name().to_pascal_case())), + format_ident!("{name}", name = self.name().to_pascal_case()), ) } } pub trait PrecedenceParserDefinitionNodeExtensions { - fn to_parser_code( - &self, - context_name: &'static str, - expression_kind: Option, - ) -> TokenStream; + fn to_parser_code(&self, context_name: &'static str, expression_kind: Ident) -> TokenStream; } impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode { @@ -72,11 +68,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode // is independent of the grammar. #[allow(clippy::too_many_lines)] // Repetition-heavy with 4 kinds of precedence operators - fn to_parser_code( - &self, - context_name: &'static str, - expression_kind: Option, - ) -> TokenStream { + fn to_parser_code(&self, context_name: &'static str, expression_kind: Ident) -> TokenStream { type OperatorParser = (TokenStream, Vec); let mut prefix_operator_parsers: Vec = Vec::new(); let mut postfix_operator_parsers: Vec = Vec::new(); @@ -239,12 +231,6 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode .push(quote! { let linear_expression_parser = |input: &mut ParserContext<'_>| #linear_expression_parser; }); } - let expression_kind_literal = if let Some(kind) = expression_kind { - quote! { Some(RuleKind::#kind) } - } else { - quote! { None } - }; - quote! { #( // TODO(#638): remove duplicates once we use DSL v2 versioning schema @@ -252,7 +238,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode #operator_closures )* - PrecedenceHelper::reduce_precedence_result(#expression_kind_literal, linear_expression_parser(input)) + PrecedenceHelper::reduce_precedence_result(RuleKind::#expression_kind, linear_expression_parser(input)) } } } diff --git a/crates/codegen/parser/runtime/src/support/precedence_helper.rs b/crates/codegen/parser/runtime/src/support/precedence_helper.rs index bc93d2e7d8..0ebe6f2a24 100644 --- a/crates/codegen/parser/runtime/src/support/precedence_helper.rs +++ b/crates/codegen/parser/runtime/src/support/precedence_helper.rs @@ -58,10 +58,7 @@ impl PrecedenceHelper { } #[allow(clippy::too_many_lines)] // Explicit on purpose, see below. - pub fn reduce_precedence_result( - child_kind: Option, - result: ParserResult, - ) -> ParserResult { + pub fn reduce_precedence_result(child_kind: RuleKind, result: ParserResult) -> ParserResult { // This requires some careful thinking. It could be more compact, // but I'm favouring obviousness here. That is also why there are // so many `unreachable!` - not only should they never be reached, @@ -162,10 +159,8 @@ impl PrecedenceHelper { let wrap_children = |children: Vec| { if children.is_empty() { children - } else if let Some(kind) = child_kind { - vec![cst::Node::rule(kind, children)] } else { - children + vec![cst::Node::rule(child_kind, children)] } }; diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index 2ae97aafbd..fc6b939bd9 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -3062,7 +3062,7 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::Expression), + RuleKind::Expression, linear_expression_parser(input), ) .with_kind(RuleKind::Expression) @@ -5119,7 +5119,7 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::TypeName), + RuleKind::TypeName, linear_expression_parser(input), ) .with_kind(RuleKind::TypeName) @@ -5994,7 +5994,7 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::VersionPragmaExpression), + RuleKind::VersionPragmaExpression, linear_expression_parser(input), ) .with_kind(RuleKind::VersionPragmaExpression) @@ -6203,7 +6203,7 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::YulExpression), + RuleKind::YulExpression, linear_expression_parser(input), ) .with_kind(RuleKind::YulExpression) diff --git a/crates/solidity/outputs/cargo/crate/src/generated/support/precedence_helper.rs b/crates/solidity/outputs/cargo/crate/src/generated/support/precedence_helper.rs index 0ee251bda3..175b2c538e 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/support/precedence_helper.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/support/precedence_helper.rs @@ -60,10 +60,7 @@ impl PrecedenceHelper { } #[allow(clippy::too_many_lines)] // Explicit on purpose, see below. - pub fn reduce_precedence_result( - child_kind: Option, - result: ParserResult, - ) -> ParserResult { + pub fn reduce_precedence_result(child_kind: RuleKind, result: ParserResult) -> ParserResult { // This requires some careful thinking. It could be more compact, // but I'm favouring obviousness here. That is also why there are // so many `unreachable!` - not only should they never be reached, @@ -164,10 +161,8 @@ impl PrecedenceHelper { let wrap_children = |children: Vec| { if children.is_empty() { children - } else if let Some(kind) = child_kind { - vec![cst::Node::rule(kind, children)] } else { - children + vec![cst::Node::rule(child_kind, children)] } }; diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index 2ae97aafbd..fc6b939bd9 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -3062,7 +3062,7 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::Expression), + RuleKind::Expression, linear_expression_parser(input), ) .with_kind(RuleKind::Expression) @@ -5119,7 +5119,7 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::TypeName), + RuleKind::TypeName, linear_expression_parser(input), ) .with_kind(RuleKind::TypeName) @@ -5994,7 +5994,7 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::VersionPragmaExpression), + RuleKind::VersionPragmaExpression, linear_expression_parser(input), ) .with_kind(RuleKind::VersionPragmaExpression) @@ -6203,7 +6203,7 @@ impl Language { }) }; PrecedenceHelper::reduce_precedence_result( - Some(RuleKind::YulExpression), + RuleKind::YulExpression, linear_expression_parser(input), ) .with_kind(RuleKind::YulExpression) diff --git a/crates/solidity/outputs/npm/crate/src/generated/support/precedence_helper.rs b/crates/solidity/outputs/npm/crate/src/generated/support/precedence_helper.rs index 0ee251bda3..175b2c538e 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/support/precedence_helper.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/support/precedence_helper.rs @@ -60,10 +60,7 @@ impl PrecedenceHelper { } #[allow(clippy::too_many_lines)] // Explicit on purpose, see below. - pub fn reduce_precedence_result( - child_kind: Option, - result: ParserResult, - ) -> ParserResult { + pub fn reduce_precedence_result(child_kind: RuleKind, result: ParserResult) -> ParserResult { // This requires some careful thinking. It could be more compact, // but I'm favouring obviousness here. That is also why there are // so many `unreachable!` - not only should they never be reached, @@ -164,10 +161,8 @@ impl PrecedenceHelper { let wrap_children = |children: Vec| { if children.is_empty() { children - } else if let Some(kind) = child_kind { - vec![cst::Node::rule(kind, children)] } else { - children + vec![cst::Node::rule(child_kind, children)] } }; From 65e2a263cc19bfffc9e5f506cbe618c31c1704fa Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 6 Dec 2023 18:55:26 +0100 Subject: [PATCH 05/17] Factor out parser helpers from precedence codegen function --- .../src/precedence_parser_definition.rs | 79 +++++++++---------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/crates/codegen/parser/generator/src/precedence_parser_definition.rs b/crates/codegen/parser/generator/src/precedence_parser_definition.rs index dc522fdcdb..2636379dfc 100644 --- a/crates/codegen/parser/generator/src/precedence_parser_definition.rs +++ b/crates/codegen/parser/generator/src/precedence_parser_definition.rs @@ -69,7 +69,6 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode #[allow(clippy::too_many_lines)] // Repetition-heavy with 4 kinds of precedence operators fn to_parser_code(&self, context_name: &'static str, expression_kind: Ident) -> TokenStream { - type OperatorParser = (TokenStream, Vec); let mut prefix_operator_parsers: Vec = Vec::new(); let mut postfix_operator_parsers: Vec = Vec::new(); let mut binary_operator_parsers: Vec = Vec::new(); @@ -148,45 +147,6 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode binding_power += 2; } - // TODO: merge these three functions into parse_definition by changing - // `to_parser_code` to use `(TokenStream, Vec)` as - // the core type i.e. the `OperatorParser` type above - #[allow(clippy::items_after_statements)] - fn make_sequence(parsers: Vec) -> TokenStream { - let parsers = parsers - .into_iter() - .map(|parser| quote! { seq.elem(#parser)?; }) - .collect::>(); - quote! { - SequenceHelper::run(|mut seq| { - #(#parsers)* - seq.finish() - }) - } - } - - #[allow(clippy::items_after_statements)] - fn make_choice(parsers: Vec) -> TokenStream { - let parsers = parsers - .into_iter() - .map(|(parser, version_quality_ranges)| { - version_quality_ranges.wrap_code( - quote! { - let result = #parser; - choice.consider(input, result)?; - }, - None, - ) - }) - .collect::>(); - quote! { - ChoiceHelper::run(input, |mut choice, input| { - #(#parsers)* - choice.finish(input) - }) - } - } - let mut binary_operand_terms = vec![]; if !prefix_operator_parsers.is_empty() { @@ -253,3 +213,42 @@ fn disambiguating_name_suffix(ranges: &[VersionQualityRange]) -> String { } suffix } + +// TODO: merge these three functions into parse_definition by changing +// `to_parser_code` to use `(TokenStream, Vec)` as +// the core type i.e. the `OperatorParser` type above +type OperatorParser = (TokenStream, Vec); + +fn make_sequence(parsers: Vec) -> TokenStream { + let parsers = parsers + .into_iter() + .map(|parser| quote! { seq.elem(#parser)?; }) + .collect::>(); + quote! { + SequenceHelper::run(|mut seq| { + #(#parsers)* + seq.finish() + }) + } +} + +fn make_choice(parsers: Vec) -> TokenStream { + let parsers = parsers + .into_iter() + .map(|(parser, version_quality_ranges)| { + version_quality_ranges.wrap_code( + quote! { + let result = #parser; + choice.consider(input, result)?; + }, + None, + ) + }) + .collect::>(); + quote! { + ChoiceHelper::run(input, |mut choice, input| { + #(#parsers)* + choice.finish(input) + }) + } +} From eddd9aeb3bb3374079729b62f9f68412e5c2a870 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 6 Dec 2023 18:56:17 +0100 Subject: [PATCH 06/17] refactor: Simplify emitted prefix/postfix parser helpers --- .../src/precedence_parser_definition.rs | 10 ++++------ .../cargo/crate/src/generated/language.rs | 20 +++++-------------- .../npm/crate/src/generated/language.rs | 20 +++++-------------- 3 files changed, 14 insertions(+), 36 deletions(-) diff --git a/crates/codegen/parser/generator/src/precedence_parser_definition.rs b/crates/codegen/parser/generator/src/precedence_parser_definition.rs index 2636379dfc..e91b90d9a0 100644 --- a/crates/codegen/parser/generator/src/precedence_parser_definition.rs +++ b/crates/codegen/parser/generator/src/precedence_parser_definition.rs @@ -152,9 +152,8 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode if !prefix_operator_parsers.is_empty() { let prefix_operator_parser = make_choice(prefix_operator_parsers); operator_closures.push(quote! { let prefix_operator_parser = |input: &mut ParserContext<'_>| #prefix_operator_parser; }); - binary_operand_terms.push( - quote! { ZeroOrMoreHelper::run(input, |input| prefix_operator_parser(input)) }, - ); + binary_operand_terms + .push(quote! { ZeroOrMoreHelper::run(input, prefix_operator_parser) }); } let primary_expression_parser = self.primary_expression.to_parser_code(context_name, false); @@ -164,9 +163,8 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode if !postfix_operator_parsers.is_empty() { let postfix_operator_parser = make_choice(postfix_operator_parsers); operator_closures.push(quote! { let postfix_operator_parser = |input: &mut ParserContext<'_>| #postfix_operator_parser; }); - binary_operand_terms.push( - quote! { ZeroOrMoreHelper::run(input, |input| postfix_operator_parser(input)) }, - ); + binary_operand_terms + .push(quote! { ZeroOrMoreHelper::run(input, postfix_operator_parser) }); } let binary_operand_parser = make_sequence(binary_operand_terms); diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index fc6b939bd9..942bcc04ce 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -2961,13 +2961,9 @@ impl Language { #[allow(unused_variables)] let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { - seq.elem(ZeroOrMoreHelper::run(input, |input| { - prefix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, prefix_operator_parser))?; seq.elem(primary_expression_parser(input))?; - seq.elem(ZeroOrMoreHelper::run(input, |input| { - postfix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, postfix_operator_parser))?; seq.finish() }) }; @@ -5112,9 +5108,7 @@ impl Language { let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; - seq.elem(ZeroOrMoreHelper::run(input, |input| { - postfix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, postfix_operator_parser))?; seq.finish() }) }; @@ -5962,9 +5956,7 @@ impl Language { #[allow(unused_variables)] let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { - seq.elem(ZeroOrMoreHelper::run(input, |input| { - prefix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, prefix_operator_parser))?; seq.elem(primary_expression_parser(input))?; seq.finish() }) @@ -6196,9 +6188,7 @@ impl Language { let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; - seq.elem(ZeroOrMoreHelper::run(input, |input| { - postfix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, postfix_operator_parser))?; seq.finish() }) }; diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index fc6b939bd9..942bcc04ce 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -2961,13 +2961,9 @@ impl Language { #[allow(unused_variables)] let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { - seq.elem(ZeroOrMoreHelper::run(input, |input| { - prefix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, prefix_operator_parser))?; seq.elem(primary_expression_parser(input))?; - seq.elem(ZeroOrMoreHelper::run(input, |input| { - postfix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, postfix_operator_parser))?; seq.finish() }) }; @@ -5112,9 +5108,7 @@ impl Language { let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; - seq.elem(ZeroOrMoreHelper::run(input, |input| { - postfix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, postfix_operator_parser))?; seq.finish() }) }; @@ -5962,9 +5956,7 @@ impl Language { #[allow(unused_variables)] let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { - seq.elem(ZeroOrMoreHelper::run(input, |input| { - prefix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, prefix_operator_parser))?; seq.elem(primary_expression_parser(input))?; seq.finish() }) @@ -6196,9 +6188,7 @@ impl Language { let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; - seq.elem(ZeroOrMoreHelper::run(input, |input| { - postfix_operator_parser(input) - }))?; + seq.elem(ZeroOrMoreHelper::run(input, postfix_operator_parser))?; seq.finish() }) }; From 029398053117e01c00839e4902d85a5bc21cc8dc Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 6 Dec 2023 19:22:59 +0100 Subject: [PATCH 07/17] Add some comments to the precedence parser codegen --- .../src/precedence_parser_definition.rs | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/crates/codegen/parser/generator/src/precedence_parser_definition.rs b/crates/codegen/parser/generator/src/precedence_parser_definition.rs index e91b90d9a0..cbca4fa427 100644 --- a/crates/codegen/parser/generator/src/precedence_parser_definition.rs +++ b/crates/codegen/parser/generator/src/precedence_parser_definition.rs @@ -149,6 +149,7 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode let mut binary_operand_terms = vec![]; + // First, establish the binary operand parser `BinaryOperand ::= PrefixOperator* PrimaryExpression PostfixOperator*` if !prefix_operator_parsers.is_empty() { let prefix_operator_parser = make_choice(prefix_operator_parsers); operator_closures.push(quote! { let prefix_operator_parser = |input: &mut ParserContext<'_>| #prefix_operator_parser; }); @@ -169,25 +170,28 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode let binary_operand_parser = make_sequence(binary_operand_terms); - if binary_operator_parsers.is_empty() { - operator_closures.push(quote! { let linear_expression_parser = |input: &mut ParserContext<'_>| #binary_operand_parser; }); + // Now, establish the linear expression parser `Expression ::= BinaryOperand ( BinaryOperator BinaryOperand )*` + let linear_expression_parser = if binary_operator_parsers.is_empty() { + // No binary operators, so the expression is simply `BinaryOperand` + binary_operand_parser } else { operator_closures.push(quote! { let binary_operand_parser = |input: &mut ParserContext<'_>| #binary_operand_parser; }); let binary_operator_parser = make_choice(binary_operator_parsers); operator_closures.push(quote! { let binary_operator_parser = |input: &mut ParserContext<'_>| #binary_operator_parser; }); - let linear_expression_parser = - make_sequence(vec![quote! { binary_operand_parser(input) }, { - let pairs = make_sequence(vec![ - quote! { binary_operator_parser(input) }, - quote! { binary_operand_parser(input) }, - ]); - quote! { ZeroOrMoreHelper::run(input, |input| #pairs) } - }]); - operator_closures + // `BinaryOperand ( BinaryOperator BinaryOperand )*` + make_sequence(vec![quote! { binary_operand_parser(input) }, { + let pairs = make_sequence(vec![ + quote! { binary_operator_parser(input) }, + quote! { binary_operand_parser(input) }, + ]); + quote! { ZeroOrMoreHelper::run(input, |input| #pairs) } + }]) + }; + + operator_closures .push(quote! { let linear_expression_parser = |input: &mut ParserContext<'_>| #linear_expression_parser; }); - } quote! { #( From 49acebb65b4eae427ca513186deeec5fe78ba8fe Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Fri, 8 Dec 2023 19:22:43 +0100 Subject: [PATCH 08/17] Deduplicate the precedence operator parser functions This also fixes a run-time regression introduced with duplicate operator parsers when migrating to v2. To support different associativity/models for precedence expressions across multiple versions, the parser generator now: - groups the operators by model for a given precedence expression - defines a sub-parser for (expression, model) as a choice over the operators with a given model - each of the precedence sub-parses reduces to the parent precedence expression rule kind. --- .../src/precedence_parser_definition.rs | 7 +- .../src/model/non_terminals/precedence.rs | 11 +- .../parser/generator/src/code_generator.rs | 14 +- .../src/precedence_parser_definition.rs | 59 +- .../solidity/inputs/language/src/grammar.rs | 58 +- .../cargo/crate/src/generated/language.rs | 2591 ++++------------- .../npm/crate/src/generated/language.rs | 2591 ++++------------- 7 files changed, 1066 insertions(+), 4265 deletions(-) diff --git a/crates/codegen/grammar/src/precedence_parser_definition.rs b/crates/codegen/grammar/src/precedence_parser_definition.rs index 8bff61e939..e410c35d42 100644 --- a/crates/codegen/grammar/src/precedence_parser_definition.rs +++ b/crates/codegen/grammar/src/precedence_parser_definition.rs @@ -1,9 +1,7 @@ use std::fmt::Debug; use std::rc::Rc; -use super::{ - GrammarVisitor, ParserDefinitionNode, ParserDefinitionRef, VersionQualityRange, Visitable, -}; +use super::{GrammarVisitor, ParserDefinitionNode, Visitable}; pub trait PrecedenceParserDefinition: Debug { fn name(&self) -> &'static str; @@ -24,10 +22,9 @@ impl Visitable for PrecedenceParserDefinitionRef { pub struct PrecedenceParserDefinitionNode { pub primary_expression: Box, pub operators: Vec<( - Vec, PrecedenceOperatorModel, &'static str, // name - ParserDefinitionRef, + ParserDefinitionNode, )>, } diff --git a/crates/codegen/language/definition/src/model/non_terminals/precedence.rs b/crates/codegen/language/definition/src/model/non_terminals/precedence.rs index f06d0716b0..696edb312c 100644 --- a/crates/codegen/language/definition/src/model/non_terminals/precedence.rs +++ b/crates/codegen/language/definition/src/model/non_terminals/precedence.rs @@ -33,7 +33,7 @@ pub struct PrecedenceOperator { pub fields: IndexMap, } -#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Hash, PartialOrd, Ord, Serialize)] #[derive_spanned_type(ParseInputTokens, WriteOutputTokens)] pub enum OperatorModel { Prefix, @@ -42,6 +42,15 @@ pub enum OperatorModel { BinaryRightAssociative, } +impl OperatorModel { + pub fn is_binary(&self) -> bool { + matches!( + self, + OperatorModel::BinaryLeftAssociative | OperatorModel::BinaryRightAssociative + ) + } +} + #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] #[derive_spanned_type(ParseInputTokens, WriteOutputTokens)] pub struct PrimaryExpression { diff --git a/crates/codegen/parser/generator/src/code_generator.rs b/crates/codegen/parser/generator/src/code_generator.rs index fc00871b3e..27b7ced2a0 100644 --- a/crates/codegen/parser/generator/src/code_generator.rs +++ b/crates/codegen/parser/generator/src/code_generator.rs @@ -12,8 +12,8 @@ use serde::Serialize; use codegen_grammar::{ Grammar, GrammarVisitor, ParserDefinitionNode, ParserDefinitionRef, - PrecedenceParserDefinitionNode, PrecedenceParserDefinitionRef, ScannerDefinitionNode, - ScannerDefinitionRef, TriviaParserDefinitionRef, + PrecedenceParserDefinitionRef, ScannerDefinitionNode, ScannerDefinitionRef, + TriviaParserDefinitionRef, }; use super::{ @@ -249,7 +249,7 @@ impl GrammarVisitor for CodeGenerator { fn precedence_parser_definition_enter(&mut self, parser: &PrecedenceParserDefinitionRef) { self.set_current_context(parser.context()); self.rule_kinds.insert(parser.name()); - for (_, _, name, _) in &parser.node().operators { + for (_, name, _) in &parser.node().operators { self.rule_kinds.insert(name); } self.parser_functions.push(( @@ -312,12 +312,4 @@ impl GrammarVisitor for CodeGenerator { _ => {} }; } - - fn precedence_parser_definition_node_enter(&mut self, node: &PrecedenceParserDefinitionNode) { - for operator in &node.operators { - for vqr in &operator.0 { - self.referenced_versions.insert(vqr.from.clone()); - } - } - } } diff --git a/crates/codegen/parser/generator/src/precedence_parser_definition.rs b/crates/codegen/parser/generator/src/precedence_parser_definition.rs index cbca4fa427..082648b5de 100644 --- a/crates/codegen/parser/generator/src/precedence_parser_definition.rs +++ b/crates/codegen/parser/generator/src/precedence_parser_definition.rs @@ -4,10 +4,9 @@ use quote::{format_ident, quote}; use codegen_grammar::{ PrecedenceOperatorModel, PrecedenceParserDefinitionNode, PrecedenceParserDefinitionRef, - VersionQualityRange, }; -use super::parser_definition::{ParserDefinitionNodeExtensions, VersionQualityRangeVecExtensions}; +use super::parser_definition::ParserDefinitionNodeExtensions; pub trait PrecedenceParserDefinitionExtensions { fn to_parser_code(&self) -> TokenStream; @@ -78,22 +77,19 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode let mut operator_closures = Vec::new(); let mut binding_power = 1u8; - for (version_quality_ranges, model, name, operator_definition) in &self.operators { - let operator_code = operator_definition - .node() - .to_parser_code(context_name, false); + for (model, name, operator_definition) in &self.operators { + let operator_code = operator_definition.to_parser_code(context_name, false); let rule_kind = format_ident!("{}", name); - let closure_name = format_ident!( - // Make a name that won't conflict with the parsers we define below - "parse_{name}{version_tag}", - version_tag = disambiguating_name_suffix(version_quality_ranges), - name = operator_definition.name().to_snake_case() - ); + let model_name = match model { + PrecedenceOperatorModel::BinaryLeftAssociative => "left", + PrecedenceOperatorModel::BinaryRightAssociative => "right", + PrecedenceOperatorModel::Prefix => "prefix", + PrecedenceOperatorModel::Postfix => "postfix", + }; + let closure_name = + format_ident!("parse_{model_name}_{name}", name = name.to_snake_case()); - let parser = ( - quote! { #closure_name(input) }, - version_quality_ranges.clone(), - ); + let parser = quote! { #closure_name(input) }; match model { PrecedenceOperatorModel::BinaryLeftAssociative => { @@ -195,8 +191,6 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode quote! { #( - // TODO(#638): remove duplicates once we use DSL v2 versioning schema - #[allow(unused_variables)] #operator_closures )* @@ -205,21 +199,9 @@ impl PrecedenceParserDefinitionNodeExtensions for PrecedenceParserDefinitionNode } } -fn disambiguating_name_suffix(ranges: &[VersionQualityRange]) -> String { - let mut suffix = String::new(); - for vqr in ranges { - suffix.push('_'); - suffix.push_str(&vqr.quality.to_string().to_lowercase()); - suffix.push_str("_from_"); - suffix.push_str(&vqr.from.to_string().replace('.', "_")); - } - suffix -} - // TODO: merge these three functions into parse_definition by changing -// `to_parser_code` to use `(TokenStream, Vec)` as -// the core type i.e. the `OperatorParser` type above -type OperatorParser = (TokenStream, Vec); +// `to_parser_code` to use `TokenStream` +type OperatorParser = TokenStream; fn make_sequence(parsers: Vec) -> TokenStream { let parsers = parsers @@ -237,14 +219,11 @@ fn make_sequence(parsers: Vec) -> TokenStream { fn make_choice(parsers: Vec) -> TokenStream { let parsers = parsers .into_iter() - .map(|(parser, version_quality_ranges)| { - version_quality_ranges.wrap_code( - quote! { - let result = #parser; - choice.consider(input, result)?; - }, - None, - ) + .map(|parser| { + quote! { + let result = #parser; + choice.consider(input, result)?; + } }) .collect::>(); quote! { diff --git a/crates/solidity/inputs/language/src/grammar.rs b/crates/solidity/inputs/language/src/grammar.rs index 41f09dd252..7327e30e44 100644 --- a/crates/solidity/inputs/language/src/grammar.rs +++ b/crates/solidity/inputs/language/src/grammar.rs @@ -2,7 +2,7 @@ //! (used for generating the parser and the CST). use std::cell::OnceCell; -use std::collections::{BTreeSet, HashMap}; +use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::rc::Rc; use codegen_grammar::Grammar; @@ -756,41 +756,43 @@ fn resolve_precedence( def: OnceCell::new(), }); - // NOTE: The DSL v1 model defines operators as having the same body definitions but uses a specific - // versioning mechanism. This is in contrast to the DSL v2, which allows for different body definitions and - // different versions. - // Thus, we shoehorn the v2 model into the first one, by creating a single parser definition node as - // a choice over the different versions of the operator body, but still define it multiple times in the DSL v1 - // model with an explicit version, that the codegen handles for us. + // Each precedence expression can have multiple operators with different modes and versions + // We partition them by model and then resolve each group separately + let mut operators_per_model = BTreeMap::<_, Vec<_>>::new(); for op in &expr.operators { - operators.push(( - op.enabled.clone().map(enabled_to_range).unwrap_or_default(), - model_to_enum(op.model), - // TODO: Don't leak - name.to_string().leak() as &_, - thunk.clone() as Rc, - )); + operators_per_model.entry(op.model).or_default().push(op); } - let defs: Vec<_> = expr - .operators - .into_iter() - .map(|op| resolve_sequence_like(op.enabled, op.fields, op.error_recovery, ctx)) - .collect(); + let mut all_operators = vec![]; + for (model, model_operators) in operators_per_model { + let defs: Vec<_> = model_operators + .into_iter() + .map(ToOwned::to_owned) + .map(|op| resolve_sequence_like(op.enabled, op.fields, op.error_recovery, ctx)) + .collect(); - let def = match defs.len() { - 0 => panic!("Precedence operator {name} has no definitions"), - 1 => defs.into_iter().next().unwrap(), - _ => ParserDefinitionNode::Choice(defs), - }; + // NOTE: This is unconditionally a choice to always account for a versioned + // model operator, even if there's only one definition. + let def = ParserDefinitionNode::Choice(defs); - thunk.def.set(def).unwrap(); + all_operators.push(def.clone()); + operators.push((model_to_enum(model), name.to_string().leak() as &_, def)); + } + + // Register the combined parser definition to appease the codegen and to mark terminals + // as reachable and ensure we emit a token kind for each + thunk + .def + .set(ParserDefinitionNode::Choice(all_operators)) + .unwrap(); assert!( !ctx.resolved.contains_key(&name), - "Encountered a duplicate Precedence Operator named {name} when resolving" + "Encountered a duplicate Precedence Expression named {name} when resolving" + ); + ctx.resolved.insert( + name.clone(), + GrammarElement::ParserDefinition(thunk.clone()), ); - ctx.resolved - .insert(name.clone(), GrammarElement::ParserDefinition(thunk)); } PrecedenceParserDefinitionNode { diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index 942bcc04ce..b63de46484 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -1182,8 +1182,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn expression(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { + let parse_left_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::AssignmentExpression, 1u8, @@ -1253,1655 +1252,396 @@ impl Language { }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, + let parse_postfix_conditional_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::ConditionalExpression, 3u8, - 3u8 + 1, ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); + let result = SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::QuestionMark, + ))?; + seq.elem(self.expression(input))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Colon, + ))?; + seq.elem(self.expression(input))?; + seq.finish() + }); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_or_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::OrExpression, + 5u8, + 5u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanEqual, + TokenKind::BarBar, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_and_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::AndExpression, + 7u8, + 7u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, + TokenKind::AmpersandAmpersand, ); choice.consider(input, result)?; choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { + let parse_left_equality_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 5u8, - 5u8 + 1, + RuleKind::EqualityExpression, + 9u8, + 9u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Equal, + TokenKind::EqualEqual, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::BarEqual, + TokenKind::BangEqual, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_comparison_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::ComparisonExpression, + 11u8, + 11u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::PlusEqual, + TokenKind::LessThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::MinusEqual, + TokenKind::GreaterThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::CaretEqual, + TokenKind::LessThanEqual, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::SlashEqual, + TokenKind::GreaterThanEqual, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_bitwise_or_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::BitwiseOrExpression, + 13u8, + 13u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::PercentEqual, + TokenKind::Bar, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_bitwise_xor_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::BitwiseXorExpression, + 15u8, + 15u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::AsteriskEqual, + TokenKind::Caret, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_bitwise_and_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::BitwiseAndExpression, + 17u8, + 17u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::AmpersandEqual, + TokenKind::Ampersand, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_shift_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::ShiftExpression, + 19u8, + 19u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::LessThanLessThanEqual, + TokenKind::LessThanLessThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanEqual, + TokenKind::GreaterThanGreaterThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, + TokenKind::GreaterThanGreaterThanGreaterThan, ); choice.consider(input, result)?; choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { + let parse_left_additive_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 7u8, - 7u8 + 1, + RuleKind::AdditiveExpression, + 21u8, + 21u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Equal, + TokenKind::Plus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::BarEqual, + TokenKind::Minus, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_multiplicative_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::MultiplicativeExpression, + 23u8, + 23u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::PlusEqual, + TokenKind::Asterisk, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::MinusEqual, + TokenKind::Slash, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::CaretEqual, + TokenKind::Percent, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_exponentiation_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::ExponentiationExpression, + 25u8, + 25u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { + if !self.version_is_at_least_0_6_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::AsteriskAsterisk, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }), + ) + }; + let parse_right_exponentiation_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::ExponentiationExpression, + 27u8 + 1, + 27u8, + ChoiceHelper::run(input, |mut choice, input| { + if self.version_is_at_least_0_6_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::AsteriskAsterisk, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }), + ) + }; + let parse_postfix_postfix_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::PostfixExpression, + 29u8, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::SlashEqual, + TokenKind::PlusPlus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PercentEqual, + TokenKind::MinusMinus, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_prefix_prefix_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_prefix_operator( + RuleKind::PrefixExpression, + 31u8, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::AsteriskEqual, + TokenKind::PlusPlus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::AmpersandEqual, + TokenKind::MinusMinus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::LessThanLessThanEqual, + TokenKind::Tilde, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanEqual, + TokenKind::Bang, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, + TokenKind::Minus, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::Plus, + ); + choice.consider(input, result)?; + } choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 9u8, - 9u8 + 1, + let parse_postfix_function_call_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::FunctionCallExpression, + 33u8, ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 11u8, - 11u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 13u8, - 13u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 15u8, - 15u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 17u8, - 17u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 19u8, - 19u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 21u8, - 21u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 23u8, - 23u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_conditional_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::ConditionalExpression, - 25u8, - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::QuestionMark, - ))?; - seq.elem(self.expression(input))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Colon, - ))?; - seq.elem(self.expression(input))?; - seq.finish() - }), - ) - }; - #[allow(unused_variables)] - let parse_or_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::OrExpression, - 27u8, - 27u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::BarBar, - ), - ) - }; - #[allow(unused_variables)] - let parse_and_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AndExpression, - 29u8, - 29u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::AmpersandAmpersand, - ), - ) - }; - #[allow(unused_variables)] - let parse_equality_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::EqualityExpression, - 31u8, - 31u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_equality_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::EqualityExpression, - 33u8, - 33u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ComparisonExpression, - 35u8, - 35u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ComparisonExpression, - 37u8, - 37u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ComparisonExpression, - 39u8, - 39u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ComparisonExpression, - 41u8, - 41u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_bitwise_or_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BitwiseOrExpression, - 43u8, - 43u8 + 1, - self.parse_token_with_trivia::(input, TokenKind::Bar), - ) - }; - #[allow(unused_variables)] - let parse_bitwise_xor_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BitwiseXorExpression, - 45u8, - 45u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ), - ) - }; - #[allow(unused_variables)] - let parse_bitwise_and_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BitwiseAndExpression, - 47u8, - 47u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::Ampersand, - ), - ) - }; - #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ShiftExpression, - 49u8, - 49u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThan, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ShiftExpression, - 51u8, - 51u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThan, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ShiftExpression, - 53u8, - 53u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThan, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_additive_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AdditiveExpression, - 55u8, - 55u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_additive_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AdditiveExpression, - 57u8, - 57u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::MultiplicativeExpression, - 59u8, - 59u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::MultiplicativeExpression, - 61u8, - 61u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::MultiplicativeExpression, - 63u8, - 63u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_exponentiation_expression_removed_from_0_6_0 = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ExponentiationExpression, - 65u8, - 65u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - if !self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_exponentiation_expression_introduced_from_0_6_0 = |input: &mut ParserContext< - '_, - >| { - PrecedenceHelper::to_binary_operator( - RuleKind::ExponentiationExpression, - 67u8 + 1, - 67u8, - ChoiceHelper::run(input, |mut choice, input| { - if !self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_postfix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::PostfixExpression, - 69u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_postfix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::PostfixExpression, - 71u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::PrefixExpression, - 73u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::PrefixExpression, - 75u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::PrefixExpression, - 77u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::PrefixExpression, - 79u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::PrefixExpression, - 81u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression_removed_from_0_5_0 = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::PrefixExpression, - 83u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } + let result = 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() + }); + choice.consider(input, result)?; choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_function_call_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::FunctionCallExpression, - 85u8, - 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() - }), - ) - }; - #[allow(unused_variables)] - let parse_member_access_expression = |input: &mut ParserContext<'_>| { + let parse_postfix_member_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::MemberAccessExpression, - 87u8, - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Period, - ))?; - seq.elem(self.member_access(input))?; - seq.finish() + 35u8, + ChoiceHelper::run(input, |mut choice, input| { + let result = SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Period, + ))?; + seq.elem(self.member_access(input))?; + seq.finish() + }); + choice.consider(input, result)?; + choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_index_access_expression = |input: &mut ParserContext<'_>| { + let parse_postfix_index_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::IndexAccessExpression, - 89u8, - SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBracket); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenBracket, - ))?; - seq.elem( - SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.elem(OptionalHelper::transform(self.index_access_end(input)))?; - seq.finish() - }) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + 37u8, + ChoiceHelper::run(input, |mut choice, input| { + let result = SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBracket); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenBracket, + ))?; + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform(self.expression(input)))?; + seq.elem(OptionalHelper::transform(self.index_access_end(input)))?; + seq.finish() + }) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::CloseBracket, + RecoverFromNoMatch::Yes, + ), + )?; + seq.elem(self.parse_token_with_trivia::( input, - self, TokenKind::CloseBracket, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseBracket, - ))?; - seq.finish() + ))?; + seq.finish() + }); + choice.consider(input, result)?; + choice.finish(input) }), ) }; - #[allow(unused_variables)] let prefix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_prefix_expression(input); + let result = parse_prefix_prefix_expression(input); choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = parse_prefix_expression_removed_from_0_5_0(input); - choice.consider(input, result)?; - } choice.finish(input) }) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.new_expression(input); @@ -2940,25 +1680,21 @@ impl Language { choice.finish(input) }) }; - #[allow(unused_variables)] let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_conditional_expression(input); + let result = parse_postfix_conditional_expression(input); choice.consider(input, result)?; - let result = parse_postfix_expression(input); + let result = parse_postfix_postfix_expression(input); choice.consider(input, result)?; - let result = parse_postfix_expression(input); + let result = parse_postfix_function_call_expression(input); choice.consider(input, result)?; - let result = parse_function_call_expression(input); + let result = parse_postfix_member_access_expression(input); choice.consider(input, result)?; - let result = parse_member_access_expression(input); - choice.consider(input, result)?; - let result = parse_index_access_expression(input); + let result = parse_postfix_index_access_expression(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(ZeroOrMoreHelper::run(input, prefix_operator_parser))?; @@ -2967,83 +1703,37 @@ impl Language { seq.finish() }) }; - #[allow(unused_variables)] let binary_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_or_expression(input); - choice.consider(input, result)?; - let result = parse_and_expression(input); + let result = parse_left_assignment_expression(input); choice.consider(input, result)?; - let result = parse_equality_expression(input); + let result = parse_left_or_expression(input); choice.consider(input, result)?; - let result = parse_equality_expression(input); + let result = parse_left_and_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + let result = parse_left_equality_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + let result = parse_left_comparison_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + let result = parse_left_bitwise_or_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + let result = parse_left_bitwise_xor_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_or_expression(input); + let result = parse_left_bitwise_and_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_xor_expression(input); + let result = parse_left_shift_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_and_expression(input); + let result = parse_left_additive_expression(input); choice.consider(input, result)?; - let result = parse_shift_expression(input); + let result = parse_left_multiplicative_expression(input); choice.consider(input, result)?; - let result = parse_shift_expression(input); + let result = parse_left_exponentiation_expression(input); choice.consider(input, result)?; - let result = parse_shift_expression(input); + let result = parse_right_exponentiation_expression(input); choice.consider(input, result)?; - let result = parse_additive_expression(input); - choice.consider(input, result)?; - let result = parse_additive_expression(input); - choice.consider(input, result)?; - let result = parse_multiplicative_expression(input); - choice.consider(input, result)?; - let result = parse_multiplicative_expression(input); - choice.consider(input, result)?; - let result = parse_multiplicative_expression(input); - choice.consider(input, result)?; - if !self.version_is_at_least_0_6_0 { - let result = parse_exponentiation_expression_removed_from_0_6_0(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = parse_exponentiation_expression_introduced_from_0_6_0(input); - choice.consider(input, result)?; - } choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(binary_operand_parser(input))?; @@ -5053,36 +3743,38 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn type_name(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_array_type_name = |input: &mut ParserContext<'_>| { + let parse_postfix_array_type_name = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::ArrayTypeName, 1u8, - SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBracket); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenBracket, - ))?; - seq.elem( - OptionalHelper::transform(self.expression(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + ChoiceHelper::run(input, |mut choice, input| { + let result = SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBracket); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenBracket, + ))?; + seq.elem( + OptionalHelper::transform(self.expression(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::CloseBracket, + RecoverFromNoMatch::Yes, + ), + )?; + seq.elem(self.parse_token_with_trivia::( input, - self, TokenKind::CloseBracket, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseBracket, - ))?; - seq.finish() + ))?; + seq.finish() + }); + choice.consider(input, result)?; + choice.finish(input) }), ) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.function_type(input); @@ -5096,15 +3788,13 @@ impl Language { choice.finish(input) }) }; - #[allow(unused_variables)] let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_array_type_name(input); + let result = parse_postfix_array_type_name(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; @@ -5395,140 +4085,12 @@ impl Language { seq.elem(self.using_target(input))?; if self.version_is_at_least_0_8_13 { seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::GlobalKeyword, - ), - ))?; - } - seq.finish() - }) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::Semicolon, - RecoverFromNoMatch::No, - ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Semicolon, - ))?; - seq.finish() - }) - .with_kind(RuleKind::UsingDirective) - } - - #[allow(unused_assignments, unused_parens)] - fn using_operator(&self, input: &mut ParserContext<'_>) -> ParserResult { - if self.version_is_at_least_0_8_19 { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Ampersand, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Bar); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Plus); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - } else { - ParserResult::disabled() - } - .with_kind(RuleKind::UsingOperator) - } - - #[allow(unused_assignments, unused_parens)] - fn using_target(&self, input: &mut ParserContext<'_>) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.type_name(input); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Asterisk); - choice.consider(input, result)?; - choice.finish(input) - }) - .with_kind(RuleKind::UsingTarget) - } - - #[allow(unused_assignments, unused_parens)] - fn variable_declaration_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem( - SequenceHelper::run(|mut seq| { - seq.elem(self.variable_declaration_type(input))?; - seq.elem(OptionalHelper::transform(self.storage_location(input)))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.elem(OptionalHelper::transform( - self.variable_declaration_value(input), - ))?; + self.parse_token_with_trivia::( + input, + TokenKind::GlobalKeyword, + ), + ))?; + } seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -5544,352 +4106,218 @@ impl Language { ))?; seq.finish() }) - .with_kind(RuleKind::VariableDeclarationStatement) + .with_kind(RuleKind::UsingDirective) } #[allow(unused_assignments, unused_parens)] - fn variable_declaration_type(&self, input: &mut ParserContext<'_>) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.type_name(input); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { + fn using_operator(&self, input: &mut ParserContext<'_>) -> ParserResult { + if self.version_is_at_least_0_8_19 { + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::VarKeyword, + TokenKind::Ampersand, ); choice.consider(input, result)?; - } - choice.finish(input) - }) - .with_kind(RuleKind::VariableDeclarationType) - } - - #[allow(unused_assignments, unused_parens)] - fn variable_declaration_value(&self, input: &mut ParserContext<'_>) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::Equal, - ), - )?; - seq.elem(self.expression(input))?; - seq.finish() - }) - .with_kind(RuleKind::VariableDeclarationValue) - } - - #[allow(unused_assignments, unused_parens)] - fn version_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::SolidityKeyword, - ))?; - seq.elem(self.version_pragma_expressions(input))?; - seq.finish() - }) - .with_kind(RuleKind::VersionPragma) - } - - #[allow(unused_assignments, unused_parens)] - fn version_pragma_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_version_pragma_or_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::VersionPragmaOrExpression, - 1u8, - 1u8 + 1, - self.parse_token_with_trivia::( + TokenKind::Asterisk, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( input, - TokenKind::BarBar, - ), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_range_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::VersionPragmaRangeExpression, - 3u8, - 3u8 + 1, - self.parse_token_with_trivia::(input, TokenKind::Minus), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaPrefixExpression, - 5u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaPrefixExpression, - 7u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaPrefixExpression, - 9u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaPrefixExpression, - 11u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + TokenKind::BangEqual, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::Bar); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Caret, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::EqualEqual, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::GreaterThan, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::GreaterThanEqual, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::LessThan, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::LessThanEqual, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Minus, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Percent, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::Plus); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Slash, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Tilde, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::UsingOperator) + } + + #[allow(unused_assignments, unused_parens)] + fn using_target(&self, input: &mut ParserContext<'_>) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.type_name(input); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::Asterisk); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::UsingTarget) + } + + #[allow(unused_assignments, unused_parens)] + fn variable_declaration_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(self.variable_declaration_type(input))?; + seq.elem(OptionalHelper::transform(self.storage_location(input)))?; + seq.elem(self.parse_token_with_trivia::( input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaPrefixExpression, - 13u8, + TokenKind::Identifier, + ))?; + seq.elem(OptionalHelper::transform( + self.variable_declaration_value(input), + ))?; + seq.finish() + }) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::Semicolon, + RecoverFromNoMatch::No, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Semicolon, + ))?; + seq.finish() + }) + .with_kind(RuleKind::VariableDeclarationStatement) + } + + #[allow(unused_assignments, unused_parens)] + fn variable_declaration_type(&self, input: &mut ParserContext<'_>) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.type_name(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::VarKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::VariableDeclarationType) + } + + #[allow(unused_assignments, unused_parens)] + fn variable_declaration_value(&self, input: &mut ParserContext<'_>) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem( + self.parse_token_with_trivia::( + input, + TokenKind::Equal, + ), + )?; + seq.elem(self.expression(input))?; + seq.finish() + }) + .with_kind(RuleKind::VariableDeclarationValue) + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::SolidityKeyword, + ))?; + seq.elem(self.version_pragma_expressions(input))?; + seq.finish() + }) + .with_kind(RuleKind::VersionPragma) + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let parse_left_version_pragma_or_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::VersionPragmaOrExpression, + 1u8, + 1u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, + TokenKind::BarBar, ); choice.consider(input, result)?; choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaPrefixExpression, - 15u8, + let parse_left_version_pragma_range_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::VersionPragmaRangeExpression, + 3u8, + 3u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, + TokenKind::Minus, ); choice.consider(input, result)?; choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { + let parse_prefix_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaPrefixExpression, - 17u8, + 5u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, @@ -5930,30 +4358,15 @@ impl Language { }), ) }; - #[allow(unused_variables)] let prefix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); + let result = parse_prefix_version_pragma_prefix_expression(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| self.version_pragma_specifier(input); - #[allow(unused_variables)] let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(ZeroOrMoreHelper::run(input, prefix_operator_parser))?; @@ -5961,17 +4374,15 @@ impl Language { seq.finish() }) }; - #[allow(unused_variables)] let binary_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_or_expression(input); + let result = parse_left_version_pragma_or_expression(input); choice.consider(input, result)?; - let result = parse_version_pragma_range_expression(input); + let result = parse_left_version_pragma_range_expression(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(binary_operand_parser(input))?; @@ -6137,36 +4548,38 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_yul_function_call_expression = |input: &mut ParserContext<'_>| { + let parse_postfix_yul_function_call_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::YulFunctionCallExpression, 1u8, - SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenParen, - ))?; - seq.elem( - OptionalHelper::transform(self.yul_arguments(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( + ChoiceHelper::run(input, |mut choice, input| { + let result = SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenParen, + ))?; + seq.elem( + OptionalHelper::transform(self.yul_arguments(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( input, self, TokenKind::CloseParen, RecoverFromNoMatch::Yes, ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, - ))?; - seq.finish() + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseParen, + ))?; + seq.finish() + }); + choice.consider(input, result)?; + choice.finish(input) }), ) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.yul_literal(input); @@ -6176,15 +4589,13 @@ impl Language { choice.finish(input) }) }; - #[allow(unused_variables)] let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_yul_function_call_expression(input); + let result = parse_postfix_yul_function_call_expression(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index 942bcc04ce..b63de46484 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -1182,8 +1182,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn expression(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { + let parse_left_assignment_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( RuleKind::AssignmentExpression, 1u8, @@ -1253,1655 +1252,396 @@ impl Language { }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, + let parse_postfix_conditional_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::ConditionalExpression, 3u8, - 3u8 + 1, ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); + let result = SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::QuestionMark, + ))?; + seq.elem(self.expression(input))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Colon, + ))?; + seq.elem(self.expression(input))?; + seq.finish() + }); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_or_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::OrExpression, + 5u8, + 5u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanEqual, + TokenKind::BarBar, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_and_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::AndExpression, + 7u8, + 7u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, + TokenKind::AmpersandAmpersand, ); choice.consider(input, result)?; choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { + let parse_left_equality_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 5u8, - 5u8 + 1, + RuleKind::EqualityExpression, + 9u8, + 9u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Equal, + TokenKind::EqualEqual, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::BarEqual, + TokenKind::BangEqual, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_comparison_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::ComparisonExpression, + 11u8, + 11u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::PlusEqual, + TokenKind::LessThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::MinusEqual, + TokenKind::GreaterThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::CaretEqual, + TokenKind::LessThanEqual, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::SlashEqual, + TokenKind::GreaterThanEqual, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_bitwise_or_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::BitwiseOrExpression, + 13u8, + 13u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::PercentEqual, + TokenKind::Bar, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_bitwise_xor_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::BitwiseXorExpression, + 15u8, + 15u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::AsteriskEqual, + TokenKind::Caret, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_bitwise_and_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::BitwiseAndExpression, + 17u8, + 17u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::AmpersandEqual, + TokenKind::Ampersand, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_shift_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::ShiftExpression, + 19u8, + 19u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::LessThanLessThanEqual, + TokenKind::LessThanLessThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanEqual, + TokenKind::GreaterThanGreaterThan, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, + TokenKind::GreaterThanGreaterThanGreaterThan, ); choice.consider(input, result)?; choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { + let parse_left_additive_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 7u8, - 7u8 + 1, + RuleKind::AdditiveExpression, + 21u8, + 21u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Equal, + TokenKind::Plus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::BarEqual, + TokenKind::Minus, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_multiplicative_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::MultiplicativeExpression, + 23u8, + 23u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::PlusEqual, + TokenKind::Asterisk, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::MinusEqual, + TokenKind::Slash, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::CaretEqual, + TokenKind::Percent, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_left_exponentiation_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::ExponentiationExpression, + 25u8, + 25u8 + 1, + ChoiceHelper::run(input, |mut choice, input| { + if !self.version_is_at_least_0_6_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::AsteriskAsterisk, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }), + ) + }; + let parse_right_exponentiation_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::ExponentiationExpression, + 27u8 + 1, + 27u8, + ChoiceHelper::run(input, |mut choice, input| { + if self.version_is_at_least_0_6_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::AsteriskAsterisk, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }), + ) + }; + let parse_postfix_postfix_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::PostfixExpression, + 29u8, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::SlashEqual, + TokenKind::PlusPlus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::PercentEqual, + TokenKind::MinusMinus, ); choice.consider(input, result)?; + choice.finish(input) + }), + ) + }; + let parse_prefix_prefix_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_prefix_operator( + RuleKind::PrefixExpression, + 31u8, + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::AsteriskEqual, + TokenKind::PlusPlus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::AmpersandEqual, + TokenKind::MinusMinus, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::LessThanLessThanEqual, + TokenKind::Tilde, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanEqual, + TokenKind::Bang, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, + TokenKind::Minus, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::Plus, + ); + choice.consider(input, result)?; + } choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 9u8, - 9u8 + 1, + let parse_postfix_function_call_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::FunctionCallExpression, + 33u8, ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 11u8, - 11u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 13u8, - 13u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 15u8, - 15u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 17u8, - 17u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 19u8, - 19u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 21u8, - 21u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_assignment_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AssignmentExpression, - 23u8, - 23u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::CaretEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::SlashEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::PercentEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_conditional_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::ConditionalExpression, - 25u8, - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::QuestionMark, - ))?; - seq.elem(self.expression(input))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Colon, - ))?; - seq.elem(self.expression(input))?; - seq.finish() - }), - ) - }; - #[allow(unused_variables)] - let parse_or_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::OrExpression, - 27u8, - 27u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::BarBar, - ), - ) - }; - #[allow(unused_variables)] - let parse_and_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AndExpression, - 29u8, - 29u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::AmpersandAmpersand, - ), - ) - }; - #[allow(unused_variables)] - let parse_equality_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::EqualityExpression, - 31u8, - 31u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_equality_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::EqualityExpression, - 33u8, - 33u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ComparisonExpression, - 35u8, - 35u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ComparisonExpression, - 37u8, - 37u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ComparisonExpression, - 39u8, - 39u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_comparison_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ComparisonExpression, - 41u8, - 41u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_bitwise_or_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BitwiseOrExpression, - 43u8, - 43u8 + 1, - self.parse_token_with_trivia::(input, TokenKind::Bar), - ) - }; - #[allow(unused_variables)] - let parse_bitwise_xor_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BitwiseXorExpression, - 45u8, - 45u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ), - ) - }; - #[allow(unused_variables)] - let parse_bitwise_and_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::BitwiseAndExpression, - 47u8, - 47u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::Ampersand, - ), - ) - }; - #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ShiftExpression, - 49u8, - 49u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThan, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ShiftExpression, - 51u8, - 51u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThan, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_shift_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ShiftExpression, - 53u8, - 53u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanLessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanGreaterThanGreaterThan, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_additive_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AdditiveExpression, - 55u8, - 55u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_additive_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::AdditiveExpression, - 57u8, - 57u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::MultiplicativeExpression, - 59u8, - 59u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::MultiplicativeExpression, - 61u8, - 61u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_multiplicative_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::MultiplicativeExpression, - 63u8, - 63u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_exponentiation_expression_removed_from_0_6_0 = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::ExponentiationExpression, - 65u8, - 65u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - if !self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_exponentiation_expression_introduced_from_0_6_0 = |input: &mut ParserContext< - '_, - >| { - PrecedenceHelper::to_binary_operator( - RuleKind::ExponentiationExpression, - 67u8 + 1, - 67u8, - ChoiceHelper::run(input, |mut choice, input| { - if !self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_postfix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::PostfixExpression, - 69u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_postfix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::PostfixExpression, - 71u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::PrefixExpression, - 73u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::PrefixExpression, - 75u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::PrefixExpression, - 77u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::PrefixExpression, - 79u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::PrefixExpression, - 81u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_prefix_expression_removed_from_0_5_0 = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::PrefixExpression, - 83u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::PlusPlus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::MinusMinus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bang, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - } + let result = 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() + }); + choice.consider(input, result)?; choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_function_call_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_postfix_operator( - RuleKind::FunctionCallExpression, - 85u8, - 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() - }), - ) - }; - #[allow(unused_variables)] - let parse_member_access_expression = |input: &mut ParserContext<'_>| { + let parse_postfix_member_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::MemberAccessExpression, - 87u8, - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Period, - ))?; - seq.elem(self.member_access(input))?; - seq.finish() + 35u8, + ChoiceHelper::run(input, |mut choice, input| { + let result = SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Period, + ))?; + seq.elem(self.member_access(input))?; + seq.finish() + }); + choice.consider(input, result)?; + choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_index_access_expression = |input: &mut ParserContext<'_>| { + let parse_postfix_index_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::IndexAccessExpression, - 89u8, - SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBracket); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenBracket, - ))?; - seq.elem( - SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.elem(OptionalHelper::transform(self.index_access_end(input)))?; - seq.finish() - }) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + 37u8, + ChoiceHelper::run(input, |mut choice, input| { + let result = SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBracket); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenBracket, + ))?; + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform(self.expression(input)))?; + seq.elem(OptionalHelper::transform(self.index_access_end(input)))?; + seq.finish() + }) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::CloseBracket, + RecoverFromNoMatch::Yes, + ), + )?; + seq.elem(self.parse_token_with_trivia::( input, - self, TokenKind::CloseBracket, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseBracket, - ))?; - seq.finish() + ))?; + seq.finish() + }); + choice.consider(input, result)?; + choice.finish(input) }), ) }; - #[allow(unused_variables)] let prefix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_prefix_expression(input); + let result = parse_prefix_prefix_expression(input); choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = parse_prefix_expression_removed_from_0_5_0(input); - choice.consider(input, result)?; - } choice.finish(input) }) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.new_expression(input); @@ -2940,25 +1680,21 @@ impl Language { choice.finish(input) }) }; - #[allow(unused_variables)] let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_conditional_expression(input); + let result = parse_postfix_conditional_expression(input); choice.consider(input, result)?; - let result = parse_postfix_expression(input); + let result = parse_postfix_postfix_expression(input); choice.consider(input, result)?; - let result = parse_postfix_expression(input); + let result = parse_postfix_function_call_expression(input); choice.consider(input, result)?; - let result = parse_function_call_expression(input); + let result = parse_postfix_member_access_expression(input); choice.consider(input, result)?; - let result = parse_member_access_expression(input); - choice.consider(input, result)?; - let result = parse_index_access_expression(input); + let result = parse_postfix_index_access_expression(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(ZeroOrMoreHelper::run(input, prefix_operator_parser))?; @@ -2967,83 +1703,37 @@ impl Language { seq.finish() }) }; - #[allow(unused_variables)] let binary_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_assignment_expression(input); - choice.consider(input, result)?; - let result = parse_or_expression(input); - choice.consider(input, result)?; - let result = parse_and_expression(input); + let result = parse_left_assignment_expression(input); choice.consider(input, result)?; - let result = parse_equality_expression(input); + let result = parse_left_or_expression(input); choice.consider(input, result)?; - let result = parse_equality_expression(input); + let result = parse_left_and_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + let result = parse_left_equality_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + let result = parse_left_comparison_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + let result = parse_left_bitwise_or_expression(input); choice.consider(input, result)?; - let result = parse_comparison_expression(input); + let result = parse_left_bitwise_xor_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_or_expression(input); + let result = parse_left_bitwise_and_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_xor_expression(input); + let result = parse_left_shift_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_and_expression(input); + let result = parse_left_additive_expression(input); choice.consider(input, result)?; - let result = parse_shift_expression(input); + let result = parse_left_multiplicative_expression(input); choice.consider(input, result)?; - let result = parse_shift_expression(input); + let result = parse_left_exponentiation_expression(input); choice.consider(input, result)?; - let result = parse_shift_expression(input); + let result = parse_right_exponentiation_expression(input); choice.consider(input, result)?; - let result = parse_additive_expression(input); - choice.consider(input, result)?; - let result = parse_additive_expression(input); - choice.consider(input, result)?; - let result = parse_multiplicative_expression(input); - choice.consider(input, result)?; - let result = parse_multiplicative_expression(input); - choice.consider(input, result)?; - let result = parse_multiplicative_expression(input); - choice.consider(input, result)?; - if !self.version_is_at_least_0_6_0 { - let result = parse_exponentiation_expression_removed_from_0_6_0(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = parse_exponentiation_expression_introduced_from_0_6_0(input); - choice.consider(input, result)?; - } choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(binary_operand_parser(input))?; @@ -5053,36 +3743,38 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn type_name(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_array_type_name = |input: &mut ParserContext<'_>| { + let parse_postfix_array_type_name = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::ArrayTypeName, 1u8, - SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBracket); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenBracket, - ))?; - seq.elem( - OptionalHelper::transform(self.expression(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + ChoiceHelper::run(input, |mut choice, input| { + let result = SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBracket); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenBracket, + ))?; + seq.elem( + OptionalHelper::transform(self.expression(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::CloseBracket, + RecoverFromNoMatch::Yes, + ), + )?; + seq.elem(self.parse_token_with_trivia::( input, - self, TokenKind::CloseBracket, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseBracket, - ))?; - seq.finish() + ))?; + seq.finish() + }); + choice.consider(input, result)?; + choice.finish(input) }), ) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.function_type(input); @@ -5096,15 +3788,13 @@ impl Language { choice.finish(input) }) }; - #[allow(unused_variables)] let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_array_type_name(input); + let result = parse_postfix_array_type_name(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; @@ -5395,140 +4085,12 @@ impl Language { seq.elem(self.using_target(input))?; if self.version_is_at_least_0_8_13 { seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::GlobalKeyword, - ), - ))?; - } - seq.finish() - }) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::Semicolon, - RecoverFromNoMatch::No, - ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Semicolon, - ))?; - seq.finish() - }) - .with_kind(RuleKind::UsingDirective) - } - - #[allow(unused_assignments, unused_parens)] - fn using_operator(&self, input: &mut ParserContext<'_>) -> ParserResult { - if self.version_is_at_least_0_8_19 { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Ampersand, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Bar); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Plus); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - } else { - ParserResult::disabled() - } - .with_kind(RuleKind::UsingOperator) - } - - #[allow(unused_assignments, unused_parens)] - fn using_target(&self, input: &mut ParserContext<'_>) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.type_name(input); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::(input, TokenKind::Asterisk); - choice.consider(input, result)?; - choice.finish(input) - }) - .with_kind(RuleKind::UsingTarget) - } - - #[allow(unused_assignments, unused_parens)] - fn variable_declaration_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem( - SequenceHelper::run(|mut seq| { - seq.elem(self.variable_declaration_type(input))?; - seq.elem(OptionalHelper::transform(self.storage_location(input)))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.elem(OptionalHelper::transform( - self.variable_declaration_value(input), - ))?; + self.parse_token_with_trivia::( + input, + TokenKind::GlobalKeyword, + ), + ))?; + } seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -5544,352 +4106,218 @@ impl Language { ))?; seq.finish() }) - .with_kind(RuleKind::VariableDeclarationStatement) + .with_kind(RuleKind::UsingDirective) } #[allow(unused_assignments, unused_parens)] - fn variable_declaration_type(&self, input: &mut ParserContext<'_>) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - let result = self.type_name(input); - choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { + fn using_operator(&self, input: &mut ParserContext<'_>) -> ParserResult { + if self.version_is_at_least_0_8_19 { + ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::VarKeyword, + TokenKind::Ampersand, ); choice.consider(input, result)?; - } - choice.finish(input) - }) - .with_kind(RuleKind::VariableDeclarationType) - } - - #[allow(unused_assignments, unused_parens)] - fn variable_declaration_value(&self, input: &mut ParserContext<'_>) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::Equal, - ), - )?; - seq.elem(self.expression(input))?; - seq.finish() - }) - .with_kind(RuleKind::VariableDeclarationValue) - } - - #[allow(unused_assignments, unused_parens)] - fn version_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::SolidityKeyword, - ))?; - seq.elem(self.version_pragma_expressions(input))?; - seq.finish() - }) - .with_kind(RuleKind::VersionPragma) - } - - #[allow(unused_assignments, unused_parens)] - fn version_pragma_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_version_pragma_or_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::VersionPragmaOrExpression, - 1u8, - 1u8 + 1, - self.parse_token_with_trivia::( + TokenKind::Asterisk, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( input, - TokenKind::BarBar, - ), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_range_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_binary_operator( - RuleKind::VersionPragmaRangeExpression, - 3u8, - 3u8 + 1, - self.parse_token_with_trivia::(input, TokenKind::Minus), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaPrefixExpression, - 5u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaPrefixExpression, - 7u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaPrefixExpression, - 9u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaPrefixExpression, - 11u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + TokenKind::BangEqual, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::Bar); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Caret, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::EqualEqual, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::GreaterThan, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::GreaterThanEqual, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::LessThan, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::LessThanEqual, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Minus, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Percent, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::Plus); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Slash, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Tilde, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::UsingOperator) + } + + #[allow(unused_assignments, unused_parens)] + fn using_target(&self, input: &mut ParserContext<'_>) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.type_name(input); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::Asterisk); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::UsingTarget) + } + + #[allow(unused_assignments, unused_parens)] + fn variable_declaration_statement(&self, input: &mut ParserContext<'_>) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(self.variable_declaration_type(input))?; + seq.elem(OptionalHelper::transform(self.storage_location(input)))?; + seq.elem(self.parse_token_with_trivia::( input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - choice.finish(input) - }), - ) - }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaPrefixExpression, - 13u8, + TokenKind::Identifier, + ))?; + seq.elem(OptionalHelper::transform( + self.variable_declaration_value(input), + ))?; + seq.finish() + }) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::Semicolon, + RecoverFromNoMatch::No, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Semicolon, + ))?; + seq.finish() + }) + .with_kind(RuleKind::VariableDeclarationStatement) + } + + #[allow(unused_assignments, unused_parens)] + fn variable_declaration_type(&self, input: &mut ParserContext<'_>) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.type_name(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::VarKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::VariableDeclarationType) + } + + #[allow(unused_assignments, unused_parens)] + fn variable_declaration_value(&self, input: &mut ParserContext<'_>) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem( + self.parse_token_with_trivia::( + input, + TokenKind::Equal, + ), + )?; + seq.elem(self.expression(input))?; + seq.finish() + }) + .with_kind(RuleKind::VariableDeclarationValue) + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::SolidityKeyword, + ))?; + seq.elem(self.version_pragma_expressions(input))?; + seq.finish() + }) + .with_kind(RuleKind::VersionPragma) + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let parse_left_version_pragma_or_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::VersionPragmaOrExpression, + 1u8, + 1u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, + TokenKind::BarBar, ); choice.consider(input, result)?; choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { - PrecedenceHelper::to_prefix_operator( - RuleKind::VersionPragmaPrefixExpression, - 15u8, + let parse_left_version_pragma_range_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_binary_operator( + RuleKind::VersionPragmaRangeExpression, + 3u8, + 3u8 + 1, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, + TokenKind::Minus, ); choice.consider(input, result)?; choice.finish(input) }), ) }; - #[allow(unused_variables)] - let parse_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { + let parse_prefix_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaPrefixExpression, - 17u8, + 5u8, ChoiceHelper::run(input, |mut choice, input| { let result = self.parse_token_with_trivia::( input, @@ -5930,30 +4358,15 @@ impl Language { }), ) }; - #[allow(unused_variables)] let prefix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); - choice.consider(input, result)?; - let result = parse_version_pragma_prefix_expression(input); + let result = parse_prefix_version_pragma_prefix_expression(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| self.version_pragma_specifier(input); - #[allow(unused_variables)] let binary_operand_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(ZeroOrMoreHelper::run(input, prefix_operator_parser))?; @@ -5961,17 +4374,15 @@ impl Language { seq.finish() }) }; - #[allow(unused_variables)] let binary_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_or_expression(input); + let result = parse_left_version_pragma_or_expression(input); choice.consider(input, result)?; - let result = parse_version_pragma_range_expression(input); + let result = parse_left_version_pragma_range_expression(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(binary_operand_parser(input))?; @@ -6137,36 +4548,38 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { - #[allow(unused_variables)] - let parse_yul_function_call_expression = |input: &mut ParserContext<'_>| { + let parse_postfix_yul_function_call_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::YulFunctionCallExpression, 1u8, - SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenParen, - ))?; - seq.elem( - OptionalHelper::transform(self.yul_arguments(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( + ChoiceHelper::run(input, |mut choice, input| { + let result = SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenParen, + ))?; + seq.elem( + OptionalHelper::transform(self.yul_arguments(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( input, self, TokenKind::CloseParen, RecoverFromNoMatch::Yes, ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, - ))?; - seq.finish() + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseParen, + ))?; + seq.finish() + }); + choice.consider(input, result)?; + choice.finish(input) }), ) }; - #[allow(unused_variables)] let primary_expression_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { let result = self.yul_literal(input); @@ -6176,15 +4589,13 @@ impl Language { choice.finish(input) }) }; - #[allow(unused_variables)] let postfix_operator_parser = |input: &mut ParserContext<'_>| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_yul_function_call_expression(input); + let result = parse_postfix_yul_function_call_expression(input); choice.consider(input, result)?; choice.finish(input) }) }; - #[allow(unused_variables)] let linear_expression_parser = |input: &mut ParserContext<'_>| { SequenceHelper::run(|mut seq| { seq.elem(primary_expression_parser(input))?; From 9f0add646f5c004908de7e05c76a5ccb11d0bcd6 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Fri, 8 Dec 2023 22:37:59 +0100 Subject: [PATCH 09/17] Allow parsing precedence expressions in our public API This lets us completely get rid of the ProductionKind, as we support parsing every `RuleKind` now. --- .../src/precedence_parser_definition.rs | 1 + .../src/model/non_terminals/precedence.rs | 9 - .../parser/generator/src/code_generator.rs | 7 + .../src/precedence_parser_definition.rs | 35 ++ .../runtime/src/templates/language.rs.jinja2 | 3 +- .../solidity/inputs/language/src/grammar.rs | 9 +- .../cargo/crate/src/generated/language.rs | 512 +++++++++++++++++- .../npm/crate/src/generated/language.rs | 512 +++++++++++++++++- 8 files changed, 1067 insertions(+), 21 deletions(-) diff --git a/crates/codegen/grammar/src/precedence_parser_definition.rs b/crates/codegen/grammar/src/precedence_parser_definition.rs index e410c35d42..dcbba9fdad 100644 --- a/crates/codegen/grammar/src/precedence_parser_definition.rs +++ b/crates/codegen/grammar/src/precedence_parser_definition.rs @@ -26,6 +26,7 @@ pub struct PrecedenceParserDefinitionNode { &'static str, // name ParserDefinitionNode, )>, + pub precedence_expression_names: Vec<&'static str>, } impl Visitable for PrecedenceParserDefinitionNode { diff --git a/crates/codegen/language/definition/src/model/non_terminals/precedence.rs b/crates/codegen/language/definition/src/model/non_terminals/precedence.rs index 696edb312c..e29058f4a5 100644 --- a/crates/codegen/language/definition/src/model/non_terminals/precedence.rs +++ b/crates/codegen/language/definition/src/model/non_terminals/precedence.rs @@ -42,15 +42,6 @@ pub enum OperatorModel { BinaryRightAssociative, } -impl OperatorModel { - pub fn is_binary(&self) -> bool { - matches!( - self, - OperatorModel::BinaryLeftAssociative | OperatorModel::BinaryRightAssociative - ) - } -} - #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] #[derive_spanned_type(ParseInputTokens, WriteOutputTokens)] pub struct PrimaryExpression { diff --git a/crates/codegen/parser/generator/src/code_generator.rs b/crates/codegen/parser/generator/src/code_generator.rs index 27b7ced2a0..0897ba1f56 100644 --- a/crates/codegen/parser/generator/src/code_generator.rs +++ b/crates/codegen/parser/generator/src/code_generator.rs @@ -252,6 +252,13 @@ impl GrammarVisitor for CodeGenerator { for (_, name, _) in &parser.node().operators { self.rule_kinds.insert(name); } + + // While it's not common to parse a precedence expression as a standalone rule, + // we generate a function for completeness. + for (name, code) in parser.to_precedence_expression_parser_code() { + self.parser_functions.push((name, code.to_string())); + } + self.parser_functions.push(( parser.name(), { diff --git a/crates/codegen/parser/generator/src/precedence_parser_definition.rs b/crates/codegen/parser/generator/src/precedence_parser_definition.rs index 082648b5de..d573e828dd 100644 --- a/crates/codegen/parser/generator/src/precedence_parser_definition.rs +++ b/crates/codegen/parser/generator/src/precedence_parser_definition.rs @@ -10,6 +10,10 @@ use super::parser_definition::ParserDefinitionNodeExtensions; pub trait PrecedenceParserDefinitionExtensions { fn to_parser_code(&self) -> TokenStream; + /// Emit a helper parser function for each precedence expression that ensures the main parser + /// identifies a single node of the expected type, with a child node being the expected + /// precedence expression. + fn to_precedence_expression_parser_code(&self) -> Vec<(&'static str, TokenStream)>; } impl PrecedenceParserDefinitionExtensions for PrecedenceParserDefinitionRef { @@ -19,6 +23,37 @@ impl PrecedenceParserDefinitionExtensions for PrecedenceParserDefinitionRef { format_ident!("{name}", name = self.name().to_pascal_case()), ) } + + fn to_precedence_expression_parser_code(&self) -> Vec<(&'static str, TokenStream)> { + let mut res = vec![]; + let parser_name = format_ident!("{}", self.name().to_snake_case()); + let rule_name = format_ident!("{}", self.name().to_pascal_case()); + + for name in &self.node().precedence_expression_names { + let op_rule_name = format_ident!("{}", name.to_pascal_case()); + + // Ensure that the parser correctly identifies a single node of the expected type, + // which contains a single child node representing the expected precedence operator. + let code = quote! { + let result = self.#parser_name(input); + let ParserResult::Match(r#match) = &result else { return result; }; + + // If the result won't match exactly, we return a dummy `ParserResult::no_match`, since + // can't precisely determine the expected tokens or completeness of the match otherwise. + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::#rule_name => match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::#op_rule_name => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + _ => ParserResult::no_match(vec![]), + } + }; + res.push((*name, code)); + } + res + } } pub trait PrecedenceParserDefinitionNodeExtensions { diff --git a/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 b/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 index 2d2c383f14..08750834a5 100644 --- a/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 +++ b/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 @@ -7,6 +7,7 @@ use {napi::bindgen_prelude::*, napi_derive::napi}; use semver::Version; use super::{ + cst, kinds::{RuleKind, TokenKind, IsLexicalContext, LexicalContextType}, lexer::Lexer, parse_output::ParseOutput, @@ -104,8 +105,6 @@ impl Language { {%- for function in code.parser_functions -%} RuleKind::{{ function.0 }} => Self::{{ function.0 | snake_case }}.parse(self, input), {%- endfor -%} - // TODO(#638): Expose parsing individual operators - _ => unimplemented!("Parsing individual precedence operators is not supported at the moment") } } } diff --git a/crates/solidity/inputs/language/src/grammar.rs b/crates/solidity/inputs/language/src/grammar.rs index 7327e30e44..9be53b5ea9 100644 --- a/crates/solidity/inputs/language/src/grammar.rs +++ b/crates/solidity/inputs/language/src/grammar.rs @@ -742,15 +742,19 @@ fn resolve_precedence( } let mut operators = vec![]; + let mut precedence_expression_names = Vec::with_capacity(item.precedence_expressions.len()); for expr in item.precedence_expressions { let name = expr.name; + // TODO: Don't leak + let leaked_name = name.to_string().leak() as &_; + precedence_expression_names.push(leaked_name); // Register it as a regular parser with a given name, however we need to // define it as a choice over the "operator" sequences // Then, when returning, we should actually return a node ref pointing to that combined parser // And ideally, we shouldn't even use the "enabled" mode of the original DSL let thunk = Rc::new(NamedParserThunk { - name: name.to_string().leak(), + name: leaked_name, context: lex_ctx, is_inline: true, def: OnceCell::new(), @@ -776,7 +780,7 @@ fn resolve_precedence( let def = ParserDefinitionNode::Choice(defs); all_operators.push(def.clone()); - operators.push((model_to_enum(model), name.to_string().leak() as &_, def)); + operators.push((model_to_enum(model), leaked_name, def)); } // Register the combined parser definition to appease the codegen and to mark terminals @@ -798,6 +802,7 @@ fn resolve_precedence( PrecedenceParserDefinitionNode { primary_expression, operators, + precedence_expression_names, } } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index b63de46484..df417730ac 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -15,6 +15,7 @@ use {napi::bindgen_prelude::*, napi_derive::napi}; use semver::Version; use super::{ + cst, kinds::{IsLexicalContext, LexicalContextType, RuleKind, TokenKind}, lexer::Lexer, parse_output::ParseOutput, @@ -209,6 +210,27 @@ impl Language { .with_kind(RuleKind::ABICoderPragma) } + #[allow(unused_assignments, unused_parens)] + fn additive_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::AdditiveExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn address_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -227,6 +249,25 @@ impl Language { .with_kind(RuleKind::AddressType) } + #[allow(unused_assignments, unused_parens)] + fn and_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::AndExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn arguments_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { @@ -266,6 +307,25 @@ impl Language { .with_kind(RuleKind::ArrayExpression) } + #[allow(unused_assignments, unused_parens)] + fn array_type_name(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.type_name(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::TypeName => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::ArrayTypeName => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn array_values(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( @@ -353,6 +413,90 @@ impl Language { .with_kind(RuleKind::AssemblyStatement) } + #[allow(unused_assignments, unused_parens)] + fn assignment_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::AssignmentExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn bitwise_and_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::BitwiseAndExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn bitwise_or_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::BitwiseOrExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn bitwise_xor_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::BitwiseXorExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn block(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -451,6 +595,48 @@ impl Language { .with_kind(RuleKind::CatchClauses) } + #[allow(unused_assignments, unused_parens)] + fn comparison_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::ComparisonExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn conditional_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::ConditionalExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn constant_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_7_4 { @@ -951,6 +1137,27 @@ impl Language { .with_kind(RuleKind::EnumMembers) } + #[allow(unused_assignments, unused_parens)] + fn equality_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::EqualityExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn error_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { @@ -1180,6 +1387,27 @@ impl Language { .with_kind(RuleKind::ExperimentalPragma) } + #[allow(unused_assignments, unused_parens)] + fn exponentiation_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::ExponentiationExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn expression(&self, input: &mut ParserContext<'_>) -> ParserResult { let parse_left_assignment_expression = |input: &mut ParserContext<'_>| { @@ -2004,6 +2232,27 @@ impl Language { .with_kind(RuleKind::FunctionBody) } + #[allow(unused_assignments, unused_parens)] + fn function_call_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::FunctionCallExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn function_call_options(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_2 { @@ -2343,6 +2592,27 @@ impl Language { .with_kind(RuleKind::IndexAccessEnd) } + #[allow(unused_assignments, unused_parens)] + fn index_access_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::IndexAccessExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn inheritance_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2596,6 +2866,27 @@ impl Language { .with_kind(RuleKind::MemberAccess) } + #[allow(unused_assignments, unused_parens)] + fn member_access_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::MemberAccessExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn modifier_attribute(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { @@ -2650,6 +2941,27 @@ impl Language { .with_kind(RuleKind::ModifierInvocation) } + #[allow(unused_assignments, unused_parens)] + fn multiplicative_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::MultiplicativeExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn named_argument(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2849,6 +3161,25 @@ impl Language { .with_kind(RuleKind::NumberUnit) } + #[allow(unused_assignments, unused_parens)] + fn or_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::OrExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn override_paths(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( @@ -3007,6 +3338,25 @@ impl Language { .with_kind(RuleKind::PositionalArgumentsDeclaration) } + #[allow(unused_assignments, unused_parens)] + fn postfix_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::PostfixExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { @@ -3049,6 +3399,25 @@ impl Language { .with_kind(RuleKind::PragmaDirective) } + #[allow(unused_assignments, unused_parens)] + fn prefix_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::PrefixExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn receive_function_attribute(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { @@ -3185,6 +3554,25 @@ impl Language { .with_kind(RuleKind::RevertStatement) } + #[allow(unused_assignments, unused_parens)] + fn shift_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::ShiftExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn source_unit(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -4409,6 +4797,69 @@ impl Language { .with_kind(RuleKind::VersionPragmaExpressions) } + #[allow(unused_assignments, unused_parens)] + fn version_pragma_or_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.version_pragma_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::VersionPragmaExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::VersionPragmaOrExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma_prefix_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.version_pragma_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::VersionPragmaExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::VersionPragmaPrefixExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma_range_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.version_pragma_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::VersionPragmaExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::VersionPragmaRangeExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn version_pragma_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Pragma>( @@ -4626,6 +5077,27 @@ impl Language { .with_kind(RuleKind::YulForStatement) } + #[allow(unused_assignments, unused_parens)] + fn yul_function_call_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.yul_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::YulExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::YulFunctionCallExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn yul_function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -6831,9 +7303,12 @@ impl Language { pub fn parse(&self, kind: RuleKind, input: &str) -> ParseOutput { match kind { RuleKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), + RuleKind::AdditiveExpression => Self::additive_expression.parse(self, input), RuleKind::AddressType => Self::address_type.parse(self, input), + RuleKind::AndExpression => Self::and_expression.parse(self, input), RuleKind::ArgumentsDeclaration => Self::arguments_declaration.parse(self, input), RuleKind::ArrayExpression => Self::array_expression.parse(self, input), + RuleKind::ArrayTypeName => Self::array_type_name.parse(self, input), RuleKind::ArrayValues => Self::array_values.parse(self, input), RuleKind::AsciiStringLiterals => Self::ascii_string_literals.parse(self, input), RuleKind::AssemblyFlags => Self::assembly_flags.parse(self, input), @@ -6841,11 +7316,17 @@ impl Language { Self::assembly_flags_declaration.parse(self, input) } RuleKind::AssemblyStatement => Self::assembly_statement.parse(self, input), + RuleKind::AssignmentExpression => Self::assignment_expression.parse(self, input), + RuleKind::BitwiseAndExpression => Self::bitwise_and_expression.parse(self, input), + RuleKind::BitwiseOrExpression => Self::bitwise_or_expression.parse(self, input), + RuleKind::BitwiseXorExpression => Self::bitwise_xor_expression.parse(self, input), RuleKind::Block => Self::block.parse(self, input), RuleKind::BreakStatement => Self::break_statement.parse(self, input), RuleKind::CatchClause => Self::catch_clause.parse(self, input), RuleKind::CatchClauseError => Self::catch_clause_error.parse(self, input), RuleKind::CatchClauses => Self::catch_clauses.parse(self, input), + RuleKind::ComparisonExpression => Self::comparison_expression.parse(self, input), + RuleKind::ConditionalExpression => Self::conditional_expression.parse(self, input), RuleKind::ConstantDefinition => Self::constant_definition.parse(self, input), RuleKind::ConstructorAttribute => Self::constructor_attribute.parse(self, input), RuleKind::ConstructorAttributes => Self::constructor_attributes.parse(self, input), @@ -6863,6 +7344,7 @@ impl Language { RuleKind::EndOfFileTrivia => Self::end_of_file_trivia.parse(self, input), RuleKind::EnumDefinition => Self::enum_definition.parse(self, input), RuleKind::EnumMembers => Self::enum_members.parse(self, input), + RuleKind::EqualityExpression => Self::equality_expression.parse(self, input), RuleKind::ErrorDefinition => Self::error_definition.parse(self, input), RuleKind::ErrorParameter => Self::error_parameter.parse(self, input), RuleKind::ErrorParameters => Self::error_parameters.parse(self, input), @@ -6877,6 +7359,9 @@ impl Language { } RuleKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), RuleKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), + RuleKind::ExponentiationExpression => { + Self::exponentiation_expression.parse(self, input) + } RuleKind::Expression => Self::expression.parse(self, input), RuleKind::ExpressionStatement => Self::expression_statement.parse(self, input), RuleKind::FallbackFunctionAttribute => { @@ -6896,6 +7381,7 @@ impl Language { RuleKind::FunctionAttribute => Self::function_attribute.parse(self, input), RuleKind::FunctionAttributes => Self::function_attributes.parse(self, input), RuleKind::FunctionBody => Self::function_body.parse(self, input), + RuleKind::FunctionCallExpression => Self::function_call_expression.parse(self, input), RuleKind::FunctionCallOptions => Self::function_call_options.parse(self, input), RuleKind::FunctionDefinition => Self::function_definition.parse(self, input), RuleKind::FunctionName => Self::function_name.parse(self, input), @@ -6917,6 +7403,7 @@ impl Language { } RuleKind::ImportDirective => Self::import_directive.parse(self, input), RuleKind::IndexAccessEnd => Self::index_access_end.parse(self, input), + RuleKind::IndexAccessExpression => Self::index_access_expression.parse(self, input), RuleKind::InheritanceSpecifier => Self::inheritance_specifier.parse(self, input), RuleKind::InheritanceType => Self::inheritance_type.parse(self, input), RuleKind::InheritanceTypes => Self::inheritance_types.parse(self, input), @@ -6930,10 +7417,14 @@ impl Language { RuleKind::MappingType => Self::mapping_type.parse(self, input), RuleKind::MappingValue => Self::mapping_value.parse(self, input), RuleKind::MemberAccess => Self::member_access.parse(self, input), + RuleKind::MemberAccessExpression => Self::member_access_expression.parse(self, input), RuleKind::ModifierAttribute => Self::modifier_attribute.parse(self, input), RuleKind::ModifierAttributes => Self::modifier_attributes.parse(self, input), RuleKind::ModifierDefinition => Self::modifier_definition.parse(self, input), RuleKind::ModifierInvocation => Self::modifier_invocation.parse(self, input), + RuleKind::MultiplicativeExpression => { + Self::multiplicative_expression.parse(self, input) + } RuleKind::NamedArgument => Self::named_argument.parse(self, input), RuleKind::NamedArgumentGroup => Self::named_argument_group.parse(self, input), RuleKind::NamedArgumentGroups => Self::named_argument_groups.parse(self, input), @@ -6944,6 +7435,7 @@ impl Language { RuleKind::NamedImport => Self::named_import.parse(self, input), RuleKind::NewExpression => Self::new_expression.parse(self, input), RuleKind::NumberUnit => Self::number_unit.parse(self, input), + RuleKind::OrExpression => Self::or_expression.parse(self, input), RuleKind::OverridePaths => Self::override_paths.parse(self, input), RuleKind::OverridePathsDeclaration => { Self::override_paths_declaration.parse(self, input) @@ -6957,8 +7449,10 @@ impl Language { RuleKind::PositionalArgumentsDeclaration => { Self::positional_arguments_declaration.parse(self, input) } + RuleKind::PostfixExpression => Self::postfix_expression.parse(self, input), RuleKind::Pragma => Self::pragma.parse(self, input), RuleKind::PragmaDirective => Self::pragma_directive.parse(self, input), + RuleKind::PrefixExpression => Self::prefix_expression.parse(self, input), RuleKind::ReceiveFunctionAttribute => { Self::receive_function_attribute.parse(self, input) } @@ -6971,6 +7465,7 @@ impl Language { RuleKind::ReturnStatement => Self::return_statement.parse(self, input), RuleKind::ReturnsDeclaration => Self::returns_declaration.parse(self, input), RuleKind::RevertStatement => Self::revert_statement.parse(self, input), + RuleKind::ShiftExpression => Self::shift_expression.parse(self, input), RuleKind::SourceUnit => Self::source_unit.parse(self, input), RuleKind::SourceUnitMember => Self::source_unit_member.parse(self, input), RuleKind::SourceUnitMembers => Self::source_unit_members.parse(self, input), @@ -7045,6 +7540,15 @@ impl Language { RuleKind::VersionPragmaExpressions => { Self::version_pragma_expressions.parse(self, input) } + RuleKind::VersionPragmaOrExpression => { + Self::version_pragma_or_expression.parse(self, input) + } + RuleKind::VersionPragmaPrefixExpression => { + Self::version_pragma_prefix_expression.parse(self, input) + } + RuleKind::VersionPragmaRangeExpression => { + Self::version_pragma_range_expression.parse(self, input) + } RuleKind::VersionPragmaSpecifier => Self::version_pragma_specifier.parse(self, input), RuleKind::WhileStatement => Self::while_statement.parse(self, input), RuleKind::YulArguments => Self::yul_arguments.parse(self, input), @@ -7055,6 +7559,9 @@ impl Language { RuleKind::YulDefaultCase => Self::yul_default_case.parse(self, input), RuleKind::YulExpression => Self::yul_expression.parse(self, input), RuleKind::YulForStatement => Self::yul_for_statement.parse(self, input), + RuleKind::YulFunctionCallExpression => { + Self::yul_function_call_expression.parse(self, input) + } RuleKind::YulFunctionDefinition => Self::yul_function_definition.parse(self, input), RuleKind::YulIdentifierPath => Self::yul_identifier_path.parse(self, input), RuleKind::YulIdentifierPaths => Self::yul_identifier_paths.parse(self, input), @@ -7078,10 +7585,7 @@ impl Language { } RuleKind::YulVariableDeclarationValue => { Self::yul_variable_declaration_value.parse(self, input) - } // TODO(#638): Expose parsing individual operators - _ => unimplemented!( - "Parsing individual precedence operators is not supported at the moment" - ), + } } } } diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index b63de46484..df417730ac 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -15,6 +15,7 @@ use {napi::bindgen_prelude::*, napi_derive::napi}; use semver::Version; use super::{ + cst, kinds::{IsLexicalContext, LexicalContextType, RuleKind, TokenKind}, lexer::Lexer, parse_output::ParseOutput, @@ -209,6 +210,27 @@ impl Language { .with_kind(RuleKind::ABICoderPragma) } + #[allow(unused_assignments, unused_parens)] + fn additive_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::AdditiveExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn address_type(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -227,6 +249,25 @@ impl Language { .with_kind(RuleKind::AddressType) } + #[allow(unused_assignments, unused_parens)] + fn and_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::AndExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn arguments_declaration(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { @@ -266,6 +307,25 @@ impl Language { .with_kind(RuleKind::ArrayExpression) } + #[allow(unused_assignments, unused_parens)] + fn array_type_name(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.type_name(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::TypeName => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::ArrayTypeName => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn array_values(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( @@ -353,6 +413,90 @@ impl Language { .with_kind(RuleKind::AssemblyStatement) } + #[allow(unused_assignments, unused_parens)] + fn assignment_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::AssignmentExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn bitwise_and_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::BitwiseAndExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn bitwise_or_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::BitwiseOrExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn bitwise_xor_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::BitwiseXorExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn block(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -451,6 +595,48 @@ impl Language { .with_kind(RuleKind::CatchClauses) } + #[allow(unused_assignments, unused_parens)] + fn comparison_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::ComparisonExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn conditional_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::ConditionalExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn constant_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_7_4 { @@ -951,6 +1137,27 @@ impl Language { .with_kind(RuleKind::EnumMembers) } + #[allow(unused_assignments, unused_parens)] + fn equality_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::EqualityExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn error_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_8_4 { @@ -1180,6 +1387,27 @@ impl Language { .with_kind(RuleKind::ExperimentalPragma) } + #[allow(unused_assignments, unused_parens)] + fn exponentiation_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::ExponentiationExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn expression(&self, input: &mut ParserContext<'_>) -> ParserResult { let parse_left_assignment_expression = |input: &mut ParserContext<'_>| { @@ -2004,6 +2232,27 @@ impl Language { .with_kind(RuleKind::FunctionBody) } + #[allow(unused_assignments, unused_parens)] + fn function_call_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::FunctionCallExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn function_call_options(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_2 { @@ -2343,6 +2592,27 @@ impl Language { .with_kind(RuleKind::IndexAccessEnd) } + #[allow(unused_assignments, unused_parens)] + fn index_access_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::IndexAccessExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn inheritance_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2596,6 +2866,27 @@ impl Language { .with_kind(RuleKind::MemberAccess) } + #[allow(unused_assignments, unused_parens)] + fn member_access_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::MemberAccessExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn modifier_attribute(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { @@ -2650,6 +2941,27 @@ impl Language { .with_kind(RuleKind::ModifierInvocation) } + #[allow(unused_assignments, unused_parens)] + fn multiplicative_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::MultiplicativeExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn named_argument(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2849,6 +3161,25 @@ impl Language { .with_kind(RuleKind::NumberUnit) } + #[allow(unused_assignments, unused_parens)] + fn or_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::OrExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn override_paths(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( @@ -3007,6 +3338,25 @@ impl Language { .with_kind(RuleKind::PositionalArgumentsDeclaration) } + #[allow(unused_assignments, unused_parens)] + fn postfix_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::PostfixExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { @@ -3049,6 +3399,25 @@ impl Language { .with_kind(RuleKind::PragmaDirective) } + #[allow(unused_assignments, unused_parens)] + fn prefix_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::PrefixExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn receive_function_attribute(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { @@ -3185,6 +3554,25 @@ impl Language { .with_kind(RuleKind::RevertStatement) } + #[allow(unused_assignments, unused_parens)] + fn shift_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::Expression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] if rule.kind == RuleKind::ShiftExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn source_unit(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -4409,6 +4797,69 @@ impl Language { .with_kind(RuleKind::VersionPragmaExpressions) } + #[allow(unused_assignments, unused_parens)] + fn version_pragma_or_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.version_pragma_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::VersionPragmaExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::VersionPragmaOrExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma_prefix_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.version_pragma_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::VersionPragmaExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::VersionPragmaPrefixExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + + #[allow(unused_assignments, unused_parens)] + fn version_pragma_range_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.version_pragma_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::VersionPragmaExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::VersionPragmaRangeExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn version_pragma_specifier(&self, input: &mut ParserContext<'_>) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Pragma>( @@ -4626,6 +5077,27 @@ impl Language { .with_kind(RuleKind::YulForStatement) } + #[allow(unused_assignments, unused_parens)] + fn yul_function_call_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.yul_expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::Node::Rule(node)] if node.kind == RuleKind::YulExpression => { + match &node.children[..] { + [inner @ cst::Node::Rule(rule)] + if rule.kind == RuleKind::YulFunctionCallExpression => + { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + } + } + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn yul_function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -6831,9 +7303,12 @@ impl Language { pub fn parse(&self, kind: RuleKind, input: &str) -> ParseOutput { match kind { RuleKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), + RuleKind::AdditiveExpression => Self::additive_expression.parse(self, input), RuleKind::AddressType => Self::address_type.parse(self, input), + RuleKind::AndExpression => Self::and_expression.parse(self, input), RuleKind::ArgumentsDeclaration => Self::arguments_declaration.parse(self, input), RuleKind::ArrayExpression => Self::array_expression.parse(self, input), + RuleKind::ArrayTypeName => Self::array_type_name.parse(self, input), RuleKind::ArrayValues => Self::array_values.parse(self, input), RuleKind::AsciiStringLiterals => Self::ascii_string_literals.parse(self, input), RuleKind::AssemblyFlags => Self::assembly_flags.parse(self, input), @@ -6841,11 +7316,17 @@ impl Language { Self::assembly_flags_declaration.parse(self, input) } RuleKind::AssemblyStatement => Self::assembly_statement.parse(self, input), + RuleKind::AssignmentExpression => Self::assignment_expression.parse(self, input), + RuleKind::BitwiseAndExpression => Self::bitwise_and_expression.parse(self, input), + RuleKind::BitwiseOrExpression => Self::bitwise_or_expression.parse(self, input), + RuleKind::BitwiseXorExpression => Self::bitwise_xor_expression.parse(self, input), RuleKind::Block => Self::block.parse(self, input), RuleKind::BreakStatement => Self::break_statement.parse(self, input), RuleKind::CatchClause => Self::catch_clause.parse(self, input), RuleKind::CatchClauseError => Self::catch_clause_error.parse(self, input), RuleKind::CatchClauses => Self::catch_clauses.parse(self, input), + RuleKind::ComparisonExpression => Self::comparison_expression.parse(self, input), + RuleKind::ConditionalExpression => Self::conditional_expression.parse(self, input), RuleKind::ConstantDefinition => Self::constant_definition.parse(self, input), RuleKind::ConstructorAttribute => Self::constructor_attribute.parse(self, input), RuleKind::ConstructorAttributes => Self::constructor_attributes.parse(self, input), @@ -6863,6 +7344,7 @@ impl Language { RuleKind::EndOfFileTrivia => Self::end_of_file_trivia.parse(self, input), RuleKind::EnumDefinition => Self::enum_definition.parse(self, input), RuleKind::EnumMembers => Self::enum_members.parse(self, input), + RuleKind::EqualityExpression => Self::equality_expression.parse(self, input), RuleKind::ErrorDefinition => Self::error_definition.parse(self, input), RuleKind::ErrorParameter => Self::error_parameter.parse(self, input), RuleKind::ErrorParameters => Self::error_parameters.parse(self, input), @@ -6877,6 +7359,9 @@ impl Language { } RuleKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), RuleKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), + RuleKind::ExponentiationExpression => { + Self::exponentiation_expression.parse(self, input) + } RuleKind::Expression => Self::expression.parse(self, input), RuleKind::ExpressionStatement => Self::expression_statement.parse(self, input), RuleKind::FallbackFunctionAttribute => { @@ -6896,6 +7381,7 @@ impl Language { RuleKind::FunctionAttribute => Self::function_attribute.parse(self, input), RuleKind::FunctionAttributes => Self::function_attributes.parse(self, input), RuleKind::FunctionBody => Self::function_body.parse(self, input), + RuleKind::FunctionCallExpression => Self::function_call_expression.parse(self, input), RuleKind::FunctionCallOptions => Self::function_call_options.parse(self, input), RuleKind::FunctionDefinition => Self::function_definition.parse(self, input), RuleKind::FunctionName => Self::function_name.parse(self, input), @@ -6917,6 +7403,7 @@ impl Language { } RuleKind::ImportDirective => Self::import_directive.parse(self, input), RuleKind::IndexAccessEnd => Self::index_access_end.parse(self, input), + RuleKind::IndexAccessExpression => Self::index_access_expression.parse(self, input), RuleKind::InheritanceSpecifier => Self::inheritance_specifier.parse(self, input), RuleKind::InheritanceType => Self::inheritance_type.parse(self, input), RuleKind::InheritanceTypes => Self::inheritance_types.parse(self, input), @@ -6930,10 +7417,14 @@ impl Language { RuleKind::MappingType => Self::mapping_type.parse(self, input), RuleKind::MappingValue => Self::mapping_value.parse(self, input), RuleKind::MemberAccess => Self::member_access.parse(self, input), + RuleKind::MemberAccessExpression => Self::member_access_expression.parse(self, input), RuleKind::ModifierAttribute => Self::modifier_attribute.parse(self, input), RuleKind::ModifierAttributes => Self::modifier_attributes.parse(self, input), RuleKind::ModifierDefinition => Self::modifier_definition.parse(self, input), RuleKind::ModifierInvocation => Self::modifier_invocation.parse(self, input), + RuleKind::MultiplicativeExpression => { + Self::multiplicative_expression.parse(self, input) + } RuleKind::NamedArgument => Self::named_argument.parse(self, input), RuleKind::NamedArgumentGroup => Self::named_argument_group.parse(self, input), RuleKind::NamedArgumentGroups => Self::named_argument_groups.parse(self, input), @@ -6944,6 +7435,7 @@ impl Language { RuleKind::NamedImport => Self::named_import.parse(self, input), RuleKind::NewExpression => Self::new_expression.parse(self, input), RuleKind::NumberUnit => Self::number_unit.parse(self, input), + RuleKind::OrExpression => Self::or_expression.parse(self, input), RuleKind::OverridePaths => Self::override_paths.parse(self, input), RuleKind::OverridePathsDeclaration => { Self::override_paths_declaration.parse(self, input) @@ -6957,8 +7449,10 @@ impl Language { RuleKind::PositionalArgumentsDeclaration => { Self::positional_arguments_declaration.parse(self, input) } + RuleKind::PostfixExpression => Self::postfix_expression.parse(self, input), RuleKind::Pragma => Self::pragma.parse(self, input), RuleKind::PragmaDirective => Self::pragma_directive.parse(self, input), + RuleKind::PrefixExpression => Self::prefix_expression.parse(self, input), RuleKind::ReceiveFunctionAttribute => { Self::receive_function_attribute.parse(self, input) } @@ -6971,6 +7465,7 @@ impl Language { RuleKind::ReturnStatement => Self::return_statement.parse(self, input), RuleKind::ReturnsDeclaration => Self::returns_declaration.parse(self, input), RuleKind::RevertStatement => Self::revert_statement.parse(self, input), + RuleKind::ShiftExpression => Self::shift_expression.parse(self, input), RuleKind::SourceUnit => Self::source_unit.parse(self, input), RuleKind::SourceUnitMember => Self::source_unit_member.parse(self, input), RuleKind::SourceUnitMembers => Self::source_unit_members.parse(self, input), @@ -7045,6 +7540,15 @@ impl Language { RuleKind::VersionPragmaExpressions => { Self::version_pragma_expressions.parse(self, input) } + RuleKind::VersionPragmaOrExpression => { + Self::version_pragma_or_expression.parse(self, input) + } + RuleKind::VersionPragmaPrefixExpression => { + Self::version_pragma_prefix_expression.parse(self, input) + } + RuleKind::VersionPragmaRangeExpression => { + Self::version_pragma_range_expression.parse(self, input) + } RuleKind::VersionPragmaSpecifier => Self::version_pragma_specifier.parse(self, input), RuleKind::WhileStatement => Self::while_statement.parse(self, input), RuleKind::YulArguments => Self::yul_arguments.parse(self, input), @@ -7055,6 +7559,9 @@ impl Language { RuleKind::YulDefaultCase => Self::yul_default_case.parse(self, input), RuleKind::YulExpression => Self::yul_expression.parse(self, input), RuleKind::YulForStatement => Self::yul_for_statement.parse(self, input), + RuleKind::YulFunctionCallExpression => { + Self::yul_function_call_expression.parse(self, input) + } RuleKind::YulFunctionDefinition => Self::yul_function_definition.parse(self, input), RuleKind::YulIdentifierPath => Self::yul_identifier_path.parse(self, input), RuleKind::YulIdentifierPaths => Self::yul_identifier_paths.parse(self, input), @@ -7078,10 +7585,7 @@ impl Language { } RuleKind::YulVariableDeclarationValue => { Self::yul_variable_declaration_value.parse(self, input) - } // TODO(#638): Expose parsing individual operators - _ => unimplemented!( - "Parsing individual precedence operators is not supported at the moment" - ), + } } } } From 0296bef296a2b10117a1e473c5bdaef80bd6f17c Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Fri, 8 Dec 2023 22:48:12 +0100 Subject: [PATCH 10/17] Add a unit test for the precedence expression parsers --- .../solidity/outputs/cargo/tests/src/lib.rs | 1 + .../outputs/cargo/tests/src/parser/mod.rs | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 crates/solidity/outputs/cargo/tests/src/parser/mod.rs diff --git a/crates/solidity/outputs/cargo/tests/src/lib.rs b/crates/solidity/outputs/cargo/tests/src/lib.rs index 7b04712139..76e1e8ef37 100644 --- a/crates/solidity/outputs/cargo/tests/src/lib.rs +++ b/crates/solidity/outputs/cargo/tests/src/lib.rs @@ -3,5 +3,6 @@ mod cst_output; mod doc_examples; mod errors; +mod parser; mod scanner; mod versions; diff --git a/crates/solidity/outputs/cargo/tests/src/parser/mod.rs b/crates/solidity/outputs/cargo/tests/src/parser/mod.rs new file mode 100644 index 0000000000..25a3bf7f84 --- /dev/null +++ b/crates/solidity/outputs/cargo/tests/src/parser/mod.rs @@ -0,0 +1,29 @@ +use semver::Version; +use slang_solidity::{kinds::RuleKind, language::Language}; + +#[test] +fn test_precedence_expression() { + let language = Language::new(Version::new(0, 8, 0)).unwrap(); + + let output = language.parse(RuleKind::ShiftExpression, "1 >> 2"); + assert!(output.is_valid()); + let output = language.parse(RuleKind::ShiftExpression, "1 + 2"); + assert!(!output.is_valid()); + let output = language.parse(RuleKind::ArrayTypeName, "uint[]"); + assert!(output.is_valid()); + + // Plus prefix was removed in 0.5.0 + let language = Language::new(Version::new(0, 4, 11)).unwrap(); + let output = language.parse(RuleKind::PrefixExpression, "+1"); + assert!(output.is_valid()); + let language = Language::new(Version::new(0, 8, 0)).unwrap(); + let output = language.parse(RuleKind::PrefixExpression, "+1"); + assert!(!output.is_valid()); + + // Changed to right-associative in 0.6.0; the rule should still be valid + let output = language.parse(RuleKind::ExponentiationExpression, "1 ** 2"); + assert!(output.is_valid()); + let language = Language::new(Version::new(0, 5, 0)).unwrap(); + let output = language.parse(RuleKind::ExponentiationExpression, "1 ** 2"); + assert!(output.is_valid()); +} From 137a1dfcc3f5b5d29006532051ad2c4d53c53e03 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sat, 9 Dec 2023 12:28:04 +0100 Subject: [PATCH 11/17] Simplify `extract_version_pragmas` with new precedence expr kinds --- .../testing/utils/src/version_pragmas/mod.rs | 67 ++++++++----------- 1 file changed, 27 insertions(+), 40 deletions(-) diff --git a/crates/solidity/testing/utils/src/version_pragmas/mod.rs b/crates/solidity/testing/utils/src/version_pragmas/mod.rs index a974e5eab9..f37e619c99 100644 --- a/crates/solidity/testing/utils/src/version_pragmas/mod.rs +++ b/crates/solidity/testing/utils/src/version_pragmas/mod.rs @@ -5,11 +5,7 @@ use std::str::FromStr; use anyhow::{bail, ensure, Context, Result}; use semver::{Comparator, Op, Version}; -use slang_solidity::{ - cst::Node, - kinds::{RuleKind, TokenKind}, - language::Language, -}; +use slang_solidity::{cst::Node, kinds::RuleKind, language::Language}; use crate::node_extensions::NodeExtensions; @@ -68,41 +64,32 @@ fn extract_pragma(expression_node: &Node) -> Result { .collect(); match inner_expression.kind { - RuleKind::VersionPragmaOrExpression | RuleKind::VersionPragmaRangeExpression => { - match &inner_children[..] { - [left, operator, right] => { - let Node::Token(operator) = operator else { - bail!("Expected rule: {operator:?}"); - }; - - match operator.kind { - TokenKind::BarBar => { - let left = extract_pragma(left)?; - let right = extract_pragma(right)?; - - Ok(VersionPragma::or(left, right)) - } - TokenKind::Minus => { - let mut left = extract_pragma(left)?.comparator()?; - let mut right = extract_pragma(right)?.comparator()?; - - // Simulate solc bug: - // https://github.com/ethereum/solidity/issues/13920 - left.op = Op::GreaterEq; - right.op = Op::LessEq; - - Ok(VersionPragma::and( - VersionPragma::single(left), - VersionPragma::single(right), - )) - } - - _ => bail!("Unexpected operator: {operator:?}"), - } - } - - _ => bail!("Expected 3 children: {inner_expression:?}"), - } + RuleKind::VersionPragmaOrExpression => { + let [left, Node::Token(_op), right] = &inner_children[..] else { + bail!("Expected 3 children: {inner_expression:?}"); + }; + let left = extract_pragma(left)?; + let right = extract_pragma(right)?; + + Ok(VersionPragma::or(left, right)) + } + RuleKind::VersionPragmaRangeExpression => { + let [left, Node::Token(_op), right] = &inner_children[..] else { + bail!("Expected 3 children: {inner_expression:?}"); + }; + + let mut left = extract_pragma(left)?.comparator()?; + let mut right = extract_pragma(right)?.comparator()?; + + // Simulate solc bug: + // https://github.com/ethereum/solidity/issues/13920 + left.op = Op::GreaterEq; + right.op = Op::LessEq; + + Ok(VersionPragma::and( + VersionPragma::single(left), + VersionPragma::single(right), + )) } RuleKind::VersionPragmaPrefixExpression => { let value = inner_expression.extract_non_trivia(); From c4dd9db92c864f400f0f4c85043d27e1f44212b9 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sat, 9 Dec 2023 12:59:16 +0100 Subject: [PATCH 12/17] Limit choice node wrapping for precedence expression op parsers --- .../solidity/inputs/language/src/grammar.rs | 10 +- .../cargo/crate/src/generated/language.rs | 268 +++++++----------- .../npm/crate/src/generated/language.rs | 268 +++++++----------- 3 files changed, 217 insertions(+), 329 deletions(-) diff --git a/crates/solidity/inputs/language/src/grammar.rs b/crates/solidity/inputs/language/src/grammar.rs index 9be53b5ea9..17e9c83638 100644 --- a/crates/solidity/inputs/language/src/grammar.rs +++ b/crates/solidity/inputs/language/src/grammar.rs @@ -775,9 +775,13 @@ fn resolve_precedence( .map(|op| resolve_sequence_like(op.enabled, op.fields, op.error_recovery, ctx)) .collect(); - // NOTE: This is unconditionally a choice to always account for a versioned - // model operator, even if there's only one definition. - let def = ParserDefinitionNode::Choice(defs); + let def = match &defs[..] { + // HACK: Despite it being a single definition, we still need to wrap a versioned + // node around the choice for it to emit the version checks for the node. + [ParserDefinitionNode::Versioned(..)] => ParserDefinitionNode::Choice(defs), + [_] => defs.into_iter().next().unwrap(), + _ => ParserDefinitionNode::Choice(defs), + }; all_operators.push(def.clone()); operators.push((model_to_enum(model), leaked_name, def)); diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index df417730ac..8e5f0cf044 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -1484,22 +1484,18 @@ impl Language { PrecedenceHelper::to_postfix_operator( RuleKind::ConditionalExpression, 3u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::QuestionMark, - ))?; - seq.elem(self.expression(input))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Colon, - ))?; - seq.elem(self.expression(input))?; - seq.finish() - }); - choice.consider(input, result)?; - choice.finish(input) + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::QuestionMark, + ))?; + seq.elem(self.expression(input))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Colon, + ))?; + seq.elem(self.expression(input))?; + seq.finish() }), ) }; @@ -1508,14 +1504,10 @@ impl Language { RuleKind::OrExpression, 5u8, 5u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarBar, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + self.parse_token_with_trivia::( + input, + TokenKind::BarBar, + ), ) }; let parse_left_and_expression = |input: &mut ParserContext<'_>| { @@ -1523,14 +1515,10 @@ impl Language { RuleKind::AndExpression, 7u8, 7u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandAmpersand, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + self.parse_token_with_trivia::( + input, + TokenKind::AmpersandAmpersand, + ), ) }; let parse_left_equality_expression = |input: &mut ParserContext<'_>| { @@ -1588,14 +1576,7 @@ impl Language { RuleKind::BitwiseOrExpression, 13u8, 13u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bar, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + self.parse_token_with_trivia::(input, TokenKind::Bar), ) }; let parse_left_bitwise_xor_expression = |input: &mut ParserContext<'_>| { @@ -1603,14 +1584,10 @@ impl Language { RuleKind::BitwiseXorExpression, 15u8, 15u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + self.parse_token_with_trivia::( + input, + TokenKind::Caret, + ), ) }; let parse_left_bitwise_and_expression = |input: &mut ParserContext<'_>| { @@ -1618,14 +1595,10 @@ impl Language { RuleKind::BitwiseAndExpression, 17u8, 17u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Ampersand, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + self.parse_token_with_trivia::( + input, + TokenKind::Ampersand, + ), ) }; let parse_left_shift_expression = |input: &mut ParserContext<'_>| { @@ -1796,16 +1769,12 @@ impl Language { PrecedenceHelper::to_postfix_operator( RuleKind::FunctionCallExpression, 33u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = 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() - }); - choice.consider(input, result)?; - choice.finish(input) + 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() }), ) }; @@ -1813,17 +1782,13 @@ impl Language { PrecedenceHelper::to_postfix_operator( RuleKind::MemberAccessExpression, 35u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Period, - ))?; - seq.elem(self.member_access(input))?; - seq.finish() - }); - choice.consider(input, result)?; - choice.finish(input) + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Period, + ))?; + seq.elem(self.member_access(input))?; + seq.finish() }), ) }; @@ -1831,35 +1796,31 @@ impl Language { PrecedenceHelper::to_postfix_operator( RuleKind::IndexAccessExpression, 37u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBracket); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenBracket, - ))?; - seq.elem( - SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.elem(OptionalHelper::transform(self.index_access_end(input)))?; - seq.finish() - }) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::CloseBracket, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem(self.parse_token_with_trivia::( + SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBracket); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenBracket, + ))?; + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform(self.expression(input)))?; + seq.elem(OptionalHelper::transform(self.index_access_end(input)))?; + seq.finish() + }) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, + self, TokenKind::CloseBracket, - ))?; - seq.finish() - }); - choice.consider(input, result)?; - choice.finish(input) + RecoverFromNoMatch::Yes, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseBracket, + ))?; + seq.finish() }), ) }; @@ -4135,31 +4096,27 @@ impl Language { PrecedenceHelper::to_postfix_operator( RuleKind::ArrayTypeName, 1u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBracket); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenBracket, - ))?; - seq.elem( - OptionalHelper::transform(self.expression(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::CloseBracket, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem(self.parse_token_with_trivia::( + SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBracket); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenBracket, + ))?; + seq.elem( + OptionalHelper::transform(self.expression(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, + self, TokenKind::CloseBracket, - ))?; - seq.finish() - }); - choice.consider(input, result)?; - choice.finish(input) + RecoverFromNoMatch::Yes, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseBracket, + ))?; + seq.finish() }), ) }; @@ -4677,14 +4634,10 @@ impl Language { RuleKind::VersionPragmaOrExpression, 1u8, 1u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarBar, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + self.parse_token_with_trivia::( + input, + TokenKind::BarBar, + ), ) }; let parse_left_version_pragma_range_expression = |input: &mut ParserContext<'_>| { @@ -4692,14 +4645,7 @@ impl Language { RuleKind::VersionPragmaRangeExpression, 3u8, 3u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + self.parse_token_with_trivia::(input, TokenKind::Minus), ) }; let parse_prefix_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { @@ -5003,31 +4949,27 @@ impl Language { PrecedenceHelper::to_postfix_operator( RuleKind::YulFunctionCallExpression, 1u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenParen, - ))?; - seq.elem( - OptionalHelper::transform(self.yul_arguments(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( + SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenParen, + ))?; + seq.elem( + OptionalHelper::transform(self.yul_arguments(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( input, self, TokenKind::CloseParen, RecoverFromNoMatch::Yes, ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, - ))?; - seq.finish() - }); - choice.consider(input, result)?; - choice.finish(input) + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseParen, + ))?; + seq.finish() }), ) }; diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index df417730ac..8e5f0cf044 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -1484,22 +1484,18 @@ impl Language { PrecedenceHelper::to_postfix_operator( RuleKind::ConditionalExpression, 3u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::QuestionMark, - ))?; - seq.elem(self.expression(input))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Colon, - ))?; - seq.elem(self.expression(input))?; - seq.finish() - }); - choice.consider(input, result)?; - choice.finish(input) + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::QuestionMark, + ))?; + seq.elem(self.expression(input))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Colon, + ))?; + seq.elem(self.expression(input))?; + seq.finish() }), ) }; @@ -1508,14 +1504,10 @@ impl Language { RuleKind::OrExpression, 5u8, 5u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarBar, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + self.parse_token_with_trivia::( + input, + TokenKind::BarBar, + ), ) }; let parse_left_and_expression = |input: &mut ParserContext<'_>| { @@ -1523,14 +1515,10 @@ impl Language { RuleKind::AndExpression, 7u8, 7u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::AmpersandAmpersand, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + self.parse_token_with_trivia::( + input, + TokenKind::AmpersandAmpersand, + ), ) }; let parse_left_equality_expression = |input: &mut ParserContext<'_>| { @@ -1588,14 +1576,7 @@ impl Language { RuleKind::BitwiseOrExpression, 13u8, 13u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Bar, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + self.parse_token_with_trivia::(input, TokenKind::Bar), ) }; let parse_left_bitwise_xor_expression = |input: &mut ParserContext<'_>| { @@ -1603,14 +1584,10 @@ impl Language { RuleKind::BitwiseXorExpression, 15u8, 15u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + self.parse_token_with_trivia::( + input, + TokenKind::Caret, + ), ) }; let parse_left_bitwise_and_expression = |input: &mut ParserContext<'_>| { @@ -1618,14 +1595,10 @@ impl Language { RuleKind::BitwiseAndExpression, 17u8, 17u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Ampersand, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + self.parse_token_with_trivia::( + input, + TokenKind::Ampersand, + ), ) }; let parse_left_shift_expression = |input: &mut ParserContext<'_>| { @@ -1796,16 +1769,12 @@ impl Language { PrecedenceHelper::to_postfix_operator( RuleKind::FunctionCallExpression, 33u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = 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() - }); - choice.consider(input, result)?; - choice.finish(input) + 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() }), ) }; @@ -1813,17 +1782,13 @@ impl Language { PrecedenceHelper::to_postfix_operator( RuleKind::MemberAccessExpression, 35u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Period, - ))?; - seq.elem(self.member_access(input))?; - seq.finish() - }); - choice.consider(input, result)?; - choice.finish(input) + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Period, + ))?; + seq.elem(self.member_access(input))?; + seq.finish() }), ) }; @@ -1831,35 +1796,31 @@ impl Language { PrecedenceHelper::to_postfix_operator( RuleKind::IndexAccessExpression, 37u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBracket); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenBracket, - ))?; - seq.elem( - SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.elem(OptionalHelper::transform(self.index_access_end(input)))?; - seq.finish() - }) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::CloseBracket, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem(self.parse_token_with_trivia::( + SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBracket); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenBracket, + ))?; + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform(self.expression(input)))?; + seq.elem(OptionalHelper::transform(self.index_access_end(input)))?; + seq.finish() + }) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, + self, TokenKind::CloseBracket, - ))?; - seq.finish() - }); - choice.consider(input, result)?; - choice.finish(input) + RecoverFromNoMatch::Yes, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseBracket, + ))?; + seq.finish() }), ) }; @@ -4135,31 +4096,27 @@ impl Language { PrecedenceHelper::to_postfix_operator( RuleKind::ArrayTypeName, 1u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseBracket); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenBracket, - ))?; - seq.elem( - OptionalHelper::transform(self.expression(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::CloseBracket, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem(self.parse_token_with_trivia::( + SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBracket); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenBracket, + ))?; + seq.elem( + OptionalHelper::transform(self.expression(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, + self, TokenKind::CloseBracket, - ))?; - seq.finish() - }); - choice.consider(input, result)?; - choice.finish(input) + RecoverFromNoMatch::Yes, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseBracket, + ))?; + seq.finish() }), ) }; @@ -4677,14 +4634,10 @@ impl Language { RuleKind::VersionPragmaOrExpression, 1u8, 1u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::BarBar, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + self.parse_token_with_trivia::( + input, + TokenKind::BarBar, + ), ) }; let parse_left_version_pragma_range_expression = |input: &mut ParserContext<'_>| { @@ -4692,14 +4645,7 @@ impl Language { RuleKind::VersionPragmaRangeExpression, 3u8, 3u8 + 1, - ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - choice.finish(input) - }), + self.parse_token_with_trivia::(input, TokenKind::Minus), ) }; let parse_prefix_version_pragma_prefix_expression = |input: &mut ParserContext<'_>| { @@ -5003,31 +4949,27 @@ impl Language { PrecedenceHelper::to_postfix_operator( RuleKind::YulFunctionCallExpression, 1u8, - ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenParen, - ))?; - seq.elem( - OptionalHelper::transform(self.yul_arguments(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( + SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenParen, + ))?; + seq.elem( + OptionalHelper::transform(self.yul_arguments(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( input, self, TokenKind::CloseParen, RecoverFromNoMatch::Yes, ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, - ))?; - seq.finish() - }); - choice.consider(input, result)?; - choice.finish(input) + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseParen, + ))?; + seq.finish() }), ) }; From b5c14bccaac201ff0de38cb5286cc1a4997ae5be Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sat, 9 Dec 2023 13:19:46 +0100 Subject: [PATCH 13/17] Add changeset files --- .changeset/breezy-otters-heal.md | 5 +++++ .changeset/new-monkeys-scream.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/breezy-otters-heal.md create mode 100644 .changeset/new-monkeys-scream.md diff --git a/.changeset/breezy-otters-heal.md b/.changeset/breezy-otters-heal.md new file mode 100644 index 0000000000..138d5c9df3 --- /dev/null +++ b/.changeset/breezy-otters-heal.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": minor +--- + +Remove ProductionKind in favor of RuleKind diff --git a/.changeset/new-monkeys-scream.md b/.changeset/new-monkeys-scream.md new file mode 100644 index 0000000000..fd91823142 --- /dev/null +++ b/.changeset/new-monkeys-scream.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": minor +--- + +Allow parsing individual precedence expressions, like `ShiftExpression` From 1ed286f043ed051095c01e78124d1d0fa2096bbe Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sat, 9 Dec 2023 23:24:26 +0100 Subject: [PATCH 14/17] Update breezy-otters-heal.md Co-authored-by: Omar Tawfik <15987992+OmarTawfik@users.noreply.github.com> --- .changeset/breezy-otters-heal.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/breezy-otters-heal.md b/.changeset/breezy-otters-heal.md index 138d5c9df3..ad9e88755f 100644 --- a/.changeset/breezy-otters-heal.md +++ b/.changeset/breezy-otters-heal.md @@ -2,4 +2,4 @@ "@nomicfoundation/slang": minor --- -Remove ProductionKind in favor of RuleKind +Remove `ProductionKind` in favor of `RuleKind` From fe12dd3bd763ec4cdb90b7945e09dc268d116156 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sat, 9 Dec 2023 23:51:44 +0100 Subject: [PATCH 15/17] Move conditional and exponentiation exprs into a dedicated CST parser test --- .../generated/ConditionalExpression.rs | 24 ++++++ .../generated/ExponentiationExpression.rs | 9 +++ .../src/cst_output/generated/Expression.rs | 25 ------ .../tests/src/cst_output/generated/mod.rs | 4 + .../generated/0.4.11-success.yml | 17 ++++ .../identifier_base}/input.sol | 0 .../nested_base/generated/0.4.11-success.yml | 28 +++++++ .../nested_base}/input.sol | 0 .../generated/0.4.11-success.yml | 39 ++++++++++ .../nested_conditions}/input.sol | 0 .../recursive/generated/0.4.11-success.yml | 76 ++++++++++++++++++ .../recursive}/input.sol | 0 .../generated/0.4.11-success.yml | 19 +++++ .../associativity/generated/0.6.0-success.yml | 19 +++++ .../associativity}/input.sol | 0 .../generated/0.4.11-success.yml | 18 ----- .../generated/0.4.11-success.yml | 29 ------- .../generated/0.4.11-success.yml | 40 ---------- .../generated/0.4.11-success.yml | 77 ------------------- .../generated/0.4.11-success.yml | 20 ----- .../generated/0.6.0-success.yml | 20 ----- 21 files changed, 235 insertions(+), 229 deletions(-) create mode 100644 crates/solidity/outputs/cargo/tests/src/cst_output/generated/ConditionalExpression.rs create mode 100644 crates/solidity/outputs/cargo/tests/src/cst_output/generated/ExponentiationExpression.rs create mode 100644 crates/solidity/testing/snapshots/cst_output/ConditionalExpression/identifier_base/generated/0.4.11-success.yml rename crates/solidity/testing/snapshots/cst_output/{Expression/conditional_expression_identifier_base => ConditionalExpression/identifier_base}/input.sol (100%) create mode 100644 crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_base/generated/0.4.11-success.yml rename crates/solidity/testing/snapshots/cst_output/{Expression/conditional_expression_nested_base => ConditionalExpression/nested_base}/input.sol (100%) create mode 100644 crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_conditions/generated/0.4.11-success.yml rename crates/solidity/testing/snapshots/cst_output/{Expression/conditional_expression_nested_conditions => ConditionalExpression/nested_conditions}/input.sol (100%) create mode 100644 crates/solidity/testing/snapshots/cst_output/ConditionalExpression/recursive/generated/0.4.11-success.yml rename crates/solidity/testing/snapshots/cst_output/{Expression/conditional_expression_recursive => ConditionalExpression/recursive}/input.sol (100%) create mode 100644 crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/generated/0.4.11-success.yml create mode 100644 crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/generated/0.6.0-success.yml rename crates/solidity/testing/snapshots/cst_output/{Expression/exponentiation_operator_associativity => ExponentiationExpression/associativity}/input.sol (100%) delete mode 100644 crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_identifier_base/generated/0.4.11-success.yml delete mode 100644 crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/generated/0.4.11-success.yml delete mode 100644 crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/generated/0.4.11-success.yml delete mode 100644 crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/generated/0.4.11-success.yml delete mode 100644 crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.4.11-success.yml delete mode 100644 crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.6.0-success.yml diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ConditionalExpression.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ConditionalExpression.rs new file mode 100644 index 0000000000..1a766d040b --- /dev/null +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ConditionalExpression.rs @@ -0,0 +1,24 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use crate::cst_output::runner::run; +use anyhow::Result; + +#[test] +fn identifier_base() -> Result<()> { + run("ConditionalExpression", "identifier_base") +} + +#[test] +fn nested_base() -> Result<()> { + run("ConditionalExpression", "nested_base") +} + +#[test] +fn nested_conditions() -> Result<()> { + run("ConditionalExpression", "nested_conditions") +} + +#[test] +fn recursive() -> Result<()> { + run("ConditionalExpression", "recursive") +} diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ExponentiationExpression.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ExponentiationExpression.rs new file mode 100644 index 0000000000..a6300eb5a6 --- /dev/null +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ExponentiationExpression.rs @@ -0,0 +1,9 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use crate::cst_output::runner::run; +use anyhow::Result; + +#[test] +fn associativity() -> Result<()> { + run("ExponentiationExpression", "associativity") +} diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/Expression.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/Expression.rs index 8c765c7e73..7f5b77c84c 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/Expression.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/Expression.rs @@ -33,31 +33,6 @@ fn areturn() -> Result<()> { run("Expression", "areturn") } -#[test] -fn conditional_expression_identifier_base() -> Result<()> { - run("Expression", "conditional_expression_identifier_base") -} - -#[test] -fn conditional_expression_nested_base() -> Result<()> { - run("Expression", "conditional_expression_nested_base") -} - -#[test] -fn conditional_expression_nested_conditions() -> Result<()> { - run("Expression", "conditional_expression_nested_conditions") -} - -#[test] -fn conditional_expression_recursive() -> Result<()> { - run("Expression", "conditional_expression_recursive") -} - -#[test] -fn exponentiation_operator_associativity() -> Result<()> { - run("Expression", "exponentiation_operator_associativity") -} - #[test] fn function_call() -> Result<()> { run("Expression", "function_call") diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs index 814f882d1d..bcfd0280bf 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/mod.rs @@ -10,6 +10,8 @@ mod Block; #[allow(non_snake_case)] mod BreakStatement; #[allow(non_snake_case)] +mod ConditionalExpression; +#[allow(non_snake_case)] mod ConstantDefinition; #[allow(non_snake_case)] mod ConstructorDefinition; @@ -28,6 +30,8 @@ mod ErrorDefinition; #[allow(non_snake_case)] mod EventDefinition; #[allow(non_snake_case)] +mod ExponentiationExpression; +#[allow(non_snake_case)] mod Expression; #[allow(non_snake_case)] mod FallbackFunctionDefinition; diff --git a/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/identifier_base/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/identifier_base/generated/0.4.11-success.yml new file mode 100644 index 0000000000..8de08367fc --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/identifier_base/generated/0.4.11-success.yml @@ -0,0 +1,17 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ foo ? true : false │ 0..18 + +Errors: [] + +Tree: + - ConditionalExpression (Rule): # 0..18 "foo ? true : false" + - Expression (Rule): # 0..3 "foo" + - Identifier (Token): "foo" # 0..3 + - QuestionMark (Token): "?" # 4..5 + - Expression (Rule): # 5..10 " true" + - TrueKeyword (Token): "true" # 6..10 + - Colon (Token): ":" # 11..12 + - Expression (Rule): # 12..18 " false" + - FalseKeyword (Token): "false" # 13..18 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_identifier_base/input.sol b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/identifier_base/input.sol similarity index 100% rename from crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_identifier_base/input.sol rename to crates/solidity/testing/snapshots/cst_output/ConditionalExpression/identifier_base/input.sol diff --git a/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_base/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_base/generated/0.4.11-success.yml new file mode 100644 index 0000000000..767918501f --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_base/generated/0.4.11-success.yml @@ -0,0 +1,28 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ (foo == bar) ? true : false │ 0..27 + +Errors: [] + +Tree: + - ConditionalExpression (Rule): # 0..27 "(foo == bar) ? true : false" + - Expression (Rule): # 0..12 "(foo == bar)" + - TupleExpression (Rule): # 0..12 "(foo == bar)" + - OpenParen (Token): "(" # 0..1 + - TupleValues (Rule): # 1..11 "foo == bar" + - TupleValue (Rule): # 1..11 "foo == bar" + - Expression (Rule): # 1..11 "foo == bar" + - EqualityExpression (Rule): # 1..11 "foo == bar" + - Expression (Rule): # 1..4 "foo" + - Identifier (Token): "foo" # 1..4 + - EqualEqual (Token): "==" # 5..7 + - Expression (Rule): # 7..11 " bar" + - Identifier (Token): "bar" # 8..11 + - CloseParen (Token): ")" # 11..12 + - QuestionMark (Token): "?" # 13..14 + - Expression (Rule): # 14..19 " true" + - TrueKeyword (Token): "true" # 15..19 + - Colon (Token): ":" # 20..21 + - Expression (Rule): # 21..27 " false" + - FalseKeyword (Token): "false" # 22..27 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/input.sol b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_base/input.sol similarity index 100% rename from crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/input.sol rename to crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_base/input.sol diff --git a/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_conditions/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_conditions/generated/0.4.11-success.yml new file mode 100644 index 0000000000..7670b903e0 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_conditions/generated/0.4.11-success.yml @@ -0,0 +1,39 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ foo ? (a + b) : (c + d) │ 0..23 + +Errors: [] + +Tree: + - ConditionalExpression (Rule): # 0..23 "foo ? (a + b) : (c + d)" + - Expression (Rule): # 0..3 "foo" + - Identifier (Token): "foo" # 0..3 + - QuestionMark (Token): "?" # 4..5 + - Expression (Rule): # 5..13 " (a + b)" + - TupleExpression (Rule): # 5..13 " (a + b)" + - OpenParen (Token): "(" # 6..7 + - TupleValues (Rule): # 7..12 "a + b" + - TupleValue (Rule): # 7..12 "a + b" + - Expression (Rule): # 7..12 "a + b" + - AdditiveExpression (Rule): # 7..12 "a + b" + - Expression (Rule): # 7..8 "a" + - Identifier (Token): "a" # 7..8 + - Plus (Token): "+" # 9..10 + - Expression (Rule): # 10..12 " b" + - Identifier (Token): "b" # 11..12 + - CloseParen (Token): ")" # 12..13 + - Colon (Token): ":" # 14..15 + - Expression (Rule): # 15..23 " (c + d)" + - TupleExpression (Rule): # 15..23 " (c + d)" + - OpenParen (Token): "(" # 16..17 + - TupleValues (Rule): # 17..22 "c + d" + - TupleValue (Rule): # 17..22 "c + d" + - Expression (Rule): # 17..22 "c + d" + - AdditiveExpression (Rule): # 17..22 "c + d" + - Expression (Rule): # 17..18 "c" + - Identifier (Token): "c" # 17..18 + - Plus (Token): "+" # 19..20 + - Expression (Rule): # 20..22 " d" + - Identifier (Token): "d" # 21..22 + - CloseParen (Token): ")" # 22..23 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/input.sol b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_conditions/input.sol similarity index 100% rename from crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/input.sol rename to crates/solidity/testing/snapshots/cst_output/ConditionalExpression/nested_conditions/input.sol diff --git a/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/recursive/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/recursive/generated/0.4.11-success.yml new file mode 100644 index 0000000000..f902117f92 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/recursive/generated/0.4.11-success.yml @@ -0,0 +1,76 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ foo ? a == b ? a + b * c : a + b * c + d : !bar ? e + f : g + h │ 0..63 + +Errors: [] + +Tree: + - ConditionalExpression (Rule): # 0..63 "foo ? a == b ? a + b * c : a + b * c + d : !bar ? ..." + - Expression (Rule): # 0..3 "foo" + - Identifier (Token): "foo" # 0..3 + - QuestionMark (Token): "?" # 4..5 + - Expression (Rule): # 5..40 " a == b ? a + b * c : a + b * c + d" + - ConditionalExpression (Rule): # 5..40 " a == b ? a + b * c : a + b * c + d" + - Expression (Rule): # 5..12 " a == b" + - EqualityExpression (Rule): # 5..12 " a == b" + - Expression (Rule): # 5..7 " a" + - Identifier (Token): "a" # 6..7 + - EqualEqual (Token): "==" # 8..10 + - Expression (Rule): # 10..12 " b" + - Identifier (Token): "b" # 11..12 + - QuestionMark (Token): "?" # 13..14 + - Expression (Rule): # 14..24 " a + b * c" + - AdditiveExpression (Rule): # 14..24 " a + b * c" + - Expression (Rule): # 14..16 " a" + - Identifier (Token): "a" # 15..16 + - Plus (Token): "+" # 17..18 + - Expression (Rule): # 18..24 " b * c" + - MultiplicativeExpression (Rule): # 18..24 " b * c" + - Expression (Rule): # 18..20 " b" + - Identifier (Token): "b" # 19..20 + - Asterisk (Token): "*" # 21..22 + - Expression (Rule): # 22..24 " c" + - Identifier (Token): "c" # 23..24 + - Colon (Token): ":" # 25..26 + - Expression (Rule): # 26..40 " a + b * c + d" + - AdditiveExpression (Rule): # 26..40 " a + b * c + d" + - Expression (Rule): # 26..36 " a + b * c" + - AdditiveExpression (Rule): # 26..36 " a + b * c" + - Expression (Rule): # 26..28 " a" + - Identifier (Token): "a" # 27..28 + - Plus (Token): "+" # 29..30 + - Expression (Rule): # 30..36 " b * c" + - MultiplicativeExpression (Rule): # 30..36 " b * c" + - Expression (Rule): # 30..32 " b" + - Identifier (Token): "b" # 31..32 + - Asterisk (Token): "*" # 33..34 + - Expression (Rule): # 34..36 " c" + - Identifier (Token): "c" # 35..36 + - Plus (Token): "+" # 37..38 + - Expression (Rule): # 38..40 " d" + - Identifier (Token): "d" # 39..40 + - Colon (Token): ":" # 41..42 + - Expression (Rule): # 42..63 " !bar ? e + f : g + h" + - ConditionalExpression (Rule): # 42..63 " !bar ? e + f : g + h" + - Expression (Rule): # 42..47 " !bar" + - PrefixExpression (Rule): # 42..47 " !bar" + - Bang (Token): "!" # 43..44 + - Expression (Rule): # 44..47 "bar" + - Identifier (Token): "bar" # 44..47 + - QuestionMark (Token): "?" # 48..49 + - Expression (Rule): # 49..55 " e + f" + - AdditiveExpression (Rule): # 49..55 " e + f" + - Expression (Rule): # 49..51 " e" + - Identifier (Token): "e" # 50..51 + - Plus (Token): "+" # 52..53 + - Expression (Rule): # 53..55 " f" + - Identifier (Token): "f" # 54..55 + - Colon (Token): ":" # 56..57 + - Expression (Rule): # 57..63 " g + h" + - AdditiveExpression (Rule): # 57..63 " g + h" + - Expression (Rule): # 57..59 " g" + - Identifier (Token): "g" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " h" + - Identifier (Token): "h" # 62..63 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/input.sol b/crates/solidity/testing/snapshots/cst_output/ConditionalExpression/recursive/input.sol similarity index 100% rename from crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/input.sol rename to crates/solidity/testing/snapshots/cst_output/ConditionalExpression/recursive/input.sol diff --git a/crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/generated/0.4.11-success.yml new file mode 100644 index 0000000000..885d2a9fbf --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/generated/0.4.11-success.yml @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ x ** y ** z │ 0..11 + +Errors: [] + +Tree: + - ExponentiationExpression (Rule): # 0..12 "x ** y ** z\n" + - Expression (Rule): # 0..6 "x ** y" + - ExponentiationExpression (Rule): # 0..6 "x ** y" + - Expression (Rule): # 0..1 "x" + - Identifier (Token): "x" # 0..1 + - AsteriskAsterisk (Token): "**" # 2..4 + - Expression (Rule): # 4..6 " y" + - Identifier (Token): "y" # 5..6 + - AsteriskAsterisk (Token): "**" # 7..9 + - Expression (Rule): # 9..12 " z\n" + - Identifier (Token): "z" # 10..11 diff --git a/crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/generated/0.6.0-success.yml b/crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/generated/0.6.0-success.yml new file mode 100644 index 0000000000..5bacd2885b --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/generated/0.6.0-success.yml @@ -0,0 +1,19 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ x ** y ** z │ 0..11 + +Errors: [] + +Tree: + - ExponentiationExpression (Rule): # 0..12 "x ** y ** z\n" + - Expression (Rule): # 0..1 "x" + - Identifier (Token): "x" # 0..1 + - AsteriskAsterisk (Token): "**" # 2..4 + - Expression (Rule): # 4..12 " y ** z\n" + - ExponentiationExpression (Rule): # 4..12 " y ** z\n" + - Expression (Rule): # 4..6 " y" + - Identifier (Token): "y" # 5..6 + - AsteriskAsterisk (Token): "**" # 7..9 + - Expression (Rule): # 9..12 " z\n" + - Identifier (Token): "z" # 10..11 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/input.sol b/crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/input.sol similarity index 100% rename from crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/input.sol rename to crates/solidity/testing/snapshots/cst_output/ExponentiationExpression/associativity/input.sol diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_identifier_base/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_identifier_base/generated/0.4.11-success.yml deleted file mode 100644 index 0c7a33c1d2..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_identifier_base/generated/0.4.11-success.yml +++ /dev/null @@ -1,18 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ foo ? true : false │ 0..18 - -Errors: [] - -Tree: - - Expression (Rule): # 0..18 "foo ? true : false" - - ConditionalExpression (Rule): # 0..18 "foo ? true : false" - - Expression (Rule): # 0..3 "foo" - - Identifier (Token): "foo" # 0..3 - - QuestionMark (Token): "?" # 4..5 - - Expression (Rule): # 5..10 " true" - - TrueKeyword (Token): "true" # 6..10 - - Colon (Token): ":" # 11..12 - - Expression (Rule): # 12..18 " false" - - FalseKeyword (Token): "false" # 13..18 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/generated/0.4.11-success.yml deleted file mode 100644 index 20cb05a4e4..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_base/generated/0.4.11-success.yml +++ /dev/null @@ -1,29 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ (foo == bar) ? true : false │ 0..27 - -Errors: [] - -Tree: - - Expression (Rule): # 0..27 "(foo == bar) ? true : false" - - ConditionalExpression (Rule): # 0..27 "(foo == bar) ? true : false" - - Expression (Rule): # 0..12 "(foo == bar)" - - TupleExpression (Rule): # 0..12 "(foo == bar)" - - OpenParen (Token): "(" # 0..1 - - TupleValues (Rule): # 1..11 "foo == bar" - - TupleValue (Rule): # 1..11 "foo == bar" - - Expression (Rule): # 1..11 "foo == bar" - - EqualityExpression (Rule): # 1..11 "foo == bar" - - Expression (Rule): # 1..4 "foo" - - Identifier (Token): "foo" # 1..4 - - EqualEqual (Token): "==" # 5..7 - - Expression (Rule): # 7..11 " bar" - - Identifier (Token): "bar" # 8..11 - - CloseParen (Token): ")" # 11..12 - - QuestionMark (Token): "?" # 13..14 - - Expression (Rule): # 14..19 " true" - - TrueKeyword (Token): "true" # 15..19 - - Colon (Token): ":" # 20..21 - - Expression (Rule): # 21..27 " false" - - FalseKeyword (Token): "false" # 22..27 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/generated/0.4.11-success.yml deleted file mode 100644 index 49401a18b8..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_nested_conditions/generated/0.4.11-success.yml +++ /dev/null @@ -1,40 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ foo ? (a + b) : (c + d) │ 0..23 - -Errors: [] - -Tree: - - Expression (Rule): # 0..23 "foo ? (a + b) : (c + d)" - - ConditionalExpression (Rule): # 0..23 "foo ? (a + b) : (c + d)" - - Expression (Rule): # 0..3 "foo" - - Identifier (Token): "foo" # 0..3 - - QuestionMark (Token): "?" # 4..5 - - Expression (Rule): # 5..13 " (a + b)" - - TupleExpression (Rule): # 5..13 " (a + b)" - - OpenParen (Token): "(" # 6..7 - - TupleValues (Rule): # 7..12 "a + b" - - TupleValue (Rule): # 7..12 "a + b" - - Expression (Rule): # 7..12 "a + b" - - AdditiveExpression (Rule): # 7..12 "a + b" - - Expression (Rule): # 7..8 "a" - - Identifier (Token): "a" # 7..8 - - Plus (Token): "+" # 9..10 - - Expression (Rule): # 10..12 " b" - - Identifier (Token): "b" # 11..12 - - CloseParen (Token): ")" # 12..13 - - Colon (Token): ":" # 14..15 - - Expression (Rule): # 15..23 " (c + d)" - - TupleExpression (Rule): # 15..23 " (c + d)" - - OpenParen (Token): "(" # 16..17 - - TupleValues (Rule): # 17..22 "c + d" - - TupleValue (Rule): # 17..22 "c + d" - - Expression (Rule): # 17..22 "c + d" - - AdditiveExpression (Rule): # 17..22 "c + d" - - Expression (Rule): # 17..18 "c" - - Identifier (Token): "c" # 17..18 - - Plus (Token): "+" # 19..20 - - Expression (Rule): # 20..22 " d" - - Identifier (Token): "d" # 21..22 - - CloseParen (Token): ")" # 22..23 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/generated/0.4.11-success.yml deleted file mode 100644 index 2280896669..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/Expression/conditional_expression_recursive/generated/0.4.11-success.yml +++ /dev/null @@ -1,77 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ foo ? a == b ? a + b * c : a + b * c + d : !bar ? e + f : g + h │ 0..63 - -Errors: [] - -Tree: - - Expression (Rule): # 0..63 "foo ? a == b ? a + b * c : a + b * c + d : !bar ? ..." - - ConditionalExpression (Rule): # 0..63 "foo ? a == b ? a + b * c : a + b * c + d : !bar ? ..." - - Expression (Rule): # 0..3 "foo" - - Identifier (Token): "foo" # 0..3 - - QuestionMark (Token): "?" # 4..5 - - Expression (Rule): # 5..40 " a == b ? a + b * c : a + b * c + d" - - ConditionalExpression (Rule): # 5..40 " a == b ? a + b * c : a + b * c + d" - - Expression (Rule): # 5..12 " a == b" - - EqualityExpression (Rule): # 5..12 " a == b" - - Expression (Rule): # 5..7 " a" - - Identifier (Token): "a" # 6..7 - - EqualEqual (Token): "==" # 8..10 - - Expression (Rule): # 10..12 " b" - - Identifier (Token): "b" # 11..12 - - QuestionMark (Token): "?" # 13..14 - - Expression (Rule): # 14..24 " a + b * c" - - AdditiveExpression (Rule): # 14..24 " a + b * c" - - Expression (Rule): # 14..16 " a" - - Identifier (Token): "a" # 15..16 - - Plus (Token): "+" # 17..18 - - Expression (Rule): # 18..24 " b * c" - - MultiplicativeExpression (Rule): # 18..24 " b * c" - - Expression (Rule): # 18..20 " b" - - Identifier (Token): "b" # 19..20 - - Asterisk (Token): "*" # 21..22 - - Expression (Rule): # 22..24 " c" - - Identifier (Token): "c" # 23..24 - - Colon (Token): ":" # 25..26 - - Expression (Rule): # 26..40 " a + b * c + d" - - AdditiveExpression (Rule): # 26..40 " a + b * c + d" - - Expression (Rule): # 26..36 " a + b * c" - - AdditiveExpression (Rule): # 26..36 " a + b * c" - - Expression (Rule): # 26..28 " a" - - Identifier (Token): "a" # 27..28 - - Plus (Token): "+" # 29..30 - - Expression (Rule): # 30..36 " b * c" - - MultiplicativeExpression (Rule): # 30..36 " b * c" - - Expression (Rule): # 30..32 " b" - - Identifier (Token): "b" # 31..32 - - Asterisk (Token): "*" # 33..34 - - Expression (Rule): # 34..36 " c" - - Identifier (Token): "c" # 35..36 - - Plus (Token): "+" # 37..38 - - Expression (Rule): # 38..40 " d" - - Identifier (Token): "d" # 39..40 - - Colon (Token): ":" # 41..42 - - Expression (Rule): # 42..63 " !bar ? e + f : g + h" - - ConditionalExpression (Rule): # 42..63 " !bar ? e + f : g + h" - - Expression (Rule): # 42..47 " !bar" - - PrefixExpression (Rule): # 42..47 " !bar" - - Bang (Token): "!" # 43..44 - - Expression (Rule): # 44..47 "bar" - - Identifier (Token): "bar" # 44..47 - - QuestionMark (Token): "?" # 48..49 - - Expression (Rule): # 49..55 " e + f" - - AdditiveExpression (Rule): # 49..55 " e + f" - - Expression (Rule): # 49..51 " e" - - Identifier (Token): "e" # 50..51 - - Plus (Token): "+" # 52..53 - - Expression (Rule): # 53..55 " f" - - Identifier (Token): "f" # 54..55 - - Colon (Token): ":" # 56..57 - - Expression (Rule): # 57..63 " g + h" - - AdditiveExpression (Rule): # 57..63 " g + h" - - Expression (Rule): # 57..59 " g" - - Identifier (Token): "g" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " h" - - Identifier (Token): "h" # 62..63 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.4.11-success.yml deleted file mode 100644 index 92a1e7aea6..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.4.11-success.yml +++ /dev/null @@ -1,20 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ x ** y ** z │ 0..11 - -Errors: [] - -Tree: - - Expression (Rule): # 0..12 "x ** y ** z\n" - - ExponentiationExpression (Rule): # 0..12 "x ** y ** z\n" - - Expression (Rule): # 0..6 "x ** y" - - ExponentiationExpression (Rule): # 0..6 "x ** y" - - Expression (Rule): # 0..1 "x" - - Identifier (Token): "x" # 0..1 - - AsteriskAsterisk (Token): "**" # 2..4 - - Expression (Rule): # 4..6 " y" - - Identifier (Token): "y" # 5..6 - - AsteriskAsterisk (Token): "**" # 7..9 - - Expression (Rule): # 9..12 " z\n" - - Identifier (Token): "z" # 10..11 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.6.0-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.6.0-success.yml deleted file mode 100644 index facdfcccd0..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/Expression/exponentiation_operator_associativity/generated/0.6.0-success.yml +++ /dev/null @@ -1,20 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ x ** y ** z │ 0..11 - -Errors: [] - -Tree: - - Expression (Rule): # 0..12 "x ** y ** z\n" - - ExponentiationExpression (Rule): # 0..12 "x ** y ** z\n" - - Expression (Rule): # 0..1 "x" - - Identifier (Token): "x" # 0..1 - - AsteriskAsterisk (Token): "**" # 2..4 - - Expression (Rule): # 4..12 " y ** z\n" - - ExponentiationExpression (Rule): # 4..12 " y ** z\n" - - Expression (Rule): # 4..6 " y" - - Identifier (Token): "y" # 5..6 - - AsteriskAsterisk (Token): "**" # 7..9 - - Expression (Rule): # 9..12 " z\n" - - Identifier (Token): "z" # 10..11 From 3da8aee672bffcd2460b378f4a5788ab8ee4a712 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sat, 9 Dec 2023 23:51:59 +0100 Subject: [PATCH 16/17] Revert "Add a unit test for the precedence expression parsers" This reverts commit 0296bef296a2b10117a1e473c5bdaef80bd6f17c. --- .../solidity/outputs/cargo/tests/src/lib.rs | 1 - .../outputs/cargo/tests/src/parser/mod.rs | 29 ------------------- 2 files changed, 30 deletions(-) delete mode 100644 crates/solidity/outputs/cargo/tests/src/parser/mod.rs diff --git a/crates/solidity/outputs/cargo/tests/src/lib.rs b/crates/solidity/outputs/cargo/tests/src/lib.rs index 76e1e8ef37..7b04712139 100644 --- a/crates/solidity/outputs/cargo/tests/src/lib.rs +++ b/crates/solidity/outputs/cargo/tests/src/lib.rs @@ -3,6 +3,5 @@ mod cst_output; mod doc_examples; mod errors; -mod parser; mod scanner; mod versions; diff --git a/crates/solidity/outputs/cargo/tests/src/parser/mod.rs b/crates/solidity/outputs/cargo/tests/src/parser/mod.rs deleted file mode 100644 index 25a3bf7f84..0000000000 --- a/crates/solidity/outputs/cargo/tests/src/parser/mod.rs +++ /dev/null @@ -1,29 +0,0 @@ -use semver::Version; -use slang_solidity::{kinds::RuleKind, language::Language}; - -#[test] -fn test_precedence_expression() { - let language = Language::new(Version::new(0, 8, 0)).unwrap(); - - let output = language.parse(RuleKind::ShiftExpression, "1 >> 2"); - assert!(output.is_valid()); - let output = language.parse(RuleKind::ShiftExpression, "1 + 2"); - assert!(!output.is_valid()); - let output = language.parse(RuleKind::ArrayTypeName, "uint[]"); - assert!(output.is_valid()); - - // Plus prefix was removed in 0.5.0 - let language = Language::new(Version::new(0, 4, 11)).unwrap(); - let output = language.parse(RuleKind::PrefixExpression, "+1"); - assert!(output.is_valid()); - let language = Language::new(Version::new(0, 8, 0)).unwrap(); - let output = language.parse(RuleKind::PrefixExpression, "+1"); - assert!(!output.is_valid()); - - // Changed to right-associative in 0.6.0; the rule should still be valid - let output = language.parse(RuleKind::ExponentiationExpression, "1 ** 2"); - assert!(output.is_valid()); - let language = Language::new(Version::new(0, 5, 0)).unwrap(); - let output = language.parse(RuleKind::ExponentiationExpression, "1 ** 2"); - assert!(output.is_valid()); -} From 04a6e59e90478630f295d322b5b4527f0ac46223 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sun, 10 Dec 2023 00:02:39 +0100 Subject: [PATCH 17/17] fixup: Fix formatting --- .../tests/src/cst_output/generated/ConditionalExpression.rs | 3 ++- .../tests/src/cst_output/generated/ExponentiationExpression.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ConditionalExpression.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ConditionalExpression.rs index 1a766d040b..c3907194a5 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ConditionalExpression.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ConditionalExpression.rs @@ -1,8 +1,9 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::cst_output::runner::run; use anyhow::Result; +use crate::cst_output::runner::run; + #[test] fn identifier_base() -> Result<()> { run("ConditionalExpression", "identifier_base") diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ExponentiationExpression.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ExponentiationExpression.rs index a6300eb5a6..832ccb2ea1 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ExponentiationExpression.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/ExponentiationExpression.rs @@ -1,8 +1,9 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::cst_output::runner::run; use anyhow::Result; +use crate::cst_output::runner::run; + #[test] fn associativity() -> Result<()> { run("ExponentiationExpression", "associativity")