diff --git a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs index 6843dbdf28..b8081e6258 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs @@ -23,6 +23,7 @@ pub enum ProductionKind { ArrayExpression, ArrayValuesList, AsciiStringLiteralsList, + AssemblyFlagsDeclaration, AssemblyFlagsList, AssemblyStatement, Block, @@ -42,6 +43,7 @@ pub enum ProductionKind { DeconstructionImportSymbolsList, DeleteStatement, DoWhileStatement, + ElseBranch, EmitStatement, EndOfFileTrivia, EnumDefinition, @@ -70,7 +72,9 @@ pub enum ProductionKind { IdentifierPathsList, IdentifiersList, IfStatement, + ImportAlias, ImportDirective, + IndexAccessEnd, InheritanceSpecifier, InheritanceType, InheritanceTypesList, @@ -87,6 +91,7 @@ pub enum ProductionKind { ModifierInvocation, NamedArgument, NamedArgumentsDeclaration, + NamedArgumentsDeclarations, NamedArgumentsList, NamedImport, NewExpression, @@ -106,6 +111,7 @@ pub enum ProductionKind { SourceUnitMembersList, StateVariableAttributesList, StateVariableDefinition, + StateVariableDefinitionValue, Statement, StatementsList, StructDefinition, @@ -116,16 +122,20 @@ pub enum ProductionKind { TryStatement, TupleDeconstructionStatement, TupleExpression, - TupleMember, + TupleMemberDeconstruction, TupleMembersList, + TupleValue, TupleValuesList, TypeExpression, TypeName, + TypedTupleMember, UncheckedBlock, UnicodeStringLiteralsList, UnnamedFunctionAttributesList, UnnamedFunctionDefinition, + UntypedTupleMember, UserDefinedValueTypeDefinition, + UsingAlias, UsingDirective, UsingDirectiveDeconstruction, UsingDirectivePath, @@ -133,6 +143,7 @@ pub enum ProductionKind { UsingDirectiveSymbolsList, VariableDeclaration, VariableDeclarationStatement, + VariableDeclarationValue, VersionPragma, VersionPragmaExpression, VersionPragmaExpressionsList, @@ -142,7 +153,7 @@ pub enum ProductionKind { YulBlock, YulBreakStatement, YulContinueStatement, - YulDeclarationStatement, + YulDefaultCase, YulExpression, YulExpressionsList, YulForStatement, @@ -156,9 +167,11 @@ pub enum ProductionKind { YulReturnsDeclaration, YulStatement, YulStatementsList, - YulSwitchCase, YulSwitchCasesList, YulSwitchStatement, + YulValueCase, + YulVariableDeclarationStatement, + YulVariableDeclarationValue, } #[derive( @@ -182,6 +195,7 @@ pub enum RuleKind { ArrayTypeName, ArrayValuesList, AsciiStringLiteralsList, + AssemblyFlagsDeclaration, AssemblyFlagsList, AssemblyStatement, BinaryExpression, @@ -203,6 +217,7 @@ pub enum RuleKind { DeconstructionImportSymbolsList, DeleteStatement, DoWhileStatement, + ElseBranch, EmitStatement, EndOfFileTrivia, EnumDefinition, @@ -232,7 +247,9 @@ pub enum RuleKind { IdentifierPathsList, IdentifiersList, IfStatement, + ImportAlias, ImportDirective, + IndexAccessEnd, IndexAccessExpression, InheritanceSpecifier, InheritanceType, @@ -251,6 +268,7 @@ pub enum RuleKind { ModifierInvocation, NamedArgument, NamedArgumentsDeclaration, + NamedArgumentsDeclarations, NamedArgumentsList, NamedImport, NewExpression, @@ -270,6 +288,7 @@ pub enum RuleKind { SourceUnitMembersList, StateVariableAttributesList, StateVariableDefinition, + StateVariableDefinitionValue, Statement, StatementsList, StructDefinition, @@ -280,18 +299,22 @@ pub enum RuleKind { TryStatement, TupleDeconstructionStatement, TupleExpression, - TupleMember, + TupleMemberDeconstruction, TupleMembersList, + TupleValue, TupleValuesList, TypeExpression, TypeName, + TypedTupleMember, UnaryPostfixExpression, UnaryPrefixExpression, UncheckedBlock, UnicodeStringLiteralsList, UnnamedFunctionAttributesList, UnnamedFunctionDefinition, + UntypedTupleMember, UserDefinedValueTypeDefinition, + UsingAlias, UsingDirective, UsingDirectiveDeconstruction, UsingDirectivePath, @@ -299,6 +322,7 @@ pub enum RuleKind { UsingDirectiveSymbolsList, VariableDeclaration, VariableDeclarationStatement, + VariableDeclarationValue, VersionPragma, VersionPragmaBinaryExpression, VersionPragmaExpression, @@ -310,7 +334,7 @@ pub enum RuleKind { YulBlock, YulBreakStatement, YulContinueStatement, - YulDeclarationStatement, + YulDefaultCase, YulExpression, YulExpressionsList, YulForStatement, @@ -325,9 +349,11 @@ pub enum RuleKind { YulReturnsDeclaration, YulStatement, YulStatementsList, - YulSwitchCase, YulSwitchCasesList, YulSwitchStatement, + YulValueCase, + YulVariableDeclarationStatement, + YulVariableDeclarationValue, } impl RuleKind { @@ -381,7 +407,7 @@ pub enum TokenKind { BoolKeyword, BreakKeyword, ByteKeyword, - CalldataKeyword, + CallDataKeyword, Caret, CaretEqual, CaseKeyword, @@ -396,7 +422,7 @@ pub enum TokenKind { ConstructorKeyword, ContinueKeyword, ContractKeyword, - CopyofKeyword, + CopyOfKeyword, DaysKeyword, DecimalLiteral, DefaultKeyword, @@ -446,7 +472,6 @@ pub enum TokenKind { InterfaceKeyword, InternalKeyword, IsKeyword, - LeaveKeyword, LessThan, LessThanEqual, LessThanLessThan, @@ -498,7 +523,7 @@ pub enum TokenKind { SignedFixedType, SignedIntegerType, SingleLineComment, - SizeofKeyword, + SizeOfKeyword, Slash, SlashEqual, SolidityKeyword, @@ -513,9 +538,9 @@ pub enum TokenKind { Tilde, TrueKeyword, TryKeyword, + TypeDefKeyword, TypeKeyword, - TypedefKeyword, - TypeofKeyword, + TypeOfKeyword, UncheckedKeyword, UnicodeStringLiteral, UnsignedFixedType, @@ -530,9 +555,116 @@ pub enum TokenKind { WhileKeyword, Whitespace, YearsKeyword, + YulAbstractKeyword, + YulAddressKeyword, + YulAfterKeyword, + YulAliasKeyword, + YulAnonymousKeyword, + YulApplyKeyword, + YulAsKeyword, + YulAssemblyKeyword, + YulAutoKeyword, + YulBoolKeyword, + YulBreakKeyword, + YulByteKeyword, + YulBytesKeyword, + YulCallDataKeyword, + YulCaseKeyword, + YulCatchKeyword, + YulConstantKeyword, + YulConstructorKeyword, + YulContinueKeyword, + YulContractKeyword, + YulCopyOfKeyword, + YulDaysKeyword, YulDecimalLiteral, + YulDefaultKeyword, + YulDefineKeyword, + YulDeleteKeyword, + YulDoKeyword, + YulElseKeyword, + YulEmitKeyword, + YulEnumKeyword, + YulEtherKeyword, + YulEventKeyword, + YulExternalKeyword, + YulFallbackKeyword, + YulFalseKeyword, + YulFinalKeyword, + YulFinneyKeyword, + YulFixedKeyword, + YulForKeyword, + YulFunctionKeyword, + YulGweiKeyword, + YulHexKeyword, YulHexLiteral, + YulHoursKeyword, YulIdentifier, + YulIfKeyword, + YulImmutableKeyword, + YulImplementsKeyword, + YulImportKeyword, + YulInKeyword, + YulIndexedKeyword, + YulInlineKeyword, + YulIntKeyword, + YulInterfaceKeyword, + YulInternalKeyword, + YulIsKeyword, + YulLeaveKeyword, + YulLetKeyword, + YulLibraryKeyword, + YulMacroKeyword, + YulMappingKeyword, + YulMatchKeyword, + YulMemoryKeyword, + YulMinutesKeyword, + YulModifierKeyword, + YulMutableKeyword, + YulNewKeyword, + YulNullKeyword, + YulOfKeyword, + YulOverrideKeyword, + YulPartialKeyword, + YulPayableKeyword, + YulPragmaKeyword, + YulPrivateKeyword, + YulPromiseKeyword, + YulPublicKeyword, + YulPureKeyword, + YulReceiveKeyword, + YulReferenceKeyword, + YulRelocatableKeyword, + YulReturnKeyword, + YulReturnsKeyword, + YulRevertKeyword, + YulSealedKeyword, + YulSecondsKeyword, + YulSizeOfKeyword, + YulStaticKeyword, + YulStorageKeyword, + YulStringKeyword, + YulStructKeyword, + YulSupportsKeyword, + YulSwitchKeyword, + YulSzaboKeyword, + YulThrowKeyword, + YulTrueKeyword, + YulTryKeyword, + YulTypeDefKeyword, + YulTypeKeyword, + YulTypeOfKeyword, + YulUfixedKeyword, + YulUintKeyword, + YulUncheckedKeyword, + YulUsingKeyword, + YulVarKeyword, + YulViewKeyword, + YulVirtualKeyword, + YulWeeksKeyword, + YulWeiKeyword, + YulWhileKeyword, + YulYearsKeyword, } #[derive(strum_macros::FromRepr)] @@ -541,8 +673,8 @@ pub enum TokenKind { #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] pub enum LexicalContext { Default, - VersionPragma, - YulBlock, + Pragma, + Yul, } /// Marker trait for type-level [`LexicalContext`] variants. @@ -560,16 +692,16 @@ pub mod LexicalContextType { LexicalContext::Default } } - pub struct VersionPragma {} - impl IsLexicalContext for VersionPragma { + pub struct Pragma {} + impl IsLexicalContext for Pragma { fn value() -> LexicalContext { - LexicalContext::VersionPragma + LexicalContext::Pragma } } - pub struct YulBlock {} - impl IsLexicalContext for YulBlock { + pub struct Yul {} + impl IsLexicalContext for Yul { fn value() -> LexicalContext { - LexicalContext::YulBlock + LexicalContext::Yul } } } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index a1704a847c..3a0e16f080 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -21,13 +21,16 @@ use super::napi::napi_parse_output::ParseOutput as NAPIParseOutput; #[cfg_attr(feature = "slang_napi_interfaces", napi(namespace = "language"))] pub struct Language { pub(crate) version: Version, + pub(crate) version_is_at_least_0_4_14: bool, pub(crate) version_is_at_least_0_4_21: bool, pub(crate) version_is_at_least_0_4_22: bool, pub(crate) version_is_at_least_0_5_0: bool, pub(crate) version_is_at_least_0_5_3: bool, + pub(crate) version_is_at_least_0_5_10: bool, pub(crate) version_is_at_least_0_6_0: bool, pub(crate) version_is_at_least_0_6_2: bool, pub(crate) version_is_at_least_0_6_5: bool, + pub(crate) version_is_at_least_0_6_8: bool, pub(crate) version_is_at_least_0_6_11: bool, pub(crate) version_is_at_least_0_7_0: bool, pub(crate) version_is_at_least_0_7_1: bool, @@ -142,13 +145,16 @@ impl Language { pub fn new(version: Version) -> std::result::Result { if Self::SUPPORTED_VERSIONS.binary_search(&version).is_ok() { Ok(Self { + version_is_at_least_0_4_14: Version::new(0, 4, 14) <= version, version_is_at_least_0_4_21: Version::new(0, 4, 21) <= version, version_is_at_least_0_4_22: Version::new(0, 4, 22) <= version, version_is_at_least_0_5_0: Version::new(0, 5, 0) <= version, version_is_at_least_0_5_3: Version::new(0, 5, 3) <= version, + version_is_at_least_0_5_10: Version::new(0, 5, 10) <= version, version_is_at_least_0_6_0: Version::new(0, 6, 0) <= version, version_is_at_least_0_6_2: Version::new(0, 6, 2) <= version, version_is_at_least_0_6_5: Version::new(0, 6, 5) <= version, + version_is_at_least_0_6_8: Version::new(0, 6, 8) <= version, version_is_at_least_0_6_11: Version::new(0, 6, 11) <= version, version_is_at_least_0_7_0: Version::new(0, 7, 0) <= version, version_is_at_least_0_7_1: Version::new(0, 7, 1) <= version, @@ -178,11 +184,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn abi_coder_pragma(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::AbicoderKeyword, ))?; - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::Identifier, ))?; @@ -193,27 +199,18 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn address_type(&self, input: &mut ParserContext) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AddressKeyword, - ))?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::PayableKeyword, - ), - ))?; - seq.finish() - }); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( input, - TokenKind::PayableKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) + TokenKind::AddressKeyword, + ))?; + seq.elem(OptionalHelper::transform( + self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ), + ))?; + seq.finish() }) .with_kind(RuleKind::AddressType) } @@ -300,57 +297,69 @@ impl Language { .with_kind(RuleKind::AsciiStringLiteralsList) } + #[allow(unused_assignments, unused_parens)] + fn assembly_flags_declaration(&self, input: &mut ParserContext) -> ParserResult { + 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( + self.assembly_flags_list(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() + }) + .with_kind(RuleKind::AssemblyFlagsDeclaration) + } + #[allow(unused_assignments, unused_parens)] fn assembly_flags_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::Default>( + OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::AsciiStringLiteral, ) }, TokenKind::Comma, - ) + )) .with_kind(RuleKind::AssemblyFlagsList) } #[allow(unused_assignments, unused_parens)] fn assembly_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::AssemblyKeyword, ))?; seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::AsciiStringLiteral, ), ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenParen, - ))?; - seq.elem( - self.assembly_flags_list(input) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, - ))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform( + self.assembly_flags_declaration(input), + ))?; seq.elem(self.yul_block(input))?; seq.finish() }) @@ -504,10 +513,7 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.modifier_invocation(input); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::InternalKeyword, - ); + let result = self.override_specifier(input); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, @@ -631,34 +637,32 @@ impl Language { choice.consider(input, result)?; let result = self.function_definition(input); choice.consider(input, result)?; - let result = self.modifier_definition(input); - choice.consider(input, result)?; - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - let result = self.event_definition(input); - choice.consider(input, result)?; - let result = self.state_variable_definition(input); - choice.consider(input, result)?; if self.version_is_at_least_0_4_22 { let result = self.constructor_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.fallback_function_definition(input); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { let result = self.unnamed_function_definition(input); choice.consider(input, result)?; } + let result = self.modifier_definition(input); + choice.consider(input, result)?; + let result = self.struct_definition(input); + choice.consider(input, result)?; + let result = self.enum_definition(input); + choice.consider(input, result)?; + let result = self.event_definition(input); + choice.consider(input, result)?; + let result = self.state_variable_definition(input); + choice.consider(input, result)?; if self.version_is_at_least_0_8_4 { let result = self.error_definition(input); choice.consider(input, result)?; @@ -685,9 +689,30 @@ impl Language { |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::DaysKeyword, + TokenKind::WeiKeyword, ); choice.consider(input, result)?; + if self.version_is_at_least_0_6_11 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::GweiKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::SzaboKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::FinneyKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::EtherKeyword, @@ -695,7 +720,7 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::HoursKeyword, + TokenKind::SecondsKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( @@ -705,17 +730,17 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::SecondsKeyword, + TokenKind::HoursKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeeksKeyword, + TokenKind::DaysKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeiKeyword, + TokenKind::WeeksKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { @@ -725,31 +750,6 @@ impl Language { ); choice.consider(input, result)?; } - if self.version_is_at_least_0_6_11 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::GweiKeyword, - ); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_7_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::FinneyKeyword, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::SzaboKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }); - choice.consider(input, result)?; - } choice.finish(input) }, )))?; @@ -803,17 +803,7 @@ impl Language { input, TokenKind::Identifier, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.import_alias(input)))?; seq.finish() }) .with_kind(RuleKind::DeconstructionImportSymbol) @@ -821,12 +811,12 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn deconstruction_import_symbols_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::Default>( + OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, |input| self.deconstruction_import_symbol(input), TokenKind::Comma, - ) + )) .with_kind(RuleKind::DeconstructionImportSymbolsList) } @@ -912,6 +902,19 @@ impl Language { .with_kind(RuleKind::DoWhileStatement) } + #[allow(unused_assignments, unused_parens)] + fn else_branch(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::ElseKeyword, + ))?; + seq.elem(self.statement(input))?; + seq.finish() + }) + .with_kind(RuleKind::ElseBranch) + } + #[allow(unused_assignments, unused_parens)] fn emit_statement(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_4_21 { @@ -1208,19 +1211,19 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn experimental_pragma(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::ExperimentalKeyword, ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::AsciiStringLiteral, + TokenKind::Identifier, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TokenKind::AsciiStringLiteral, ); choice.consider(input, result)?; choice.finish(input) @@ -1232,7 +1235,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn expression(&self, input: &mut ParserContext) -> ParserResult { - let parse_assignment_operator = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 1u8, @@ -1302,7 +1305,7 @@ impl Language { }), ) }; - let parse_conditional_operator = |input: &mut ParserContext| { + let parse_conditional_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::ConditionalExpression, 3u8, @@ -1321,7 +1324,7 @@ impl Language { }), ) }; - let parse_or_operator = |input: &mut ParserContext| { + let parse_or_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 5u8, @@ -1332,7 +1335,7 @@ impl Language { ), ) }; - let parse_and_operator = |input: &mut ParserContext| { + let parse_and_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 7u8, @@ -1343,7 +1346,7 @@ impl Language { ), ) }; - let parse_equality_comparison_operator = |input: &mut ParserContext| { + let parse_equality_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 9u8, @@ -1363,7 +1366,7 @@ impl Language { }), ) }; - let parse_order_comparison_operator = |input: &mut ParserContext| { + let parse_comparison_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 11u8, @@ -1393,7 +1396,7 @@ impl Language { }), ) }; - let parse_bitwise_or_operator = |input: &mut ParserContext| { + let parse_bitwise_or_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 13u8, @@ -1401,7 +1404,7 @@ impl Language { self.parse_token_with_trivia::(input, TokenKind::Bar), ) }; - let parse_bitwise_x_or_operator = |input: &mut ParserContext| { + let parse_bitwise_xor_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 15u8, @@ -1412,7 +1415,7 @@ impl Language { ), ) }; - let parse_bitwise_and_operator = |input: &mut ParserContext| { + let parse_bitwise_and_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 17u8, @@ -1423,7 +1426,7 @@ impl Language { ), ) }; - let parse_shift_operator = |input: &mut ParserContext| { + let parse_shift_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 19u8, @@ -1448,7 +1451,7 @@ impl Language { }), ) }; - let parse_add_sub_operator = |input: &mut ParserContext| { + let parse_additive_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 21u8, @@ -1468,7 +1471,7 @@ impl Language { }), ) }; - let parse_mul_div_mod_operator = |input: &mut ParserContext| { + let parse_multiplicative_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 23u8, @@ -1493,29 +1496,55 @@ impl Language { }), ) }; - let parse_exponentiation_operator_removed_from_0_6_0 = |input: &mut ParserContext| { + let parse_exponentiation_expression_removed_from_0_6_0 = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 25u8, 25u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ), + 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) + }), ) }; - let parse_exponentiation_operator_introduced_from_0_6_0 = |input: &mut ParserContext| { + let parse_exponentiation_expression_introduced_from_0_6_0 = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 27u8 + 1, 27u8, - self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ), + 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) + }), ) }; - let parse_unary_postfix_operator = |input: &mut ParserContext| { + let parse_postfix_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::UnaryPostfixExpression, 29u8, @@ -1534,51 +1563,184 @@ impl Language { }), ) }; - let parse_unary_prefix_operator = |input: &mut ParserContext| { + let parse_prefix_expression_removed_from_0_5_0 = |input: &mut ParserContext| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 31u8, 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) - }), - ) - }; - let parse_function_call_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_postfix_operator( - RuleKind::FunctionCallExpression, + let result = 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)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Plus, + ); + choice.consider(input, result)?; + choice.finish(input) + }); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_5_0 { + let result = 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)?; + choice.finish(input) + }); + choice.consider(input, result)?; + } + choice.finish(input) + }), + ) + }; + let parse_prefix_expression_introduced_from_0_5_0 = |input: &mut ParserContext| { + PrecedenceHelper::to_prefix_operator( + RuleKind::UnaryPrefixExpression, 33u8, + ChoiceHelper::run(input, |mut choice, input| { + if !self.version_is_at_least_0_5_0 { + let result = 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)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Plus, + ); + choice.consider(input, result)?; + choice.finish(input) + }); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_5_0 { + let result = 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)?; + choice.finish(input) + }); + choice.consider(input, result)?; + } + choice.finish(input) + }), + ) + }; + let parse_function_call_expression = |input: &mut ParserContext| { + PrecedenceHelper::to_postfix_operator( + RuleKind::FunctionCallExpression, + 35u8, SequenceHelper::run(|mut seq| { if self.version_is_at_least_0_6_2 { seq.elem(OptionalHelper::transform(self.function_call_options(input)))?; @@ -1588,10 +1750,10 @@ impl Language { }), ) }; - let parse_member_access_operator = |input: &mut ParserContext| { + let parse_member_access_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::MemberAccessExpression, - 35u8, + 37u8, SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -1614,10 +1776,10 @@ impl Language { }), ) }; - let parse_index_access_operator = |input: &mut ParserContext| { + let parse_index_access_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::IndexAccessExpression, - 37u8, + 39u8, SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBracket); let input = delim_guard.ctx(); @@ -1628,16 +1790,7 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::Colon, - ), - )?; - seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.index_access_end(input)))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -1657,8 +1810,14 @@ impl Language { }; let prefix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_unary_prefix_operator(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)?; + } + if self.version_is_at_least_0_5_0 { + let result = parse_prefix_expression_introduced_from_0_5_0(input); + choice.consider(input, result)?; + } choice.finish(input) }) }; @@ -1668,29 +1827,15 @@ impl Language { choice.consider(input, result)?; let result = self.tuple_expression(input); choice.consider(input, result)?; + if self.version_is_at_least_0_5_3 { + let result = self.type_expression(input); + choice.consider(input, result)?; + } let result = self.array_expression(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::TrueKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::FalseKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.hex_number_expression(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.decimal_number_expression(input); - choice.consider(input, result)?; - let result = self.hex_number_expression(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.decimal_number_expression(input); choice.consider(input, result)?; let result = ChoiceHelper::run(input, |mut choice, input| { let result = self.hex_string_literals_list(input); @@ -1710,6 +1855,13 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::StringKeyword, @@ -1717,6 +1869,11 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::FixedBytesType, @@ -1742,39 +1899,38 @@ impl Language { TokenKind::UnsignedFixedType, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::TrueKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::FalseKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Identifier, ); choice.consider(input, result)?; - if self.version_is_at_least_0_5_3 { - let result = self.type_expression(input); - choice.consider(input, result)?; - } choice.finish(input) }) }; let postfix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_conditional_operator(input); + let result = parse_conditional_expression(input); choice.consider(input, result)?; - let result = parse_unary_postfix_operator(input); + let result = parse_postfix_expression(input); choice.consider(input, result)?; - let result = parse_function_call_operator(input); + let result = parse_function_call_expression(input); choice.consider(input, result)?; - let result = parse_member_access_operator(input); + let result = parse_member_access_expression(input); choice.consider(input, result)?; - let result = parse_index_access_operator(input); + let result = parse_index_access_expression(input); choice.consider(input, result)?; choice.finish(input) }) @@ -1793,34 +1949,34 @@ impl Language { }; let binary_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_assignment_operator(input); + let result = parse_assignment_expression(input); choice.consider(input, result)?; - let result = parse_or_operator(input); + let result = parse_or_expression(input); choice.consider(input, result)?; - let result = parse_and_operator(input); + let result = parse_and_expression(input); choice.consider(input, result)?; - let result = parse_equality_comparison_operator(input); + let result = parse_equality_expression(input); choice.consider(input, result)?; - let result = parse_order_comparison_operator(input); + let result = parse_comparison_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_or_operator(input); + let result = parse_bitwise_or_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_x_or_operator(input); + let result = parse_bitwise_xor_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_and_operator(input); + let result = parse_bitwise_and_expression(input); choice.consider(input, result)?; - let result = parse_shift_operator(input); + let result = parse_shift_expression(input); choice.consider(input, result)?; - let result = parse_add_sub_operator(input); + let result = parse_additive_expression(input); choice.consider(input, result)?; - let result = parse_mul_div_mod_operator(input); + let result = parse_multiplicative_expression(input); choice.consider(input, result)?; if !self.version_is_at_least_0_6_0 { - let result = parse_exponentiation_operator_removed_from_0_6_0(input); + 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_operator_introduced_from_0_6_0(input); + let result = parse_exponentiation_expression_introduced_from_0_6_0(input); choice.consider(input, result)?; } choice.finish(input) @@ -1928,13 +2084,13 @@ impl Language { ))?; seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -1962,15 +2118,11 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); + choice.consider(input, result)?; + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( @@ -2021,6 +2173,13 @@ impl Language { choice.consider(input, result)?; let result = self.override_specifier(input); choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ConstantKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::ExternalKeyword, @@ -2056,13 +2215,6 @@ impl Language { TokenKind::ViewKeyword, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ConstantKeyword, - ); - choice.consider(input, result)?; - } if self.version_is_at_least_0_6_0 { let result = self.parse_token_with_trivia::( input, @@ -2078,18 +2230,19 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn function_call_options(&self, input: &mut ParserContext) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { - let result = - OneOrMoreHelper::run(input, |input| self.named_arguments_declaration(input)); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_0 { - let result = self.named_arguments_declaration(input); - choice.consider(input, result)?; - } - choice.finish(input) - }) + if self.version_is_at_least_0_6_2 { + SequenceHelper::run(|mut seq| { + seq.elem(self.named_arguments_declaration(input))?; + if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { + seq.elem(OptionalHelper::transform( + self.named_arguments_declarations(input), + ))?; + } + seq.finish() + }) + } else { + ParserResult::disabled() + } .with_kind(RuleKind::FunctionCallOptions) } @@ -2124,13 +2277,13 @@ impl Language { ))?; seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -2213,9 +2366,33 @@ impl Language { |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::DaysKeyword, + TokenKind::WeiKeyword, ); choice.consider(input, result)?; + if self.version_is_at_least_0_6_11 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::GweiKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::SzaboKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::FinneyKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::EtherKeyword, @@ -2223,7 +2400,7 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::HoursKeyword, + TokenKind::SecondsKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( @@ -2233,17 +2410,17 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::SecondsKeyword, + TokenKind::HoursKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeeksKeyword, + TokenKind::DaysKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeiKeyword, + TokenKind::WeeksKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { @@ -2254,32 +2431,6 @@ impl Language { ); choice.consider(input, result)?; } - if self.version_is_at_least_0_6_11 { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::GweiKeyword, - ); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_7_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::FinneyKeyword, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::SzaboKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }); - choice.consider(input, result)?; - } choice.finish(input) }, )))?; @@ -2373,19 +2524,28 @@ impl Language { seq.finish() }))?; seq.elem(self.statement(input))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::ElseKeyword, - ))?; - seq.elem(self.statement(input))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.else_branch(input)))?; seq.finish() }) .with_kind(RuleKind::IfStatement) } + #[allow(unused_assignments, unused_parens)] + fn import_alias(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::AsKeyword, + ))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Identifier, + ))?; + seq.finish() + }) + .with_kind(RuleKind::ImportAlias) + } + #[allow(unused_assignments, unused_parens)] fn import_directive(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2422,6 +2582,21 @@ impl Language { .with_kind(RuleKind::ImportDirective) } + #[allow(unused_assignments, unused_parens)] + fn index_access_end(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem( + self.parse_token_with_trivia::( + input, + TokenKind::Colon, + ), + )?; + seq.elem(OptionalHelper::transform(self.expression(input)))?; + seq.finish() + }) + .with_kind(RuleKind::IndexAccessEnd) + } + #[allow(unused_assignments, unused_parens)] fn inheritance_specifier(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2503,34 +2678,32 @@ impl Language { choice.consider(input, result)?; let result = self.function_definition(input); choice.consider(input, result)?; - let result = self.modifier_definition(input); - choice.consider(input, result)?; - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - let result = self.event_definition(input); - choice.consider(input, result)?; - let result = self.state_variable_definition(input); - choice.consider(input, result)?; if self.version_is_at_least_0_4_22 { let result = self.constructor_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.fallback_function_definition(input); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { let result = self.unnamed_function_definition(input); choice.consider(input, result)?; } + let result = self.modifier_definition(input); + choice.consider(input, result)?; + let result = self.struct_definition(input); + choice.consider(input, result)?; + let result = self.enum_definition(input); + choice.consider(input, result)?; + let result = self.event_definition(input); + choice.consider(input, result)?; + let result = self.state_variable_definition(input); + choice.consider(input, result)?; if self.version_is_at_least_0_8_4 { let result = self.error_definition(input); choice.consider(input, result)?; @@ -2615,34 +2788,32 @@ impl Language { choice.consider(input, result)?; let result = self.function_definition(input); choice.consider(input, result)?; - let result = self.modifier_definition(input); - choice.consider(input, result)?; - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - let result = self.event_definition(input); - choice.consider(input, result)?; - let result = self.state_variable_definition(input); - choice.consider(input, result)?; if self.version_is_at_least_0_4_22 { let result = self.constructor_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.fallback_function_definition(input); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { let result = self.unnamed_function_definition(input); choice.consider(input, result)?; } + let result = self.modifier_definition(input); + choice.consider(input, result)?; + let result = self.struct_definition(input); + choice.consider(input, result)?; + let result = self.enum_definition(input); + choice.consider(input, result)?; + let result = self.event_definition(input); + choice.consider(input, result)?; + let result = self.state_variable_definition(input); + choice.consider(input, result)?; if self.version_is_at_least_0_8_4 { let result = self.error_definition(input); choice.consider(input, result)?; @@ -2667,6 +2838,13 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::StringKeyword, @@ -2674,6 +2852,11 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::FixedBytesType, @@ -2699,13 +2882,6 @@ impl Language { TokenKind::UnsignedFixedType, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }); choice.consider(input, result)?; @@ -2822,13 +2998,13 @@ impl Language { self.modifier_attributes_list(input), ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -2892,6 +3068,16 @@ impl Language { .with_kind(RuleKind::NamedArgumentsDeclaration) } + #[allow(unused_assignments, unused_parens)] + fn named_arguments_declarations(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { + OneOrMoreHelper::run(input, |input| self.named_arguments_declaration(input)) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::NamedArgumentsDeclarations) + } + #[allow(unused_assignments, unused_parens)] fn named_arguments_list(&self, input: &mut ParserContext) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( @@ -2910,14 +3096,7 @@ impl Language { input, TokenKind::Asterisk, ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; + seq.elem(self.import_alias(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::FromKeyword, @@ -2951,7 +3130,7 @@ impl Language { input, TokenKind::OverrideKeyword, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); seq.elem(self.parse_token_with_trivia::( @@ -2959,20 +3138,20 @@ impl Language { TokenKind::OpenParen, ))?; seq.elem( - OptionalHelper::transform(self.identifier_paths_list(input)) + self.identifier_paths_list(input) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, - ), + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), )?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::CloseParen, ))?; seq.finish() - })))?; + }))?; seq.finish() }) .with_kind(RuleKind::OverrideSpecifier) @@ -2998,7 +3177,7 @@ impl Language { if self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::CalldataKeyword, + TokenKind::CallDataKeyword, ); choice.consider(input, result)?; } @@ -3061,17 +3240,7 @@ impl Language { input, TokenKind::AsciiStringLiteral, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.import_alias(input)))?; seq.finish() }) .with_kind(RuleKind::PathImport) @@ -3093,7 +3262,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::PragmaKeyword, ))?; @@ -3108,14 +3277,14 @@ impl Language { }))?; seq.finish() }) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + .recover_until_with_nested_delims::<_, LexicalContextType::Pragma>( input, self, TokenKind::Semicolon, RecoverFromNoMatch::No, ), )?; - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::Semicolon, ))?; @@ -3174,13 +3343,13 @@ impl Language { self.receive_function_attributes_list(input), ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -3234,30 +3403,34 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn revert_statement(&self, input: &mut ParserContext) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem( - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + if self.version_is_at_least_0_8_4 { + SequenceHelper::run(|mut seq| { + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::RevertKeyword, + ))?; + seq.elem(OptionalHelper::transform(self.identifier_path(input)))?; + seq.elem(self.arguments_declaration(input))?; + seq.finish() + }) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, - TokenKind::RevertKeyword, - ))?; - seq.elem(OptionalHelper::transform(self.identifier_path(input)))?; - seq.elem(self.arguments_declaration(input))?; - seq.finish() - }) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + self, + TokenKind::Semicolon, + RecoverFromNoMatch::No, + ), + )?; + seq.elem(self.parse_token_with_trivia::( input, - self, TokenKind::Semicolon, - RecoverFromNoMatch::No, - ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Semicolon, - ))?; - seq.finish() - }) + ))?; + seq.finish() + }) + } else { + ParserResult::disabled() + } .with_kind(RuleKind::RevertStatement) } @@ -3288,13 +3461,11 @@ impl Language { let result = self.library_definition(input); choice.consider(input, result)?; if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.struct_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.enum_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_7_1 { @@ -3379,14 +3550,9 @@ impl Language { input, TokenKind::Identifier, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ))?; - seq.elem(self.expression(input))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform( + self.state_variable_definition_value(input), + ))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -3405,55 +3571,62 @@ impl Language { .with_kind(RuleKind::StateVariableDefinition) } + #[allow(unused_assignments, unused_parens)] + fn state_variable_definition_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::StateVariableDefinitionValue) + } + #[allow(unused_assignments, unused_parens)] fn statement(&self, input: &mut ParserContext) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.if_statement(input); + choice.consider(input, result)?; + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); choice.consider(input, result)?; - let result = self.break_statement(input); + } + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); choice.consider(input, result)?; - let result = self.delete_statement(input); + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); choice.consider(input, result)?; - let result = self.return_statement(input); + } + if self.version_is_at_least_0_8_4 { + let result = self.revert_statement(input); choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_4 { - let result = self.revert_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }); - choice.consider(input, result)?; + } let result = self.assembly_statement(input); choice.consider(input, result)?; let result = self.block(input); @@ -3624,13 +3797,13 @@ impl Language { TokenKind::OpenParen, ))?; seq.elem( - OptionalHelper::transform(self.tuple_members_list(input)) + self.tuple_members_list(input) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, - ), + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), )?; seq.elem(self.parse_token_with_trivia::( input, @@ -3689,95 +3862,39 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn tuple_member(&self, input: &mut ParserContext) -> ParserResult { + fn tuple_member_deconstruction(&self, input: &mut ParserContext) -> ParserResult { OptionalHelper::transform(ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem(OptionalHelper::transform(ChoiceHelper::run( - input, - |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::MemoryKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::StorageKeyword, - ); - choice.consider(input, result)?; - if self.version_is_at_least_0_5_0 { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::CalldataKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }, - )))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.finish() - }); + let result = self.typed_tuple_member(input); choice.consider(input, result)?; - let result = SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform(ChoiceHelper::run( - input, - |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::MemoryKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::StorageKeyword, - ); - choice.consider(input, result)?; - if self.version_is_at_least_0_5_0 { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::CalldataKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }, - )))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.finish() - }); + let result = self.untyped_tuple_member(input); choice.consider(input, result)?; choice.finish(input) })) - .with_kind(RuleKind::TupleMember) + .with_kind(RuleKind::TupleMemberDeconstruction) } #[allow(unused_assignments, unused_parens)] fn tuple_members_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::Default>( + OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| self.tuple_member(input), + |input| self.tuple_member_deconstruction(input), TokenKind::Comma, - ) + )) .with_kind(RuleKind::TupleMembersList) } + #[allow(unused_assignments, unused_parens)] + fn tuple_value(&self, input: &mut ParserContext) -> ParserResult { + OptionalHelper::transform(self.expression(input)).with_kind(RuleKind::TupleValue) + } + #[allow(unused_assignments, unused_parens)] fn tuple_values_list(&self, input: &mut ParserContext) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| OptionalHelper::transform(self.expression(input)), + |input| self.tuple_value(input), TokenKind::Comma, ) .with_kind(RuleKind::TupleValuesList) @@ -3823,7 +3940,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn type_name(&self, input: &mut ParserContext) -> ParserResult { - let parse_array_type_name_operator = |input: &mut ParserContext| { + let parse_array_type_name = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::ArrayTypeName, 1u8, @@ -3863,6 +3980,13 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::StringKeyword, @@ -3870,6 +3994,11 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::FixedBytesType, @@ -3895,13 +4024,6 @@ impl Language { TokenKind::UnsignedFixedType, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }); choice.consider(input, result)?; @@ -3912,7 +4034,7 @@ impl Language { }; let postfix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_array_type_name_operator(input); + let result = parse_array_type_name(input); choice.consider(input, result)?; choice.finish(input) }) @@ -3933,6 +4055,42 @@ impl Language { .with_kind(RuleKind::TypeName) } + #[allow(unused_assignments, unused_parens)] + fn typed_tuple_member(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = self.parse_token_with_trivia::( + input, + TokenKind::MemoryKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::StorageKeyword, + ); + choice.consider(input, result)?; + if self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::CallDataKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }, + )))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Identifier, + ))?; + seq.finish() + }) + .with_kind(RuleKind::TypedTupleMember) + } + #[allow(unused_assignments, unused_parens)] fn unchecked_block(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_8_0 { @@ -4020,13 +4178,13 @@ impl Language { self.unnamed_function_attributes_list(input), ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -4037,6 +4195,41 @@ impl Language { .with_kind(RuleKind::UnnamedFunctionDefinition) } + #[allow(unused_assignments, unused_parens)] + fn untyped_tuple_member(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = self.parse_token_with_trivia::( + input, + TokenKind::MemoryKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::StorageKeyword, + ); + choice.consider(input, result)?; + if self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::CallDataKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }, + )))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Identifier, + ))?; + seq.finish() + }) + .with_kind(RuleKind::UntypedTupleMember) + } + #[allow(unused_assignments, unused_parens)] fn user_defined_value_type_definition(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_8_8 { @@ -4062,6 +4255,14 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self .parse_token_with_trivia::( input, @@ -4070,6 +4271,12 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, @@ -4100,14 +4307,6 @@ impl Language { TokenKind::UnsignedFixedType, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }))?; seq.finish() @@ -4132,33 +4331,129 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn using_directive(&self, input: &mut ParserContext) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem( - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + fn using_alias(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_8_19 { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::AsKeyword, + ))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.parse_token_with_trivia::( input, - TokenKind::UsingKeyword, - ))?; - seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.using_directive_path(input); - choice.consider(input, result)?; - let result = self.using_directive_deconstruction(input); - choice.consider(input, result)?; - choice.finish(input) - }))?; - seq.elem(self.parse_token_with_trivia::( + TokenKind::Ampersand, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( input, - TokenKind::ForKeyword, - ))?; - seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; + 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) + }))?; + seq.finish() + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::UsingAlias) + } + + #[allow(unused_assignments, unused_parens)] + fn using_directive(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::UsingKeyword, + ))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.using_directive_path(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_8_13 { + let result = self.using_directive_deconstruction(input); + choice.consider(input, result)?; + } + choice.finish(input) + }))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::ForKeyword, + ))?; + seq.elem(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) }))?; if self.version_is_at_least_0_8_13 { @@ -4230,110 +4525,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem(self.identifier_path(input))?; if self.version_is_at_least_0_8_19 { - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(if self.version_is_at_least_0_8_19 { - ChoiceHelper::run(input, |mut choice, input| { - let result = self - .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() - })?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.using_alias(input)))?; } seq.finish() }) @@ -4345,12 +4537,16 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn using_directive_symbols_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::Default>( - input, - self, - |input| self.using_directive_symbol(input), - TokenKind::Comma, - ) + if self.version_is_at_least_0_8_13 { + OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Default>( + input, + self, + |input| self.using_directive_symbol(input), + TokenKind::Comma, + )) + } else { + ParserResult::disabled() + } .with_kind(RuleKind::UsingDirectiveSymbolsList) } @@ -4358,6 +4554,8 @@ impl Language { fn variable_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(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, @@ -4365,8 +4563,6 @@ impl Language { ); choice.consider(input, result)?; } - let result = self.type_name(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.elem(OptionalHelper::transform(ChoiceHelper::run( @@ -4385,7 +4581,7 @@ impl Language { if self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::CalldataKeyword, + TokenKind::CallDataKeyword, ); choice.consider(input, result)?; } @@ -4407,14 +4603,9 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem(self.variable_declaration(input))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ))?; - seq.elem(self.expression(input))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform( + self.variable_declaration_value(input), + ))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -4434,14 +4625,27 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn version_pragma(&self, input: &mut ParserContext) -> ParserResult { + fn variable_declaration_value(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::SolidityKeyword, + 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_list(input))?; seq.finish() }) @@ -4450,64 +4654,61 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn version_pragma_expression(&self, input: &mut ParserContext) -> ParserResult { - let parse_version_pragma_or_operator = |input: &mut ParserContext| { + let parse_version_pragma_or_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::VersionPragmaBinaryExpression, 1u8, 1u8 + 1, - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::BarBar, ), ) }; - let parse_version_pragma_range_operator = |input: &mut ParserContext| { + let parse_version_pragma_range_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::VersionPragmaBinaryExpression, 3u8, 3u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ), + self.parse_token_with_trivia::(input, TokenKind::Minus), ) }; - let parse_version_pragma_unary_operator = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 5u8, ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::Caret, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::Tilde, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::Equal, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::LessThan, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::GreaterThan, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::LessThanEqual, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::GreaterThanEqual, ); @@ -4518,13 +4719,18 @@ impl Language { }; let prefix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_unary_operator(input); + let result = parse_version_pragma_prefix_expression(input); + choice.consider(input, result)?; + choice.finish(input) + }) + }; + let primary_expression_parser = |input: &mut ParserContext| { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.version_pragma_specifier(input); choice.consider(input, result)?; choice.finish(input) }) }; - let primary_expression_parser = - |input: &mut ParserContext| self.version_pragma_specifier(input); let binary_operand_parser = |input: &mut ParserContext| { SequenceHelper::run(|mut seq| { seq.elem(ZeroOrMoreHelper::run(input, |input| { @@ -4536,9 +4742,9 @@ impl Language { }; let binary_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_or_operator(input); + let result = parse_version_pragma_or_expression(input); choice.consider(input, result)?; - let result = parse_version_pragma_range_operator(input); + let result = parse_version_pragma_range_expression(input); choice.consider(input, result)?; choice.finish(input) }) @@ -4571,11 +4777,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn version_pragma_specifier(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::VersionPragma>( + SeparatedHelper::run::<_, LexicalContextType::Pragma>( input, self, |input| { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::VersionPragmaValue, ) @@ -4625,7 +4831,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem(self.yul_identifier_paths_list(input))?; seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::ColonEqual, ), @@ -4642,22 +4848,22 @@ impl Language { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); let input = delim_guard.ctx(); seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::OpenBrace, ), )?; seq.elem( - OptionalHelper::transform(self.yul_statements_list(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::YulBlock>( - input, - self, - TokenKind::CloseBrace, - RecoverFromNoMatch::Yes, - ), + self.yul_statements_list(input) + .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( + input, + self, + TokenKind::CloseBrace, + RecoverFromNoMatch::Yes, + ), )?; seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::CloseBrace, ), @@ -4669,74 +4875,58 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_break_statement(&self, input: &mut ParserContext) -> ParserResult { - self.parse_token_with_trivia::(input, TokenKind::BreakKeyword) + self.parse_token_with_trivia::(input, TokenKind::YulBreakKeyword) .with_kind(RuleKind::YulBreakStatement) } #[allow(unused_assignments, unused_parens)] fn yul_continue_statement(&self, input: &mut ParserContext) -> ParserResult { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::ContinueKeyword, + TokenKind::YulContinueKeyword, ) .with_kind(RuleKind::YulContinueStatement) } #[allow(unused_assignments, unused_parens)] - fn yul_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_default_case(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::LetKeyword, - ), - )?; - seq.elem(self.yul_identifier_paths_list(input))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::ColonEqual, - ), - )?; - seq.elem(self.yul_expression(input))?; - seq.finish() - })))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulDefaultKeyword, + ))?; + seq.elem(self.yul_block(input))?; seq.finish() }) - .with_kind(RuleKind::YulDeclarationStatement) + .with_kind(RuleKind::YulDefaultCase) } #[allow(unused_assignments, unused_parens)] fn yul_expression(&self, input: &mut ParserContext) -> ParserResult { - let parse_yul_function_call_operator = |input: &mut ParserContext| { + let parse_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( - self.parse_token_with_trivia::( - input, - TokenKind::OpenParen, - ), - )?; - seq.elem( - OptionalHelper::transform(self.yul_expressions_list(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::YulBlock>( - input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, - ), + self.yul_expressions_list(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() }), ) @@ -4744,32 +4934,32 @@ impl Language { let primary_expression_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::TrueKeyword, + TokenKind::YulTrueKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::FalseKeyword, + TokenKind::YulFalseKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::YulHexLiteral, + TokenKind::YulDecimalLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::YulDecimalLiteral, + TokenKind::YulHexLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::HexStringLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::AsciiStringLiteral, ); @@ -4784,7 +4974,7 @@ impl Language { }; let postfix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_yul_function_call_operator(input); + let result = parse_yul_function_call_expression(input); choice.consider(input, result)?; choice.finish(input) }) @@ -4807,24 +4997,22 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_expressions_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( + OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| self.yul_expression(input), TokenKind::Comma, - ) + )) .with_kind(RuleKind::YulExpressionsList) } #[allow(unused_assignments, unused_parens)] fn yul_for_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::ForKeyword, - ), - )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulForKeyword, + ))?; seq.elem(self.yul_block(input))?; seq.elem(self.yul_expression(input))?; seq.elem(self.yul_block(input))?; @@ -4837,18 +5025,14 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_function_definition(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::FunctionKeyword, - ), - )?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::YulIdentifier, - ), - )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulFunctionKeyword, + ))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulIdentifier, + ))?; seq.elem(self.yul_parameters_declaration(input))?; seq.elem(OptionalHelper::transform( self.yul_returns_declaration(input), @@ -4861,11 +5045,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_identifier_path(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( + SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::YulIdentifier, ) @@ -4877,7 +5061,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_identifier_paths_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( + SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| self.yul_identifier_path(input), @@ -4888,11 +5072,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_identifiers_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( + SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::YulIdentifier, ) @@ -4905,12 +5089,10 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_if_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::IfKeyword, - ), - )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulIfKeyword, + ))?; seq.elem(self.yul_expression(input))?; seq.elem(self.yul_block(input))?; seq.finish() @@ -4921,9 +5103,9 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_leave_statement(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::LeaveKeyword, + TokenKind::YulLeaveKeyword, ) } else { ParserResult::disabled() @@ -4937,22 +5119,22 @@ impl Language { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::OpenParen, ), )?; seq.elem( OptionalHelper::transform(self.yul_identifiers_list(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::YulBlock>( - input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, - ), + .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), )?; seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::CloseParen, ), @@ -4965,12 +5147,10 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_returns_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::MinusGreaterThan, - ), - )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::MinusGreaterThan, + ))?; seq.elem(self.yul_identifiers_list(input))?; seq.finish() }) @@ -4984,7 +5164,7 @@ impl Language { choice.consider(input, result)?; let result = self.yul_function_definition(input); choice.consider(input, result)?; - let result = self.yul_declaration_statement(input); + let result = self.yul_variable_declaration_statement(input); choice.consider(input, result)?; let result = self.yul_assignment_statement(input); choice.consider(input, result)?; @@ -5011,90 +5191,113 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_statements_list(&self, input: &mut ParserContext) -> ParserResult { - OneOrMoreHelper::run(input, |input| self.yul_statement(input)) + ZeroOrMoreHelper::run(input, |input| self.yul_statement(input)) .with_kind(RuleKind::YulStatementsList) } #[allow(unused_assignments, unused_parens)] - fn yul_switch_case(&self, input: &mut ParserContext) -> ParserResult { + fn yul_switch_cases_list(&self, input: &mut ParserContext) -> ParserResult { + OneOrMoreHelper::run(input, |input| { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.yul_default_case(input); + choice.consider(input, result)?; + let result = self.yul_value_case(input); + choice.consider(input, result)?; + choice.finish(input) + }) + }) + .with_kind(RuleKind::YulSwitchCasesList) + } + + #[allow(unused_assignments, unused_parens)] + fn yul_switch_statement(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulSwitchKeyword, + ))?; + seq.elem(self.yul_expression(input))?; + seq.elem(self.yul_switch_cases_list(input))?; + seq.finish() + }) + .with_kind(RuleKind::YulSwitchStatement) + } + + #[allow(unused_assignments, unused_parens)] + fn yul_value_case(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulCaseKeyword, + ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::DefaultKeyword, + TokenKind::YulTrueKeyword, ); choice.consider(input, result)?; - let result = SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::CaseKeyword, - ), - )?; - seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::TrueKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::FalseKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::YulHexLiteral, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::YulDecimalLiteral, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::HexStringLiteral, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsciiStringLiteral, - ); - choice.consider(input, result)?; - choice.finish(input) - }))?; - seq.finish() - }); + let result = self.parse_token_with_trivia::( + input, + TokenKind::YulFalseKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::YulDecimalLiteral, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::YulHexLiteral, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::HexStringLiteral, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::AsciiStringLiteral, + ); choice.consider(input, result)?; choice.finish(input) }))?; seq.elem(self.yul_block(input))?; seq.finish() }) - .with_kind(RuleKind::YulSwitchCase) + .with_kind(RuleKind::YulValueCase) } #[allow(unused_assignments, unused_parens)] - fn yul_switch_cases_list(&self, input: &mut ParserContext) -> ParserResult { - OneOrMoreHelper::run(input, |input| self.yul_switch_case(input)) - .with_kind(RuleKind::YulSwitchCasesList) + fn yul_variable_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulLetKeyword, + ))?; + seq.elem(self.yul_identifier_paths_list(input))?; + seq.elem(OptionalHelper::transform( + self.yul_variable_declaration_value(input), + ))?; + seq.finish() + }) + .with_kind(RuleKind::YulVariableDeclarationStatement) } #[allow(unused_assignments, unused_parens)] - fn yul_switch_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_variable_declaration_value(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::SwitchKeyword, + TokenKind::ColonEqual, ), )?; seq.elem(self.yul_expression(input))?; - seq.elem(self.yul_switch_cases_list(input))?; seq.finish() }) - .with_kind(RuleKind::YulSwitchStatement) + .with_kind(RuleKind::YulVariableDeclarationValue) } /******************************************** @@ -5102,22 +5305,11 @@ impl Language { ********************************************/ #[allow(unused_assignments, unused_parens)] - fn ascii_character_without_double_quote_or_backslash(&self, input: &mut ParserContext) -> bool { - scan_choice!( - input, - scan_char_range!(input, ' ', '!'), - scan_char_range!(input, '#', '['), - scan_char_range!(input, ']', '~') - ) - } - - #[allow(unused_assignments, unused_parens)] - fn ascii_character_without_single_quote_or_backslash(&self, input: &mut ParserContext) -> bool { - scan_choice!( + fn ampersand(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( input, - scan_char_range!(input, ' ', '&'), - scan_char_range!(input, '(', '['), - scan_char_range!(input, ']', '~') + scan_chars!(input, '&'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '&')) ) } @@ -5146,19 +5338,47 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn decimal_digit(&self, input: &mut ParserContext) -> bool { - scan_char_range!(input, '0', '9') + fn asterisk(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '*'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '*')) + ) + } + + #[allow(unused_assignments, unused_parens)] + fn bang(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '!'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn bar(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '|'), + scan_choice!(input, scan_chars!(input, '|'), scan_chars!(input, '=')) + ) + } + + #[allow(unused_assignments, unused_parens)] + fn caret(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '^'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn colon(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, ':'), scan_chars!(input, '=')) } #[allow(unused_assignments, unused_parens)] fn decimal_digits(&self, input: &mut ParserContext) -> bool { scan_sequence!( - scan_one_or_more!(input, self.decimal_digit(input)), + scan_one_or_more!(input, scan_char_range!(input, '0', '9')), scan_zero_or_more!( input, scan_sequence!( scan_chars!(input, '_'), - scan_one_or_more!(input, self.decimal_digit(input)) + scan_one_or_more!(input, scan_char_range!(input, '0', '9')) ) ) ) @@ -5175,35 +5395,55 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn decimal_literal(&self, input: &mut ParserContext) -> bool { - scan_not_followed_by!( + scan_choice!( input, - scan_sequence!( - scan_choice!( - input, + scan_not_followed_by!( + input, + scan_sequence!( scan_not_followed_by!( input, self.decimal_digits(input), scan_chars!(input, '.') ), - if !self.version_is_at_least_0_5_0 { + scan_optional!(input, self.decimal_exponent(input)) + ), + self.identifier_start(input) + ), + if !self.version_is_at_least_0_5_0 { + scan_not_followed_by!( + input, + scan_sequence!( scan_not_followed_by!( input, scan_sequence!(self.decimal_digits(input), scan_chars!(input, '.')), self.decimal_digits(input) - ) - } else { - false - }, - scan_sequence!(scan_chars!(input, '.'), self.decimal_digits(input)), - scan_sequence!( - self.decimal_digits(input), - scan_chars!(input, '.'), - self.decimal_digits(input) - ) + ), + scan_optional!(input, self.decimal_exponent(input)) + ), + self.identifier_start(input) + ) + } else { + false + }, + scan_not_followed_by!( + input, + scan_sequence!( + scan_chars!(input, '.'), + self.decimal_digits(input), + scan_optional!(input, self.decimal_exponent(input)) ), - scan_optional!(input, self.decimal_exponent(input)) + self.identifier_start(input) ), - self.identifier_start(input) + scan_not_followed_by!( + input, + scan_sequence!( + self.decimal_digits(input), + scan_chars!(input, '.'), + self.decimal_digits(input), + scan_optional!(input, self.decimal_exponent(input)) + ), + self.identifier_start(input) + ) ) } @@ -5216,7 +5456,9 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - self.ascii_character_without_double_quote_or_backslash(input) + scan_char_range!(input, ' ', '!'), + scan_char_range!(input, '#', '['), + scan_char_range!(input, ']', '~') ) ), scan_chars!(input, '"') @@ -5242,7 +5484,7 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - scan_none_of!(input, '\n', '\r', '"', '\\') + scan_none_of!(input, '"', '\\', '\r', '\n') ) ), scan_chars!(input, '"') @@ -5260,6 +5502,15 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn equal(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '='), + scan_choice!(input, scan_chars!(input, '>'), scan_chars!(input, '=')) + ) + } + #[allow(unused_assignments, unused_parens)] fn escape_sequence(&self, input: &mut ParserContext) -> bool { scan_sequence!( @@ -5277,55 +5528,68 @@ impl Language { fn fixed_bytes_type(&self, input: &mut ParserContext) -> bool { scan_sequence!( scan_chars!(input, 'b', 'y', 't', 'e', 's'), - self.fixed_bytes_type_size(input) + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '8'), + scan_chars!(input, '7'), + scan_chars!(input, '6'), + scan_chars!(input, '5'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1') + ) ) } #[allow(unused_assignments, unused_parens)] - fn fixed_bytes_type_size(&self, input: &mut ParserContext) -> bool { - scan_choice!( + fn greater_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( input, - scan_chars!(input, '9'), - scan_chars!(input, '8'), - scan_chars!(input, '7'), - scan_chars!(input, '6'), - scan_chars!(input, '5'), - scan_chars!(input, '4'), - scan_chars!(input, '3', '2'), - scan_chars!(input, '3', '1'), - scan_chars!(input, '3', '0'), - scan_chars!(input, '3'), - scan_chars!(input, '2', '9'), - scan_chars!(input, '2', '8'), - scan_chars!(input, '2', '7'), - scan_chars!(input, '2', '6'), - scan_chars!(input, '2', '5'), - scan_chars!(input, '2', '4'), - scan_chars!(input, '2', '3'), - scan_chars!(input, '2', '2'), - scan_chars!(input, '2', '1'), - scan_chars!(input, '2', '0'), - scan_chars!(input, '2'), - scan_chars!(input, '1', '9'), - scan_chars!(input, '1', '8'), - scan_chars!(input, '1', '7'), - scan_chars!(input, '1', '6'), - scan_chars!(input, '1', '5'), - scan_chars!(input, '1', '4'), - scan_chars!(input, '1', '3'), - scan_chars!(input, '1', '2'), - scan_chars!(input, '1', '1'), - scan_chars!(input, '1', '0'), - scan_chars!(input, '1') + scan_chars!(input, '>'), + scan_choice!(input, scan_chars!(input, '>'), scan_chars!(input, '=')) ) } #[allow(unused_assignments, unused_parens)] - fn fixed_type_size(&self, input: &mut ParserContext) -> bool { - scan_sequence!( - scan_one_or_more!(input, scan_char_range!(input, '0', '9')), - scan_chars!(input, 'x'), - scan_one_or_more!(input, scan_char_range!(input, '0', '9')) + fn greater_than_greater_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '>', '>'), + scan_choice!(input, scan_chars!(input, '>'), scan_chars!(input, '=')) + ) + } + + #[allow(unused_assignments, unused_parens)] + fn greater_than_greater_than_greater_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '>', '>', '>'), + scan_chars!(input, '=') ) } @@ -5342,36 +5606,50 @@ impl Language { fn hex_character(&self, input: &mut ParserContext) -> bool { scan_choice!( input, - self.decimal_digit(input), - scan_char_range!(input, 'A', 'F'), - scan_char_range!(input, 'a', 'f') + scan_char_range!(input, '0', '9'), + scan_char_range!(input, 'a', 'f'), + scan_char_range!(input, 'A', 'F') ) } #[allow(unused_assignments, unused_parens)] fn hex_literal(&self, input: &mut ParserContext) -> bool { - scan_not_followed_by!( + scan_choice!( input, - scan_sequence!( - scan_choice!( - input, + scan_not_followed_by!( + input, + scan_sequence!( scan_chars!(input, '0', 'x'), - if !self.version_is_at_least_0_5_0 { - scan_chars!(input, '0', 'X') - } else { - false - } + scan_one_or_more!(input, self.hex_character(input)), + scan_zero_or_more!( + input, + scan_sequence!( + scan_chars!(input, '_'), + scan_one_or_more!(input, self.hex_character(input)) + ) + ) ), - scan_one_or_more!(input, self.hex_character(input)), - scan_zero_or_more!( + self.identifier_start(input) + ), + if !self.version_is_at_least_0_5_0 { + scan_not_followed_by!( input, scan_sequence!( - scan_chars!(input, '_'), - scan_one_or_more!(input, self.hex_character(input)) - ) + scan_chars!(input, '0', 'X'), + scan_one_or_more!(input, self.hex_character(input)), + scan_zero_or_more!( + input, + scan_sequence!( + scan_chars!(input, '_'), + scan_one_or_more!(input, self.hex_character(input)) + ) + ) + ), + self.identifier_start(input) ) - ), - self.identifier_start(input) + } else { + false + } ) } @@ -5420,58 +5698,47 @@ impl Language { input, scan_chars!(input, '_'), scan_chars!(input, '$'), - scan_char_range!(input, 'A', 'Z'), - scan_char_range!(input, 'a', 'z') + scan_char_range!(input, 'a', 'z'), + scan_char_range!(input, 'A', 'Z') ) } #[allow(unused_assignments, unused_parens)] - fn integer_type_size(&self, input: &mut ParserContext) -> bool { - scan_choice!( + fn less_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( input, - scan_chars!(input, '9', '6'), - scan_chars!(input, '8', '8'), - scan_chars!(input, '8', '0'), - scan_chars!(input, '8'), - scan_chars!(input, '7', '2'), - scan_chars!(input, '6', '4'), - scan_chars!(input, '5', '6'), - scan_chars!(input, '4', '8'), - scan_chars!(input, '4', '0'), - scan_chars!(input, '3', '2'), - scan_chars!(input, '2', '5', '6'), - scan_chars!(input, '2', '4', '8'), - scan_chars!(input, '2', '4', '0'), - scan_chars!(input, '2', '4'), - scan_chars!(input, '2', '3', '2'), - scan_chars!(input, '2', '2', '4'), - scan_chars!(input, '2', '1', '6'), - scan_chars!(input, '2', '0', '8'), - scan_chars!(input, '2', '0', '0'), - scan_chars!(input, '1', '9', '2'), - scan_chars!(input, '1', '8', '4'), - scan_chars!(input, '1', '7', '6'), - scan_chars!(input, '1', '6', '8'), - scan_chars!(input, '1', '6', '0'), - scan_chars!(input, '1', '6'), - scan_chars!(input, '1', '5', '2'), - scan_chars!(input, '1', '4', '4'), - scan_chars!(input, '1', '3', '6'), - scan_chars!(input, '1', '2', '8'), - scan_chars!(input, '1', '2', '0'), - scan_chars!(input, '1', '1', '2'), - scan_chars!(input, '1', '0', '4') + scan_chars!(input, '<'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '<')) ) } #[allow(unused_assignments, unused_parens)] - fn multiline_comment(&self, input: &mut ParserContext) -> bool { - scan_sequence!( - scan_chars!(input, '/'), - scan_chars!(input, '*'), - scan_zero_or_more!( - input, - scan_choice!( + fn less_than_less_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '<', '<'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn minus(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '-'), + scan_choice!( + input, + scan_chars!(input, '>'), + scan_chars!(input, '='), + scan_chars!(input, '-') + ) + ) + } + + #[allow(unused_assignments, unused_parens)] + fn multiline_comment(&self, input: &mut ParserContext) -> bool { + scan_sequence!( + scan_chars!(input, '/'), + scan_chars!(input, '*'), + scan_zero_or_more!( + input, + scan_choice!( input, scan_none_of!(input, '*'), scan_not_followed_by!(input, scan_chars!(input, '*'), scan_chars!(input, '/')) @@ -5482,6 +5749,20 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn percent(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '%'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn plus(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '+'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '+')) + ) + } + #[allow(unused_assignments, unused_parens)] fn raw_identifier(&self, input: &mut ParserContext) -> bool { scan_sequence!( @@ -5492,9 +5773,284 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn signed_fixed_type(&self, input: &mut ParserContext) -> bool { - scan_sequence!( + scan_choice!( + input, scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), - scan_optional!(input, self.fixed_type_size(input)) + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ), + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ), + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } ) } @@ -5502,7 +6058,44 @@ impl Language { fn signed_integer_type(&self, input: &mut ParserContext) -> bool { scan_sequence!( scan_chars!(input, 'i', 'n', 't'), - scan_optional!(input, self.integer_type_size(input)) + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) ) } @@ -5523,7 +6116,9 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - self.ascii_character_without_single_quote_or_backslash(input) + scan_char_range!(input, ' ', '&'), + scan_char_range!(input, '(', '['), + scan_char_range!(input, ']', '~') ) ), scan_chars!(input, '\'') @@ -5549,7 +6144,7 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - scan_none_of!(input, '\n', '\r', '\'', '\\') + scan_none_of!(input, '\'', '\\', '\r', '\n') ) ), scan_chars!(input, '\'') @@ -5559,6 +6154,11 @@ impl Language { } } + #[allow(unused_assignments, unused_parens)] + fn slash(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '/'), scan_chars!(input, '=')) + } + #[allow(unused_assignments, unused_parens)] fn unicode_escape(&self, input: &mut ParserContext) -> bool { scan_sequence!( @@ -5572,22 +6172,301 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn unicode_string_literal(&self, input: &mut ParserContext) -> bool { - if self.version_is_at_least_0_7_0 { - scan_choice!( - input, - self.single_quoted_unicode_string_literal(input), + scan_choice!( + input, + if self.version_is_at_least_0_7_0 { + self.single_quoted_unicode_string_literal(input) + } else { + false + }, + if self.version_is_at_least_0_7_0 { self.double_quoted_unicode_string_literal(input) - ) - } else { - false - } + } else { + false + } + ) } #[allow(unused_assignments, unused_parens)] fn unsigned_fixed_type(&self, input: &mut ParserContext) -> bool { - scan_sequence!( + scan_choice!( + input, scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), - scan_optional!(input, self.fixed_type_size(input)) + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ), + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ), + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } ) } @@ -5595,7 +6474,44 @@ impl Language { fn unsigned_integer_type(&self, input: &mut ParserContext) -> bool { scan_sequence!( scan_chars!(input, 'u', 'i', 'n', 't'), - scan_optional!(input, self.integer_type_size(input)) + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) ) } @@ -5621,6 +6537,52 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn yul_bytes_keyword(&self, input: &mut ParserContext) -> bool { + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'b', 'y', 't', 'e', 's'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '8'), + scan_chars!(input, '7'), + scan_chars!(input, '6'), + scan_chars!(input, '5'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1') + ) + ) + } else { + false + } + } + #[allow(unused_assignments, unused_parens)] fn yul_decimal_literal(&self, input: &mut ParserContext) -> bool { scan_not_followed_by!( @@ -5630,13 +6592,308 @@ impl Language { scan_chars!(input, '0'), scan_sequence!( scan_char_range!(input, '1', '9'), - scan_zero_or_more!(input, self.decimal_digit(input)) + scan_zero_or_more!(input, scan_char_range!(input, '0', '9')) ) ), self.identifier_start(input) ) } + #[allow(unused_assignments, unused_parens)] + fn yul_fixed_keyword(&self, input: &mut ParserContext) -> bool { + scan_choice!( + input, + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'f', 'i', 'x', 'e', 'd') + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ) + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } + ) + } + #[allow(unused_assignments, unused_parens)] fn yul_hex_literal(&self, input: &mut ParserContext) -> bool { scan_not_followed_by!( @@ -5654,18 +6911,409 @@ impl Language { self.raw_identifier(input) } + #[allow(unused_assignments, unused_parens)] + fn yul_int_keyword(&self, input: &mut ParserContext) -> bool { + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'i', 'n', 't'), + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) + ) + } else { + false + } + } + + #[allow(unused_assignments, unused_parens)] + fn yul_ufixed_keyword(&self, input: &mut ParserContext) -> bool { + scan_choice!( + input, + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd') + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ) + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } + ) + } + + #[allow(unused_assignments, unused_parens)] + fn yul_uint_keyword(&self, input: &mut ParserContext) -> bool { + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'i', 'n', 't'), + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) + ) + } else { + false + } + } + pub fn scan(&self, lexical_context: LexicalContext, input: &str) -> Option { let mut input = ParserContext::new(input); match lexical_context { LexicalContext::Default => { Lexer::next_token::(self, &mut input) } - LexicalContext::VersionPragma => { - Lexer::next_token::(self, &mut input) - } - LexicalContext::YulBlock => { - Lexer::next_token::(self, &mut input) + LexicalContext::Pragma => { + Lexer::next_token::(self, &mut input) } + LexicalContext::Yul => Lexer::next_token::(self, &mut input), } } @@ -5679,6 +7327,9 @@ impl Language { ProductionKind::AsciiStringLiteralsList => { Self::ascii_string_literals_list.parse(self, input) } + ProductionKind::AssemblyFlagsDeclaration => { + Self::assembly_flags_declaration.parse(self, input) + } ProductionKind::AssemblyFlagsList => Self::assembly_flags_list.parse(self, input), ProductionKind::AssemblyStatement => Self::assembly_statement.parse(self, input), ProductionKind::Block => Self::block.parse(self, input), @@ -5708,6 +7359,7 @@ impl Language { } ProductionKind::DeleteStatement => Self::delete_statement.parse(self, input), ProductionKind::DoWhileStatement => Self::do_while_statement.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), @@ -5750,7 +7402,9 @@ impl Language { ProductionKind::IdentifierPathsList => Self::identifier_paths_list.parse(self, input), ProductionKind::IdentifiersList => Self::identifiers_list.parse(self, input), ProductionKind::IfStatement => Self::if_statement.parse(self, input), + ProductionKind::ImportAlias => Self::import_alias.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::InheritanceTypesList => Self::inheritance_types_list.parse(self, input), @@ -5771,6 +7425,9 @@ impl Language { ProductionKind::NamedArgumentsDeclaration => { Self::named_arguments_declaration.parse(self, input) } + ProductionKind::NamedArgumentsDeclarations => { + Self::named_arguments_declarations.parse(self, input) + } ProductionKind::NamedArgumentsList => Self::named_arguments_list.parse(self, input), ProductionKind::NamedImport => Self::named_import.parse(self, input), ProductionKind::NewExpression => Self::new_expression.parse(self, input), @@ -5804,6 +7461,9 @@ impl Language { ProductionKind::StateVariableDefinition => { Self::state_variable_definition.parse(self, input) } + ProductionKind::StateVariableDefinitionValue => { + Self::state_variable_definition_value.parse(self, input) + } ProductionKind::Statement => Self::statement.parse(self, input), ProductionKind::StatementsList => Self::statements_list.parse(self, input), ProductionKind::StructDefinition => Self::struct_definition.parse(self, input), @@ -5816,11 +7476,15 @@ impl Language { Self::tuple_deconstruction_statement.parse(self, input) } ProductionKind::TupleExpression => Self::tuple_expression.parse(self, input), - ProductionKind::TupleMember => Self::tuple_member.parse(self, input), + ProductionKind::TupleMemberDeconstruction => { + Self::tuple_member_deconstruction.parse(self, input) + } ProductionKind::TupleMembersList => Self::tuple_members_list.parse(self, input), + ProductionKind::TupleValue => Self::tuple_value.parse(self, input), ProductionKind::TupleValuesList => Self::tuple_values_list.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::UnicodeStringLiteralsList => { Self::unicode_string_literals_list.parse(self, input) @@ -5831,9 +7495,11 @@ impl Language { ProductionKind::UnnamedFunctionDefinition => { Self::unnamed_function_definition.parse(self, input) } + ProductionKind::UntypedTupleMember => Self::untyped_tuple_member.parse(self, input), ProductionKind::UserDefinedValueTypeDefinition => { Self::user_defined_value_type_definition.parse(self, input) } + ProductionKind::UsingAlias => Self::using_alias.parse(self, input), ProductionKind::UsingDirective => Self::using_directive.parse(self, input), ProductionKind::UsingDirectiveDeconstruction => { Self::using_directive_deconstruction.parse(self, input) @@ -5847,6 +7513,9 @@ impl Language { ProductionKind::VariableDeclarationStatement => { Self::variable_declaration_statement.parse(self, input) } + ProductionKind::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) @@ -5864,9 +7533,7 @@ impl Language { 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::YulDeclarationStatement => { - Self::yul_declaration_statement.parse(self, input) - } + ProductionKind::YulDefaultCase => Self::yul_default_case.parse(self, input), ProductionKind::YulExpression => Self::yul_expression.parse(self, input), ProductionKind::YulExpressionsList => Self::yul_expressions_list.parse(self, input), ProductionKind::YulForStatement => Self::yul_for_statement.parse(self, input), @@ -5888,9 +7555,15 @@ impl Language { } ProductionKind::YulStatement => Self::yul_statement.parse(self, input), ProductionKind::YulStatementsList => Self::yul_statements_list.parse(self, input), - ProductionKind::YulSwitchCase => Self::yul_switch_case.parse(self, input), ProductionKind::YulSwitchCasesList => Self::yul_switch_cases_list.parse(self, input), ProductionKind::YulSwitchStatement => Self::yul_switch_statement.parse(self, input), + ProductionKind::YulValueCase => Self::yul_value_case.parse(self, input), + ProductionKind::YulVariableDeclarationStatement => { + Self::yul_variable_declaration_statement.parse(self, input) + } + ProductionKind::YulVariableDeclarationValue => { + Self::yul_variable_declaration_value.parse(self, input) + } } } } @@ -5911,8 +7584,8 @@ impl Lexer for Language { (TokenKind::OpenBracket, TokenKind::CloseBracket), (TokenKind::OpenParen, TokenKind::CloseParen), ], - LexicalContext::VersionPragma => &[], - LexicalContext::YulBlock => &[ + LexicalContext::Pragma => &[], + LexicalContext::Yul => &[ (TokenKind::OpenBrace, TokenKind::CloseBrace), (TokenKind::OpenParen, TokenKind::CloseParen), ], @@ -5940,17 +7613,8 @@ impl Lexer for Language { if let Some(kind) = match input.next() { Some('a') => match input.next() { - Some('b') => match input.next() { - Some('i') => scan_chars!(input, 'c', 'o', 'd', 'e', 'r') - .then_some(TokenKind::AbicoderKeyword), - Some('s') => scan_chars!(input, 't', 'r', 'a', 'c', 't') - .then_some(TokenKind::AbstractKeyword), - Some(_) => { - input.undo(); - None - } - None => None, - }, + Some('b') => scan_chars!(input, 's', 't', 'r', 'a', 'c', 't') + .then_some(TokenKind::AbstractKeyword), Some('d') => scan_chars!(input, 'd', 'r', 'e', 's', 's') .then_some(TokenKind::AddressKeyword), Some('f') => { @@ -6011,7 +7675,7 @@ impl Lexer for Language { Some('l') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'l', 'd', 'a', 't', 'a') - .then_some(TokenKind::CalldataKeyword) + .then_some(TokenKind::CallDataKeyword) } else { None } @@ -6071,7 +7735,7 @@ impl Lexer for Language { Some('p') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'y', 'o', 'f') - .then_some(TokenKind::CopyofKeyword) + .then_some(TokenKind::CopyOfKeyword) } else { None } @@ -6146,19 +7810,8 @@ impl Lexer for Language { Some('v') => { scan_chars!(input, 'e', 'n', 't').then_some(TokenKind::EventKeyword) } - Some('x') => match input.next() { - Some('p') => { - scan_chars!(input, 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l') - .then_some(TokenKind::ExperimentalKeyword) - } - Some('t') => scan_chars!(input, 'e', 'r', 'n', 'a', 'l') - .then_some(TokenKind::ExternalKeyword), - Some(_) => { - input.undo(); - None - } - None => None, - }, + Some('x') => scan_chars!(input, 't', 'e', 'r', 'n', 'a', 'l') + .then_some(TokenKind::ExternalKeyword), Some(_) => { input.undo(); None @@ -6328,21 +7981,7 @@ impl Lexer for Language { None => None, }, Some('l') => match input.next() { - Some('e') => match input.next() { - Some('a') => { - if self.version_is_at_least_0_6_0 { - scan_chars!(input, 'v', 'e').then_some(TokenKind::LeaveKeyword) - } else { - None - } - } - Some('t') => Some(TokenKind::LetKeyword), - Some(_) => { - input.undo(); - None - } - None => None, - }, + Some('e') => scan_chars!(input, 't').then_some(TokenKind::LetKeyword), Some('i') => scan_chars!(input, 'b', 'r', 'a', 'r', 'y') .then_some(TokenKind::LibraryKeyword), Some(_) => { @@ -6545,13 +8184,11 @@ impl Lexer for Language { Some('i') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'z', 'e', 'o', 'f') - .then_some(TokenKind::SizeofKeyword) + .then_some(TokenKind::SizeOfKeyword) } else { None } } - Some('o') => scan_chars!(input, 'l', 'i', 'd', 'i', 't', 'y') - .then_some(TokenKind::SolidityKeyword), Some('t') => { match input.next() { Some('a') => scan_chars!(input, 't', 'i', 'c') @@ -6618,13 +8255,13 @@ impl Lexer for Language { Some('d') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'e', 'f') - .then_some(TokenKind::TypedefKeyword) + .then_some(TokenKind::TypeDefKeyword) } else { None } } Some('o') => { - scan_chars!(input, 'f').then_some(TokenKind::TypeofKeyword) + scan_chars!(input, 'f').then_some(TokenKind::TypeOfKeyword) } Some(_) => { input.undo(); @@ -6723,30 +8360,16 @@ impl Lexer for Language { input.set_position(save); if let Some(kind) = match input.next() { - Some('!') => match input.next() { - Some('=') => Some(TokenKind::BangEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Bang) - } - None => Some(TokenKind::Bang), - }, - Some('%') => match input.next() { - Some('=') => Some(TokenKind::PercentEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Percent) - } - None => Some(TokenKind::Percent), - }, + Some('!') => scan_chars!(input, '=').then_some(TokenKind::BangEqual), + Some('%') => scan_chars!(input, '=').then_some(TokenKind::PercentEqual), Some('&') => match input.next() { Some('&') => Some(TokenKind::AmpersandAmpersand), Some('=') => Some(TokenKind::AmpersandEqual), Some(_) => { input.undo(); - Some(TokenKind::Ampersand) + None } - None => Some(TokenKind::Ampersand), + None => None, }, Some('(') => Some(TokenKind::OpenParen), Some(')') => Some(TokenKind::CloseParen), @@ -6755,18 +8378,18 @@ impl Lexer for Language { Some('=') => Some(TokenKind::AsteriskEqual), Some(_) => { input.undo(); - Some(TokenKind::Asterisk) + None } - None => Some(TokenKind::Asterisk), + None => None, }, Some('+') => match input.next() { Some('+') => Some(TokenKind::PlusPlus), Some('=') => Some(TokenKind::PlusEqual), Some(_) => { input.undo(); - Some(TokenKind::Plus) + None } - None => Some(TokenKind::Plus), + None => None, }, Some(',') => Some(TokenKind::Comma), Some('-') => match input.next() { @@ -6774,92 +8397,64 @@ impl Lexer for Language { Some('=') => Some(TokenKind::MinusEqual), Some(_) => { input.undo(); - Some(TokenKind::Minus) + None } - None => Some(TokenKind::Minus), + None => None, }, Some('.') => Some(TokenKind::Period), - Some('/') => match input.next() { - Some('=') => Some(TokenKind::SlashEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Slash) - } - None => Some(TokenKind::Slash), - }, - Some(':') => Some(TokenKind::Colon), + Some('/') => scan_chars!(input, '=').then_some(TokenKind::SlashEqual), Some(';') => Some(TokenKind::Semicolon), Some('<') => match input.next() { - Some('<') => match input.next() { - Some('=') => Some(TokenKind::LessThanLessThanEqual), - Some(_) => { - input.undo(); - Some(TokenKind::LessThanLessThan) - } - None => Some(TokenKind::LessThanLessThan), - }, + Some('<') => { + scan_chars!(input, '=').then_some(TokenKind::LessThanLessThanEqual) + } Some('=') => Some(TokenKind::LessThanEqual), Some(_) => { input.undo(); - Some(TokenKind::LessThan) + None } - None => Some(TokenKind::LessThan), + None => None, }, Some('=') => match input.next() { Some('=') => Some(TokenKind::EqualEqual), Some('>') => Some(TokenKind::EqualGreaterThan), Some(_) => { input.undo(); - Some(TokenKind::Equal) + None } - None => Some(TokenKind::Equal), + None => None, }, Some('>') => match input.next() { Some('=') => Some(TokenKind::GreaterThanEqual), Some('>') => match input.next() { Some('=') => Some(TokenKind::GreaterThanGreaterThanEqual), - Some('>') => match input.next() { - Some('=') => { - Some(TokenKind::GreaterThanGreaterThanGreaterThanEqual) - } - Some(_) => { - input.undo(); - Some(TokenKind::GreaterThanGreaterThanGreaterThan) - } - None => Some(TokenKind::GreaterThanGreaterThanGreaterThan), - }, + Some('>') => scan_chars!(input, '=') + .then_some(TokenKind::GreaterThanGreaterThanGreaterThanEqual), Some(_) => { input.undo(); - Some(TokenKind::GreaterThanGreaterThan) + None } - None => Some(TokenKind::GreaterThanGreaterThan), + None => None, }, Some(_) => { input.undo(); - Some(TokenKind::GreaterThan) + None } - None => Some(TokenKind::GreaterThan), + None => None, }, Some('?') => Some(TokenKind::QuestionMark), Some('[') => Some(TokenKind::OpenBracket), Some(']') => Some(TokenKind::CloseBracket), - Some('^') => match input.next() { - Some('=') => Some(TokenKind::CaretEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Caret) - } - None => Some(TokenKind::Caret), - }, + Some('^') => scan_chars!(input, '=').then_some(TokenKind::CaretEqual), Some('{') => Some(TokenKind::OpenBrace), Some('|') => match input.next() { Some('=') => Some(TokenKind::BarEqual), Some('|') => Some(TokenKind::BarBar), Some(_) => { input.undo(); - Some(TokenKind::Bar) + None } - None => Some(TokenKind::Bar), + None => None, }, Some('}') => Some(TokenKind::CloseBrace), Some('~') => Some(TokenKind::Tilde), @@ -6875,16 +8470,32 @@ impl Lexer for Language { input.set_position(save); longest_match! { + { Ampersand = ampersand } { AsciiStringLiteral = ascii_string_literal } + { Asterisk = asterisk } + { Bang = bang } + { Bar = bar } + { Caret = caret } + { Colon = colon } { DecimalLiteral = decimal_literal } { EndOfLine = end_of_line } + { Equal = equal } { FixedBytesType = fixed_bytes_type } + { GreaterThan = greater_than } + { GreaterThanGreaterThan = greater_than_greater_than } + { GreaterThanGreaterThanGreaterThan = greater_than_greater_than_greater_than } { HexLiteral = hex_literal } { HexStringLiteral = hex_string_literal } + { LessThan = less_than } + { LessThanLessThan = less_than_less_than } + { Minus = minus } { MultilineComment = multiline_comment } + { Percent = percent } + { Plus = plus } { SignedFixedType = signed_fixed_type } { SignedIntegerType = signed_integer_type } { SingleLineComment = single_line_comment } + { Slash = slash } { UnicodeStringLiteral = unicode_string_literal } { UnsignedFixedType = unsigned_fixed_type } { UnsignedIntegerType = unsigned_integer_type } @@ -6892,7 +8503,7 @@ impl Lexer for Language { { Identifier = identifier } } } - LexicalContext::VersionPragma => { + LexicalContext::Pragma => { macro_rules! longest_match { ($( { $kind:ident = $function:ident } )*) => { $( @@ -6905,9 +8516,23 @@ impl Lexer for Language { }; } - if let Some(kind) = scan_chars!(input, 's', 'o', 'l', 'i', 'd', 'i', 't', 'y') - .then_some(TokenKind::SolidityKeyword) - { + if let Some(kind) = match input.next() { + Some('a') => scan_chars!(input, 'b', 'i', 'c', 'o', 'd', 'e', 'r') + .then_some(TokenKind::AbicoderKeyword), + Some('e') => { + scan_chars!(input, 'x', 'p', 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l') + .then_some(TokenKind::ExperimentalKeyword) + } + Some('p') => scan_chars!(input, 'r', 'a', 'g', 'm', 'a') + .then_some(TokenKind::PragmaKeyword), + Some('s') => scan_chars!(input, 'o', 'l', 'i', 'd', 'i', 't', 'y') + .then_some(TokenKind::SolidityKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + } { // Make sure that this is not the start of an identifier if !self.identifier_part(input) { furthest_position = input.position(); @@ -6917,26 +8542,10 @@ impl Lexer for Language { input.set_position(save); if let Some(kind) = match input.next() { - Some('-') => Some(TokenKind::Minus), Some('.') => Some(TokenKind::Period), - Some('<') => match input.next() { - Some('=') => Some(TokenKind::LessThanEqual), - Some(_) => { - input.undo(); - Some(TokenKind::LessThan) - } - None => Some(TokenKind::LessThan), - }, - Some('=') => Some(TokenKind::Equal), - Some('>') => match input.next() { - Some('=') => Some(TokenKind::GreaterThanEqual), - Some(_) => { - input.undo(); - Some(TokenKind::GreaterThan) - } - None => Some(TokenKind::GreaterThan), - }, - Some('^') => Some(TokenKind::Caret), + Some(';') => Some(TokenKind::Semicolon), + Some('<') => scan_chars!(input, '=').then_some(TokenKind::LessThanEqual), + Some('>') => scan_chars!(input, '=').then_some(TokenKind::GreaterThanEqual), Some('|') => scan_chars!(input, '|').then_some(TokenKind::BarBar), Some('~') => Some(TokenKind::Tilde), Some(_) => { @@ -6951,10 +8560,17 @@ impl Lexer for Language { input.set_position(save); longest_match! { + { AsciiStringLiteral = ascii_string_literal } + { Caret = caret } + { Equal = equal } + { GreaterThan = greater_than } + { LessThan = less_than } + { Minus = minus } { VersionPragmaValue = version_pragma_value } + { Identifier = identifier } } } - LexicalContext::YulBlock => { + LexicalContext::Yul => { macro_rules! longest_match { ($( { $kind:ident = $function:ident } )*) => { $( @@ -6968,62 +8584,1097 @@ impl Lexer for Language { } if let Some(kind) = match input.next() { - Some('b') => { - scan_chars!(input, 'r', 'e', 'a', 'k').then_some(TokenKind::BreakKeyword) - } - Some('c') => match input.next() { - Some('a') => scan_chars!(input, 's', 'e').then_some(TokenKind::CaseKeyword), - Some('o') => scan_chars!(input, 'n', 't', 'i', 'n', 'u', 'e') - .then_some(TokenKind::ContinueKeyword), + Some('a') => match input.next() { + Some('b') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 's', 't', 'r', 'a', 'c', 't') + .then_some(TokenKind::YulAbstractKeyword) + } else { + None + } + } + Some('d') => scan_chars!(input, 'd', 'r', 'e', 's', 's') + .then_some(TokenKind::YulAddressKeyword), + Some('f') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'e', 'r') + .then_some(TokenKind::YulAfterKeyword) + } else { + None + } + } + Some('l') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'a', 's') + .then_some(TokenKind::YulAliasKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'o', 'n', 'y', 'm', 'o', 'u', 's') + .then_some(TokenKind::YulAnonymousKeyword) + } else { + None + } + } + Some('p') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'p', 'l', 'y') + .then_some(TokenKind::YulApplyKeyword) + } else { + None + } + } + Some('s') => match input.next() { + Some('s') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'm', 'b', 'l', 'y') + .then_some(TokenKind::YulAssemblyKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulAsKeyword) + } else { + None + } + } + None => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulAsKeyword) + } else { + None + } + } + }, + Some('u') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'o').then_some(TokenKind::YulAutoKeyword) + } else { + None + } + } Some(_) => { input.undo(); None } None => None, }, - Some('d') => scan_chars!(input, 'e', 'f', 'a', 'u', 'l', 't') - .then_some(TokenKind::DefaultKeyword), - Some('f') => match input.next() { - Some('a') => { - scan_chars!(input, 'l', 's', 'e').then_some(TokenKind::FalseKeyword) + Some('b') => match input.next() { + Some('o') => { + if !self.version_is_at_least_0_5_10 { + scan_chars!(input, 'o', 'l').then_some(TokenKind::YulBoolKeyword) + } else { + None + } + } + Some('r') => { + scan_chars!(input, 'e', 'a', 'k').then_some(TokenKind::YulBreakKeyword) + } + Some('y') => { + scan_chars!(input, 't', 'e').then_some(TokenKind::YulByteKeyword) } - Some('o') => scan_chars!(input, 'r').then_some(TokenKind::ForKeyword), - Some('u') => scan_chars!(input, 'n', 'c', 't', 'i', 'o', 'n') - .then_some(TokenKind::FunctionKeyword), Some(_) => { input.undo(); None } None => None, }, - Some('h') => scan_chars!(input, 'e', 'x').then_some(TokenKind::HexKeyword), - Some('i') => scan_chars!(input, 'f').then_some(TokenKind::IfKeyword), - Some('l') => { - if scan_chars!(input, 'e') { - match input.next() { - Some('a') => { - if self.version_is_at_least_0_6_0 { - scan_chars!(input, 'v', 'e') - .then_some(TokenKind::LeaveKeyword) + Some('c') => match input.next() { + Some('a') => match input.next() { + Some('l') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'l', 'd', 'a', 't', 'a') + .then_some(TokenKind::YulCallDataKeyword) + } else { + None + } + } + Some('s') => { + scan_chars!(input, 'e').then_some(TokenKind::YulCaseKeyword) + } + Some('t') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 'h') + .then_some(TokenKind::YulCatchKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('o') => match input.next() { + Some('n') => match input.next() { + Some('s') => { + if scan_chars!(input, 't') { + match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'n', 't') + .then_some(TokenKind::YulConstantKeyword) + } else { + None + } + } + Some('r') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'u', 'c', 't', 'o', 'r') + .then_some(TokenKind::YulConstructorKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('t') => match input.next() { + Some('i') => scan_chars!(input, 'n', 'u', 'e') + .then_some(TokenKind::YulContinueKeyword), + Some('r') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'c', 't') + .then_some(TokenKind::YulContractKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('p') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'y', 'o', 'f') + .then_some(TokenKind::YulCopyOfKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('d') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'y', 's').then_some(TokenKind::YulDaysKeyword) + } else { + None + } + } + Some('e') => match input.next() { + Some('f') => match input.next() { + Some('a') => scan_chars!(input, 'u', 'l', 't') + .then_some(TokenKind::YulDefaultKeyword), + Some('i') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'n', 'e') + .then_some(TokenKind::YulDefineKeyword) } else { None } } - Some('t') => Some(TokenKind::LetKeyword), Some(_) => { input.undo(); None } None => None, + }, + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 't', 'e') + .then_some(TokenKind::YulDeleteKeyword) + } else { + None + } } - } else { + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('o') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulDoKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('e') => match input.next() { + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 's', 'e').then_some(TokenKind::YulElseKeyword) + } else { + None + } + } + Some('m') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 't').then_some(TokenKind::YulEmitKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'u', 'm').then_some(TokenKind::YulEnumKeyword) + } else { + None + } + } + Some('t') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'h', 'e', 'r') + .then_some(TokenKind::YulEtherKeyword) + } else { + None + } + } + Some('v') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'n', 't') + .then_some(TokenKind::YulEventKeyword) + } else { + None + } + } + Some('x') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'e', 'r', 'n', 'a', 'l') + .then_some(TokenKind::YulExternalKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('f') => match input.next() { + Some('a') => { + if scan_chars!(input, 'l') { + match input.next() { + Some('l') => { + if self.version_is_at_least_0_6_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'b', 'a', 'c', 'k') + .then_some(TokenKind::YulFallbackKeyword) + } else { + None + } + } + Some('s') => scan_chars!(input, 'e') + .then_some(TokenKind::YulFalseKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('i') => { + if scan_chars!(input, 'n') { + match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'l') + .then_some(TokenKind::YulFinalKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_0 { + scan_chars!(input, 'e', 'y') + .then_some(TokenKind::YulFinneyKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('o') => scan_chars!(input, 'r').then_some(TokenKind::YulForKeyword), + Some('u') => scan_chars!(input, 'n', 'c', 't', 'i', 'o', 'n') + .then_some(TokenKind::YulFunctionKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('g') => { + if self.version_is_at_least_0_7_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'w', 'e', 'i').then_some(TokenKind::YulGweiKeyword) + } else { + None + } + } + Some('h') => match input.next() { + Some('e') => scan_chars!(input, 'x').then_some(TokenKind::YulHexKeyword), + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'u', 'r', 's') + .then_some(TokenKind::YulHoursKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('i') => match input.next() { + Some('f') => Some(TokenKind::YulIfKeyword), + Some('m') => match input.next() { + Some('m') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'u', 't', 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulImmutableKeyword) + } else { + None + } + } + Some('p') => match input.next() { + Some('l') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'm', 'e', 'n', 't', 's') + .then_some(TokenKind::YulImplementsKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'r', 't') + .then_some(TokenKind::YulImportKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('n') => match input.next() { + Some('d') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'x', 'e', 'd') + .then_some(TokenKind::YulIndexedKeyword) + } else { + None + } + } + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'n', 'e') + .then_some(TokenKind::YulInlineKeyword) + } else { + None + } + } + Some('t') => { + if scan_chars!(input, 'e', 'r') { + match input.next() { + Some('f') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'c', 'e') + .then_some(TokenKind::YulInterfaceKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'l') + .then_some(TokenKind::YulInternalKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some(_) => { + input.undo(); + if !self.version_is_at_least_0_6_8 { + Some(TokenKind::YulInKeyword) + } else { + None + } + } + None => { + if !self.version_is_at_least_0_6_8 { + Some(TokenKind::YulInKeyword) + } else { + None + } + } + }, + Some('s') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulIsKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('l') => match input.next() { + Some('e') => match input.next() { + Some('a') => { + if self.version_is_at_least_0_6_0 { + scan_chars!(input, 'v', 'e') + .then_some(TokenKind::YulLeaveKeyword) + } else { + None + } + } + Some('t') => Some(TokenKind::YulLetKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'b', 'r', 'a', 'r', 'y') + .then_some(TokenKind::YulLibraryKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('m') => match input.next() { + Some('a') => match input.next() { + Some('c') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'r', 'o') + .then_some(TokenKind::YulMacroKeyword) + } else { + None + } + } + Some('p') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'p', 'i', 'n', 'g') + .then_some(TokenKind::YulMappingKeyword) + } else { + None + } + } + Some('t') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 'h') + .then_some(TokenKind::YulMatchKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'm', 'o', 'r', 'y') + .then_some(TokenKind::YulMemoryKeyword) + } else { + None + } + } + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'n', 'u', 't', 'e', 's') + .then_some(TokenKind::YulMinutesKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'd', 'i', 'f', 'i', 'e', 'r') + .then_some(TokenKind::YulModifierKeyword) + } else { + None + } + } + Some('u') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulMutableKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('n') => match input.next() { + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'w').then_some(TokenKind::YulNewKeyword) + } else { + None + } + } + Some('u') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'l', 'l').then_some(TokenKind::YulNullKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('o') => match input.next() { + Some('f') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulOfKeyword) + } else { + None + } + } + Some('v') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'r', 'r', 'i', 'd', 'e') + .then_some(TokenKind::YulOverrideKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('p') => match input.next() { + Some('a') => match input.next() { + Some('r') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 't', 'i', 'a', 'l') + .then_some(TokenKind::YulPartialKeyword) + } else { + None + } + } + Some('y') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulPayableKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('r') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'g', 'm', 'a') + .then_some(TokenKind::YulPragmaKeyword) + } else { + None + } + } + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'v', 'a', 't', 'e') + .then_some(TokenKind::YulPrivateKeyword) + } else { + None + } + } + Some('o') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'm', 'i', 's', 'e') + .then_some(TokenKind::YulPromiseKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('u') => match input.next() { + Some('b') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'l', 'i', 'c') + .then_some(TokenKind::YulPublicKeyword) + } else { + None + } + } + Some('r') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e').then_some(TokenKind::YulPureKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('r') => { + if scan_chars!(input, 'e') { + match input.next() { + Some('c') => { + if self.version_is_at_least_0_6_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'i', 'v', 'e') + .then_some(TokenKind::YulReceiveKeyword) + } else { + None + } + } + Some('f') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'r', 'e', 'n', 'c', 'e') + .then_some(TokenKind::YulReferenceKeyword) + } else { + None + } + } + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'o', 'c', 'a', 't', 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulRelocatableKeyword) + } else { + None + } + } + Some('t') => { + if scan_chars!(input, 'u', 'r', 'n') { + match input.next() { + Some('s') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulReturnsKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + Some(TokenKind::YulReturnKeyword) + } + None => Some(TokenKind::YulReturnKeyword), + } + } else { + None + } + } + Some('v') => scan_chars!(input, 'e', 'r', 't') + .then_some(TokenKind::YulRevertKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('s') => match input.next() { + Some('e') => match input.next() { + Some('a') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'l', 'e', 'd') + .then_some(TokenKind::YulSealedKeyword) + } else { + None + } + } + Some('c') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'o', 'n', 'd', 's') + .then_some(TokenKind::YulSecondsKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('i') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'z', 'e', 'o', 'f') + .then_some(TokenKind::YulSizeOfKeyword) + } else { + None + } + } + Some('t') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'i', 'c') + .then_some(TokenKind::YulStaticKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'r', 'a', 'g', 'e') + .then_some(TokenKind::YulStorageKeyword) + } else { + None + } + } + Some('r') => match input.next() { + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'n', 'g') + .then_some(TokenKind::YulStringKeyword) + } else { + None + } + } + Some('u') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 't') + .then_some(TokenKind::YulStructKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('u') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'p', 'p', 'o', 'r', 't', 's') + .then_some(TokenKind::YulSupportsKeyword) + } else { + None + } + } + Some('w') => scan_chars!(input, 'i', 't', 'c', 'h') + .then_some(TokenKind::YulSwitchKeyword), + Some('z') => { + if !self.version_is_at_least_0_7_0 { + scan_chars!(input, 'a', 'b', 'o') + .then_some(TokenKind::YulSzaboKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('t') => match input.next() { + Some('h') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'r', 'o', 'w') + .then_some(TokenKind::YulThrowKeyword) + } else { + None + } + } + Some('r') => match input.next() { + Some('u') => { + scan_chars!(input, 'e').then_some(TokenKind::YulTrueKeyword) + } + Some('y') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulTryKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('y') => { + if scan_chars!(input, 'p', 'e') { + match input.next() { + Some('d') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'f') + .then_some(TokenKind::YulTypeDefKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'f') + .then_some(TokenKind::YulTypeOfKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulTypeKeyword) + } else { + None + } + } + None => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulTypeKeyword) + } else { + None + } + } + } + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('u') => match input.next() { + Some('n') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 'h', 'e', 'c', 'k', 'e', 'd') + .then_some(TokenKind::YulUncheckedKeyword) + } else { + None + } + } + Some('s') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'n', 'g') + .then_some(TokenKind::YulUsingKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('v') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_6_5 { + scan_chars!(input, 'r').then_some(TokenKind::YulVarKeyword) + } else { + None + } + } + Some('i') => match input.next() { + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'w').then_some(TokenKind::YulViewKeyword) + } else { + None + } + } + Some('r') => { + if self.version_is_at_least_0_6_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 't', 'u', 'a', 'l') + .then_some(TokenKind::YulVirtualKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('w') => match input.next() { + Some('e') => match input.next() { + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'k', 's') + .then_some(TokenKind::YulWeeksKeyword) + } else { + None + } + } + Some('i') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulWeiKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('h') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'l', 'e') + .then_some(TokenKind::YulWhileKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('y') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'a', 'r', 's') + .then_some(TokenKind::YulYearsKeyword) + } else { None } - } - Some('s') => scan_chars!(input, 'w', 'i', 't', 'c', 'h') - .then_some(TokenKind::SwitchKeyword), - Some('t') => { - scan_chars!(input, 'r', 'u', 'e').then_some(TokenKind::TrueKeyword) } Some(_) => { input.undo(); @@ -7062,9 +9713,14 @@ impl Lexer for Language { longest_match! { { AsciiStringLiteral = ascii_string_literal } { HexStringLiteral = hex_string_literal } + { YulBytesKeyword = yul_bytes_keyword } { YulDecimalLiteral = yul_decimal_literal } + { YulFixedKeyword = yul_fixed_keyword } { YulHexLiteral = yul_hex_literal } { YulIdentifier = yul_identifier } + { YulIntKeyword = yul_int_keyword } + { YulUfixedKeyword = yul_ufixed_keyword } + { YulUintKeyword = yul_uint_keyword } } } } diff --git a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs index 6843dbdf28..b8081e6258 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs @@ -23,6 +23,7 @@ pub enum ProductionKind { ArrayExpression, ArrayValuesList, AsciiStringLiteralsList, + AssemblyFlagsDeclaration, AssemblyFlagsList, AssemblyStatement, Block, @@ -42,6 +43,7 @@ pub enum ProductionKind { DeconstructionImportSymbolsList, DeleteStatement, DoWhileStatement, + ElseBranch, EmitStatement, EndOfFileTrivia, EnumDefinition, @@ -70,7 +72,9 @@ pub enum ProductionKind { IdentifierPathsList, IdentifiersList, IfStatement, + ImportAlias, ImportDirective, + IndexAccessEnd, InheritanceSpecifier, InheritanceType, InheritanceTypesList, @@ -87,6 +91,7 @@ pub enum ProductionKind { ModifierInvocation, NamedArgument, NamedArgumentsDeclaration, + NamedArgumentsDeclarations, NamedArgumentsList, NamedImport, NewExpression, @@ -106,6 +111,7 @@ pub enum ProductionKind { SourceUnitMembersList, StateVariableAttributesList, StateVariableDefinition, + StateVariableDefinitionValue, Statement, StatementsList, StructDefinition, @@ -116,16 +122,20 @@ pub enum ProductionKind { TryStatement, TupleDeconstructionStatement, TupleExpression, - TupleMember, + TupleMemberDeconstruction, TupleMembersList, + TupleValue, TupleValuesList, TypeExpression, TypeName, + TypedTupleMember, UncheckedBlock, UnicodeStringLiteralsList, UnnamedFunctionAttributesList, UnnamedFunctionDefinition, + UntypedTupleMember, UserDefinedValueTypeDefinition, + UsingAlias, UsingDirective, UsingDirectiveDeconstruction, UsingDirectivePath, @@ -133,6 +143,7 @@ pub enum ProductionKind { UsingDirectiveSymbolsList, VariableDeclaration, VariableDeclarationStatement, + VariableDeclarationValue, VersionPragma, VersionPragmaExpression, VersionPragmaExpressionsList, @@ -142,7 +153,7 @@ pub enum ProductionKind { YulBlock, YulBreakStatement, YulContinueStatement, - YulDeclarationStatement, + YulDefaultCase, YulExpression, YulExpressionsList, YulForStatement, @@ -156,9 +167,11 @@ pub enum ProductionKind { YulReturnsDeclaration, YulStatement, YulStatementsList, - YulSwitchCase, YulSwitchCasesList, YulSwitchStatement, + YulValueCase, + YulVariableDeclarationStatement, + YulVariableDeclarationValue, } #[derive( @@ -182,6 +195,7 @@ pub enum RuleKind { ArrayTypeName, ArrayValuesList, AsciiStringLiteralsList, + AssemblyFlagsDeclaration, AssemblyFlagsList, AssemblyStatement, BinaryExpression, @@ -203,6 +217,7 @@ pub enum RuleKind { DeconstructionImportSymbolsList, DeleteStatement, DoWhileStatement, + ElseBranch, EmitStatement, EndOfFileTrivia, EnumDefinition, @@ -232,7 +247,9 @@ pub enum RuleKind { IdentifierPathsList, IdentifiersList, IfStatement, + ImportAlias, ImportDirective, + IndexAccessEnd, IndexAccessExpression, InheritanceSpecifier, InheritanceType, @@ -251,6 +268,7 @@ pub enum RuleKind { ModifierInvocation, NamedArgument, NamedArgumentsDeclaration, + NamedArgumentsDeclarations, NamedArgumentsList, NamedImport, NewExpression, @@ -270,6 +288,7 @@ pub enum RuleKind { SourceUnitMembersList, StateVariableAttributesList, StateVariableDefinition, + StateVariableDefinitionValue, Statement, StatementsList, StructDefinition, @@ -280,18 +299,22 @@ pub enum RuleKind { TryStatement, TupleDeconstructionStatement, TupleExpression, - TupleMember, + TupleMemberDeconstruction, TupleMembersList, + TupleValue, TupleValuesList, TypeExpression, TypeName, + TypedTupleMember, UnaryPostfixExpression, UnaryPrefixExpression, UncheckedBlock, UnicodeStringLiteralsList, UnnamedFunctionAttributesList, UnnamedFunctionDefinition, + UntypedTupleMember, UserDefinedValueTypeDefinition, + UsingAlias, UsingDirective, UsingDirectiveDeconstruction, UsingDirectivePath, @@ -299,6 +322,7 @@ pub enum RuleKind { UsingDirectiveSymbolsList, VariableDeclaration, VariableDeclarationStatement, + VariableDeclarationValue, VersionPragma, VersionPragmaBinaryExpression, VersionPragmaExpression, @@ -310,7 +334,7 @@ pub enum RuleKind { YulBlock, YulBreakStatement, YulContinueStatement, - YulDeclarationStatement, + YulDefaultCase, YulExpression, YulExpressionsList, YulForStatement, @@ -325,9 +349,11 @@ pub enum RuleKind { YulReturnsDeclaration, YulStatement, YulStatementsList, - YulSwitchCase, YulSwitchCasesList, YulSwitchStatement, + YulValueCase, + YulVariableDeclarationStatement, + YulVariableDeclarationValue, } impl RuleKind { @@ -381,7 +407,7 @@ pub enum TokenKind { BoolKeyword, BreakKeyword, ByteKeyword, - CalldataKeyword, + CallDataKeyword, Caret, CaretEqual, CaseKeyword, @@ -396,7 +422,7 @@ pub enum TokenKind { ConstructorKeyword, ContinueKeyword, ContractKeyword, - CopyofKeyword, + CopyOfKeyword, DaysKeyword, DecimalLiteral, DefaultKeyword, @@ -446,7 +472,6 @@ pub enum TokenKind { InterfaceKeyword, InternalKeyword, IsKeyword, - LeaveKeyword, LessThan, LessThanEqual, LessThanLessThan, @@ -498,7 +523,7 @@ pub enum TokenKind { SignedFixedType, SignedIntegerType, SingleLineComment, - SizeofKeyword, + SizeOfKeyword, Slash, SlashEqual, SolidityKeyword, @@ -513,9 +538,9 @@ pub enum TokenKind { Tilde, TrueKeyword, TryKeyword, + TypeDefKeyword, TypeKeyword, - TypedefKeyword, - TypeofKeyword, + TypeOfKeyword, UncheckedKeyword, UnicodeStringLiteral, UnsignedFixedType, @@ -530,9 +555,116 @@ pub enum TokenKind { WhileKeyword, Whitespace, YearsKeyword, + YulAbstractKeyword, + YulAddressKeyword, + YulAfterKeyword, + YulAliasKeyword, + YulAnonymousKeyword, + YulApplyKeyword, + YulAsKeyword, + YulAssemblyKeyword, + YulAutoKeyword, + YulBoolKeyword, + YulBreakKeyword, + YulByteKeyword, + YulBytesKeyword, + YulCallDataKeyword, + YulCaseKeyword, + YulCatchKeyword, + YulConstantKeyword, + YulConstructorKeyword, + YulContinueKeyword, + YulContractKeyword, + YulCopyOfKeyword, + YulDaysKeyword, YulDecimalLiteral, + YulDefaultKeyword, + YulDefineKeyword, + YulDeleteKeyword, + YulDoKeyword, + YulElseKeyword, + YulEmitKeyword, + YulEnumKeyword, + YulEtherKeyword, + YulEventKeyword, + YulExternalKeyword, + YulFallbackKeyword, + YulFalseKeyword, + YulFinalKeyword, + YulFinneyKeyword, + YulFixedKeyword, + YulForKeyword, + YulFunctionKeyword, + YulGweiKeyword, + YulHexKeyword, YulHexLiteral, + YulHoursKeyword, YulIdentifier, + YulIfKeyword, + YulImmutableKeyword, + YulImplementsKeyword, + YulImportKeyword, + YulInKeyword, + YulIndexedKeyword, + YulInlineKeyword, + YulIntKeyword, + YulInterfaceKeyword, + YulInternalKeyword, + YulIsKeyword, + YulLeaveKeyword, + YulLetKeyword, + YulLibraryKeyword, + YulMacroKeyword, + YulMappingKeyword, + YulMatchKeyword, + YulMemoryKeyword, + YulMinutesKeyword, + YulModifierKeyword, + YulMutableKeyword, + YulNewKeyword, + YulNullKeyword, + YulOfKeyword, + YulOverrideKeyword, + YulPartialKeyword, + YulPayableKeyword, + YulPragmaKeyword, + YulPrivateKeyword, + YulPromiseKeyword, + YulPublicKeyword, + YulPureKeyword, + YulReceiveKeyword, + YulReferenceKeyword, + YulRelocatableKeyword, + YulReturnKeyword, + YulReturnsKeyword, + YulRevertKeyword, + YulSealedKeyword, + YulSecondsKeyword, + YulSizeOfKeyword, + YulStaticKeyword, + YulStorageKeyword, + YulStringKeyword, + YulStructKeyword, + YulSupportsKeyword, + YulSwitchKeyword, + YulSzaboKeyword, + YulThrowKeyword, + YulTrueKeyword, + YulTryKeyword, + YulTypeDefKeyword, + YulTypeKeyword, + YulTypeOfKeyword, + YulUfixedKeyword, + YulUintKeyword, + YulUncheckedKeyword, + YulUsingKeyword, + YulVarKeyword, + YulViewKeyword, + YulVirtualKeyword, + YulWeeksKeyword, + YulWeiKeyword, + YulWhileKeyword, + YulYearsKeyword, } #[derive(strum_macros::FromRepr)] @@ -541,8 +673,8 @@ pub enum TokenKind { #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] pub enum LexicalContext { Default, - VersionPragma, - YulBlock, + Pragma, + Yul, } /// Marker trait for type-level [`LexicalContext`] variants. @@ -560,16 +692,16 @@ pub mod LexicalContextType { LexicalContext::Default } } - pub struct VersionPragma {} - impl IsLexicalContext for VersionPragma { + pub struct Pragma {} + impl IsLexicalContext for Pragma { fn value() -> LexicalContext { - LexicalContext::VersionPragma + LexicalContext::Pragma } } - pub struct YulBlock {} - impl IsLexicalContext for YulBlock { + pub struct Yul {} + impl IsLexicalContext for Yul { fn value() -> LexicalContext { - LexicalContext::YulBlock + LexicalContext::Yul } } } diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index a1704a847c..3a0e16f080 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -21,13 +21,16 @@ use super::napi::napi_parse_output::ParseOutput as NAPIParseOutput; #[cfg_attr(feature = "slang_napi_interfaces", napi(namespace = "language"))] pub struct Language { pub(crate) version: Version, + pub(crate) version_is_at_least_0_4_14: bool, pub(crate) version_is_at_least_0_4_21: bool, pub(crate) version_is_at_least_0_4_22: bool, pub(crate) version_is_at_least_0_5_0: bool, pub(crate) version_is_at_least_0_5_3: bool, + pub(crate) version_is_at_least_0_5_10: bool, pub(crate) version_is_at_least_0_6_0: bool, pub(crate) version_is_at_least_0_6_2: bool, pub(crate) version_is_at_least_0_6_5: bool, + pub(crate) version_is_at_least_0_6_8: bool, pub(crate) version_is_at_least_0_6_11: bool, pub(crate) version_is_at_least_0_7_0: bool, pub(crate) version_is_at_least_0_7_1: bool, @@ -142,13 +145,16 @@ impl Language { pub fn new(version: Version) -> std::result::Result { if Self::SUPPORTED_VERSIONS.binary_search(&version).is_ok() { Ok(Self { + version_is_at_least_0_4_14: Version::new(0, 4, 14) <= version, version_is_at_least_0_4_21: Version::new(0, 4, 21) <= version, version_is_at_least_0_4_22: Version::new(0, 4, 22) <= version, version_is_at_least_0_5_0: Version::new(0, 5, 0) <= version, version_is_at_least_0_5_3: Version::new(0, 5, 3) <= version, + version_is_at_least_0_5_10: Version::new(0, 5, 10) <= version, version_is_at_least_0_6_0: Version::new(0, 6, 0) <= version, version_is_at_least_0_6_2: Version::new(0, 6, 2) <= version, version_is_at_least_0_6_5: Version::new(0, 6, 5) <= version, + version_is_at_least_0_6_8: Version::new(0, 6, 8) <= version, version_is_at_least_0_6_11: Version::new(0, 6, 11) <= version, version_is_at_least_0_7_0: Version::new(0, 7, 0) <= version, version_is_at_least_0_7_1: Version::new(0, 7, 1) <= version, @@ -178,11 +184,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn abi_coder_pragma(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::AbicoderKeyword, ))?; - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::Identifier, ))?; @@ -193,27 +199,18 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn address_type(&self, input: &mut ParserContext) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AddressKeyword, - ))?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::PayableKeyword, - ), - ))?; - seq.finish() - }); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( input, - TokenKind::PayableKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) + TokenKind::AddressKeyword, + ))?; + seq.elem(OptionalHelper::transform( + self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ), + ))?; + seq.finish() }) .with_kind(RuleKind::AddressType) } @@ -300,57 +297,69 @@ impl Language { .with_kind(RuleKind::AsciiStringLiteralsList) } + #[allow(unused_assignments, unused_parens)] + fn assembly_flags_declaration(&self, input: &mut ParserContext) -> ParserResult { + 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( + self.assembly_flags_list(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() + }) + .with_kind(RuleKind::AssemblyFlagsDeclaration) + } + #[allow(unused_assignments, unused_parens)] fn assembly_flags_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::Default>( + OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::AsciiStringLiteral, ) }, TokenKind::Comma, - ) + )) .with_kind(RuleKind::AssemblyFlagsList) } #[allow(unused_assignments, unused_parens)] fn assembly_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::AssemblyKeyword, ))?; seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::AsciiStringLiteral, ), ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenParen, - ))?; - seq.elem( - self.assembly_flags_list(input) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, - ))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform( + self.assembly_flags_declaration(input), + ))?; seq.elem(self.yul_block(input))?; seq.finish() }) @@ -504,10 +513,7 @@ impl Language { ChoiceHelper::run(input, |mut choice, input| { let result = self.modifier_invocation(input); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::InternalKeyword, - ); + let result = self.override_specifier(input); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, @@ -631,34 +637,32 @@ impl Language { choice.consider(input, result)?; let result = self.function_definition(input); choice.consider(input, result)?; - let result = self.modifier_definition(input); - choice.consider(input, result)?; - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - let result = self.event_definition(input); - choice.consider(input, result)?; - let result = self.state_variable_definition(input); - choice.consider(input, result)?; if self.version_is_at_least_0_4_22 { let result = self.constructor_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.fallback_function_definition(input); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { let result = self.unnamed_function_definition(input); choice.consider(input, result)?; } + let result = self.modifier_definition(input); + choice.consider(input, result)?; + let result = self.struct_definition(input); + choice.consider(input, result)?; + let result = self.enum_definition(input); + choice.consider(input, result)?; + let result = self.event_definition(input); + choice.consider(input, result)?; + let result = self.state_variable_definition(input); + choice.consider(input, result)?; if self.version_is_at_least_0_8_4 { let result = self.error_definition(input); choice.consider(input, result)?; @@ -685,9 +689,30 @@ impl Language { |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::DaysKeyword, + TokenKind::WeiKeyword, ); choice.consider(input, result)?; + if self.version_is_at_least_0_6_11 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::GweiKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::SzaboKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::FinneyKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::EtherKeyword, @@ -695,7 +720,7 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::HoursKeyword, + TokenKind::SecondsKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( @@ -705,17 +730,17 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::SecondsKeyword, + TokenKind::HoursKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeeksKeyword, + TokenKind::DaysKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeiKeyword, + TokenKind::WeeksKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { @@ -725,31 +750,6 @@ impl Language { ); choice.consider(input, result)?; } - if self.version_is_at_least_0_6_11 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::GweiKeyword, - ); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_7_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::FinneyKeyword, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::SzaboKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }); - choice.consider(input, result)?; - } choice.finish(input) }, )))?; @@ -803,17 +803,7 @@ impl Language { input, TokenKind::Identifier, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.import_alias(input)))?; seq.finish() }) .with_kind(RuleKind::DeconstructionImportSymbol) @@ -821,12 +811,12 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn deconstruction_import_symbols_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::Default>( + OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, |input| self.deconstruction_import_symbol(input), TokenKind::Comma, - ) + )) .with_kind(RuleKind::DeconstructionImportSymbolsList) } @@ -912,6 +902,19 @@ impl Language { .with_kind(RuleKind::DoWhileStatement) } + #[allow(unused_assignments, unused_parens)] + fn else_branch(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::ElseKeyword, + ))?; + seq.elem(self.statement(input))?; + seq.finish() + }) + .with_kind(RuleKind::ElseBranch) + } + #[allow(unused_assignments, unused_parens)] fn emit_statement(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_4_21 { @@ -1208,19 +1211,19 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn experimental_pragma(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::ExperimentalKeyword, ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::AsciiStringLiteral, + TokenKind::Identifier, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::Identifier, + TokenKind::AsciiStringLiteral, ); choice.consider(input, result)?; choice.finish(input) @@ -1232,7 +1235,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn expression(&self, input: &mut ParserContext) -> ParserResult { - let parse_assignment_operator = |input: &mut ParserContext| { + let parse_assignment_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 1u8, @@ -1302,7 +1305,7 @@ impl Language { }), ) }; - let parse_conditional_operator = |input: &mut ParserContext| { + let parse_conditional_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::ConditionalExpression, 3u8, @@ -1321,7 +1324,7 @@ impl Language { }), ) }; - let parse_or_operator = |input: &mut ParserContext| { + let parse_or_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 5u8, @@ -1332,7 +1335,7 @@ impl Language { ), ) }; - let parse_and_operator = |input: &mut ParserContext| { + let parse_and_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 7u8, @@ -1343,7 +1346,7 @@ impl Language { ), ) }; - let parse_equality_comparison_operator = |input: &mut ParserContext| { + let parse_equality_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 9u8, @@ -1363,7 +1366,7 @@ impl Language { }), ) }; - let parse_order_comparison_operator = |input: &mut ParserContext| { + let parse_comparison_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 11u8, @@ -1393,7 +1396,7 @@ impl Language { }), ) }; - let parse_bitwise_or_operator = |input: &mut ParserContext| { + let parse_bitwise_or_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 13u8, @@ -1401,7 +1404,7 @@ impl Language { self.parse_token_with_trivia::(input, TokenKind::Bar), ) }; - let parse_bitwise_x_or_operator = |input: &mut ParserContext| { + let parse_bitwise_xor_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 15u8, @@ -1412,7 +1415,7 @@ impl Language { ), ) }; - let parse_bitwise_and_operator = |input: &mut ParserContext| { + let parse_bitwise_and_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 17u8, @@ -1423,7 +1426,7 @@ impl Language { ), ) }; - let parse_shift_operator = |input: &mut ParserContext| { + let parse_shift_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 19u8, @@ -1448,7 +1451,7 @@ impl Language { }), ) }; - let parse_add_sub_operator = |input: &mut ParserContext| { + let parse_additive_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 21u8, @@ -1468,7 +1471,7 @@ impl Language { }), ) }; - let parse_mul_div_mod_operator = |input: &mut ParserContext| { + let parse_multiplicative_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 23u8, @@ -1493,29 +1496,55 @@ impl Language { }), ) }; - let parse_exponentiation_operator_removed_from_0_6_0 = |input: &mut ParserContext| { + let parse_exponentiation_expression_removed_from_0_6_0 = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 25u8, 25u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ), + 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) + }), ) }; - let parse_exponentiation_operator_introduced_from_0_6_0 = |input: &mut ParserContext| { + let parse_exponentiation_expression_introduced_from_0_6_0 = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::BinaryExpression, 27u8 + 1, 27u8, - self.parse_token_with_trivia::( - input, - TokenKind::AsteriskAsterisk, - ), + 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) + }), ) }; - let parse_unary_postfix_operator = |input: &mut ParserContext| { + let parse_postfix_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::UnaryPostfixExpression, 29u8, @@ -1534,51 +1563,184 @@ impl Language { }), ) }; - let parse_unary_prefix_operator = |input: &mut ParserContext| { + let parse_prefix_expression_removed_from_0_5_0 = |input: &mut ParserContext| { PrecedenceHelper::to_prefix_operator( RuleKind::UnaryPrefixExpression, 31u8, 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) - }), - ) - }; - let parse_function_call_operator = |input: &mut ParserContext| { - PrecedenceHelper::to_postfix_operator( - RuleKind::FunctionCallExpression, + let result = 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)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Plus, + ); + choice.consider(input, result)?; + choice.finish(input) + }); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_5_0 { + let result = 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)?; + choice.finish(input) + }); + choice.consider(input, result)?; + } + choice.finish(input) + }), + ) + }; + let parse_prefix_expression_introduced_from_0_5_0 = |input: &mut ParserContext| { + PrecedenceHelper::to_prefix_operator( + RuleKind::UnaryPrefixExpression, 33u8, + ChoiceHelper::run(input, |mut choice, input| { + if !self.version_is_at_least_0_5_0 { + let result = 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)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Plus, + ); + choice.consider(input, result)?; + choice.finish(input) + }); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_5_0 { + let result = 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)?; + choice.finish(input) + }); + choice.consider(input, result)?; + } + choice.finish(input) + }), + ) + }; + let parse_function_call_expression = |input: &mut ParserContext| { + PrecedenceHelper::to_postfix_operator( + RuleKind::FunctionCallExpression, + 35u8, SequenceHelper::run(|mut seq| { if self.version_is_at_least_0_6_2 { seq.elem(OptionalHelper::transform(self.function_call_options(input)))?; @@ -1588,10 +1750,10 @@ impl Language { }), ) }; - let parse_member_access_operator = |input: &mut ParserContext| { + let parse_member_access_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::MemberAccessExpression, - 35u8, + 37u8, SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, @@ -1614,10 +1776,10 @@ impl Language { }), ) }; - let parse_index_access_operator = |input: &mut ParserContext| { + let parse_index_access_expression = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::IndexAccessExpression, - 37u8, + 39u8, SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBracket); let input = delim_guard.ctx(); @@ -1628,16 +1790,7 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::Colon, - ), - )?; - seq.elem(OptionalHelper::transform(self.expression(input)))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.index_access_end(input)))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -1657,8 +1810,14 @@ impl Language { }; let prefix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_unary_prefix_operator(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)?; + } + if self.version_is_at_least_0_5_0 { + let result = parse_prefix_expression_introduced_from_0_5_0(input); + choice.consider(input, result)?; + } choice.finish(input) }) }; @@ -1668,29 +1827,15 @@ impl Language { choice.consider(input, result)?; let result = self.tuple_expression(input); choice.consider(input, result)?; + if self.version_is_at_least_0_5_3 { + let result = self.type_expression(input); + choice.consider(input, result)?; + } let result = self.array_expression(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::TrueKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::FalseKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.hex_number_expression(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.decimal_number_expression(input); - choice.consider(input, result)?; - let result = self.hex_number_expression(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.decimal_number_expression(input); choice.consider(input, result)?; let result = ChoiceHelper::run(input, |mut choice, input| { let result = self.hex_string_literals_list(input); @@ -1710,6 +1855,13 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::StringKeyword, @@ -1717,6 +1869,11 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::FixedBytesType, @@ -1742,39 +1899,38 @@ impl Language { TokenKind::UnsignedFixedType, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::TrueKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::FalseKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Identifier, ); choice.consider(input, result)?; - if self.version_is_at_least_0_5_3 { - let result = self.type_expression(input); - choice.consider(input, result)?; - } choice.finish(input) }) }; let postfix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_conditional_operator(input); + let result = parse_conditional_expression(input); choice.consider(input, result)?; - let result = parse_unary_postfix_operator(input); + let result = parse_postfix_expression(input); choice.consider(input, result)?; - let result = parse_function_call_operator(input); + let result = parse_function_call_expression(input); choice.consider(input, result)?; - let result = parse_member_access_operator(input); + let result = parse_member_access_expression(input); choice.consider(input, result)?; - let result = parse_index_access_operator(input); + let result = parse_index_access_expression(input); choice.consider(input, result)?; choice.finish(input) }) @@ -1793,34 +1949,34 @@ impl Language { }; let binary_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_assignment_operator(input); + let result = parse_assignment_expression(input); choice.consider(input, result)?; - let result = parse_or_operator(input); + let result = parse_or_expression(input); choice.consider(input, result)?; - let result = parse_and_operator(input); + let result = parse_and_expression(input); choice.consider(input, result)?; - let result = parse_equality_comparison_operator(input); + let result = parse_equality_expression(input); choice.consider(input, result)?; - let result = parse_order_comparison_operator(input); + let result = parse_comparison_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_or_operator(input); + let result = parse_bitwise_or_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_x_or_operator(input); + let result = parse_bitwise_xor_expression(input); choice.consider(input, result)?; - let result = parse_bitwise_and_operator(input); + let result = parse_bitwise_and_expression(input); choice.consider(input, result)?; - let result = parse_shift_operator(input); + let result = parse_shift_expression(input); choice.consider(input, result)?; - let result = parse_add_sub_operator(input); + let result = parse_additive_expression(input); choice.consider(input, result)?; - let result = parse_mul_div_mod_operator(input); + let result = parse_multiplicative_expression(input); choice.consider(input, result)?; if !self.version_is_at_least_0_6_0 { - let result = parse_exponentiation_operator_removed_from_0_6_0(input); + 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_operator_introduced_from_0_6_0(input); + let result = parse_exponentiation_expression_introduced_from_0_6_0(input); choice.consider(input, result)?; } choice.finish(input) @@ -1928,13 +2084,13 @@ impl Language { ))?; seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -1962,15 +2118,11 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); + choice.consider(input, result)?; + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); choice.consider(input, result)?; let result = self .parse_token_with_trivia::( @@ -2021,6 +2173,13 @@ impl Language { choice.consider(input, result)?; let result = self.override_specifier(input); choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ConstantKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::ExternalKeyword, @@ -2056,13 +2215,6 @@ impl Language { TokenKind::ViewKeyword, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_5_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ConstantKeyword, - ); - choice.consider(input, result)?; - } if self.version_is_at_least_0_6_0 { let result = self.parse_token_with_trivia::( input, @@ -2078,18 +2230,19 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn function_call_options(&self, input: &mut ParserContext) -> ParserResult { - ChoiceHelper::run(input, |mut choice, input| { - if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { - let result = - OneOrMoreHelper::run(input, |input| self.named_arguments_declaration(input)); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_0 { - let result = self.named_arguments_declaration(input); - choice.consider(input, result)?; - } - choice.finish(input) - }) + if self.version_is_at_least_0_6_2 { + SequenceHelper::run(|mut seq| { + seq.elem(self.named_arguments_declaration(input))?; + if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { + seq.elem(OptionalHelper::transform( + self.named_arguments_declarations(input), + ))?; + } + seq.finish() + }) + } else { + ParserResult::disabled() + } .with_kind(RuleKind::FunctionCallOptions) } @@ -2124,13 +2277,13 @@ impl Language { ))?; seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -2213,9 +2366,33 @@ impl Language { |mut choice, input| { let result = self.parse_token_with_trivia::( input, - TokenKind::DaysKeyword, + TokenKind::WeiKeyword, ); choice.consider(input, result)?; + if self.version_is_at_least_0_6_11 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::GweiKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::SzaboKeyword, + ); + choice.consider(input, result)?; + } + if !self.version_is_at_least_0_7_0 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::FinneyKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::EtherKeyword, @@ -2223,7 +2400,7 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::HoursKeyword, + TokenKind::SecondsKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( @@ -2233,17 +2410,17 @@ impl Language { choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::SecondsKeyword, + TokenKind::HoursKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeeksKeyword, + TokenKind::DaysKeyword, ); choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, - TokenKind::WeiKeyword, + TokenKind::WeeksKeyword, ); choice.consider(input, result)?; if !self.version_is_at_least_0_5_0 { @@ -2254,32 +2431,6 @@ impl Language { ); choice.consider(input, result)?; } - if self.version_is_at_least_0_6_11 { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::GweiKeyword, - ); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_7_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::FinneyKeyword, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::SzaboKeyword, - ); - choice.consider(input, result)?; - choice.finish(input) - }); - choice.consider(input, result)?; - } choice.finish(input) }, )))?; @@ -2373,19 +2524,28 @@ impl Language { seq.finish() }))?; seq.elem(self.statement(input))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::ElseKeyword, - ))?; - seq.elem(self.statement(input))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.else_branch(input)))?; seq.finish() }) .with_kind(RuleKind::IfStatement) } + #[allow(unused_assignments, unused_parens)] + fn import_alias(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::AsKeyword, + ))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Identifier, + ))?; + seq.finish() + }) + .with_kind(RuleKind::ImportAlias) + } + #[allow(unused_assignments, unused_parens)] fn import_directive(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2422,6 +2582,21 @@ impl Language { .with_kind(RuleKind::ImportDirective) } + #[allow(unused_assignments, unused_parens)] + fn index_access_end(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem( + self.parse_token_with_trivia::( + input, + TokenKind::Colon, + ), + )?; + seq.elem(OptionalHelper::transform(self.expression(input)))?; + seq.finish() + }) + .with_kind(RuleKind::IndexAccessEnd) + } + #[allow(unused_assignments, unused_parens)] fn inheritance_specifier(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2503,34 +2678,32 @@ impl Language { choice.consider(input, result)?; let result = self.function_definition(input); choice.consider(input, result)?; - let result = self.modifier_definition(input); - choice.consider(input, result)?; - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - let result = self.event_definition(input); - choice.consider(input, result)?; - let result = self.state_variable_definition(input); - choice.consider(input, result)?; if self.version_is_at_least_0_4_22 { let result = self.constructor_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.fallback_function_definition(input); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { let result = self.unnamed_function_definition(input); choice.consider(input, result)?; } + let result = self.modifier_definition(input); + choice.consider(input, result)?; + let result = self.struct_definition(input); + choice.consider(input, result)?; + let result = self.enum_definition(input); + choice.consider(input, result)?; + let result = self.event_definition(input); + choice.consider(input, result)?; + let result = self.state_variable_definition(input); + choice.consider(input, result)?; if self.version_is_at_least_0_8_4 { let result = self.error_definition(input); choice.consider(input, result)?; @@ -2615,34 +2788,32 @@ impl Language { choice.consider(input, result)?; let result = self.function_definition(input); choice.consider(input, result)?; - let result = self.modifier_definition(input); - choice.consider(input, result)?; - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - let result = self.event_definition(input); - choice.consider(input, result)?; - let result = self.state_variable_definition(input); - choice.consider(input, result)?; if self.version_is_at_least_0_4_22 { let result = self.constructor_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.fallback_function_definition(input); - choice.consider(input, result)?; - let result = self.receive_function_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.receive_function_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.fallback_function_definition(input); choice.consider(input, result)?; } if !self.version_is_at_least_0_6_0 { let result = self.unnamed_function_definition(input); choice.consider(input, result)?; } + let result = self.modifier_definition(input); + choice.consider(input, result)?; + let result = self.struct_definition(input); + choice.consider(input, result)?; + let result = self.enum_definition(input); + choice.consider(input, result)?; + let result = self.event_definition(input); + choice.consider(input, result)?; + let result = self.state_variable_definition(input); + choice.consider(input, result)?; if self.version_is_at_least_0_8_4 { let result = self.error_definition(input); choice.consider(input, result)?; @@ -2667,6 +2838,13 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::StringKeyword, @@ -2674,6 +2852,11 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::FixedBytesType, @@ -2699,13 +2882,6 @@ impl Language { TokenKind::UnsignedFixedType, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }); choice.consider(input, result)?; @@ -2822,13 +2998,13 @@ impl Language { self.modifier_attributes_list(input), ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -2892,6 +3068,16 @@ impl Language { .with_kind(RuleKind::NamedArgumentsDeclaration) } + #[allow(unused_assignments, unused_parens)] + fn named_arguments_declarations(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { + OneOrMoreHelper::run(input, |input| self.named_arguments_declaration(input)) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::NamedArgumentsDeclarations) + } + #[allow(unused_assignments, unused_parens)] fn named_arguments_list(&self, input: &mut ParserContext) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( @@ -2910,14 +3096,7 @@ impl Language { input, TokenKind::Asterisk, ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; + seq.elem(self.import_alias(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::FromKeyword, @@ -2951,7 +3130,7 @@ impl Language { input, TokenKind::OverrideKeyword, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); seq.elem(self.parse_token_with_trivia::( @@ -2959,20 +3138,20 @@ impl Language { TokenKind::OpenParen, ))?; seq.elem( - OptionalHelper::transform(self.identifier_paths_list(input)) + self.identifier_paths_list(input) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, - ), + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), )?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::CloseParen, ))?; seq.finish() - })))?; + }))?; seq.finish() }) .with_kind(RuleKind::OverrideSpecifier) @@ -2998,7 +3177,7 @@ impl Language { if self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::CalldataKeyword, + TokenKind::CallDataKeyword, ); choice.consider(input, result)?; } @@ -3061,17 +3240,7 @@ impl Language { input, TokenKind::AsciiStringLiteral, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.import_alias(input)))?; seq.finish() }) .with_kind(RuleKind::PathImport) @@ -3093,7 +3262,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem( SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::PragmaKeyword, ))?; @@ -3108,14 +3277,14 @@ impl Language { }))?; seq.finish() }) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + .recover_until_with_nested_delims::<_, LexicalContextType::Pragma>( input, self, TokenKind::Semicolon, RecoverFromNoMatch::No, ), )?; - seq.elem(self.parse_token_with_trivia::( + seq.elem(self.parse_token_with_trivia::( input, TokenKind::Semicolon, ))?; @@ -3174,13 +3343,13 @@ impl Language { self.receive_function_attributes_list(input), ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -3234,30 +3403,34 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn revert_statement(&self, input: &mut ParserContext) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem( - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + if self.version_is_at_least_0_8_4 { + SequenceHelper::run(|mut seq| { + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::RevertKeyword, + ))?; + seq.elem(OptionalHelper::transform(self.identifier_path(input)))?; + seq.elem(self.arguments_declaration(input))?; + seq.finish() + }) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( input, - TokenKind::RevertKeyword, - ))?; - seq.elem(OptionalHelper::transform(self.identifier_path(input)))?; - seq.elem(self.arguments_declaration(input))?; - seq.finish() - }) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + self, + TokenKind::Semicolon, + RecoverFromNoMatch::No, + ), + )?; + seq.elem(self.parse_token_with_trivia::( input, - self, TokenKind::Semicolon, - RecoverFromNoMatch::No, - ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Semicolon, - ))?; - seq.finish() - }) + ))?; + seq.finish() + }) + } else { + ParserResult::disabled() + } .with_kind(RuleKind::RevertStatement) } @@ -3288,13 +3461,11 @@ impl Language { let result = self.library_definition(input); choice.consider(input, result)?; if self.version_is_at_least_0_6_0 { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.struct_definition(input); - choice.consider(input, result)?; - let result = self.enum_definition(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.struct_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_6_0 { + let result = self.enum_definition(input); choice.consider(input, result)?; } if self.version_is_at_least_0_7_1 { @@ -3379,14 +3550,9 @@ impl Language { input, TokenKind::Identifier, ))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ))?; - seq.elem(self.expression(input))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform( + self.state_variable_definition_value(input), + ))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -3405,55 +3571,62 @@ impl Language { .with_kind(RuleKind::StateVariableDefinition) } + #[allow(unused_assignments, unused_parens)] + fn state_variable_definition_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::StateVariableDefinitionValue) + } + #[allow(unused_assignments, unused_parens)] fn statement(&self, input: &mut ParserContext) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.expression_statement(input); - choice.consider(input, result)?; - let result = self.variable_declaration_statement(input); - choice.consider(input, result)?; - let result = self.tuple_deconstruction_statement(input); - choice.consider(input, result)?; - choice.finish(input) - }); + let result = self.expression_statement(input); choice.consider(input, result)?; - let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.if_statement(input); - choice.consider(input, result)?; - let result = self.for_statement(input); - choice.consider(input, result)?; - let result = self.while_statement(input); - choice.consider(input, result)?; - let result = self.do_while_statement(input); - choice.consider(input, result)?; - let result = self.continue_statement(input); + let result = self.variable_declaration_statement(input); + choice.consider(input, result)?; + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.if_statement(input); + choice.consider(input, result)?; + let result = self.for_statement(input); + choice.consider(input, result)?; + let result = self.while_statement(input); + choice.consider(input, result)?; + let result = self.do_while_statement(input); + choice.consider(input, result)?; + let result = self.continue_statement(input); + choice.consider(input, result)?; + let result = self.break_statement(input); + choice.consider(input, result)?; + let result = self.delete_statement(input); + choice.consider(input, result)?; + let result = self.return_statement(input); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.throw_statement(input); choice.consider(input, result)?; - let result = self.break_statement(input); + } + if self.version_is_at_least_0_4_21 { + let result = self.emit_statement(input); choice.consider(input, result)?; - let result = self.delete_statement(input); + } + if self.version_is_at_least_0_6_0 { + let result = self.try_statement(input); choice.consider(input, result)?; - let result = self.return_statement(input); + } + if self.version_is_at_least_0_8_4 { + let result = self.revert_statement(input); choice.consider(input, result)?; - if self.version_is_at_least_0_4_21 { - let result = self.emit_statement(input); - choice.consider(input, result)?; - } - if !self.version_is_at_least_0_5_0 { - let result = self.throw_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_6_0 { - let result = self.try_statement(input); - choice.consider(input, result)?; - } - if self.version_is_at_least_0_8_4 { - let result = self.revert_statement(input); - choice.consider(input, result)?; - } - choice.finish(input) - }); - choice.consider(input, result)?; + } let result = self.assembly_statement(input); choice.consider(input, result)?; let result = self.block(input); @@ -3624,13 +3797,13 @@ impl Language { TokenKind::OpenParen, ))?; seq.elem( - OptionalHelper::transform(self.tuple_members_list(input)) + self.tuple_members_list(input) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, - ), + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), )?; seq.elem(self.parse_token_with_trivia::( input, @@ -3689,95 +3862,39 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn tuple_member(&self, input: &mut ParserContext) -> ParserResult { + fn tuple_member_deconstruction(&self, input: &mut ParserContext) -> ParserResult { OptionalHelper::transform(ChoiceHelper::run(input, |mut choice, input| { - let result = SequenceHelper::run(|mut seq| { - seq.elem(self.type_name(input))?; - seq.elem(OptionalHelper::transform(ChoiceHelper::run( - input, - |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::MemoryKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::StorageKeyword, - ); - choice.consider(input, result)?; - if self.version_is_at_least_0_5_0 { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::CalldataKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }, - )))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.finish() - }); + let result = self.typed_tuple_member(input); choice.consider(input, result)?; - let result = SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform(ChoiceHelper::run( - input, - |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::MemoryKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::StorageKeyword, - ); - choice.consider(input, result)?; - if self.version_is_at_least_0_5_0 { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::CalldataKeyword, - ); - choice.consider(input, result)?; - } - choice.finish(input) - }, - )))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Identifier, - ))?; - seq.finish() - }); + let result = self.untyped_tuple_member(input); choice.consider(input, result)?; choice.finish(input) })) - .with_kind(RuleKind::TupleMember) + .with_kind(RuleKind::TupleMemberDeconstruction) } #[allow(unused_assignments, unused_parens)] fn tuple_members_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::Default>( + OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| self.tuple_member(input), + |input| self.tuple_member_deconstruction(input), TokenKind::Comma, - ) + )) .with_kind(RuleKind::TupleMembersList) } + #[allow(unused_assignments, unused_parens)] + fn tuple_value(&self, input: &mut ParserContext) -> ParserResult { + OptionalHelper::transform(self.expression(input)).with_kind(RuleKind::TupleValue) + } + #[allow(unused_assignments, unused_parens)] fn tuple_values_list(&self, input: &mut ParserContext) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( input, self, - |input| OptionalHelper::transform(self.expression(input)), + |input| self.tuple_value(input), TokenKind::Comma, ) .with_kind(RuleKind::TupleValuesList) @@ -3823,7 +3940,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn type_name(&self, input: &mut ParserContext) -> ParserResult { - let parse_array_type_name_operator = |input: &mut ParserContext| { + let parse_array_type_name = |input: &mut ParserContext| { PrecedenceHelper::to_postfix_operator( RuleKind::ArrayTypeName, 1u8, @@ -3863,6 +3980,13 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self.parse_token_with_trivia::( input, TokenKind::StringKeyword, @@ -3870,6 +3994,11 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::FixedBytesType, @@ -3895,13 +4024,6 @@ impl Language { TokenKind::UnsignedFixedType, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self.parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }); choice.consider(input, result)?; @@ -3912,7 +4034,7 @@ impl Language { }; let postfix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_array_type_name_operator(input); + let result = parse_array_type_name(input); choice.consider(input, result)?; choice.finish(input) }) @@ -3933,6 +4055,42 @@ impl Language { .with_kind(RuleKind::TypeName) } + #[allow(unused_assignments, unused_parens)] + fn typed_tuple_member(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.type_name(input))?; + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = self.parse_token_with_trivia::( + input, + TokenKind::MemoryKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::StorageKeyword, + ); + choice.consider(input, result)?; + if self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::CallDataKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }, + )))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Identifier, + ))?; + seq.finish() + }) + .with_kind(RuleKind::TypedTupleMember) + } + #[allow(unused_assignments, unused_parens)] fn unchecked_block(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_8_0 { @@ -4020,13 +4178,13 @@ impl Language { self.unnamed_function_attributes_list(input), ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.block(input); + choice.consider(input, result)?; let result = self.parse_token_with_trivia::( input, TokenKind::Semicolon, ); choice.consider(input, result)?; - let result = self.block(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.finish() @@ -4037,6 +4195,41 @@ impl Language { .with_kind(RuleKind::UnnamedFunctionDefinition) } + #[allow(unused_assignments, unused_parens)] + fn untyped_tuple_member(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(OptionalHelper::transform(ChoiceHelper::run( + input, + |mut choice, input| { + let result = self.parse_token_with_trivia::( + input, + TokenKind::MemoryKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::StorageKeyword, + ); + choice.consider(input, result)?; + if self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::CallDataKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }, + )))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Identifier, + ))?; + seq.finish() + }) + .with_kind(RuleKind::UntypedTupleMember) + } + #[allow(unused_assignments, unused_parens)] fn user_defined_value_type_definition(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_8_8 { @@ -4062,6 +4255,14 @@ impl Language { TokenKind::BoolKeyword, ); choice.consider(input, result)?; + if !self.version_is_at_least_0_8_0 { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::ByteKeyword, + ); + choice.consider(input, result)?; + } let result = self .parse_token_with_trivia::( input, @@ -4070,6 +4271,12 @@ impl Language { choice.consider(input, result)?; let result = self.address_type(input); choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; let result = self .parse_token_with_trivia::( input, @@ -4100,14 +4307,6 @@ impl Language { TokenKind::UnsignedFixedType, ); choice.consider(input, result)?; - if !self.version_is_at_least_0_8_0 { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::ByteKeyword, - ); - choice.consider(input, result)?; - } choice.finish(input) }))?; seq.finish() @@ -4132,33 +4331,129 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn using_directive(&self, input: &mut ParserContext) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem( - SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( + fn using_alias(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_8_19 { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::AsKeyword, + ))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.parse_token_with_trivia::( input, - TokenKind::UsingKeyword, - ))?; - seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.using_directive_path(input); - choice.consider(input, result)?; - let result = self.using_directive_deconstruction(input); - choice.consider(input, result)?; - choice.finish(input) - }))?; - seq.elem(self.parse_token_with_trivia::( + TokenKind::Ampersand, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( input, - TokenKind::ForKeyword, - ))?; - seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; + 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) + }))?; + seq.finish() + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::UsingAlias) + } + + #[allow(unused_assignments, unused_parens)] + fn using_directive(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::UsingKeyword, + ))?; + seq.elem(ChoiceHelper::run(input, |mut choice, input| { + let result = self.using_directive_path(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_8_13 { + let result = self.using_directive_deconstruction(input); + choice.consider(input, result)?; + } + choice.finish(input) + }))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::ForKeyword, + ))?; + seq.elem(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) }))?; if self.version_is_at_least_0_8_13 { @@ -4230,110 +4525,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem(self.identifier_path(input))?; if self.version_is_at_least_0_8_19 { - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(if self.version_is_at_least_0_8_19 { - ChoiceHelper::run(input, |mut choice, input| { - let result = self - .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() - })?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform(self.using_alias(input)))?; } seq.finish() }) @@ -4345,12 +4537,16 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn using_directive_symbols_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::Default>( - input, - self, - |input| self.using_directive_symbol(input), - TokenKind::Comma, - ) + if self.version_is_at_least_0_8_13 { + OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Default>( + input, + self, + |input| self.using_directive_symbol(input), + TokenKind::Comma, + )) + } else { + ParserResult::disabled() + } .with_kind(RuleKind::UsingDirectiveSymbolsList) } @@ -4358,6 +4554,8 @@ impl Language { fn variable_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem(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, @@ -4365,8 +4563,6 @@ impl Language { ); choice.consider(input, result)?; } - let result = self.type_name(input); - choice.consider(input, result)?; choice.finish(input) }))?; seq.elem(OptionalHelper::transform(ChoiceHelper::run( @@ -4385,7 +4581,7 @@ impl Language { if self.version_is_at_least_0_5_0 { let result = self.parse_token_with_trivia::( input, - TokenKind::CalldataKeyword, + TokenKind::CallDataKeyword, ); choice.consider(input, result)?; } @@ -4407,14 +4603,9 @@ impl Language { seq.elem( SequenceHelper::run(|mut seq| { seq.elem(self.variable_declaration(input))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::Equal, - ))?; - seq.elem(self.expression(input))?; - seq.finish() - })))?; + seq.elem(OptionalHelper::transform( + self.variable_declaration_value(input), + ))?; seq.finish() }) .recover_until_with_nested_delims::<_, LexicalContextType::Default>( @@ -4434,14 +4625,27 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn version_pragma(&self, input: &mut ParserContext) -> ParserResult { + fn variable_declaration_value(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::SolidityKeyword, + 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_list(input))?; seq.finish() }) @@ -4450,64 +4654,61 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn version_pragma_expression(&self, input: &mut ParserContext) -> ParserResult { - let parse_version_pragma_or_operator = |input: &mut ParserContext| { + let parse_version_pragma_or_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::VersionPragmaBinaryExpression, 1u8, 1u8 + 1, - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::BarBar, ), ) }; - let parse_version_pragma_range_operator = |input: &mut ParserContext| { + let parse_version_pragma_range_expression = |input: &mut ParserContext| { PrecedenceHelper::to_binary_operator( RuleKind::VersionPragmaBinaryExpression, 3u8, 3u8 + 1, - self.parse_token_with_trivia::( - input, - TokenKind::Minus, - ), + self.parse_token_with_trivia::(input, TokenKind::Minus), ) }; - let parse_version_pragma_unary_operator = |input: &mut ParserContext| { + let parse_version_pragma_prefix_expression = |input: &mut ParserContext| { PrecedenceHelper::to_prefix_operator( RuleKind::VersionPragmaUnaryExpression, 5u8, ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::Caret, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::Tilde, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::Equal, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::LessThan, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::GreaterThan, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::LessThanEqual, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::GreaterThanEqual, ); @@ -4518,13 +4719,18 @@ impl Language { }; let prefix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_unary_operator(input); + let result = parse_version_pragma_prefix_expression(input); + choice.consider(input, result)?; + choice.finish(input) + }) + }; + let primary_expression_parser = |input: &mut ParserContext| { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.version_pragma_specifier(input); choice.consider(input, result)?; choice.finish(input) }) }; - let primary_expression_parser = - |input: &mut ParserContext| self.version_pragma_specifier(input); let binary_operand_parser = |input: &mut ParserContext| { SequenceHelper::run(|mut seq| { seq.elem(ZeroOrMoreHelper::run(input, |input| { @@ -4536,9 +4742,9 @@ impl Language { }; let binary_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_version_pragma_or_operator(input); + let result = parse_version_pragma_or_expression(input); choice.consider(input, result)?; - let result = parse_version_pragma_range_operator(input); + let result = parse_version_pragma_range_expression(input); choice.consider(input, result)?; choice.finish(input) }) @@ -4571,11 +4777,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn version_pragma_specifier(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::VersionPragma>( + SeparatedHelper::run::<_, LexicalContextType::Pragma>( input, self, |input| { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::VersionPragmaValue, ) @@ -4625,7 +4831,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem(self.yul_identifier_paths_list(input))?; seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::ColonEqual, ), @@ -4642,22 +4848,22 @@ impl Language { let mut delim_guard = input.open_delim(TokenKind::CloseBrace); let input = delim_guard.ctx(); seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::OpenBrace, ), )?; seq.elem( - OptionalHelper::transform(self.yul_statements_list(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::YulBlock>( - input, - self, - TokenKind::CloseBrace, - RecoverFromNoMatch::Yes, - ), + self.yul_statements_list(input) + .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( + input, + self, + TokenKind::CloseBrace, + RecoverFromNoMatch::Yes, + ), )?; seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::CloseBrace, ), @@ -4669,74 +4875,58 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_break_statement(&self, input: &mut ParserContext) -> ParserResult { - self.parse_token_with_trivia::(input, TokenKind::BreakKeyword) + self.parse_token_with_trivia::(input, TokenKind::YulBreakKeyword) .with_kind(RuleKind::YulBreakStatement) } #[allow(unused_assignments, unused_parens)] fn yul_continue_statement(&self, input: &mut ParserContext) -> ParserResult { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::ContinueKeyword, + TokenKind::YulContinueKeyword, ) .with_kind(RuleKind::YulContinueStatement) } #[allow(unused_assignments, unused_parens)] - fn yul_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_default_case(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::LetKeyword, - ), - )?; - seq.elem(self.yul_identifier_paths_list(input))?; - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::ColonEqual, - ), - )?; - seq.elem(self.yul_expression(input))?; - seq.finish() - })))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulDefaultKeyword, + ))?; + seq.elem(self.yul_block(input))?; seq.finish() }) - .with_kind(RuleKind::YulDeclarationStatement) + .with_kind(RuleKind::YulDefaultCase) } #[allow(unused_assignments, unused_parens)] fn yul_expression(&self, input: &mut ParserContext) -> ParserResult { - let parse_yul_function_call_operator = |input: &mut ParserContext| { + let parse_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( - self.parse_token_with_trivia::( - input, - TokenKind::OpenParen, - ), - )?; - seq.elem( - OptionalHelper::transform(self.yul_expressions_list(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::YulBlock>( - input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, - ), + self.yul_expressions_list(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() }), ) @@ -4744,32 +4934,32 @@ impl Language { let primary_expression_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { let result = ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::TrueKeyword, + TokenKind::YulTrueKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::FalseKeyword, + TokenKind::YulFalseKeyword, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::YulHexLiteral, + TokenKind::YulDecimalLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::YulDecimalLiteral, + TokenKind::YulHexLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::HexStringLiteral, ); choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, TokenKind::AsciiStringLiteral, ); @@ -4784,7 +4974,7 @@ impl Language { }; let postfix_operator_parser = |input: &mut ParserContext| { ChoiceHelper::run(input, |mut choice, input| { - let result = parse_yul_function_call_operator(input); + let result = parse_yul_function_call_expression(input); choice.consider(input, result)?; choice.finish(input) }) @@ -4807,24 +4997,22 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_expressions_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( + OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| self.yul_expression(input), TokenKind::Comma, - ) + )) .with_kind(RuleKind::YulExpressionsList) } #[allow(unused_assignments, unused_parens)] fn yul_for_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::ForKeyword, - ), - )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulForKeyword, + ))?; seq.elem(self.yul_block(input))?; seq.elem(self.yul_expression(input))?; seq.elem(self.yul_block(input))?; @@ -4837,18 +5025,14 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_function_definition(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::FunctionKeyword, - ), - )?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::YulIdentifier, - ), - )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulFunctionKeyword, + ))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulIdentifier, + ))?; seq.elem(self.yul_parameters_declaration(input))?; seq.elem(OptionalHelper::transform( self.yul_returns_declaration(input), @@ -4861,11 +5045,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_identifier_path(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( + SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::YulIdentifier, ) @@ -4877,7 +5061,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_identifier_paths_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( + SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| self.yul_identifier_path(input), @@ -4888,11 +5072,11 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_identifiers_list(&self, input: &mut ParserContext) -> ParserResult { - SeparatedHelper::run::<_, LexicalContextType::YulBlock>( + SeparatedHelper::run::<_, LexicalContextType::Yul>( input, self, |input| { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::YulIdentifier, ) @@ -4905,12 +5089,10 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_if_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::IfKeyword, - ), - )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulIfKeyword, + ))?; seq.elem(self.yul_expression(input))?; seq.elem(self.yul_block(input))?; seq.finish() @@ -4921,9 +5103,9 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_leave_statement(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::LeaveKeyword, + TokenKind::YulLeaveKeyword, ) } else { ParserResult::disabled() @@ -4937,22 +5119,22 @@ impl Language { let mut delim_guard = input.open_delim(TokenKind::CloseParen); let input = delim_guard.ctx(); seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::OpenParen, ), )?; seq.elem( OptionalHelper::transform(self.yul_identifiers_list(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::YulBlock>( - input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, - ), + .recover_until_with_nested_delims::<_, LexicalContextType::Yul>( + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), )?; seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, TokenKind::CloseParen, ), @@ -4965,12 +5147,10 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_returns_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::MinusGreaterThan, - ), - )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::MinusGreaterThan, + ))?; seq.elem(self.yul_identifiers_list(input))?; seq.finish() }) @@ -4984,7 +5164,7 @@ impl Language { choice.consider(input, result)?; let result = self.yul_function_definition(input); choice.consider(input, result)?; - let result = self.yul_declaration_statement(input); + let result = self.yul_variable_declaration_statement(input); choice.consider(input, result)?; let result = self.yul_assignment_statement(input); choice.consider(input, result)?; @@ -5011,90 +5191,113 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_statements_list(&self, input: &mut ParserContext) -> ParserResult { - OneOrMoreHelper::run(input, |input| self.yul_statement(input)) + ZeroOrMoreHelper::run(input, |input| self.yul_statement(input)) .with_kind(RuleKind::YulStatementsList) } #[allow(unused_assignments, unused_parens)] - fn yul_switch_case(&self, input: &mut ParserContext) -> ParserResult { + fn yul_switch_cases_list(&self, input: &mut ParserContext) -> ParserResult { + OneOrMoreHelper::run(input, |input| { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.yul_default_case(input); + choice.consider(input, result)?; + let result = self.yul_value_case(input); + choice.consider(input, result)?; + choice.finish(input) + }) + }) + .with_kind(RuleKind::YulSwitchCasesList) + } + + #[allow(unused_assignments, unused_parens)] + fn yul_switch_statement(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulSwitchKeyword, + ))?; + seq.elem(self.yul_expression(input))?; + seq.elem(self.yul_switch_cases_list(input))?; + seq.finish() + }) + .with_kind(RuleKind::YulSwitchStatement) + } + + #[allow(unused_assignments, unused_parens)] + fn yul_value_case(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulCaseKeyword, + ))?; seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( + let result = self.parse_token_with_trivia::( input, - TokenKind::DefaultKeyword, + TokenKind::YulTrueKeyword, ); choice.consider(input, result)?; - let result = SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::CaseKeyword, - ), - )?; - seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::TrueKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::FalseKeyword, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::YulHexLiteral, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::YulDecimalLiteral, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::HexStringLiteral, - ); - choice.consider(input, result)?; - let result = self.parse_token_with_trivia::( - input, - TokenKind::AsciiStringLiteral, - ); - choice.consider(input, result)?; - choice.finish(input) - }))?; - seq.finish() - }); + let result = self.parse_token_with_trivia::( + input, + TokenKind::YulFalseKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::YulDecimalLiteral, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::YulHexLiteral, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::HexStringLiteral, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::AsciiStringLiteral, + ); choice.consider(input, result)?; choice.finish(input) }))?; seq.elem(self.yul_block(input))?; seq.finish() }) - .with_kind(RuleKind::YulSwitchCase) + .with_kind(RuleKind::YulValueCase) } #[allow(unused_assignments, unused_parens)] - fn yul_switch_cases_list(&self, input: &mut ParserContext) -> ParserResult { - OneOrMoreHelper::run(input, |input| self.yul_switch_case(input)) - .with_kind(RuleKind::YulSwitchCasesList) + fn yul_variable_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::YulLetKeyword, + ))?; + seq.elem(self.yul_identifier_paths_list(input))?; + seq.elem(OptionalHelper::transform( + self.yul_variable_declaration_value(input), + ))?; + seq.finish() + }) + .with_kind(RuleKind::YulVariableDeclarationStatement) } #[allow(unused_assignments, unused_parens)] - fn yul_switch_statement(&self, input: &mut ParserContext) -> ParserResult { + fn yul_variable_declaration_value(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem( - self.parse_token_with_trivia::( + self.parse_token_with_trivia::( input, - TokenKind::SwitchKeyword, + TokenKind::ColonEqual, ), )?; seq.elem(self.yul_expression(input))?; - seq.elem(self.yul_switch_cases_list(input))?; seq.finish() }) - .with_kind(RuleKind::YulSwitchStatement) + .with_kind(RuleKind::YulVariableDeclarationValue) } /******************************************** @@ -5102,22 +5305,11 @@ impl Language { ********************************************/ #[allow(unused_assignments, unused_parens)] - fn ascii_character_without_double_quote_or_backslash(&self, input: &mut ParserContext) -> bool { - scan_choice!( - input, - scan_char_range!(input, ' ', '!'), - scan_char_range!(input, '#', '['), - scan_char_range!(input, ']', '~') - ) - } - - #[allow(unused_assignments, unused_parens)] - fn ascii_character_without_single_quote_or_backslash(&self, input: &mut ParserContext) -> bool { - scan_choice!( + fn ampersand(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( input, - scan_char_range!(input, ' ', '&'), - scan_char_range!(input, '(', '['), - scan_char_range!(input, ']', '~') + scan_chars!(input, '&'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '&')) ) } @@ -5146,19 +5338,47 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn decimal_digit(&self, input: &mut ParserContext) -> bool { - scan_char_range!(input, '0', '9') + fn asterisk(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '*'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '*')) + ) + } + + #[allow(unused_assignments, unused_parens)] + fn bang(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '!'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn bar(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '|'), + scan_choice!(input, scan_chars!(input, '|'), scan_chars!(input, '=')) + ) + } + + #[allow(unused_assignments, unused_parens)] + fn caret(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '^'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn colon(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, ':'), scan_chars!(input, '=')) } #[allow(unused_assignments, unused_parens)] fn decimal_digits(&self, input: &mut ParserContext) -> bool { scan_sequence!( - scan_one_or_more!(input, self.decimal_digit(input)), + scan_one_or_more!(input, scan_char_range!(input, '0', '9')), scan_zero_or_more!( input, scan_sequence!( scan_chars!(input, '_'), - scan_one_or_more!(input, self.decimal_digit(input)) + scan_one_or_more!(input, scan_char_range!(input, '0', '9')) ) ) ) @@ -5175,35 +5395,55 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn decimal_literal(&self, input: &mut ParserContext) -> bool { - scan_not_followed_by!( + scan_choice!( input, - scan_sequence!( - scan_choice!( - input, + scan_not_followed_by!( + input, + scan_sequence!( scan_not_followed_by!( input, self.decimal_digits(input), scan_chars!(input, '.') ), - if !self.version_is_at_least_0_5_0 { + scan_optional!(input, self.decimal_exponent(input)) + ), + self.identifier_start(input) + ), + if !self.version_is_at_least_0_5_0 { + scan_not_followed_by!( + input, + scan_sequence!( scan_not_followed_by!( input, scan_sequence!(self.decimal_digits(input), scan_chars!(input, '.')), self.decimal_digits(input) - ) - } else { - false - }, - scan_sequence!(scan_chars!(input, '.'), self.decimal_digits(input)), - scan_sequence!( - self.decimal_digits(input), - scan_chars!(input, '.'), - self.decimal_digits(input) - ) + ), + scan_optional!(input, self.decimal_exponent(input)) + ), + self.identifier_start(input) + ) + } else { + false + }, + scan_not_followed_by!( + input, + scan_sequence!( + scan_chars!(input, '.'), + self.decimal_digits(input), + scan_optional!(input, self.decimal_exponent(input)) ), - scan_optional!(input, self.decimal_exponent(input)) + self.identifier_start(input) ), - self.identifier_start(input) + scan_not_followed_by!( + input, + scan_sequence!( + self.decimal_digits(input), + scan_chars!(input, '.'), + self.decimal_digits(input), + scan_optional!(input, self.decimal_exponent(input)) + ), + self.identifier_start(input) + ) ) } @@ -5216,7 +5456,9 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - self.ascii_character_without_double_quote_or_backslash(input) + scan_char_range!(input, ' ', '!'), + scan_char_range!(input, '#', '['), + scan_char_range!(input, ']', '~') ) ), scan_chars!(input, '"') @@ -5242,7 +5484,7 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - scan_none_of!(input, '\n', '\r', '"', '\\') + scan_none_of!(input, '"', '\\', '\r', '\n') ) ), scan_chars!(input, '"') @@ -5260,6 +5502,15 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn equal(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '='), + scan_choice!(input, scan_chars!(input, '>'), scan_chars!(input, '=')) + ) + } + #[allow(unused_assignments, unused_parens)] fn escape_sequence(&self, input: &mut ParserContext) -> bool { scan_sequence!( @@ -5277,55 +5528,68 @@ impl Language { fn fixed_bytes_type(&self, input: &mut ParserContext) -> bool { scan_sequence!( scan_chars!(input, 'b', 'y', 't', 'e', 's'), - self.fixed_bytes_type_size(input) + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '8'), + scan_chars!(input, '7'), + scan_chars!(input, '6'), + scan_chars!(input, '5'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1') + ) ) } #[allow(unused_assignments, unused_parens)] - fn fixed_bytes_type_size(&self, input: &mut ParserContext) -> bool { - scan_choice!( + fn greater_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( input, - scan_chars!(input, '9'), - scan_chars!(input, '8'), - scan_chars!(input, '7'), - scan_chars!(input, '6'), - scan_chars!(input, '5'), - scan_chars!(input, '4'), - scan_chars!(input, '3', '2'), - scan_chars!(input, '3', '1'), - scan_chars!(input, '3', '0'), - scan_chars!(input, '3'), - scan_chars!(input, '2', '9'), - scan_chars!(input, '2', '8'), - scan_chars!(input, '2', '7'), - scan_chars!(input, '2', '6'), - scan_chars!(input, '2', '5'), - scan_chars!(input, '2', '4'), - scan_chars!(input, '2', '3'), - scan_chars!(input, '2', '2'), - scan_chars!(input, '2', '1'), - scan_chars!(input, '2', '0'), - scan_chars!(input, '2'), - scan_chars!(input, '1', '9'), - scan_chars!(input, '1', '8'), - scan_chars!(input, '1', '7'), - scan_chars!(input, '1', '6'), - scan_chars!(input, '1', '5'), - scan_chars!(input, '1', '4'), - scan_chars!(input, '1', '3'), - scan_chars!(input, '1', '2'), - scan_chars!(input, '1', '1'), - scan_chars!(input, '1', '0'), - scan_chars!(input, '1') + scan_chars!(input, '>'), + scan_choice!(input, scan_chars!(input, '>'), scan_chars!(input, '=')) ) } #[allow(unused_assignments, unused_parens)] - fn fixed_type_size(&self, input: &mut ParserContext) -> bool { - scan_sequence!( - scan_one_or_more!(input, scan_char_range!(input, '0', '9')), - scan_chars!(input, 'x'), - scan_one_or_more!(input, scan_char_range!(input, '0', '9')) + fn greater_than_greater_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '>', '>'), + scan_choice!(input, scan_chars!(input, '>'), scan_chars!(input, '=')) + ) + } + + #[allow(unused_assignments, unused_parens)] + fn greater_than_greater_than_greater_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '>', '>', '>'), + scan_chars!(input, '=') ) } @@ -5342,36 +5606,50 @@ impl Language { fn hex_character(&self, input: &mut ParserContext) -> bool { scan_choice!( input, - self.decimal_digit(input), - scan_char_range!(input, 'A', 'F'), - scan_char_range!(input, 'a', 'f') + scan_char_range!(input, '0', '9'), + scan_char_range!(input, 'a', 'f'), + scan_char_range!(input, 'A', 'F') ) } #[allow(unused_assignments, unused_parens)] fn hex_literal(&self, input: &mut ParserContext) -> bool { - scan_not_followed_by!( + scan_choice!( input, - scan_sequence!( - scan_choice!( - input, + scan_not_followed_by!( + input, + scan_sequence!( scan_chars!(input, '0', 'x'), - if !self.version_is_at_least_0_5_0 { - scan_chars!(input, '0', 'X') - } else { - false - } + scan_one_or_more!(input, self.hex_character(input)), + scan_zero_or_more!( + input, + scan_sequence!( + scan_chars!(input, '_'), + scan_one_or_more!(input, self.hex_character(input)) + ) + ) ), - scan_one_or_more!(input, self.hex_character(input)), - scan_zero_or_more!( + self.identifier_start(input) + ), + if !self.version_is_at_least_0_5_0 { + scan_not_followed_by!( input, scan_sequence!( - scan_chars!(input, '_'), - scan_one_or_more!(input, self.hex_character(input)) - ) + scan_chars!(input, '0', 'X'), + scan_one_or_more!(input, self.hex_character(input)), + scan_zero_or_more!( + input, + scan_sequence!( + scan_chars!(input, '_'), + scan_one_or_more!(input, self.hex_character(input)) + ) + ) + ), + self.identifier_start(input) ) - ), - self.identifier_start(input) + } else { + false + } ) } @@ -5420,58 +5698,47 @@ impl Language { input, scan_chars!(input, '_'), scan_chars!(input, '$'), - scan_char_range!(input, 'A', 'Z'), - scan_char_range!(input, 'a', 'z') + scan_char_range!(input, 'a', 'z'), + scan_char_range!(input, 'A', 'Z') ) } #[allow(unused_assignments, unused_parens)] - fn integer_type_size(&self, input: &mut ParserContext) -> bool { - scan_choice!( + fn less_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( input, - scan_chars!(input, '9', '6'), - scan_chars!(input, '8', '8'), - scan_chars!(input, '8', '0'), - scan_chars!(input, '8'), - scan_chars!(input, '7', '2'), - scan_chars!(input, '6', '4'), - scan_chars!(input, '5', '6'), - scan_chars!(input, '4', '8'), - scan_chars!(input, '4', '0'), - scan_chars!(input, '3', '2'), - scan_chars!(input, '2', '5', '6'), - scan_chars!(input, '2', '4', '8'), - scan_chars!(input, '2', '4', '0'), - scan_chars!(input, '2', '4'), - scan_chars!(input, '2', '3', '2'), - scan_chars!(input, '2', '2', '4'), - scan_chars!(input, '2', '1', '6'), - scan_chars!(input, '2', '0', '8'), - scan_chars!(input, '2', '0', '0'), - scan_chars!(input, '1', '9', '2'), - scan_chars!(input, '1', '8', '4'), - scan_chars!(input, '1', '7', '6'), - scan_chars!(input, '1', '6', '8'), - scan_chars!(input, '1', '6', '0'), - scan_chars!(input, '1', '6'), - scan_chars!(input, '1', '5', '2'), - scan_chars!(input, '1', '4', '4'), - scan_chars!(input, '1', '3', '6'), - scan_chars!(input, '1', '2', '8'), - scan_chars!(input, '1', '2', '0'), - scan_chars!(input, '1', '1', '2'), - scan_chars!(input, '1', '0', '4') + scan_chars!(input, '<'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '<')) ) } #[allow(unused_assignments, unused_parens)] - fn multiline_comment(&self, input: &mut ParserContext) -> bool { - scan_sequence!( - scan_chars!(input, '/'), - scan_chars!(input, '*'), - scan_zero_or_more!( - input, - scan_choice!( + fn less_than_less_than(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '<', '<'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn minus(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '-'), + scan_choice!( + input, + scan_chars!(input, '>'), + scan_chars!(input, '='), + scan_chars!(input, '-') + ) + ) + } + + #[allow(unused_assignments, unused_parens)] + fn multiline_comment(&self, input: &mut ParserContext) -> bool { + scan_sequence!( + scan_chars!(input, '/'), + scan_chars!(input, '*'), + scan_zero_or_more!( + input, + scan_choice!( input, scan_none_of!(input, '*'), scan_not_followed_by!(input, scan_chars!(input, '*'), scan_chars!(input, '/')) @@ -5482,6 +5749,20 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn percent(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '%'), scan_chars!(input, '=')) + } + + #[allow(unused_assignments, unused_parens)] + fn plus(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!( + input, + scan_chars!(input, '+'), + scan_choice!(input, scan_chars!(input, '='), scan_chars!(input, '+')) + ) + } + #[allow(unused_assignments, unused_parens)] fn raw_identifier(&self, input: &mut ParserContext) -> bool { scan_sequence!( @@ -5492,9 +5773,284 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn signed_fixed_type(&self, input: &mut ParserContext) -> bool { - scan_sequence!( + scan_choice!( + input, scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), - scan_optional!(input, self.fixed_type_size(input)) + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ), + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ), + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } ) } @@ -5502,7 +6058,44 @@ impl Language { fn signed_integer_type(&self, input: &mut ParserContext) -> bool { scan_sequence!( scan_chars!(input, 'i', 'n', 't'), - scan_optional!(input, self.integer_type_size(input)) + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) ) } @@ -5523,7 +6116,9 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - self.ascii_character_without_single_quote_or_backslash(input) + scan_char_range!(input, ' ', '&'), + scan_char_range!(input, '(', '['), + scan_char_range!(input, ']', '~') ) ), scan_chars!(input, '\'') @@ -5549,7 +6144,7 @@ impl Language { scan_choice!( input, self.escape_sequence(input), - scan_none_of!(input, '\n', '\r', '\'', '\\') + scan_none_of!(input, '\'', '\\', '\r', '\n') ) ), scan_chars!(input, '\'') @@ -5559,6 +6154,11 @@ impl Language { } } + #[allow(unused_assignments, unused_parens)] + fn slash(&self, input: &mut ParserContext) -> bool { + scan_not_followed_by!(input, scan_chars!(input, '/'), scan_chars!(input, '=')) + } + #[allow(unused_assignments, unused_parens)] fn unicode_escape(&self, input: &mut ParserContext) -> bool { scan_sequence!( @@ -5572,22 +6172,301 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn unicode_string_literal(&self, input: &mut ParserContext) -> bool { - if self.version_is_at_least_0_7_0 { - scan_choice!( - input, - self.single_quoted_unicode_string_literal(input), + scan_choice!( + input, + if self.version_is_at_least_0_7_0 { + self.single_quoted_unicode_string_literal(input) + } else { + false + }, + if self.version_is_at_least_0_7_0 { self.double_quoted_unicode_string_literal(input) - ) - } else { - false - } + } else { + false + } + ) } #[allow(unused_assignments, unused_parens)] fn unsigned_fixed_type(&self, input: &mut ParserContext) -> bool { - scan_sequence!( + scan_choice!( + input, scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), - scan_optional!(input, self.fixed_type_size(input)) + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ), + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ), + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } ) } @@ -5595,7 +6474,44 @@ impl Language { fn unsigned_integer_type(&self, input: &mut ParserContext) -> bool { scan_sequence!( scan_chars!(input, 'u', 'i', 'n', 't'), - scan_optional!(input, self.integer_type_size(input)) + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) ) } @@ -5621,6 +6537,52 @@ impl Language { ) } + #[allow(unused_assignments, unused_parens)] + fn yul_bytes_keyword(&self, input: &mut ParserContext) -> bool { + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'b', 'y', 't', 'e', 's'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '8'), + scan_chars!(input, '7'), + scan_chars!(input, '6'), + scan_chars!(input, '5'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1') + ) + ) + } else { + false + } + } + #[allow(unused_assignments, unused_parens)] fn yul_decimal_literal(&self, input: &mut ParserContext) -> bool { scan_not_followed_by!( @@ -5630,13 +6592,308 @@ impl Language { scan_chars!(input, '0'), scan_sequence!( scan_char_range!(input, '1', '9'), - scan_zero_or_more!(input, self.decimal_digit(input)) + scan_zero_or_more!(input, scan_char_range!(input, '0', '9')) ) ), self.identifier_start(input) ) } + #[allow(unused_assignments, unused_parens)] + fn yul_fixed_keyword(&self, input: &mut ParserContext) -> bool { + scan_choice!( + input, + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'f', 'i', 'x', 'e', 'd') + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ) + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } + ) + } + #[allow(unused_assignments, unused_parens)] fn yul_hex_literal(&self, input: &mut ParserContext) -> bool { scan_not_followed_by!( @@ -5654,18 +6911,409 @@ impl Language { self.raw_identifier(input) } + #[allow(unused_assignments, unused_parens)] + fn yul_int_keyword(&self, input: &mut ParserContext) -> bool { + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'i', 'n', 't'), + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) + ) + } else { + false + } + } + + #[allow(unused_assignments, unused_parens)] + fn yul_ufixed_keyword(&self, input: &mut ParserContext) -> bool { + scan_choice!( + input, + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd') + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '1', '6') + ) + ) + } else { + false + }, + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '4', '8', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '8'), + scan_chars!(input, '2', '4', '0', 'x', '1', '6'), + scan_chars!(input, '2', '3', '2', 'x', '8'), + scan_chars!(input, '2', '3', '2', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '1', '6'), + scan_chars!(input, '2', '2', '4', 'x', '8'), + scan_chars!(input, '2', '2', '4', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '2', '4'), + scan_chars!(input, '2', '2', '4', 'x', '1', '6'), + scan_chars!(input, '2', '1', '6', 'x', '8'), + scan_chars!(input, '2', '1', '6', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '3', '2'), + scan_chars!(input, '2', '1', '6', 'x', '2', '4'), + scan_chars!(input, '2', '1', '6', 'x', '1', '6'), + scan_chars!(input, '2', '0', '8', 'x', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '4', '0'), + scan_chars!(input, '2', '0', '8', 'x', '3', '2'), + scan_chars!(input, '2', '0', '8', 'x', '2', '4'), + scan_chars!(input, '2', '0', '8', 'x', '1', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8'), + scan_chars!(input, '2', '0', '0', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '4', '8'), + scan_chars!(input, '2', '0', '0', 'x', '4', '0'), + scan_chars!(input, '2', '0', '0', 'x', '3', '2'), + scan_chars!(input, '2', '0', '0', 'x', '2', '4'), + scan_chars!(input, '2', '0', '0', 'x', '1', '6'), + scan_chars!(input, '1', '9', '2', 'x', '8'), + scan_chars!(input, '1', '9', '2', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '5', '6'), + scan_chars!(input, '1', '9', '2', 'x', '4', '8'), + scan_chars!(input, '1', '9', '2', 'x', '4', '0'), + scan_chars!(input, '1', '9', '2', 'x', '3', '2'), + scan_chars!(input, '1', '9', '2', 'x', '2', '4'), + scan_chars!(input, '1', '9', '2', 'x', '1', '6'), + scan_chars!(input, '1', '8', '4', 'x', '8'), + scan_chars!(input, '1', '8', '4', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '6', '4'), + scan_chars!(input, '1', '8', '4', 'x', '5', '6'), + scan_chars!(input, '1', '8', '4', 'x', '4', '8'), + scan_chars!(input, '1', '8', '4', 'x', '4', '0'), + scan_chars!(input, '1', '8', '4', 'x', '3', '2'), + scan_chars!(input, '1', '8', '4', 'x', '2', '4'), + scan_chars!(input, '1', '8', '4', 'x', '1', '6') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '2', '5', '6', 'x', '8', '0'), + scan_chars!(input, '2', '5', '6', 'x', '8'), + scan_chars!(input, '2', '5', '6', 'x', '7', '2'), + scan_chars!(input, '2', '5', '6', 'x', '6', '4'), + scan_chars!(input, '2', '5', '6', 'x', '5', '6'), + scan_chars!(input, '2', '5', '6', 'x', '4', '8'), + scan_chars!(input, '2', '5', '6', 'x', '4', '0'), + scan_chars!(input, '2', '5', '6', 'x', '3', '2'), + scan_chars!(input, '2', '5', '6', 'x', '2', '4'), + scan_chars!(input, '2', '5', '6', 'x', '1', '6'), + scan_chars!(input, '2', '4', '8', 'x', '8', '0'), + scan_chars!(input, '2', '4', '8', 'x', '7', '2'), + scan_chars!(input, '2', '4', '8', 'x', '6', '4'), + scan_chars!(input, '2', '4', '8', 'x', '5', '6'), + scan_chars!(input, '2', '4', '8', 'x', '4', '8'), + scan_chars!(input, '2', '4', '8', 'x', '4', '0'), + scan_chars!(input, '2', '4', '8', 'x', '3', '2'), + scan_chars!(input, '2', '4', '8', 'x', '2', '4'), + scan_chars!(input, '2', '4', '8', 'x', '1', '6'), + scan_chars!(input, '2', '4', '0', 'x', '8', '0'), + scan_chars!(input, '2', '4', '0', 'x', '7', '2'), + scan_chars!(input, '2', '4', '0', 'x', '6', '4'), + scan_chars!(input, '2', '4', '0', 'x', '5', '6'), + scan_chars!(input, '2', '4', '0', 'x', '4', '8'), + scan_chars!(input, '2', '4', '0', 'x', '4', '0'), + scan_chars!(input, '2', '4', '0', 'x', '3', '2'), + scan_chars!(input, '2', '4', '0', 'x', '2', '4'), + scan_chars!(input, '2', '3', '2', 'x', '8', '0'), + scan_chars!(input, '2', '3', '2', 'x', '7', '2'), + scan_chars!(input, '2', '3', '2', 'x', '6', '4'), + scan_chars!(input, '2', '3', '2', 'x', '5', '6'), + scan_chars!(input, '2', '3', '2', 'x', '4', '8'), + scan_chars!(input, '2', '3', '2', 'x', '4', '0'), + scan_chars!(input, '2', '3', '2', 'x', '3', '2'), + scan_chars!(input, '2', '2', '4', 'x', '8', '0'), + scan_chars!(input, '2', '2', '4', 'x', '7', '2'), + scan_chars!(input, '2', '2', '4', 'x', '6', '4'), + scan_chars!(input, '2', '2', '4', 'x', '5', '6'), + scan_chars!(input, '2', '2', '4', 'x', '4', '8'), + scan_chars!(input, '2', '2', '4', 'x', '4', '0'), + scan_chars!(input, '2', '1', '6', 'x', '8', '0'), + scan_chars!(input, '2', '1', '6', 'x', '7', '2'), + scan_chars!(input, '2', '1', '6', 'x', '6', '4'), + scan_chars!(input, '2', '1', '6', 'x', '5', '6'), + scan_chars!(input, '2', '1', '6', 'x', '4', '8'), + scan_chars!(input, '2', '0', '8', 'x', '8', '0'), + scan_chars!(input, '2', '0', '8', 'x', '7', '2'), + scan_chars!(input, '2', '0', '8', 'x', '6', '4'), + scan_chars!(input, '2', '0', '8', 'x', '5', '6'), + scan_chars!(input, '2', '0', '0', 'x', '8', '0'), + scan_chars!(input, '2', '0', '0', 'x', '7', '2'), + scan_chars!(input, '2', '0', '0', 'x', '6', '4'), + scan_chars!(input, '1', '9', '2', 'x', '8', '0'), + scan_chars!(input, '1', '9', '2', 'x', '7', '2'), + scan_chars!(input, '1', '8', '4', 'x', '8', '0') + ) + ) + } else { + false + }, + if self.version_is_at_least_0_4_14 && !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'f', 'i', 'x', 'e', 'd'), + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ), + scan_chars!(input, 'x'), + scan_choice!( + input, + scan_chars!(input, '9'), + scan_chars!(input, '7', '9'), + scan_chars!(input, '7', '8'), + scan_chars!(input, '7', '7'), + scan_chars!(input, '7', '6'), + scan_chars!(input, '7', '5'), + scan_chars!(input, '7', '4'), + scan_chars!(input, '7', '3'), + scan_chars!(input, '7', '1'), + scan_chars!(input, '7', '0'), + scan_chars!(input, '7'), + scan_chars!(input, '6', '9'), + scan_chars!(input, '6', '8'), + scan_chars!(input, '6', '7'), + scan_chars!(input, '6', '6'), + scan_chars!(input, '6', '5'), + scan_chars!(input, '6', '3'), + scan_chars!(input, '6', '2'), + scan_chars!(input, '6', '1'), + scan_chars!(input, '6', '0'), + scan_chars!(input, '6'), + scan_chars!(input, '5', '9'), + scan_chars!(input, '5', '8'), + scan_chars!(input, '5', '7'), + scan_chars!(input, '5', '5'), + scan_chars!(input, '5', '4'), + scan_chars!(input, '5', '3'), + scan_chars!(input, '5', '2'), + scan_chars!(input, '5', '1'), + scan_chars!(input, '5', '0'), + scan_chars!(input, '5'), + scan_chars!(input, '4', '9'), + scan_chars!(input, '4', '7'), + scan_chars!(input, '4', '6'), + scan_chars!(input, '4', '5'), + scan_chars!(input, '4', '4'), + scan_chars!(input, '4', '3'), + scan_chars!(input, '4', '2'), + scan_chars!(input, '4', '1'), + scan_chars!(input, '4'), + scan_chars!(input, '3', '9'), + scan_chars!(input, '3', '8'), + scan_chars!(input, '3', '7'), + scan_chars!(input, '3', '6'), + scan_chars!(input, '3', '5'), + scan_chars!(input, '3', '4'), + scan_chars!(input, '3', '3'), + scan_chars!(input, '3', '1'), + scan_chars!(input, '3', '0'), + scan_chars!(input, '3'), + scan_chars!(input, '2', '9'), + scan_chars!(input, '2', '8'), + scan_chars!(input, '2', '7'), + scan_chars!(input, '2', '6'), + scan_chars!(input, '2', '5'), + scan_chars!(input, '2', '3'), + scan_chars!(input, '2', '2'), + scan_chars!(input, '2', '1'), + scan_chars!(input, '2', '0'), + scan_chars!(input, '2'), + scan_chars!(input, '1', '9'), + scan_chars!(input, '1', '8'), + scan_chars!(input, '1', '7'), + scan_chars!(input, '1', '5'), + scan_chars!(input, '1', '4'), + scan_chars!(input, '1', '3'), + scan_chars!(input, '1', '2'), + scan_chars!(input, '1', '1'), + scan_chars!(input, '1', '0'), + scan_chars!(input, '1'), + scan_chars!(input, '0') + ) + ) + } else { + false + } + ) + } + + #[allow(unused_assignments, unused_parens)] + fn yul_uint_keyword(&self, input: &mut ParserContext) -> bool { + if !self.version_is_at_least_0_7_1 { + scan_sequence!( + scan_chars!(input, 'u', 'i', 'n', 't'), + scan_optional!( + input, + scan_choice!( + input, + scan_chars!(input, '9', '6'), + scan_chars!(input, '8', '8'), + scan_chars!(input, '8', '0'), + scan_chars!(input, '8'), + scan_chars!(input, '7', '2'), + scan_chars!(input, '6', '4'), + scan_chars!(input, '5', '6'), + scan_chars!(input, '4', '8'), + scan_chars!(input, '4', '0'), + scan_chars!(input, '3', '2'), + scan_chars!(input, '2', '5', '6'), + scan_chars!(input, '2', '4', '8'), + scan_chars!(input, '2', '4', '0'), + scan_chars!(input, '2', '4'), + scan_chars!(input, '2', '3', '2'), + scan_chars!(input, '2', '2', '4'), + scan_chars!(input, '2', '1', '6'), + scan_chars!(input, '2', '0', '8'), + scan_chars!(input, '2', '0', '0'), + scan_chars!(input, '1', '9', '2'), + scan_chars!(input, '1', '8', '4'), + scan_chars!(input, '1', '7', '6'), + scan_chars!(input, '1', '6', '8'), + scan_chars!(input, '1', '6', '0'), + scan_chars!(input, '1', '6'), + scan_chars!(input, '1', '5', '2'), + scan_chars!(input, '1', '4', '4'), + scan_chars!(input, '1', '3', '6'), + scan_chars!(input, '1', '2', '8'), + scan_chars!(input, '1', '2', '0'), + scan_chars!(input, '1', '1', '2'), + scan_chars!(input, '1', '0', '4') + ) + ) + ) + } else { + false + } + } + pub fn scan(&self, lexical_context: LexicalContext, input: &str) -> Option { let mut input = ParserContext::new(input); match lexical_context { LexicalContext::Default => { Lexer::next_token::(self, &mut input) } - LexicalContext::VersionPragma => { - Lexer::next_token::(self, &mut input) - } - LexicalContext::YulBlock => { - Lexer::next_token::(self, &mut input) + LexicalContext::Pragma => { + Lexer::next_token::(self, &mut input) } + LexicalContext::Yul => Lexer::next_token::(self, &mut input), } } @@ -5679,6 +7327,9 @@ impl Language { ProductionKind::AsciiStringLiteralsList => { Self::ascii_string_literals_list.parse(self, input) } + ProductionKind::AssemblyFlagsDeclaration => { + Self::assembly_flags_declaration.parse(self, input) + } ProductionKind::AssemblyFlagsList => Self::assembly_flags_list.parse(self, input), ProductionKind::AssemblyStatement => Self::assembly_statement.parse(self, input), ProductionKind::Block => Self::block.parse(self, input), @@ -5708,6 +7359,7 @@ impl Language { } ProductionKind::DeleteStatement => Self::delete_statement.parse(self, input), ProductionKind::DoWhileStatement => Self::do_while_statement.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), @@ -5750,7 +7402,9 @@ impl Language { ProductionKind::IdentifierPathsList => Self::identifier_paths_list.parse(self, input), ProductionKind::IdentifiersList => Self::identifiers_list.parse(self, input), ProductionKind::IfStatement => Self::if_statement.parse(self, input), + ProductionKind::ImportAlias => Self::import_alias.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::InheritanceTypesList => Self::inheritance_types_list.parse(self, input), @@ -5771,6 +7425,9 @@ impl Language { ProductionKind::NamedArgumentsDeclaration => { Self::named_arguments_declaration.parse(self, input) } + ProductionKind::NamedArgumentsDeclarations => { + Self::named_arguments_declarations.parse(self, input) + } ProductionKind::NamedArgumentsList => Self::named_arguments_list.parse(self, input), ProductionKind::NamedImport => Self::named_import.parse(self, input), ProductionKind::NewExpression => Self::new_expression.parse(self, input), @@ -5804,6 +7461,9 @@ impl Language { ProductionKind::StateVariableDefinition => { Self::state_variable_definition.parse(self, input) } + ProductionKind::StateVariableDefinitionValue => { + Self::state_variable_definition_value.parse(self, input) + } ProductionKind::Statement => Self::statement.parse(self, input), ProductionKind::StatementsList => Self::statements_list.parse(self, input), ProductionKind::StructDefinition => Self::struct_definition.parse(self, input), @@ -5816,11 +7476,15 @@ impl Language { Self::tuple_deconstruction_statement.parse(self, input) } ProductionKind::TupleExpression => Self::tuple_expression.parse(self, input), - ProductionKind::TupleMember => Self::tuple_member.parse(self, input), + ProductionKind::TupleMemberDeconstruction => { + Self::tuple_member_deconstruction.parse(self, input) + } ProductionKind::TupleMembersList => Self::tuple_members_list.parse(self, input), + ProductionKind::TupleValue => Self::tuple_value.parse(self, input), ProductionKind::TupleValuesList => Self::tuple_values_list.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::UnicodeStringLiteralsList => { Self::unicode_string_literals_list.parse(self, input) @@ -5831,9 +7495,11 @@ impl Language { ProductionKind::UnnamedFunctionDefinition => { Self::unnamed_function_definition.parse(self, input) } + ProductionKind::UntypedTupleMember => Self::untyped_tuple_member.parse(self, input), ProductionKind::UserDefinedValueTypeDefinition => { Self::user_defined_value_type_definition.parse(self, input) } + ProductionKind::UsingAlias => Self::using_alias.parse(self, input), ProductionKind::UsingDirective => Self::using_directive.parse(self, input), ProductionKind::UsingDirectiveDeconstruction => { Self::using_directive_deconstruction.parse(self, input) @@ -5847,6 +7513,9 @@ impl Language { ProductionKind::VariableDeclarationStatement => { Self::variable_declaration_statement.parse(self, input) } + ProductionKind::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) @@ -5864,9 +7533,7 @@ impl Language { 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::YulDeclarationStatement => { - Self::yul_declaration_statement.parse(self, input) - } + ProductionKind::YulDefaultCase => Self::yul_default_case.parse(self, input), ProductionKind::YulExpression => Self::yul_expression.parse(self, input), ProductionKind::YulExpressionsList => Self::yul_expressions_list.parse(self, input), ProductionKind::YulForStatement => Self::yul_for_statement.parse(self, input), @@ -5888,9 +7555,15 @@ impl Language { } ProductionKind::YulStatement => Self::yul_statement.parse(self, input), ProductionKind::YulStatementsList => Self::yul_statements_list.parse(self, input), - ProductionKind::YulSwitchCase => Self::yul_switch_case.parse(self, input), ProductionKind::YulSwitchCasesList => Self::yul_switch_cases_list.parse(self, input), ProductionKind::YulSwitchStatement => Self::yul_switch_statement.parse(self, input), + ProductionKind::YulValueCase => Self::yul_value_case.parse(self, input), + ProductionKind::YulVariableDeclarationStatement => { + Self::yul_variable_declaration_statement.parse(self, input) + } + ProductionKind::YulVariableDeclarationValue => { + Self::yul_variable_declaration_value.parse(self, input) + } } } } @@ -5911,8 +7584,8 @@ impl Lexer for Language { (TokenKind::OpenBracket, TokenKind::CloseBracket), (TokenKind::OpenParen, TokenKind::CloseParen), ], - LexicalContext::VersionPragma => &[], - LexicalContext::YulBlock => &[ + LexicalContext::Pragma => &[], + LexicalContext::Yul => &[ (TokenKind::OpenBrace, TokenKind::CloseBrace), (TokenKind::OpenParen, TokenKind::CloseParen), ], @@ -5940,17 +7613,8 @@ impl Lexer for Language { if let Some(kind) = match input.next() { Some('a') => match input.next() { - Some('b') => match input.next() { - Some('i') => scan_chars!(input, 'c', 'o', 'd', 'e', 'r') - .then_some(TokenKind::AbicoderKeyword), - Some('s') => scan_chars!(input, 't', 'r', 'a', 'c', 't') - .then_some(TokenKind::AbstractKeyword), - Some(_) => { - input.undo(); - None - } - None => None, - }, + Some('b') => scan_chars!(input, 's', 't', 'r', 'a', 'c', 't') + .then_some(TokenKind::AbstractKeyword), Some('d') => scan_chars!(input, 'd', 'r', 'e', 's', 's') .then_some(TokenKind::AddressKeyword), Some('f') => { @@ -6011,7 +7675,7 @@ impl Lexer for Language { Some('l') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'l', 'd', 'a', 't', 'a') - .then_some(TokenKind::CalldataKeyword) + .then_some(TokenKind::CallDataKeyword) } else { None } @@ -6071,7 +7735,7 @@ impl Lexer for Language { Some('p') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'y', 'o', 'f') - .then_some(TokenKind::CopyofKeyword) + .then_some(TokenKind::CopyOfKeyword) } else { None } @@ -6146,19 +7810,8 @@ impl Lexer for Language { Some('v') => { scan_chars!(input, 'e', 'n', 't').then_some(TokenKind::EventKeyword) } - Some('x') => match input.next() { - Some('p') => { - scan_chars!(input, 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l') - .then_some(TokenKind::ExperimentalKeyword) - } - Some('t') => scan_chars!(input, 'e', 'r', 'n', 'a', 'l') - .then_some(TokenKind::ExternalKeyword), - Some(_) => { - input.undo(); - None - } - None => None, - }, + Some('x') => scan_chars!(input, 't', 'e', 'r', 'n', 'a', 'l') + .then_some(TokenKind::ExternalKeyword), Some(_) => { input.undo(); None @@ -6328,21 +7981,7 @@ impl Lexer for Language { None => None, }, Some('l') => match input.next() { - Some('e') => match input.next() { - Some('a') => { - if self.version_is_at_least_0_6_0 { - scan_chars!(input, 'v', 'e').then_some(TokenKind::LeaveKeyword) - } else { - None - } - } - Some('t') => Some(TokenKind::LetKeyword), - Some(_) => { - input.undo(); - None - } - None => None, - }, + Some('e') => scan_chars!(input, 't').then_some(TokenKind::LetKeyword), Some('i') => scan_chars!(input, 'b', 'r', 'a', 'r', 'y') .then_some(TokenKind::LibraryKeyword), Some(_) => { @@ -6545,13 +8184,11 @@ impl Lexer for Language { Some('i') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'z', 'e', 'o', 'f') - .then_some(TokenKind::SizeofKeyword) + .then_some(TokenKind::SizeOfKeyword) } else { None } } - Some('o') => scan_chars!(input, 'l', 'i', 'd', 'i', 't', 'y') - .then_some(TokenKind::SolidityKeyword), Some('t') => { match input.next() { Some('a') => scan_chars!(input, 't', 'i', 'c') @@ -6618,13 +8255,13 @@ impl Lexer for Language { Some('d') => { if self.version_is_at_least_0_5_0 { scan_chars!(input, 'e', 'f') - .then_some(TokenKind::TypedefKeyword) + .then_some(TokenKind::TypeDefKeyword) } else { None } } Some('o') => { - scan_chars!(input, 'f').then_some(TokenKind::TypeofKeyword) + scan_chars!(input, 'f').then_some(TokenKind::TypeOfKeyword) } Some(_) => { input.undo(); @@ -6723,30 +8360,16 @@ impl Lexer for Language { input.set_position(save); if let Some(kind) = match input.next() { - Some('!') => match input.next() { - Some('=') => Some(TokenKind::BangEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Bang) - } - None => Some(TokenKind::Bang), - }, - Some('%') => match input.next() { - Some('=') => Some(TokenKind::PercentEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Percent) - } - None => Some(TokenKind::Percent), - }, + Some('!') => scan_chars!(input, '=').then_some(TokenKind::BangEqual), + Some('%') => scan_chars!(input, '=').then_some(TokenKind::PercentEqual), Some('&') => match input.next() { Some('&') => Some(TokenKind::AmpersandAmpersand), Some('=') => Some(TokenKind::AmpersandEqual), Some(_) => { input.undo(); - Some(TokenKind::Ampersand) + None } - None => Some(TokenKind::Ampersand), + None => None, }, Some('(') => Some(TokenKind::OpenParen), Some(')') => Some(TokenKind::CloseParen), @@ -6755,18 +8378,18 @@ impl Lexer for Language { Some('=') => Some(TokenKind::AsteriskEqual), Some(_) => { input.undo(); - Some(TokenKind::Asterisk) + None } - None => Some(TokenKind::Asterisk), + None => None, }, Some('+') => match input.next() { Some('+') => Some(TokenKind::PlusPlus), Some('=') => Some(TokenKind::PlusEqual), Some(_) => { input.undo(); - Some(TokenKind::Plus) + None } - None => Some(TokenKind::Plus), + None => None, }, Some(',') => Some(TokenKind::Comma), Some('-') => match input.next() { @@ -6774,92 +8397,64 @@ impl Lexer for Language { Some('=') => Some(TokenKind::MinusEqual), Some(_) => { input.undo(); - Some(TokenKind::Minus) + None } - None => Some(TokenKind::Minus), + None => None, }, Some('.') => Some(TokenKind::Period), - Some('/') => match input.next() { - Some('=') => Some(TokenKind::SlashEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Slash) - } - None => Some(TokenKind::Slash), - }, - Some(':') => Some(TokenKind::Colon), + Some('/') => scan_chars!(input, '=').then_some(TokenKind::SlashEqual), Some(';') => Some(TokenKind::Semicolon), Some('<') => match input.next() { - Some('<') => match input.next() { - Some('=') => Some(TokenKind::LessThanLessThanEqual), - Some(_) => { - input.undo(); - Some(TokenKind::LessThanLessThan) - } - None => Some(TokenKind::LessThanLessThan), - }, + Some('<') => { + scan_chars!(input, '=').then_some(TokenKind::LessThanLessThanEqual) + } Some('=') => Some(TokenKind::LessThanEqual), Some(_) => { input.undo(); - Some(TokenKind::LessThan) + None } - None => Some(TokenKind::LessThan), + None => None, }, Some('=') => match input.next() { Some('=') => Some(TokenKind::EqualEqual), Some('>') => Some(TokenKind::EqualGreaterThan), Some(_) => { input.undo(); - Some(TokenKind::Equal) + None } - None => Some(TokenKind::Equal), + None => None, }, Some('>') => match input.next() { Some('=') => Some(TokenKind::GreaterThanEqual), Some('>') => match input.next() { Some('=') => Some(TokenKind::GreaterThanGreaterThanEqual), - Some('>') => match input.next() { - Some('=') => { - Some(TokenKind::GreaterThanGreaterThanGreaterThanEqual) - } - Some(_) => { - input.undo(); - Some(TokenKind::GreaterThanGreaterThanGreaterThan) - } - None => Some(TokenKind::GreaterThanGreaterThanGreaterThan), - }, + Some('>') => scan_chars!(input, '=') + .then_some(TokenKind::GreaterThanGreaterThanGreaterThanEqual), Some(_) => { input.undo(); - Some(TokenKind::GreaterThanGreaterThan) + None } - None => Some(TokenKind::GreaterThanGreaterThan), + None => None, }, Some(_) => { input.undo(); - Some(TokenKind::GreaterThan) + None } - None => Some(TokenKind::GreaterThan), + None => None, }, Some('?') => Some(TokenKind::QuestionMark), Some('[') => Some(TokenKind::OpenBracket), Some(']') => Some(TokenKind::CloseBracket), - Some('^') => match input.next() { - Some('=') => Some(TokenKind::CaretEqual), - Some(_) => { - input.undo(); - Some(TokenKind::Caret) - } - None => Some(TokenKind::Caret), - }, + Some('^') => scan_chars!(input, '=').then_some(TokenKind::CaretEqual), Some('{') => Some(TokenKind::OpenBrace), Some('|') => match input.next() { Some('=') => Some(TokenKind::BarEqual), Some('|') => Some(TokenKind::BarBar), Some(_) => { input.undo(); - Some(TokenKind::Bar) + None } - None => Some(TokenKind::Bar), + None => None, }, Some('}') => Some(TokenKind::CloseBrace), Some('~') => Some(TokenKind::Tilde), @@ -6875,16 +8470,32 @@ impl Lexer for Language { input.set_position(save); longest_match! { + { Ampersand = ampersand } { AsciiStringLiteral = ascii_string_literal } + { Asterisk = asterisk } + { Bang = bang } + { Bar = bar } + { Caret = caret } + { Colon = colon } { DecimalLiteral = decimal_literal } { EndOfLine = end_of_line } + { Equal = equal } { FixedBytesType = fixed_bytes_type } + { GreaterThan = greater_than } + { GreaterThanGreaterThan = greater_than_greater_than } + { GreaterThanGreaterThanGreaterThan = greater_than_greater_than_greater_than } { HexLiteral = hex_literal } { HexStringLiteral = hex_string_literal } + { LessThan = less_than } + { LessThanLessThan = less_than_less_than } + { Minus = minus } { MultilineComment = multiline_comment } + { Percent = percent } + { Plus = plus } { SignedFixedType = signed_fixed_type } { SignedIntegerType = signed_integer_type } { SingleLineComment = single_line_comment } + { Slash = slash } { UnicodeStringLiteral = unicode_string_literal } { UnsignedFixedType = unsigned_fixed_type } { UnsignedIntegerType = unsigned_integer_type } @@ -6892,7 +8503,7 @@ impl Lexer for Language { { Identifier = identifier } } } - LexicalContext::VersionPragma => { + LexicalContext::Pragma => { macro_rules! longest_match { ($( { $kind:ident = $function:ident } )*) => { $( @@ -6905,9 +8516,23 @@ impl Lexer for Language { }; } - if let Some(kind) = scan_chars!(input, 's', 'o', 'l', 'i', 'd', 'i', 't', 'y') - .then_some(TokenKind::SolidityKeyword) - { + if let Some(kind) = match input.next() { + Some('a') => scan_chars!(input, 'b', 'i', 'c', 'o', 'd', 'e', 'r') + .then_some(TokenKind::AbicoderKeyword), + Some('e') => { + scan_chars!(input, 'x', 'p', 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l') + .then_some(TokenKind::ExperimentalKeyword) + } + Some('p') => scan_chars!(input, 'r', 'a', 'g', 'm', 'a') + .then_some(TokenKind::PragmaKeyword), + Some('s') => scan_chars!(input, 'o', 'l', 'i', 'd', 'i', 't', 'y') + .then_some(TokenKind::SolidityKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + } { // Make sure that this is not the start of an identifier if !self.identifier_part(input) { furthest_position = input.position(); @@ -6917,26 +8542,10 @@ impl Lexer for Language { input.set_position(save); if let Some(kind) = match input.next() { - Some('-') => Some(TokenKind::Minus), Some('.') => Some(TokenKind::Period), - Some('<') => match input.next() { - Some('=') => Some(TokenKind::LessThanEqual), - Some(_) => { - input.undo(); - Some(TokenKind::LessThan) - } - None => Some(TokenKind::LessThan), - }, - Some('=') => Some(TokenKind::Equal), - Some('>') => match input.next() { - Some('=') => Some(TokenKind::GreaterThanEqual), - Some(_) => { - input.undo(); - Some(TokenKind::GreaterThan) - } - None => Some(TokenKind::GreaterThan), - }, - Some('^') => Some(TokenKind::Caret), + Some(';') => Some(TokenKind::Semicolon), + Some('<') => scan_chars!(input, '=').then_some(TokenKind::LessThanEqual), + Some('>') => scan_chars!(input, '=').then_some(TokenKind::GreaterThanEqual), Some('|') => scan_chars!(input, '|').then_some(TokenKind::BarBar), Some('~') => Some(TokenKind::Tilde), Some(_) => { @@ -6951,10 +8560,17 @@ impl Lexer for Language { input.set_position(save); longest_match! { + { AsciiStringLiteral = ascii_string_literal } + { Caret = caret } + { Equal = equal } + { GreaterThan = greater_than } + { LessThan = less_than } + { Minus = minus } { VersionPragmaValue = version_pragma_value } + { Identifier = identifier } } } - LexicalContext::YulBlock => { + LexicalContext::Yul => { macro_rules! longest_match { ($( { $kind:ident = $function:ident } )*) => { $( @@ -6968,62 +8584,1097 @@ impl Lexer for Language { } if let Some(kind) = match input.next() { - Some('b') => { - scan_chars!(input, 'r', 'e', 'a', 'k').then_some(TokenKind::BreakKeyword) - } - Some('c') => match input.next() { - Some('a') => scan_chars!(input, 's', 'e').then_some(TokenKind::CaseKeyword), - Some('o') => scan_chars!(input, 'n', 't', 'i', 'n', 'u', 'e') - .then_some(TokenKind::ContinueKeyword), + Some('a') => match input.next() { + Some('b') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 's', 't', 'r', 'a', 'c', 't') + .then_some(TokenKind::YulAbstractKeyword) + } else { + None + } + } + Some('d') => scan_chars!(input, 'd', 'r', 'e', 's', 's') + .then_some(TokenKind::YulAddressKeyword), + Some('f') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'e', 'r') + .then_some(TokenKind::YulAfterKeyword) + } else { + None + } + } + Some('l') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'a', 's') + .then_some(TokenKind::YulAliasKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'o', 'n', 'y', 'm', 'o', 'u', 's') + .then_some(TokenKind::YulAnonymousKeyword) + } else { + None + } + } + Some('p') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'p', 'l', 'y') + .then_some(TokenKind::YulApplyKeyword) + } else { + None + } + } + Some('s') => match input.next() { + Some('s') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'm', 'b', 'l', 'y') + .then_some(TokenKind::YulAssemblyKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulAsKeyword) + } else { + None + } + } + None => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulAsKeyword) + } else { + None + } + } + }, + Some('u') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'o').then_some(TokenKind::YulAutoKeyword) + } else { + None + } + } Some(_) => { input.undo(); None } None => None, }, - Some('d') => scan_chars!(input, 'e', 'f', 'a', 'u', 'l', 't') - .then_some(TokenKind::DefaultKeyword), - Some('f') => match input.next() { - Some('a') => { - scan_chars!(input, 'l', 's', 'e').then_some(TokenKind::FalseKeyword) + Some('b') => match input.next() { + Some('o') => { + if !self.version_is_at_least_0_5_10 { + scan_chars!(input, 'o', 'l').then_some(TokenKind::YulBoolKeyword) + } else { + None + } + } + Some('r') => { + scan_chars!(input, 'e', 'a', 'k').then_some(TokenKind::YulBreakKeyword) + } + Some('y') => { + scan_chars!(input, 't', 'e').then_some(TokenKind::YulByteKeyword) } - Some('o') => scan_chars!(input, 'r').then_some(TokenKind::ForKeyword), - Some('u') => scan_chars!(input, 'n', 'c', 't', 'i', 'o', 'n') - .then_some(TokenKind::FunctionKeyword), Some(_) => { input.undo(); None } None => None, }, - Some('h') => scan_chars!(input, 'e', 'x').then_some(TokenKind::HexKeyword), - Some('i') => scan_chars!(input, 'f').then_some(TokenKind::IfKeyword), - Some('l') => { - if scan_chars!(input, 'e') { - match input.next() { - Some('a') => { - if self.version_is_at_least_0_6_0 { - scan_chars!(input, 'v', 'e') - .then_some(TokenKind::LeaveKeyword) + Some('c') => match input.next() { + Some('a') => match input.next() { + Some('l') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'l', 'd', 'a', 't', 'a') + .then_some(TokenKind::YulCallDataKeyword) + } else { + None + } + } + Some('s') => { + scan_chars!(input, 'e').then_some(TokenKind::YulCaseKeyword) + } + Some('t') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 'h') + .then_some(TokenKind::YulCatchKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('o') => match input.next() { + Some('n') => match input.next() { + Some('s') => { + if scan_chars!(input, 't') { + match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'n', 't') + .then_some(TokenKind::YulConstantKeyword) + } else { + None + } + } + Some('r') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'u', 'c', 't', 'o', 'r') + .then_some(TokenKind::YulConstructorKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('t') => match input.next() { + Some('i') => scan_chars!(input, 'n', 'u', 'e') + .then_some(TokenKind::YulContinueKeyword), + Some('r') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'c', 't') + .then_some(TokenKind::YulContractKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('p') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'y', 'o', 'f') + .then_some(TokenKind::YulCopyOfKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('d') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'y', 's').then_some(TokenKind::YulDaysKeyword) + } else { + None + } + } + Some('e') => match input.next() { + Some('f') => match input.next() { + Some('a') => scan_chars!(input, 'u', 'l', 't') + .then_some(TokenKind::YulDefaultKeyword), + Some('i') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'n', 'e') + .then_some(TokenKind::YulDefineKeyword) } else { None } } - Some('t') => Some(TokenKind::LetKeyword), Some(_) => { input.undo(); None } None => None, + }, + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 't', 'e') + .then_some(TokenKind::YulDeleteKeyword) + } else { + None + } } - } else { + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('o') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulDoKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('e') => match input.next() { + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 's', 'e').then_some(TokenKind::YulElseKeyword) + } else { + None + } + } + Some('m') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 't').then_some(TokenKind::YulEmitKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'u', 'm').then_some(TokenKind::YulEnumKeyword) + } else { + None + } + } + Some('t') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'h', 'e', 'r') + .then_some(TokenKind::YulEtherKeyword) + } else { + None + } + } + Some('v') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'n', 't') + .then_some(TokenKind::YulEventKeyword) + } else { + None + } + } + Some('x') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'e', 'r', 'n', 'a', 'l') + .then_some(TokenKind::YulExternalKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('f') => match input.next() { + Some('a') => { + if scan_chars!(input, 'l') { + match input.next() { + Some('l') => { + if self.version_is_at_least_0_6_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'b', 'a', 'c', 'k') + .then_some(TokenKind::YulFallbackKeyword) + } else { + None + } + } + Some('s') => scan_chars!(input, 'e') + .then_some(TokenKind::YulFalseKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('i') => { + if scan_chars!(input, 'n') { + match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'l') + .then_some(TokenKind::YulFinalKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_0 { + scan_chars!(input, 'e', 'y') + .then_some(TokenKind::YulFinneyKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('o') => scan_chars!(input, 'r').then_some(TokenKind::YulForKeyword), + Some('u') => scan_chars!(input, 'n', 'c', 't', 'i', 'o', 'n') + .then_some(TokenKind::YulFunctionKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('g') => { + if self.version_is_at_least_0_7_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'w', 'e', 'i').then_some(TokenKind::YulGweiKeyword) + } else { + None + } + } + Some('h') => match input.next() { + Some('e') => scan_chars!(input, 'x').then_some(TokenKind::YulHexKeyword), + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'u', 'r', 's') + .then_some(TokenKind::YulHoursKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('i') => match input.next() { + Some('f') => Some(TokenKind::YulIfKeyword), + Some('m') => match input.next() { + Some('m') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'u', 't', 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulImmutableKeyword) + } else { + None + } + } + Some('p') => match input.next() { + Some('l') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'm', 'e', 'n', 't', 's') + .then_some(TokenKind::YulImplementsKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'r', 't') + .then_some(TokenKind::YulImportKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('n') => match input.next() { + Some('d') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'x', 'e', 'd') + .then_some(TokenKind::YulIndexedKeyword) + } else { + None + } + } + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'n', 'e') + .then_some(TokenKind::YulInlineKeyword) + } else { + None + } + } + Some('t') => { + if scan_chars!(input, 'e', 'r') { + match input.next() { + Some('f') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'c', 'e') + .then_some(TokenKind::YulInterfaceKeyword) + } else { + None + } + } + Some('n') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'l') + .then_some(TokenKind::YulInternalKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some(_) => { + input.undo(); + if !self.version_is_at_least_0_6_8 { + Some(TokenKind::YulInKeyword) + } else { + None + } + } + None => { + if !self.version_is_at_least_0_6_8 { + Some(TokenKind::YulInKeyword) + } else { + None + } + } + }, + Some('s') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulIsKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('l') => match input.next() { + Some('e') => match input.next() { + Some('a') => { + if self.version_is_at_least_0_6_0 { + scan_chars!(input, 'v', 'e') + .then_some(TokenKind::YulLeaveKeyword) + } else { + None + } + } + Some('t') => Some(TokenKind::YulLetKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'b', 'r', 'a', 'r', 'y') + .then_some(TokenKind::YulLibraryKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('m') => match input.next() { + Some('a') => match input.next() { + Some('c') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'r', 'o') + .then_some(TokenKind::YulMacroKeyword) + } else { + None + } + } + Some('p') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'p', 'i', 'n', 'g') + .then_some(TokenKind::YulMappingKeyword) + } else { + None + } + } + Some('t') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 'h') + .then_some(TokenKind::YulMatchKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'm', 'o', 'r', 'y') + .then_some(TokenKind::YulMemoryKeyword) + } else { + None + } + } + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'n', 'u', 't', 'e', 's') + .then_some(TokenKind::YulMinutesKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'd', 'i', 'f', 'i', 'e', 'r') + .then_some(TokenKind::YulModifierKeyword) + } else { + None + } + } + Some('u') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulMutableKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('n') => match input.next() { + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'w').then_some(TokenKind::YulNewKeyword) + } else { + None + } + } + Some('u') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'l', 'l').then_some(TokenKind::YulNullKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('o') => match input.next() { + Some('f') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulOfKeyword) + } else { + None + } + } + Some('v') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'r', 'r', 'i', 'd', 'e') + .then_some(TokenKind::YulOverrideKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('p') => match input.next() { + Some('a') => match input.next() { + Some('r') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 't', 'i', 'a', 'l') + .then_some(TokenKind::YulPartialKeyword) + } else { + None + } + } + Some('y') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulPayableKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('r') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'g', 'm', 'a') + .then_some(TokenKind::YulPragmaKeyword) + } else { + None + } + } + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'v', 'a', 't', 'e') + .then_some(TokenKind::YulPrivateKeyword) + } else { + None + } + } + Some('o') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'm', 'i', 's', 'e') + .then_some(TokenKind::YulPromiseKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('u') => match input.next() { + Some('b') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'l', 'i', 'c') + .then_some(TokenKind::YulPublicKeyword) + } else { + None + } + } + Some('r') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e').then_some(TokenKind::YulPureKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('r') => { + if scan_chars!(input, 'e') { + match input.next() { + Some('c') => { + if self.version_is_at_least_0_6_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'i', 'v', 'e') + .then_some(TokenKind::YulReceiveKeyword) + } else { + None + } + } + Some('f') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'r', 'e', 'n', 'c', 'e') + .then_some(TokenKind::YulReferenceKeyword) + } else { + None + } + } + Some('l') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'o', 'c', 'a', 't', 'a', 'b', 'l', 'e') + .then_some(TokenKind::YulRelocatableKeyword) + } else { + None + } + } + Some('t') => { + if scan_chars!(input, 'u', 'r', 'n') { + match input.next() { + Some('s') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulReturnsKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + Some(TokenKind::YulReturnKeyword) + } + None => Some(TokenKind::YulReturnKeyword), + } + } else { + None + } + } + Some('v') => scan_chars!(input, 'e', 'r', 't') + .then_some(TokenKind::YulRevertKeyword), + Some(_) => { + input.undo(); + None + } + None => None, + } + } else { + None + } + } + Some('s') => match input.next() { + Some('e') => match input.next() { + Some('a') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'l', 'e', 'd') + .then_some(TokenKind::YulSealedKeyword) + } else { + None + } + } + Some('c') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'o', 'n', 'd', 's') + .then_some(TokenKind::YulSecondsKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('i') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'z', 'e', 'o', 'f') + .then_some(TokenKind::YulSizeOfKeyword) + } else { + None + } + } + Some('t') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 't', 'i', 'c') + .then_some(TokenKind::YulStaticKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'r', 'a', 'g', 'e') + .then_some(TokenKind::YulStorageKeyword) + } else { + None + } + } + Some('r') => match input.next() { + Some('i') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'n', 'g') + .then_some(TokenKind::YulStringKeyword) + } else { + None + } + } + Some('u') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 't') + .then_some(TokenKind::YulStructKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('u') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'p', 'p', 'o', 'r', 't', 's') + .then_some(TokenKind::YulSupportsKeyword) + } else { + None + } + } + Some('w') => scan_chars!(input, 'i', 't', 'c', 'h') + .then_some(TokenKind::YulSwitchKeyword), + Some('z') => { + if !self.version_is_at_least_0_7_0 { + scan_chars!(input, 'a', 'b', 'o') + .then_some(TokenKind::YulSzaboKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('t') => match input.next() { + Some('h') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'r', 'o', 'w') + .then_some(TokenKind::YulThrowKeyword) + } else { + None + } + } + Some('r') => match input.next() { + Some('u') => { + scan_chars!(input, 'e').then_some(TokenKind::YulTrueKeyword) + } + Some('y') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulTryKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('y') => { + if scan_chars!(input, 'p', 'e') { + match input.next() { + Some('d') => { + if self.version_is_at_least_0_5_0 + && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 'e', 'f') + .then_some(TokenKind::YulTypeDefKeyword) + } else { + None + } + } + Some('o') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'f') + .then_some(TokenKind::YulTypeOfKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulTypeKeyword) + } else { + None + } + } + None => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulTypeKeyword) + } else { + None + } + } + } + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('u') => match input.next() { + Some('n') => { + if self.version_is_at_least_0_5_0 && !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'c', 'h', 'e', 'c', 'k', 'e', 'd') + .then_some(TokenKind::YulUncheckedKeyword) + } else { + None + } + } + Some('s') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'n', 'g') + .then_some(TokenKind::YulUsingKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('v') => match input.next() { + Some('a') => { + if !self.version_is_at_least_0_6_5 { + scan_chars!(input, 'r').then_some(TokenKind::YulVarKeyword) + } else { + None + } + } + Some('i') => match input.next() { + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'w').then_some(TokenKind::YulViewKeyword) + } else { + None + } + } + Some('r') => { + if self.version_is_at_least_0_6_0 && !self.version_is_at_least_0_7_1 + { + scan_chars!(input, 't', 'u', 'a', 'l') + .then_some(TokenKind::YulVirtualKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('w') => match input.next() { + Some('e') => match input.next() { + Some('e') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'k', 's') + .then_some(TokenKind::YulWeeksKeyword) + } else { + None + } + } + Some('i') => { + if !self.version_is_at_least_0_7_1 { + Some(TokenKind::YulWeiKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('h') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'i', 'l', 'e') + .then_some(TokenKind::YulWhileKeyword) + } else { + None + } + } + Some(_) => { + input.undo(); + None + } + None => None, + }, + Some('y') => { + if !self.version_is_at_least_0_7_1 { + scan_chars!(input, 'e', 'a', 'r', 's') + .then_some(TokenKind::YulYearsKeyword) + } else { None } - } - Some('s') => scan_chars!(input, 'w', 'i', 't', 'c', 'h') - .then_some(TokenKind::SwitchKeyword), - Some('t') => { - scan_chars!(input, 'r', 'u', 'e').then_some(TokenKind::TrueKeyword) } Some(_) => { input.undo(); @@ -7062,9 +9713,14 @@ impl Lexer for Language { longest_match! { { AsciiStringLiteral = ascii_string_literal } { HexStringLiteral = hex_string_literal } + { YulBytesKeyword = yul_bytes_keyword } { YulDecimalLiteral = yul_decimal_literal } + { YulFixedKeyword = yul_fixed_keyword } { YulHexLiteral = yul_hex_literal } { YulIdentifier = yul_identifier } + { YulIntKeyword = yul_int_keyword } + { YulUfixedKeyword = yul_ufixed_keyword } + { YulUintKeyword = yul_uint_keyword } } } } 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 429674de4a..cc8f7d02fc 100644 --- a/crates/solidity/outputs/npm/package/src/generated/index.d.ts +++ b/crates/solidity/outputs/npm/package/src/generated/index.d.ts @@ -18,6 +18,7 @@ export namespace kinds { ArrayExpression = "ArrayExpression", ArrayValuesList = "ArrayValuesList", AsciiStringLiteralsList = "AsciiStringLiteralsList", + AssemblyFlagsDeclaration = "AssemblyFlagsDeclaration", AssemblyFlagsList = "AssemblyFlagsList", AssemblyStatement = "AssemblyStatement", Block = "Block", @@ -37,6 +38,7 @@ export namespace kinds { DeconstructionImportSymbolsList = "DeconstructionImportSymbolsList", DeleteStatement = "DeleteStatement", DoWhileStatement = "DoWhileStatement", + ElseBranch = "ElseBranch", EmitStatement = "EmitStatement", EndOfFileTrivia = "EndOfFileTrivia", EnumDefinition = "EnumDefinition", @@ -65,7 +67,9 @@ export namespace kinds { IdentifierPathsList = "IdentifierPathsList", IdentifiersList = "IdentifiersList", IfStatement = "IfStatement", + ImportAlias = "ImportAlias", ImportDirective = "ImportDirective", + IndexAccessEnd = "IndexAccessEnd", InheritanceSpecifier = "InheritanceSpecifier", InheritanceType = "InheritanceType", InheritanceTypesList = "InheritanceTypesList", @@ -82,6 +86,7 @@ export namespace kinds { ModifierInvocation = "ModifierInvocation", NamedArgument = "NamedArgument", NamedArgumentsDeclaration = "NamedArgumentsDeclaration", + NamedArgumentsDeclarations = "NamedArgumentsDeclarations", NamedArgumentsList = "NamedArgumentsList", NamedImport = "NamedImport", NewExpression = "NewExpression", @@ -101,6 +106,7 @@ export namespace kinds { SourceUnitMembersList = "SourceUnitMembersList", StateVariableAttributesList = "StateVariableAttributesList", StateVariableDefinition = "StateVariableDefinition", + StateVariableDefinitionValue = "StateVariableDefinitionValue", Statement = "Statement", StatementsList = "StatementsList", StructDefinition = "StructDefinition", @@ -111,16 +117,20 @@ export namespace kinds { TryStatement = "TryStatement", TupleDeconstructionStatement = "TupleDeconstructionStatement", TupleExpression = "TupleExpression", - TupleMember = "TupleMember", + TupleMemberDeconstruction = "TupleMemberDeconstruction", TupleMembersList = "TupleMembersList", + TupleValue = "TupleValue", TupleValuesList = "TupleValuesList", TypeExpression = "TypeExpression", TypeName = "TypeName", + TypedTupleMember = "TypedTupleMember", UncheckedBlock = "UncheckedBlock", UnicodeStringLiteralsList = "UnicodeStringLiteralsList", UnnamedFunctionAttributesList = "UnnamedFunctionAttributesList", UnnamedFunctionDefinition = "UnnamedFunctionDefinition", + UntypedTupleMember = "UntypedTupleMember", UserDefinedValueTypeDefinition = "UserDefinedValueTypeDefinition", + UsingAlias = "UsingAlias", UsingDirective = "UsingDirective", UsingDirectiveDeconstruction = "UsingDirectiveDeconstruction", UsingDirectivePath = "UsingDirectivePath", @@ -128,6 +138,7 @@ export namespace kinds { UsingDirectiveSymbolsList = "UsingDirectiveSymbolsList", VariableDeclaration = "VariableDeclaration", VariableDeclarationStatement = "VariableDeclarationStatement", + VariableDeclarationValue = "VariableDeclarationValue", VersionPragma = "VersionPragma", VersionPragmaExpression = "VersionPragmaExpression", VersionPragmaExpressionsList = "VersionPragmaExpressionsList", @@ -137,7 +148,7 @@ export namespace kinds { YulBlock = "YulBlock", YulBreakStatement = "YulBreakStatement", YulContinueStatement = "YulContinueStatement", - YulDeclarationStatement = "YulDeclarationStatement", + YulDefaultCase = "YulDefaultCase", YulExpression = "YulExpression", YulExpressionsList = "YulExpressionsList", YulForStatement = "YulForStatement", @@ -151,9 +162,11 @@ export namespace kinds { YulReturnsDeclaration = "YulReturnsDeclaration", YulStatement = "YulStatement", YulStatementsList = "YulStatementsList", - YulSwitchCase = "YulSwitchCase", YulSwitchCasesList = "YulSwitchCasesList", YulSwitchStatement = "YulSwitchStatement", + YulValueCase = "YulValueCase", + YulVariableDeclarationStatement = "YulVariableDeclarationStatement", + YulVariableDeclarationValue = "YulVariableDeclarationValue", } export enum RuleKind { ABICoderPragma = "ABICoderPragma", @@ -163,6 +176,7 @@ export namespace kinds { ArrayTypeName = "ArrayTypeName", ArrayValuesList = "ArrayValuesList", AsciiStringLiteralsList = "AsciiStringLiteralsList", + AssemblyFlagsDeclaration = "AssemblyFlagsDeclaration", AssemblyFlagsList = "AssemblyFlagsList", AssemblyStatement = "AssemblyStatement", BinaryExpression = "BinaryExpression", @@ -184,6 +198,7 @@ export namespace kinds { DeconstructionImportSymbolsList = "DeconstructionImportSymbolsList", DeleteStatement = "DeleteStatement", DoWhileStatement = "DoWhileStatement", + ElseBranch = "ElseBranch", EmitStatement = "EmitStatement", EndOfFileTrivia = "EndOfFileTrivia", EnumDefinition = "EnumDefinition", @@ -213,7 +228,9 @@ export namespace kinds { IdentifierPathsList = "IdentifierPathsList", IdentifiersList = "IdentifiersList", IfStatement = "IfStatement", + ImportAlias = "ImportAlias", ImportDirective = "ImportDirective", + IndexAccessEnd = "IndexAccessEnd", IndexAccessExpression = "IndexAccessExpression", InheritanceSpecifier = "InheritanceSpecifier", InheritanceType = "InheritanceType", @@ -232,6 +249,7 @@ export namespace kinds { ModifierInvocation = "ModifierInvocation", NamedArgument = "NamedArgument", NamedArgumentsDeclaration = "NamedArgumentsDeclaration", + NamedArgumentsDeclarations = "NamedArgumentsDeclarations", NamedArgumentsList = "NamedArgumentsList", NamedImport = "NamedImport", NewExpression = "NewExpression", @@ -251,6 +269,7 @@ export namespace kinds { SourceUnitMembersList = "SourceUnitMembersList", StateVariableAttributesList = "StateVariableAttributesList", StateVariableDefinition = "StateVariableDefinition", + StateVariableDefinitionValue = "StateVariableDefinitionValue", Statement = "Statement", StatementsList = "StatementsList", StructDefinition = "StructDefinition", @@ -261,18 +280,22 @@ export namespace kinds { TryStatement = "TryStatement", TupleDeconstructionStatement = "TupleDeconstructionStatement", TupleExpression = "TupleExpression", - TupleMember = "TupleMember", + TupleMemberDeconstruction = "TupleMemberDeconstruction", TupleMembersList = "TupleMembersList", + TupleValue = "TupleValue", TupleValuesList = "TupleValuesList", TypeExpression = "TypeExpression", TypeName = "TypeName", + TypedTupleMember = "TypedTupleMember", UnaryPostfixExpression = "UnaryPostfixExpression", UnaryPrefixExpression = "UnaryPrefixExpression", UncheckedBlock = "UncheckedBlock", UnicodeStringLiteralsList = "UnicodeStringLiteralsList", UnnamedFunctionAttributesList = "UnnamedFunctionAttributesList", UnnamedFunctionDefinition = "UnnamedFunctionDefinition", + UntypedTupleMember = "UntypedTupleMember", UserDefinedValueTypeDefinition = "UserDefinedValueTypeDefinition", + UsingAlias = "UsingAlias", UsingDirective = "UsingDirective", UsingDirectiveDeconstruction = "UsingDirectiveDeconstruction", UsingDirectivePath = "UsingDirectivePath", @@ -280,6 +303,7 @@ export namespace kinds { UsingDirectiveSymbolsList = "UsingDirectiveSymbolsList", VariableDeclaration = "VariableDeclaration", VariableDeclarationStatement = "VariableDeclarationStatement", + VariableDeclarationValue = "VariableDeclarationValue", VersionPragma = "VersionPragma", VersionPragmaBinaryExpression = "VersionPragmaBinaryExpression", VersionPragmaExpression = "VersionPragmaExpression", @@ -291,7 +315,7 @@ export namespace kinds { YulBlock = "YulBlock", YulBreakStatement = "YulBreakStatement", YulContinueStatement = "YulContinueStatement", - YulDeclarationStatement = "YulDeclarationStatement", + YulDefaultCase = "YulDefaultCase", YulExpression = "YulExpression", YulExpressionsList = "YulExpressionsList", YulForStatement = "YulForStatement", @@ -306,9 +330,11 @@ export namespace kinds { YulReturnsDeclaration = "YulReturnsDeclaration", YulStatement = "YulStatement", YulStatementsList = "YulStatementsList", - YulSwitchCase = "YulSwitchCase", YulSwitchCasesList = "YulSwitchCasesList", YulSwitchStatement = "YulSwitchStatement", + YulValueCase = "YulValueCase", + YulVariableDeclarationStatement = "YulVariableDeclarationStatement", + YulVariableDeclarationValue = "YulVariableDeclarationValue", } export enum TokenKind { SKIPPED = "SKIPPED", @@ -337,7 +363,7 @@ export namespace kinds { BoolKeyword = "BoolKeyword", BreakKeyword = "BreakKeyword", ByteKeyword = "ByteKeyword", - CalldataKeyword = "CalldataKeyword", + CallDataKeyword = "CallDataKeyword", Caret = "Caret", CaretEqual = "CaretEqual", CaseKeyword = "CaseKeyword", @@ -352,7 +378,7 @@ export namespace kinds { ConstructorKeyword = "ConstructorKeyword", ContinueKeyword = "ContinueKeyword", ContractKeyword = "ContractKeyword", - CopyofKeyword = "CopyofKeyword", + CopyOfKeyword = "CopyOfKeyword", DaysKeyword = "DaysKeyword", DecimalLiteral = "DecimalLiteral", DefaultKeyword = "DefaultKeyword", @@ -402,7 +428,6 @@ export namespace kinds { InterfaceKeyword = "InterfaceKeyword", InternalKeyword = "InternalKeyword", IsKeyword = "IsKeyword", - LeaveKeyword = "LeaveKeyword", LessThan = "LessThan", LessThanEqual = "LessThanEqual", LessThanLessThan = "LessThanLessThan", @@ -454,7 +479,7 @@ export namespace kinds { SignedFixedType = "SignedFixedType", SignedIntegerType = "SignedIntegerType", SingleLineComment = "SingleLineComment", - SizeofKeyword = "SizeofKeyword", + SizeOfKeyword = "SizeOfKeyword", Slash = "Slash", SlashEqual = "SlashEqual", SolidityKeyword = "SolidityKeyword", @@ -469,9 +494,9 @@ export namespace kinds { Tilde = "Tilde", TrueKeyword = "TrueKeyword", TryKeyword = "TryKeyword", + TypeDefKeyword = "TypeDefKeyword", TypeKeyword = "TypeKeyword", - TypedefKeyword = "TypedefKeyword", - TypeofKeyword = "TypeofKeyword", + TypeOfKeyword = "TypeOfKeyword", UncheckedKeyword = "UncheckedKeyword", UnicodeStringLiteral = "UnicodeStringLiteral", UnsignedFixedType = "UnsignedFixedType", @@ -486,17 +511,124 @@ export namespace kinds { WhileKeyword = "WhileKeyword", Whitespace = "Whitespace", YearsKeyword = "YearsKeyword", + YulAbstractKeyword = "YulAbstractKeyword", + YulAddressKeyword = "YulAddressKeyword", + YulAfterKeyword = "YulAfterKeyword", + YulAliasKeyword = "YulAliasKeyword", + YulAnonymousKeyword = "YulAnonymousKeyword", + YulApplyKeyword = "YulApplyKeyword", + YulAsKeyword = "YulAsKeyword", + YulAssemblyKeyword = "YulAssemblyKeyword", + YulAutoKeyword = "YulAutoKeyword", + YulBoolKeyword = "YulBoolKeyword", + YulBreakKeyword = "YulBreakKeyword", + YulByteKeyword = "YulByteKeyword", + YulBytesKeyword = "YulBytesKeyword", + YulCallDataKeyword = "YulCallDataKeyword", + YulCaseKeyword = "YulCaseKeyword", + YulCatchKeyword = "YulCatchKeyword", + YulConstantKeyword = "YulConstantKeyword", + YulConstructorKeyword = "YulConstructorKeyword", + YulContinueKeyword = "YulContinueKeyword", + YulContractKeyword = "YulContractKeyword", + YulCopyOfKeyword = "YulCopyOfKeyword", + YulDaysKeyword = "YulDaysKeyword", YulDecimalLiteral = "YulDecimalLiteral", + YulDefaultKeyword = "YulDefaultKeyword", + YulDefineKeyword = "YulDefineKeyword", + YulDeleteKeyword = "YulDeleteKeyword", + YulDoKeyword = "YulDoKeyword", + YulElseKeyword = "YulElseKeyword", + YulEmitKeyword = "YulEmitKeyword", + YulEnumKeyword = "YulEnumKeyword", + YulEtherKeyword = "YulEtherKeyword", + YulEventKeyword = "YulEventKeyword", + YulExternalKeyword = "YulExternalKeyword", + YulFallbackKeyword = "YulFallbackKeyword", + YulFalseKeyword = "YulFalseKeyword", + YulFinalKeyword = "YulFinalKeyword", + YulFinneyKeyword = "YulFinneyKeyword", + YulFixedKeyword = "YulFixedKeyword", + YulForKeyword = "YulForKeyword", + YulFunctionKeyword = "YulFunctionKeyword", + YulGweiKeyword = "YulGweiKeyword", + YulHexKeyword = "YulHexKeyword", YulHexLiteral = "YulHexLiteral", + YulHoursKeyword = "YulHoursKeyword", YulIdentifier = "YulIdentifier", + YulIfKeyword = "YulIfKeyword", + YulImmutableKeyword = "YulImmutableKeyword", + YulImplementsKeyword = "YulImplementsKeyword", + YulImportKeyword = "YulImportKeyword", + YulInKeyword = "YulInKeyword", + YulIndexedKeyword = "YulIndexedKeyword", + YulInlineKeyword = "YulInlineKeyword", + YulIntKeyword = "YulIntKeyword", + YulInterfaceKeyword = "YulInterfaceKeyword", + YulInternalKeyword = "YulInternalKeyword", + YulIsKeyword = "YulIsKeyword", + YulLeaveKeyword = "YulLeaveKeyword", + YulLetKeyword = "YulLetKeyword", + YulLibraryKeyword = "YulLibraryKeyword", + YulMacroKeyword = "YulMacroKeyword", + YulMappingKeyword = "YulMappingKeyword", + YulMatchKeyword = "YulMatchKeyword", + YulMemoryKeyword = "YulMemoryKeyword", + YulMinutesKeyword = "YulMinutesKeyword", + YulModifierKeyword = "YulModifierKeyword", + YulMutableKeyword = "YulMutableKeyword", + YulNewKeyword = "YulNewKeyword", + YulNullKeyword = "YulNullKeyword", + YulOfKeyword = "YulOfKeyword", + YulOverrideKeyword = "YulOverrideKeyword", + YulPartialKeyword = "YulPartialKeyword", + YulPayableKeyword = "YulPayableKeyword", + YulPragmaKeyword = "YulPragmaKeyword", + YulPrivateKeyword = "YulPrivateKeyword", + YulPromiseKeyword = "YulPromiseKeyword", + YulPublicKeyword = "YulPublicKeyword", + YulPureKeyword = "YulPureKeyword", + YulReceiveKeyword = "YulReceiveKeyword", + YulReferenceKeyword = "YulReferenceKeyword", + YulRelocatableKeyword = "YulRelocatableKeyword", + YulReturnKeyword = "YulReturnKeyword", + YulReturnsKeyword = "YulReturnsKeyword", + YulRevertKeyword = "YulRevertKeyword", + YulSealedKeyword = "YulSealedKeyword", + YulSecondsKeyword = "YulSecondsKeyword", + YulSizeOfKeyword = "YulSizeOfKeyword", + YulStaticKeyword = "YulStaticKeyword", + YulStorageKeyword = "YulStorageKeyword", + YulStringKeyword = "YulStringKeyword", + YulStructKeyword = "YulStructKeyword", + YulSupportsKeyword = "YulSupportsKeyword", + YulSwitchKeyword = "YulSwitchKeyword", + YulSzaboKeyword = "YulSzaboKeyword", + YulThrowKeyword = "YulThrowKeyword", + YulTrueKeyword = "YulTrueKeyword", + YulTryKeyword = "YulTryKeyword", + YulTypeDefKeyword = "YulTypeDefKeyword", + YulTypeKeyword = "YulTypeKeyword", + YulTypeOfKeyword = "YulTypeOfKeyword", + YulUfixedKeyword = "YulUfixedKeyword", + YulUintKeyword = "YulUintKeyword", + YulUncheckedKeyword = "YulUncheckedKeyword", + YulUsingKeyword = "YulUsingKeyword", + YulVarKeyword = "YulVarKeyword", + YulViewKeyword = "YulViewKeyword", + YulVirtualKeyword = "YulVirtualKeyword", + YulWeeksKeyword = "YulWeeksKeyword", + YulWeiKeyword = "YulWeiKeyword", + YulWhileKeyword = "YulWhileKeyword", + YulYearsKeyword = "YulYearsKeyword", } } export namespace language { /** The lexical context of the scanner. */ export enum LexicalContext { Default = "Default", - VersionPragma = "VersionPragma", - YulBlock = "YulBlock", + Pragma = "Pragma", + Yul = "Yul", } export class Language { constructor(version: string); 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 41b8661c2d..82e6277129 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 @@ -91,12 +91,13 @@ Tree: - TupleDeconstructionStatement (Rule): # 201..262 "\n (bool success, ) = recipient.call{ value: amo..." - OpenParen (Token): "(" # 206..207 - TupleMembersList (Rule): # 207..220 "bool success," - - TupleMember (Rule): # 207..219 "bool success" - - TypeName (Rule): # 207..211 "bool" - - BoolKeyword (Token): "bool" # 207..211 - - Identifier (Token): "success" # 212..219 + - TupleMemberDeconstruction (Rule): # 207..219 "bool success" + - TypedTupleMember (Rule): # 207..219 "bool success" + - TypeName (Rule): # 207..211 "bool" + - BoolKeyword (Token): "bool" # 207..211 + - Identifier (Token): "success" # 212..219 - Comma (Token): "," # 219..220 - - TupleMember (Rule): [] # 220..220 + - TupleMemberDeconstruction (Rule): [] # 220..220 - CloseParen (Token): ")" # 221..222 - Equal (Token): "=" # 223..224 - Expression (Rule): # 224..239 " recipient.call" 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 042b47fad3..0840496b6b 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 @@ -83,12 +83,13 @@ Tree: - TupleDeconstructionStatement (Rule): # 201..262 "\n (bool success, ) = recipient.call{ value: amo..." - OpenParen (Token): "(" # 206..207 - TupleMembersList (Rule): # 207..220 "bool success," - - TupleMember (Rule): # 207..219 "bool success" - - TypeName (Rule): # 207..211 "bool" - - BoolKeyword (Token): "bool" # 207..211 - - Identifier (Token): "success" # 212..219 + - TupleMemberDeconstruction (Rule): # 207..219 "bool success" + - TypedTupleMember (Rule): # 207..219 "bool success" + - TypeName (Rule): # 207..211 "bool" + - BoolKeyword (Token): "bool" # 207..211 + - Identifier (Token): "success" # 212..219 - Comma (Token): "," # 219..220 - - TupleMember (Rule): [] # 220..220 + - TupleMemberDeconstruction (Rule): [] # 220..220 - CloseParen (Token): ")" # 221..222 - Equal (Token): "=" # 223..224 - Expression (Rule): # 224..260 ' recipient.call{ value: amount }("")' diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.4.11-failure.yml index aa3a1c972f..abfa38da35 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.4.11-failure.yml @@ -80,10 +80,11 @@ Tree: - TypeName (Rule): # 113..123 "\t\t\tuint256" - UnsignedIntegerType (Token): "uint256" # 116..123 - Identifier (Token): "a" # 124..125 - - Equal (Token): "=" # 126..127 - - Expression (Rule): # 127..129 " 1" - - DecimalNumberExpression (Rule): # 127..129 " 1" - - DecimalLiteral (Token): "1" # 128..129 + - VariableDeclarationValue (Rule): # 125..129 " = 1" + - Equal (Token): "=" # 126..127 + - Expression (Rule): # 127..129 " 1" + - DecimalNumberExpression (Rule): # 127..129 " 1" + - DecimalLiteral (Token): "1" # 128..129 - Semicolon (Token): ";" # 129..130 - CloseBrace (Token): "}" # 133..134 - CloseBrace (Token): "}" # 136..137 @@ -102,10 +103,11 @@ Tree: - TypeName (Rule): # 157..166 "\t\tuint256" - UnsignedIntegerType (Token): "uint256" # 159..166 - Identifier (Token): "x" # 167..168 - - Equal (Token): "=" # 169..170 - - Expression (Rule): # 170..172 " 0" - - DecimalNumberExpression (Rule): # 170..172 " 0" - - DecimalLiteral (Token): "0" # 171..172 + - VariableDeclarationValue (Rule): # 168..172 " = 0" + - Equal (Token): "=" # 169..170 + - Expression (Rule): # 170..172 " 0" + - DecimalNumberExpression (Rule): # 170..172 " 0" + - DecimalLiteral (Token): "0" # 171..172 - Semicolon (Token): ";" # 172..173 - Statement (Rule): # 174..186 "\t\tunchecked " - ExpressionStatement (Rule): # 174..186 "\t\tunchecked " diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.0-failure.yml index d3cd50fd19..cc61fe79a7 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.0-failure.yml @@ -80,10 +80,11 @@ Tree: - TypeName (Rule): # 113..123 "\t\t\tuint256" - UnsignedIntegerType (Token): "uint256" # 116..123 - Identifier (Token): "a" # 124..125 - - Equal (Token): "=" # 126..127 - - Expression (Rule): # 127..129 " 1" - - DecimalNumberExpression (Rule): # 127..129 " 1" - - DecimalLiteral (Token): "1" # 128..129 + - VariableDeclarationValue (Rule): # 125..129 " = 1" + - Equal (Token): "=" # 126..127 + - Expression (Rule): # 127..129 " 1" + - DecimalNumberExpression (Rule): # 127..129 " 1" + - DecimalLiteral (Token): "1" # 128..129 - Semicolon (Token): ";" # 129..130 - CloseBrace (Token): "}" # 133..134 - CloseBrace (Token): "}" # 136..137 @@ -102,10 +103,11 @@ Tree: - TypeName (Rule): # 157..166 "\t\tuint256" - UnsignedIntegerType (Token): "uint256" # 159..166 - Identifier (Token): "x" # 167..168 - - Equal (Token): "=" # 169..170 - - Expression (Rule): # 170..172 " 0" - - DecimalNumberExpression (Rule): # 170..172 " 0" - - DecimalLiteral (Token): "0" # 171..172 + - VariableDeclarationValue (Rule): # 168..172 " = 0" + - Equal (Token): "=" # 169..170 + - Expression (Rule): # 170..172 " 0" + - DecimalNumberExpression (Rule): # 170..172 " 0" + - DecimalLiteral (Token): "0" # 171..172 - Semicolon (Token): ";" # 172..173 - SKIPPED (Token): "unchecked { invalid sequence }\n\t" # 176..208 - CloseBrace (Token): "}" # 208..209 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.3-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.3-failure.yml index c6e57449a1..7961625f57 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.3-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.5.3-failure.yml @@ -80,10 +80,11 @@ Tree: - TypeName (Rule): # 113..123 "\t\t\tuint256" - UnsignedIntegerType (Token): "uint256" # 116..123 - Identifier (Token): "a" # 124..125 - - Equal (Token): "=" # 126..127 - - Expression (Rule): # 127..129 " 1" - - DecimalNumberExpression (Rule): # 127..129 " 1" - - DecimalLiteral (Token): "1" # 128..129 + - VariableDeclarationValue (Rule): # 125..129 " = 1" + - Equal (Token): "=" # 126..127 + - Expression (Rule): # 127..129 " 1" + - DecimalNumberExpression (Rule): # 127..129 " 1" + - DecimalLiteral (Token): "1" # 128..129 - Semicolon (Token): ";" # 129..130 - CloseBrace (Token): "}" # 133..134 - CloseBrace (Token): "}" # 136..137 @@ -102,10 +103,11 @@ Tree: - TypeName (Rule): # 157..166 "\t\tuint256" - UnsignedIntegerType (Token): "uint256" # 159..166 - Identifier (Token): "x" # 167..168 - - Equal (Token): "=" # 169..170 - - Expression (Rule): # 170..172 " 0" - - DecimalNumberExpression (Rule): # 170..172 " 0" - - DecimalLiteral (Token): "0" # 171..172 + - VariableDeclarationValue (Rule): # 168..172 " = 0" + - Equal (Token): "=" # 169..170 + - Expression (Rule): # 170..172 " 0" + - DecimalNumberExpression (Rule): # 170..172 " 0" + - DecimalLiteral (Token): "0" # 171..172 - Semicolon (Token): ";" # 172..173 - SKIPPED (Token): "unchecked { invalid sequence }\n\t" # 176..208 - CloseBrace (Token): "}" # 208..209 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.6.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.6.0-failure.yml index f14fc5379e..f2d2b118b8 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.6.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.6.0-failure.yml @@ -80,10 +80,11 @@ Tree: - TypeName (Rule): # 113..123 "\t\t\tuint256" - UnsignedIntegerType (Token): "uint256" # 116..123 - Identifier (Token): "a" # 124..125 - - Equal (Token): "=" # 126..127 - - Expression (Rule): # 127..129 " 1" - - DecimalNumberExpression (Rule): # 127..129 " 1" - - DecimalLiteral (Token): "1" # 128..129 + - VariableDeclarationValue (Rule): # 125..129 " = 1" + - Equal (Token): "=" # 126..127 + - Expression (Rule): # 127..129 " 1" + - DecimalNumberExpression (Rule): # 127..129 " 1" + - DecimalLiteral (Token): "1" # 128..129 - Semicolon (Token): ";" # 129..130 - CloseBrace (Token): "}" # 133..134 - CloseBrace (Token): "}" # 136..137 @@ -102,10 +103,11 @@ Tree: - TypeName (Rule): # 157..166 "\t\tuint256" - UnsignedIntegerType (Token): "uint256" # 159..166 - Identifier (Token): "x" # 167..168 - - Equal (Token): "=" # 169..170 - - Expression (Rule): # 170..172 " 0" - - DecimalNumberExpression (Rule): # 170..172 " 0" - - DecimalLiteral (Token): "0" # 171..172 + - VariableDeclarationValue (Rule): # 168..172 " = 0" + - Equal (Token): "=" # 169..170 + - Expression (Rule): # 170..172 " 0" + - DecimalNumberExpression (Rule): # 170..172 " 0" + - DecimalLiteral (Token): "0" # 171..172 - Semicolon (Token): ";" # 172..173 - SKIPPED (Token): "unchecked { invalid sequence }\n\t" # 176..208 - CloseBrace (Token): "}" # 208..209 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.7.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.7.0-failure.yml index 26a41f478f..85711b54c2 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.7.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.7.0-failure.yml @@ -80,10 +80,11 @@ Tree: - TypeName (Rule): # 113..123 "\t\t\tuint256" - UnsignedIntegerType (Token): "uint256" # 116..123 - Identifier (Token): "a" # 124..125 - - Equal (Token): "=" # 126..127 - - Expression (Rule): # 127..129 " 1" - - DecimalNumberExpression (Rule): # 127..129 " 1" - - DecimalLiteral (Token): "1" # 128..129 + - VariableDeclarationValue (Rule): # 125..129 " = 1" + - Equal (Token): "=" # 126..127 + - Expression (Rule): # 127..129 " 1" + - DecimalNumberExpression (Rule): # 127..129 " 1" + - DecimalLiteral (Token): "1" # 128..129 - Semicolon (Token): ";" # 129..130 - CloseBrace (Token): "}" # 133..134 - CloseBrace (Token): "}" # 136..137 @@ -102,10 +103,11 @@ Tree: - TypeName (Rule): # 157..166 "\t\tuint256" - UnsignedIntegerType (Token): "uint256" # 159..166 - Identifier (Token): "x" # 167..168 - - Equal (Token): "=" # 169..170 - - Expression (Rule): # 170..172 " 0" - - DecimalNumberExpression (Rule): # 170..172 " 0" - - DecimalLiteral (Token): "0" # 171..172 + - VariableDeclarationValue (Rule): # 168..172 " = 0" + - Equal (Token): "=" # 169..170 + - Expression (Rule): # 170..172 " 0" + - DecimalNumberExpression (Rule): # 170..172 " 0" + - DecimalLiteral (Token): "0" # 171..172 - Semicolon (Token): ";" # 172..173 - SKIPPED (Token): "unchecked { invalid sequence }\n\t" # 176..208 - CloseBrace (Token): "}" # 208..209 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.8.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.8.0-failure.yml index ebb94757a7..9faee912b0 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.8.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/recovery_testbed/generated/0.8.0-failure.yml @@ -79,10 +79,11 @@ Tree: - TypeName (Rule): # 113..123 "\t\t\tuint256" - UnsignedIntegerType (Token): "uint256" # 116..123 - Identifier (Token): "a" # 124..125 - - Equal (Token): "=" # 126..127 - - Expression (Rule): # 127..129 " 1" - - DecimalNumberExpression (Rule): # 127..129 " 1" - - DecimalLiteral (Token): "1" # 128..129 + - VariableDeclarationValue (Rule): # 125..129 " = 1" + - Equal (Token): "=" # 126..127 + - Expression (Rule): # 127..129 " 1" + - DecimalNumberExpression (Rule): # 127..129 " 1" + - DecimalLiteral (Token): "1" # 128..129 - Semicolon (Token): ";" # 129..130 - CloseBrace (Token): "}" # 133..134 - CloseBrace (Token): "}" # 136..137 @@ -101,10 +102,11 @@ Tree: - TypeName (Rule): # 157..166 "\t\tuint256" - UnsignedIntegerType (Token): "uint256" # 159..166 - Identifier (Token): "x" # 167..168 - - Equal (Token): "=" # 169..170 - - Expression (Rule): # 170..172 " 0" - - DecimalNumberExpression (Rule): # 170..172 " 0" - - DecimalLiteral (Token): "0" # 171..172 + - VariableDeclarationValue (Rule): # 168..172 " = 0" + - Equal (Token): "=" # 169..170 + - Expression (Rule): # 170..172 " 0" + - DecimalNumberExpression (Rule): # 170..172 " 0" + - DecimalLiteral (Token): "0" # 171..172 - Semicolon (Token): ";" # 172..173 - Statement (Rule): # 174..207 "\t\tunchecked { invalid sequence }\n" - UncheckedBlock (Rule): # 174..207 "\t\tunchecked { invalid sequence }\n" diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/local_expression/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/local_expression/generated/0.4.11-success.yml index d21b509f0e..5cbdbff902 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/local_expression/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/local_expression/generated/0.4.11-success.yml @@ -24,21 +24,22 @@ Tree: - TypeName (Rule): # 18..24 " uint" - UnsignedIntegerType (Token): "uint" # 20..24 - Identifier (Token): "a" # 25..26 - - Equal (Token): "=" # 27..28 - - Expression (Rule): # 28..38 " 1 + 2 * 3" - - BinaryExpression (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" - - Expression (Rule): # 32..34 " 2" - - DecimalNumberExpression (Rule): # 32..34 " 2" - - DecimalLiteral (Token): "2" # 33..34 - - Asterisk (Token): "*" # 35..36 - - Expression (Rule): # 36..38 " 3" - - DecimalNumberExpression (Rule): # 36..38 " 3" - - DecimalLiteral (Token): "3" # 37..38 + - 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" + - 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" + - Expression (Rule): # 32..34 " 2" + - DecimalNumberExpression (Rule): # 32..34 " 2" + - DecimalLiteral (Token): "2" # 33..34 + - Asterisk (Token): "*" # 35..36 + - Expression (Rule): # 36..38 " 3" + - DecimalNumberExpression (Rule): # 36..38 " 3" + - DecimalLiteral (Token): "3" # 37..38 - Semicolon (Token): ";" # 38..39 - CloseBrace (Token): "}" # 40..41 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.4.11-failure.yml index d14ea24157..2dc982449d 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.4.11-failure.yml @@ -49,20 +49,22 @@ Tree: - TypeName (Rule): # 35..50 " uint256" - UnsignedIntegerType (Token): "uint256" # 43..50 - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValuesList (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValuesList (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.4.21-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.4.21-failure.yml index 6c5cf820bf..748138466f 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.4.21-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.4.21-failure.yml @@ -49,20 +49,22 @@ Tree: - TypeName (Rule): # 35..50 " uint256" - UnsignedIntegerType (Token): "uint256" # 43..50 - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValuesList (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValuesList (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.5.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.5.0-failure.yml index 9415860f15..2360321188 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.5.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.5.0-failure.yml @@ -49,20 +49,22 @@ Tree: - TypeName (Rule): # 35..50 " uint256" - UnsignedIntegerType (Token): "uint256" # 43..50 - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValuesList (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValuesList (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.5.3-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.5.3-failure.yml index 376268a6e5..7ed1c53499 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.5.3-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.5.3-failure.yml @@ -49,20 +49,22 @@ Tree: - TypeName (Rule): # 35..50 " uint256" - UnsignedIntegerType (Token): "uint256" # 43..50 - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValuesList (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValuesList (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.6.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.6.0-failure.yml index 03a35f6581..3845d2f893 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.6.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.6.0-failure.yml @@ -49,20 +49,22 @@ Tree: - TypeName (Rule): # 35..50 " uint256" - UnsignedIntegerType (Token): "uint256" # 43..50 - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValuesList (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValuesList (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.7.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.7.0-failure.yml index fa1723a09b..1016f35171 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.7.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.7.0-failure.yml @@ -49,20 +49,22 @@ Tree: - TypeName (Rule): # 35..50 " uint256" - UnsignedIntegerType (Token): "uint256" # 43..50 - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValuesList (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValuesList (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.8.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.8.0-failure.yml index cf00a29717..c4488659e5 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.8.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.8.0-failure.yml @@ -49,20 +49,22 @@ Tree: - TypeName (Rule): # 35..50 " uint256" - UnsignedIntegerType (Token): "uint256" # 43..50 - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValuesList (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValuesList (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.8.4-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.8.4-failure.yml index da57bef2a3..3c4da4156f 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.8.4-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembersList/mismatched_delimiter/generated/0.8.4-failure.yml @@ -49,20 +49,22 @@ Tree: - TypeName (Rule): # 35..50 " uint256" - UnsignedIntegerType (Token): "uint256" # 43..50 - Identifier (Token): "arg" # 51..54 - - Equal (Token): "=" # 55..56 - - Expression (Rule): # 56..63 " (1 + 2" - - TupleExpression (Rule): # 56..63 " (1 + 2" - - OpenParen (Token): "(" # 57..58 - - TupleValuesList (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..63 "1 + 2" - - BinaryExpression (Rule): # 58..63 "1 + 2" - - Expression (Rule): # 58..59 "1" - - DecimalNumberExpression (Rule): # 58..59 "1" - - DecimalLiteral (Token): "1" # 58..59 - - Plus (Token): "+" # 60..61 - - Expression (Rule): # 61..63 " 2" - - DecimalNumberExpression (Rule): # 61..63 " 2" - - DecimalLiteral (Token): "2" # 62..63 + - VariableDeclarationValue (Rule): # 54..63 " = (1 + 2" + - Equal (Token): "=" # 55..56 + - Expression (Rule): # 56..63 " (1 + 2" + - TupleExpression (Rule): # 56..63 " (1 + 2" + - OpenParen (Token): "(" # 57..58 + - TupleValuesList (Rule): # 58..63 "1 + 2" + - TupleValue (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..63 "1 + 2" + - BinaryExpression (Rule): # 58..63 "1 + 2" + - Expression (Rule): # 58..59 "1" + - DecimalNumberExpression (Rule): # 58..59 "1" + - DecimalLiteral (Token): "1" # 58..59 + - Plus (Token): "+" # 60..61 + - Expression (Rule): # 61..63 " 2" + - DecimalNumberExpression (Rule): # 61..63 " 2" + - DecimalLiteral (Token): "2" # 62..63 - SKIPPED (Token): ";\n " # 63..69 - CloseBrace (Token): "}" # 69..70 - SKIPPED (Token): ")\n" # 70..72 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 2791370ebe..7d2d8f70b8 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 @@ -12,13 +12,14 @@ Tree: - TupleExpression (Rule): # 0..12 "(foo == bar)" - OpenParen (Token): "(" # 0..1 - TupleValuesList (Rule): # 1..11 "foo == bar" - - Expression (Rule): # 1..11 "foo == bar" - - BinaryExpression (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 + - TupleValue (Rule): # 1..11 "foo == bar" + - Expression (Rule): # 1..11 "foo == bar" + - BinaryExpression (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" 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 88caf9a361..7678e21f36 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 @@ -15,24 +15,26 @@ Tree: - TupleExpression (Rule): # 5..13 " (a + b)" - OpenParen (Token): "(" # 6..7 - TupleValuesList (Rule): # 7..12 "a + b" - - Expression (Rule): # 7..12 "a + b" - - BinaryExpression (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 + - TupleValue (Rule): # 7..12 "a + b" + - Expression (Rule): # 7..12 "a + b" + - BinaryExpression (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 - TupleValuesList (Rule): # 17..22 "c + d" - - Expression (Rule): # 17..22 "c + d" - - BinaryExpression (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 + - TupleValue (Rule): # 17..22 "c + d" + - Expression (Rule): # 17..22 "c + d" + - BinaryExpression (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/function_call_options_split/generated/0.6.2-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/generated/0.6.2-success.yml index 2d85cac3ff..f892bc4766 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/generated/0.6.2-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/generated/0.6.2-success.yml @@ -25,16 +25,17 @@ Tree: - DecimalNumberExpression (Rule): # 10..12 " 0" - DecimalLiteral (Token): "0" # 11..12 - CloseBrace (Token): "}" # 12..13 - - NamedArgumentsDeclaration (Rule): # 13..21 "{gas: 1}" - - OpenBrace (Token): "{" # 13..14 - - NamedArgumentsList (Rule): # 14..20 "gas: 1" - - NamedArgument (Rule): # 14..20 "gas: 1" - - Identifier (Token): "gas" # 14..17 - - Colon (Token): ":" # 17..18 - - Expression (Rule): # 18..20 " 1" - - DecimalNumberExpression (Rule): # 18..20 " 1" - - DecimalLiteral (Token): "1" # 19..20 - - CloseBrace (Token): "}" # 20..21 + - NamedArgumentsDeclarations (Rule): # 13..21 "{gas: 1}" + - NamedArgumentsDeclaration (Rule): # 13..21 "{gas: 1}" + - OpenBrace (Token): "{" # 13..14 + - NamedArgumentsList (Rule): # 14..20 "gas: 1" + - NamedArgument (Rule): # 14..20 "gas: 1" + - Identifier (Token): "gas" # 14..17 + - Colon (Token): ":" # 17..18 + - Expression (Rule): # 18..20 " 1" + - DecimalNumberExpression (Rule): # 18..20 " 1" + - DecimalLiteral (Token): "1" # 19..20 + - CloseBrace (Token): "}" # 20..21 - ArgumentsDeclaration (Rule): # 21..25 '("")' - OpenParen (Token): "(" # 21..22 - PositionalArgumentsList (Rule): # 22..24 '""' diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_end/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_end/generated/0.4.11-success.yml index b83e96cd68..bfa1a01032 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_end/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_end/generated/0.4.11-success.yml @@ -11,7 +11,8 @@ Tree: - Expression (Rule): # 0..3 "arr" - Identifier (Token): "arr" # 0..3 - OpenBracket (Token): "[" # 3..4 - - Colon (Token): ":" # 4..5 - - Expression (Rule): # 5..8 "end" - - Identifier (Token): "end" # 5..8 + - IndexAccessEnd (Rule): # 4..8 ":end" + - Colon (Token): ":" # 4..5 + - Expression (Rule): # 5..8 "end" + - Identifier (Token): "end" # 5..8 - CloseBracket (Token): "]" # 8..9 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start/generated/0.4.11-success.yml index d8e8d07b1f..abc7f34656 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start/generated/0.4.11-success.yml @@ -13,5 +13,6 @@ Tree: - OpenBracket (Token): "[" # 3..4 - Expression (Rule): # 4..9 "start" - Identifier (Token): "start" # 4..9 - - Colon (Token): ":" # 9..10 + - IndexAccessEnd (Rule): # 9..10 ":" + - Colon (Token): ":" # 9..10 - CloseBracket (Token): "]" # 10..11 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start_end/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start_end/generated/0.4.11-success.yml index 9c394bfb08..bab2b1cf62 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start_end/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_start_end/generated/0.4.11-success.yml @@ -13,7 +13,8 @@ Tree: - OpenBracket (Token): "[" # 3..4 - Expression (Rule): # 4..9 "start" - Identifier (Token): "start" # 4..9 - - Colon (Token): ":" # 9..10 - - Expression (Rule): # 10..13 "end" - - Identifier (Token): "end" # 10..13 + - IndexAccessEnd (Rule): # 9..13 ":end" + - Colon (Token): ":" # 9..10 + - Expression (Rule): # 10..13 "end" + - Identifier (Token): "end" # 10..13 - CloseBracket (Token): "]" # 13..14 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_unbounded/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_unbounded/generated/0.4.11-success.yml index d4a159481d..97158ca73e 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_unbounded/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/index_slice_unbounded/generated/0.4.11-success.yml @@ -11,5 +11,6 @@ Tree: - Expression (Rule): # 0..3 "arr" - Identifier (Token): "arr" # 0..3 - OpenBracket (Token): "[" # 3..4 - - Colon (Token): ":" # 4..5 + - IndexAccessEnd (Rule): # 4..5 ":" + - Colon (Token): ":" # 4..5 - CloseBracket (Token): "]" # 5..6 diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/payable_call/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/payable_call/generated/0.4.11-success.yml index 488cdd6cc9..1dbbf99be1 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/payable_call/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/payable_call/generated/0.4.11-success.yml @@ -9,8 +9,7 @@ Tree: - Expression (Rule): # 0..14 "payable(value)" - FunctionCallExpression (Rule): # 0..14 "payable(value)" - Expression (Rule): # 0..7 "payable" - - AddressType (Rule): # 0..7 "payable" - - PayableKeyword (Token): "payable" # 0..7 + - PayableKeyword (Token): "payable" # 0..7 - ArgumentsDeclaration (Rule): # 7..14 "(value)" - OpenParen (Token): "(" # 7..8 - PositionalArgumentsList (Rule): # 8..13 "value" diff --git a/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_multiple/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_multiple/generated/0.4.11-success.yml index f954111db8..119fc70b36 100644 --- a/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_multiple/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_multiple/generated/0.4.11-success.yml @@ -13,16 +13,18 @@ Tree: - DeconstructionImportSymbolsList (Rule): # 8..31 " A1 as A2, B1, C1 as C2" - DeconstructionImportSymbol (Rule): # 8..17 " A1 as A2" - Identifier (Token): "A1" # 9..11 - - AsKeyword (Token): "as" # 12..14 - - Identifier (Token): "A2" # 15..17 + - ImportAlias (Rule): # 11..17 " as A2" + - AsKeyword (Token): "as" # 12..14 + - Identifier (Token): "A2" # 15..17 - Comma (Token): "," # 17..18 - DeconstructionImportSymbol (Rule): # 18..21 " B1" - Identifier (Token): "B1" # 19..21 - Comma (Token): "," # 21..22 - DeconstructionImportSymbol (Rule): # 22..31 " C1 as C2" - Identifier (Token): "C1" # 23..25 - - AsKeyword (Token): "as" # 26..28 - - Identifier (Token): "C2" # 29..31 + - ImportAlias (Rule): # 25..31 " as C2" + - AsKeyword (Token): "as" # 26..28 + - Identifier (Token): "C2" # 29..31 - CloseBrace (Token): "}" # 32..33 - FromKeyword (Token): "from" # 34..38 - AsciiStringLiteral (Token): '"foo"' # 39..44 diff --git a/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_single/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_single/generated/0.4.11-success.yml index d62862b618..c316db9acf 100644 --- a/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_single/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ImportDirective/destructure_import_single/generated/0.4.11-success.yml @@ -13,8 +13,9 @@ Tree: - DeconstructionImportSymbolsList (Rule): # 8..15 " x as y" - DeconstructionImportSymbol (Rule): # 8..15 " x as y" - Identifier (Token): "x" # 9..10 - - AsKeyword (Token): "as" # 11..13 - - Identifier (Token): "y" # 14..15 + - ImportAlias (Rule): # 10..15 " as y" + - AsKeyword (Token): "as" # 11..13 + - Identifier (Token): "y" # 14..15 - CloseBrace (Token): "}" # 16..17 - FromKeyword (Token): "from" # 18..22 - AsciiStringLiteral (Token): '"foo"' # 23..28 diff --git a/crates/solidity/testing/snapshots/cst_output/ImportDirective/named_import/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ImportDirective/named_import/generated/0.4.11-success.yml index 03a76fb81c..b0338d5bbb 100644 --- a/crates/solidity/testing/snapshots/cst_output/ImportDirective/named_import/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ImportDirective/named_import/generated/0.4.11-success.yml @@ -10,8 +10,9 @@ Tree: - ImportKeyword (Token): "import" # 0..6 - NamedImport (Rule): # 6..26 ' * as foo from "bar"' - Asterisk (Token): "*" # 7..8 - - AsKeyword (Token): "as" # 9..11 - - Identifier (Token): "foo" # 12..15 + - ImportAlias (Rule): # 8..15 " as foo" + - AsKeyword (Token): "as" # 9..11 + - Identifier (Token): "foo" # 12..15 - FromKeyword (Token): "from" # 16..20 - AsciiStringLiteral (Token): '"bar"' # 21..26 - Semicolon (Token): ";" # 26..27 diff --git a/crates/solidity/testing/snapshots/cst_output/ImportDirective/path_import_with_alias/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ImportDirective/path_import_with_alias/generated/0.4.11-success.yml index a8a320ec38..f61f91b142 100644 --- a/crates/solidity/testing/snapshots/cst_output/ImportDirective/path_import_with_alias/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ImportDirective/path_import_with_alias/generated/0.4.11-success.yml @@ -10,6 +10,7 @@ Tree: - ImportKeyword (Token): "import" # 0..6 - PathImport (Rule): # 6..19 ' "foo" as bar' - AsciiStringLiteral (Token): '"foo"' # 7..12 - - AsKeyword (Token): "as" # 13..15 - - Identifier (Token): "bar" # 16..19 + - ImportAlias (Rule): # 12..19 " as bar" + - AsKeyword (Token): "as" # 13..15 + - Identifier (Token): "bar" # 16..19 - Semicolon (Token): ";" # 19..20 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 cdb990ad86..e72c28b0a8 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 @@ -68,14 +68,15 @@ Tree: - TypeName (Rule): # 115..128 " uint256" - UnsignedIntegerType (Token): "uint256" # 121..128 - Identifier (Token): "c" # 129..130 - - Equal (Token): "=" # 131..132 - - Expression (Rule): # 132..138 " a + b" - - BinaryExpression (Rule): # 132..138 " a + b" - - Expression (Rule): # 132..134 " a" - - Identifier (Token): "a" # 133..134 - - Plus (Token): "+" # 135..136 - - Expression (Rule): # 136..138 " b" - - Identifier (Token): "b" # 137..138 + - VariableDeclarationValue (Rule): # 130..138 " = a + b" + - Equal (Token): "=" # 131..132 + - Expression (Rule): # 132..138 " a + b" + - BinaryExpression (Rule): # 132..138 " a + b" + - Expression (Rule): # 132..134 " a" + - Identifier (Token): "a" # 133..134 + - Plus (Token): "+" # 135..136 + - Expression (Rule): # 136..138 " b" + - Identifier (Token): "b" # 137..138 - Semicolon (Token): ";" # 138..139 - Statement (Rule): # 140..176 " if (c < a) return (false, 0);\n" - IfStatement (Rule): # 140..176 " if (c < a) return (false, 0);\n" @@ -96,12 +97,14 @@ Tree: - TupleExpression (Rule): # 163..174 " (false, 0)" - OpenParen (Token): "(" # 164..165 - TupleValuesList (Rule): # 165..173 "false, 0" - - Expression (Rule): # 165..170 "false" - - FalseKeyword (Token): "false" # 165..170 + - TupleValue (Rule): # 165..170 "false" + - Expression (Rule): # 165..170 "false" + - FalseKeyword (Token): "false" # 165..170 - Comma (Token): "," # 170..171 - - Expression (Rule): # 171..173 " 0" - - DecimalNumberExpression (Rule): # 171..173 " 0" - - DecimalLiteral (Token): "0" # 172..173 + - TupleValue (Rule): # 171..173 " 0" + - Expression (Rule): # 171..173 " 0" + - DecimalNumberExpression (Rule): # 171..173 " 0" + - DecimalLiteral (Token): "0" # 172..173 - CloseParen (Token): ")" # 173..174 - Semicolon (Token): ";" # 174..175 - Statement (Rule): # 176..200 " return (true, c);\n" @@ -111,11 +114,13 @@ Tree: - TupleExpression (Rule): # 188..198 " (true, c)" - OpenParen (Token): "(" # 189..190 - TupleValuesList (Rule): # 190..197 "true, c" - - Expression (Rule): # 190..194 "true" - - TrueKeyword (Token): "true" # 190..194 + - TupleValue (Rule): # 190..194 "true" + - Expression (Rule): # 190..194 "true" + - TrueKeyword (Token): "true" # 190..194 - Comma (Token): "," # 194..195 - - Expression (Rule): # 195..197 " c" - - Identifier (Token): "c" # 196..197 + - TupleValue (Rule): # 195..197 " c" + - Expression (Rule): # 195..197 " c" + - Identifier (Token): "c" # 196..197 - CloseParen (Token): ")" # 197..198 - Semicolon (Token): ";" # 198..199 - CloseBrace (Token): "}" # 204..205 diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_array_type/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_array_type/generated/0.4.11-success.yml index 6d1bc827c5..6939415eba 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_array_type/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_array_type/generated/0.4.11-success.yml @@ -9,20 +9,22 @@ Tree: - TupleDeconstructionStatement (Rule): # 0..69 "(uint32 a, uint32[] memory b) = abi.decode(data, (..." - OpenParen (Token): "(" # 0..1 - TupleMembersList (Rule): # 1..28 "uint32 a, uint32[] memory b" - - TupleMember (Rule): # 1..9 "uint32 a" - - TypeName (Rule): # 1..7 "uint32" - - UnsignedIntegerType (Token): "uint32" # 1..7 - - Identifier (Token): "a" # 8..9 + - TupleMemberDeconstruction (Rule): # 1..9 "uint32 a" + - TypedTupleMember (Rule): # 1..9 "uint32 a" + - TypeName (Rule): # 1..7 "uint32" + - UnsignedIntegerType (Token): "uint32" # 1..7 + - Identifier (Token): "a" # 8..9 - Comma (Token): "," # 9..10 - - TupleMember (Rule): # 10..28 " uint32[] memory b" - - TypeName (Rule): # 10..19 " uint32[]" - - ArrayTypeName (Rule): # 10..19 " uint32[]" - - TypeName (Rule): # 10..17 " uint32" - - UnsignedIntegerType (Token): "uint32" # 11..17 - - OpenBracket (Token): "[" # 17..18 - - CloseBracket (Token): "]" # 18..19 - - MemoryKeyword (Token): "memory" # 20..26 - - Identifier (Token): "b" # 27..28 + - TupleMemberDeconstruction (Rule): # 10..28 " uint32[] memory b" + - TypedTupleMember (Rule): # 10..28 " uint32[] memory b" + - TypeName (Rule): # 10..19 " uint32[]" + - ArrayTypeName (Rule): # 10..19 " uint32[]" + - TypeName (Rule): # 10..17 " uint32" + - UnsignedIntegerType (Token): "uint32" # 11..17 + - OpenBracket (Token): "[" # 17..18 + - CloseBracket (Token): "]" # 18..19 + - MemoryKeyword (Token): "memory" # 20..26 + - Identifier (Token): "b" # 27..28 - CloseParen (Token): ")" # 28..29 - Equal (Token): "=" # 30..31 - Expression (Rule): # 31..68 " abi.decode(data, (uint32, uint32[]))" @@ -43,15 +45,17 @@ Tree: - TupleExpression (Rule): # 48..67 " (uint32, uint32[])" - OpenParen (Token): "(" # 49..50 - TupleValuesList (Rule): # 50..66 "uint32, uint32[]" - - Expression (Rule): # 50..56 "uint32" - - UnsignedIntegerType (Token): "uint32" # 50..56 + - TupleValue (Rule): # 50..56 "uint32" + - Expression (Rule): # 50..56 "uint32" + - UnsignedIntegerType (Token): "uint32" # 50..56 - Comma (Token): "," # 56..57 - - Expression (Rule): # 57..66 " uint32[]" - - IndexAccessExpression (Rule): # 57..66 " uint32[]" - - Expression (Rule): # 57..64 " uint32" - - UnsignedIntegerType (Token): "uint32" # 58..64 - - OpenBracket (Token): "[" # 64..65 - - CloseBracket (Token): "]" # 65..66 + - TupleValue (Rule): # 57..66 " uint32[]" + - Expression (Rule): # 57..66 " uint32[]" + - IndexAccessExpression (Rule): # 57..66 " uint32[]" + - Expression (Rule): # 57..64 " uint32" + - UnsignedIntegerType (Token): "uint32" # 58..64 + - OpenBracket (Token): "[" # 64..65 + - CloseBracket (Token): "]" # 65..66 - CloseParen (Token): ")" # 66..67 - CloseParen (Token): ")" # 67..68 - Semicolon (Token): ";" # 68..69 diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_singleton_type/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_singleton_type/generated/0.4.11-success.yml index e806954ebc..59223f3742 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_singleton_type/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/abi_decode_singleton_type/generated/0.4.11-success.yml @@ -9,15 +9,17 @@ Tree: - TupleDeconstructionStatement (Rule): # 0..58 "(uint32 a, uint32 b) = abi.decode(data, (uint32, u..." - OpenParen (Token): "(" # 0..1 - TupleMembersList (Rule): # 1..19 "uint32 a, uint32 b" - - TupleMember (Rule): # 1..9 "uint32 a" - - TypeName (Rule): # 1..7 "uint32" - - UnsignedIntegerType (Token): "uint32" # 1..7 - - Identifier (Token): "a" # 8..9 + - TupleMemberDeconstruction (Rule): # 1..9 "uint32 a" + - TypedTupleMember (Rule): # 1..9 "uint32 a" + - TypeName (Rule): # 1..7 "uint32" + - UnsignedIntegerType (Token): "uint32" # 1..7 + - Identifier (Token): "a" # 8..9 - Comma (Token): "," # 9..10 - - TupleMember (Rule): # 10..19 " uint32 b" - - TypeName (Rule): # 10..17 " uint32" - - UnsignedIntegerType (Token): "uint32" # 11..17 - - Identifier (Token): "b" # 18..19 + - TupleMemberDeconstruction (Rule): # 10..19 " uint32 b" + - TypedTupleMember (Rule): # 10..19 " uint32 b" + - TypeName (Rule): # 10..17 " uint32" + - UnsignedIntegerType (Token): "uint32" # 11..17 + - Identifier (Token): "b" # 18..19 - CloseParen (Token): ")" # 19..20 - Equal (Token): "=" # 21..22 - Expression (Rule): # 22..57 " abi.decode(data, (uint32, uint32))" @@ -38,11 +40,13 @@ Tree: - TupleExpression (Rule): # 39..56 " (uint32, uint32)" - OpenParen (Token): "(" # 40..41 - TupleValuesList (Rule): # 41..55 "uint32, uint32" - - Expression (Rule): # 41..47 "uint32" - - UnsignedIntegerType (Token): "uint32" # 41..47 + - TupleValue (Rule): # 41..47 "uint32" + - Expression (Rule): # 41..47 "uint32" + - UnsignedIntegerType (Token): "uint32" # 41..47 - Comma (Token): "," # 47..48 - - Expression (Rule): # 48..55 " uint32" - - UnsignedIntegerType (Token): "uint32" # 49..55 + - TupleValue (Rule): # 48..55 " uint32" + - Expression (Rule): # 48..55 " uint32" + - UnsignedIntegerType (Token): "uint32" # 49..55 - CloseParen (Token): ")" # 55..56 - CloseParen (Token): ")" # 56..57 - Semicolon (Token): ";" # 57..58 diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/ignored_members/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/ignored_members/generated/0.4.11-success.yml index 0ff86ba9a6..eee86aea08 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/ignored_members/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/ignored_members/generated/0.4.11-success.yml @@ -9,15 +9,17 @@ Tree: - TupleDeconstructionStatement (Rule): # 0..27 "(, second, , fourth) = rhs;" - OpenParen (Token): "(" # 0..1 - TupleMembersList (Rule): # 1..19 ", second, , fourth" - - TupleMember (Rule): [] # 1..1 + - TupleMemberDeconstruction (Rule): [] # 1..1 - Comma (Token): "," # 1..2 - - TupleMember (Rule): # 2..9 " second" - - Identifier (Token): "second" # 3..9 + - TupleMemberDeconstruction (Rule): # 2..9 " second" + - UntypedTupleMember (Rule): # 2..9 " second" + - Identifier (Token): "second" # 3..9 - Comma (Token): "," # 9..10 - - TupleMember (Rule): [] # 10..10 + - TupleMemberDeconstruction (Rule): [] # 10..10 - Comma (Token): "," # 11..12 - - TupleMember (Rule): # 12..19 " fourth" - - Identifier (Token): "fourth" # 13..19 + - TupleMemberDeconstruction (Rule): # 12..19 " fourth" + - UntypedTupleMember (Rule): # 12..19 " fourth" + - Identifier (Token): "fourth" # 13..19 - CloseParen (Token): ")" # 19..20 - Equal (Token): "=" # 21..22 - Expression (Rule): # 22..26 " rhs" diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.4.11-failure.yml index b96faed213..e2e41f916d 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.4.11-failure.yml @@ -20,23 +20,27 @@ Tree: - TupleDeconstructionStatement (Rule): # 0..35 "(a, b) = (123, 135)\n/**/\n{ throw; \n" - OpenParen (Token): "(" # 0..1 - TupleMembersList (Rule): # 1..5 "a, b" - - TupleMember (Rule): # 1..2 "a" - - Identifier (Token): "a" # 1..2 + - TupleMemberDeconstruction (Rule): # 1..2 "a" + - UntypedTupleMember (Rule): # 1..2 "a" + - Identifier (Token): "a" # 1..2 - Comma (Token): "," # 2..3 - - TupleMember (Rule): # 3..5 " b" - - Identifier (Token): "b" # 4..5 + - TupleMemberDeconstruction (Rule): # 3..5 " b" + - UntypedTupleMember (Rule): # 3..5 " b" + - Identifier (Token): "b" # 4..5 - CloseParen (Token): ")" # 5..6 - Equal (Token): "=" # 7..8 - Expression (Rule): # 8..20 " (123, 135)\n" - TupleExpression (Rule): # 8..20 " (123, 135)\n" - OpenParen (Token): "(" # 9..10 - TupleValuesList (Rule): # 10..18 "123, 135" - - Expression (Rule): # 10..13 "123" - - DecimalNumberExpression (Rule): # 10..13 "123" - - DecimalLiteral (Token): "123" # 10..13 + - TupleValue (Rule): # 10..13 "123" + - Expression (Rule): # 10..13 "123" + - DecimalNumberExpression (Rule): # 10..13 "123" + - DecimalLiteral (Token): "123" # 10..13 - Comma (Token): "," # 13..14 - - Expression (Rule): # 14..18 " 135" - - DecimalNumberExpression (Rule): # 14..18 " 135" - - DecimalLiteral (Token): "135" # 15..18 + - TupleValue (Rule): # 14..18 " 135" + - Expression (Rule): # 14..18 " 135" + - DecimalNumberExpression (Rule): # 14..18 " 135" + - DecimalLiteral (Token): "135" # 15..18 - CloseParen (Token): ")" # 18..19 - SKIPPED (Token): "/**/\n{ throw; \n" # 20..35 diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.6.2-failure.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.6.2-failure.yml index 901bacbd0c..5fa87a76dc 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.6.2-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.6.2-failure.yml @@ -19,24 +19,28 @@ Tree: - TupleDeconstructionStatement (Rule): # 0..35 "(a, b) = (123, 135)\n/**/\n{ throw; \n" - OpenParen (Token): "(" # 0..1 - TupleMembersList (Rule): # 1..5 "a, b" - - TupleMember (Rule): # 1..2 "a" - - Identifier (Token): "a" # 1..2 + - TupleMemberDeconstruction (Rule): # 1..2 "a" + - UntypedTupleMember (Rule): # 1..2 "a" + - Identifier (Token): "a" # 1..2 - Comma (Token): "," # 2..3 - - TupleMember (Rule): # 3..5 " b" - - Identifier (Token): "b" # 4..5 + - TupleMemberDeconstruction (Rule): # 3..5 " b" + - UntypedTupleMember (Rule): # 3..5 " b" + - Identifier (Token): "b" # 4..5 - CloseParen (Token): ")" # 5..6 - Equal (Token): "=" # 7..8 - Expression (Rule): # 8..26 " (123, 135)\n/**/\n{" - TupleExpression (Rule): # 8..20 " (123, 135)\n" - OpenParen (Token): "(" # 9..10 - TupleValuesList (Rule): # 10..18 "123, 135" - - Expression (Rule): # 10..13 "123" - - DecimalNumberExpression (Rule): # 10..13 "123" - - DecimalLiteral (Token): "123" # 10..13 + - TupleValue (Rule): # 10..13 "123" + - Expression (Rule): # 10..13 "123" + - DecimalNumberExpression (Rule): # 10..13 "123" + - DecimalLiteral (Token): "123" # 10..13 - Comma (Token): "," # 13..14 - - Expression (Rule): # 14..18 " 135" - - DecimalNumberExpression (Rule): # 14..18 " 135" - - DecimalLiteral (Token): "135" # 15..18 + - TupleValue (Rule): # 14..18 " 135" + - Expression (Rule): # 14..18 " 135" + - DecimalNumberExpression (Rule): # 14..18 " 135" + - DecimalLiteral (Token): "135" # 15..18 - CloseParen (Token): ")" # 18..19 - FunctionCallOptions (Rule): # 20..26 "/**/\n{" - NamedArgumentsDeclaration (Rule): # 20..26 "/**/\n{" diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/with_location/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/with_location/generated/0.4.11-success.yml index 710b79fc6d..9e53e86205 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/with_location/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/with_location/generated/0.4.11-success.yml @@ -9,12 +9,14 @@ Tree: - TupleDeconstructionStatement (Rule): # 0..47 "(memory with_location, without_location) = rhs;" - OpenParen (Token): "(" # 0..1 - TupleMembersList (Rule): # 1..39 "memory with_location, without_location" - - TupleMember (Rule): # 1..21 "memory with_location" - - MemoryKeyword (Token): "memory" # 1..7 - - Identifier (Token): "with_location" # 8..21 + - TupleMemberDeconstruction (Rule): # 1..21 "memory with_location" + - UntypedTupleMember (Rule): # 1..21 "memory with_location" + - MemoryKeyword (Token): "memory" # 1..7 + - Identifier (Token): "with_location" # 8..21 - Comma (Token): "," # 21..22 - - TupleMember (Rule): # 22..39 " without_location" - - Identifier (Token): "without_location" # 23..39 + - TupleMemberDeconstruction (Rule): # 22..39 " without_location" + - UntypedTupleMember (Rule): # 22..39 " without_location" + - Identifier (Token): "without_location" # 23..39 - CloseParen (Token): ")" # 39..40 - Equal (Token): "=" # 41..42 - Expression (Rule): # 42..46 " rhs" diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/with_type/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/with_type/generated/0.4.11-success.yml index 1d0e120d45..30b73954a3 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/with_type/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/with_type/generated/0.4.11-success.yml @@ -9,13 +9,15 @@ Tree: - TupleDeconstructionStatement (Rule): # 0..37 "(bool with_type, without_type) = rhs;" - OpenParen (Token): "(" # 0..1 - TupleMembersList (Rule): # 1..29 "bool with_type, without_type" - - TupleMember (Rule): # 1..15 "bool with_type" - - TypeName (Rule): # 1..5 "bool" - - BoolKeyword (Token): "bool" # 1..5 - - Identifier (Token): "with_type" # 6..15 + - TupleMemberDeconstruction (Rule): # 1..15 "bool with_type" + - TypedTupleMember (Rule): # 1..15 "bool with_type" + - TypeName (Rule): # 1..5 "bool" + - BoolKeyword (Token): "bool" # 1..5 + - Identifier (Token): "with_type" # 6..15 - Comma (Token): "," # 15..16 - - TupleMember (Rule): # 16..29 " without_type" - - Identifier (Token): "without_type" # 17..29 + - TupleMemberDeconstruction (Rule): # 16..29 " without_type" + - UntypedTupleMember (Rule): # 16..29 " without_type" + - Identifier (Token): "without_type" # 17..29 - CloseParen (Token): ")" # 29..30 - Equal (Token): "=" # 31..32 - Expression (Rule): # 32..36 " rhs" diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/with_type_and_location/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/with_type_and_location/generated/0.4.11-success.yml index 475926b369..e676c47157 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/with_type_and_location/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/with_type_and_location/generated/0.4.11-success.yml @@ -9,17 +9,19 @@ Tree: - TupleDeconstructionStatement (Rule): # 0..38 "(bool memory x, bool storage y) = rhs;" - OpenParen (Token): "(" # 0..1 - TupleMembersList (Rule): # 1..30 "bool memory x, bool storage y" - - TupleMember (Rule): # 1..14 "bool memory x" - - TypeName (Rule): # 1..5 "bool" - - BoolKeyword (Token): "bool" # 1..5 - - MemoryKeyword (Token): "memory" # 6..12 - - Identifier (Token): "x" # 13..14 + - TupleMemberDeconstruction (Rule): # 1..14 "bool memory x" + - TypedTupleMember (Rule): # 1..14 "bool memory x" + - TypeName (Rule): # 1..5 "bool" + - BoolKeyword (Token): "bool" # 1..5 + - MemoryKeyword (Token): "memory" # 6..12 + - Identifier (Token): "x" # 13..14 - Comma (Token): "," # 14..15 - - TupleMember (Rule): # 15..30 " bool storage y" - - TypeName (Rule): # 15..20 " bool" - - BoolKeyword (Token): "bool" # 16..20 - - StorageKeyword (Token): "storage" # 21..28 - - Identifier (Token): "y" # 29..30 + - TupleMemberDeconstruction (Rule): # 15..30 " bool storage y" + - TypedTupleMember (Rule): # 15..30 " bool storage y" + - TypeName (Rule): # 15..20 " bool" + - BoolKeyword (Token): "bool" # 16..20 + - StorageKeyword (Token): "storage" # 21..28 + - Identifier (Token): "y" # 29..30 - CloseParen (Token): ")" # 30..31 - Equal (Token): "=" # 32..33 - Expression (Rule): # 33..37 " rhs" diff --git a/crates/solidity/testing/snapshots/cst_output/TupleExpression/empty/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleExpression/empty/generated/0.4.11-success.yml index a03a765449..113759508a 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleExpression/empty/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleExpression/empty/generated/0.4.11-success.yml @@ -9,4 +9,5 @@ Tree: - TupleExpression (Rule): # 0..3 "( )" - OpenParen (Token): "(" # 0..1 - TupleValuesList (Rule): [] # 1..1 + - TupleValue (Rule): [] # 1..1 - CloseParen (Token): ")" # 2..3 diff --git a/crates/solidity/testing/snapshots/cst_output/TupleExpression/full/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleExpression/full/generated/0.4.11-success.yml index 98b6f7f194..f4658b8fe9 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleExpression/full/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleExpression/full/generated/0.4.11-success.yml @@ -9,15 +9,19 @@ Tree: - TupleExpression (Rule): # 0..30 "(first, second, third, fourth)" - OpenParen (Token): "(" # 0..1 - TupleValuesList (Rule): # 1..29 "first, second, third, fourth" - - Expression (Rule): # 1..6 "first" - - Identifier (Token): "first" # 1..6 + - TupleValue (Rule): # 1..6 "first" + - Expression (Rule): # 1..6 "first" + - Identifier (Token): "first" # 1..6 - Comma (Token): "," # 6..7 - - Expression (Rule): # 7..14 " second" - - Identifier (Token): "second" # 8..14 + - TupleValue (Rule): # 7..14 " second" + - Expression (Rule): # 7..14 " second" + - Identifier (Token): "second" # 8..14 - Comma (Token): "," # 14..15 - - Expression (Rule): # 15..21 " third" - - Identifier (Token): "third" # 16..21 + - TupleValue (Rule): # 15..21 " third" + - Expression (Rule): # 15..21 " third" + - Identifier (Token): "third" # 16..21 - Comma (Token): "," # 21..22 - - Expression (Rule): # 22..29 " fourth" - - Identifier (Token): "fourth" # 23..29 + - TupleValue (Rule): # 22..29 " fourth" + - Expression (Rule): # 22..29 " fourth" + - Identifier (Token): "fourth" # 23..29 - CloseParen (Token): ")" # 29..30 diff --git a/crates/solidity/testing/snapshots/cst_output/TupleExpression/missing_elements/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/TupleExpression/missing_elements/generated/0.4.11-success.yml index dc78569463..a45a7027c5 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleExpression/missing_elements/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleExpression/missing_elements/generated/0.4.11-success.yml @@ -9,11 +9,15 @@ Tree: - TupleExpression (Rule): # 0..20 "(, second, , fourth)" - OpenParen (Token): "(" # 0..1 - TupleValuesList (Rule): # 1..19 ", second, , fourth" + - TupleValue (Rule): [] # 1..1 - Comma (Token): "," # 1..2 - - Expression (Rule): # 2..9 " second" - - Identifier (Token): "second" # 3..9 + - TupleValue (Rule): # 2..9 " second" + - Expression (Rule): # 2..9 " second" + - Identifier (Token): "second" # 3..9 - Comma (Token): "," # 9..10 + - TupleValue (Rule): [] # 10..10 - Comma (Token): "," # 11..12 - - Expression (Rule): # 12..19 " fourth" - - Identifier (Token): "fourth" # 13..19 + - TupleValue (Rule): # 12..19 " fourth" + - Expression (Rule): # 12..19 " fourth" + - Identifier (Token): "fourth" # 13..19 - CloseParen (Token): ")" # 19..20 diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDirective/destructure_multiple/generated/0.8.19-success.yml b/crates/solidity/testing/snapshots/cst_output/UsingDirective/destructure_multiple/generated/0.8.19-success.yml index d0a2f4dcdc..fdb267e3b5 100644 --- a/crates/solidity/testing/snapshots/cst_output/UsingDirective/destructure_multiple/generated/0.8.19-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/UsingDirective/destructure_multiple/generated/0.8.19-success.yml @@ -14,8 +14,9 @@ Tree: - UsingDirectiveSymbol (Rule): # 7..15 "add as +" - IdentifierPath (Rule): # 7..10 "add" - Identifier (Token): "add" # 7..10 - - AsKeyword (Token): "as" # 11..13 - - Plus (Token): "+" # 14..15 + - UsingAlias (Rule): # 10..15 " as +" + - AsKeyword (Token): "as" # 11..13 + - Plus (Token): "+" # 14..15 - Comma (Token): "," # 15..16 - UsingDirectiveSymbol (Rule): # 16..20 " sub" - IdentifierPath (Rule): # 16..20 " sub" @@ -28,8 +29,9 @@ Tree: - UsingDirectiveSymbol (Rule): # 26..35 " div as /" - IdentifierPath (Rule): # 26..30 " div" - Identifier (Token): "div" # 27..30 - - AsKeyword (Token): "as" # 31..33 - - Slash (Token): "/" # 34..35 + - UsingAlias (Rule): # 30..35 " as /" + - AsKeyword (Token): "as" # 31..33 + - Slash (Token): "/" # 34..35 - CloseBrace (Token): "}" # 35..36 - ForKeyword (Token): "for" # 37..40 - TypeName (Rule): # 40..44 " Int" diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDirective/user_defined_operator/generated/0.8.19-success.yml b/crates/solidity/testing/snapshots/cst_output/UsingDirective/user_defined_operator/generated/0.8.19-success.yml index 3250979b5d..ddfb451034 100644 --- a/crates/solidity/testing/snapshots/cst_output/UsingDirective/user_defined_operator/generated/0.8.19-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/UsingDirective/user_defined_operator/generated/0.8.19-success.yml @@ -14,8 +14,9 @@ Tree: - UsingDirectiveSymbol (Rule): # 7..15 "div as /" - IdentifierPath (Rule): # 7..10 "div" - Identifier (Token): "div" # 7..10 - - AsKeyword (Token): "as" # 11..13 - - Slash (Token): "/" # 14..15 + - UsingAlias (Rule): # 10..15 " as /" + - AsKeyword (Token): "as" # 11..13 + - Slash (Token): "/" # 14..15 - CloseBrace (Token): "}" # 15..16 - ForKeyword (Token): "for" # 17..20 - TypeName (Rule): # 20..24 " Int" diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/generated/0.8.19-success.yml b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/generated/0.8.19-success.yml index 4b629a2288..577cad3c10 100644 --- a/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/generated/0.8.19-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/generated/0.8.19-success.yml @@ -11,5 +11,6 @@ Tree: - Identifier (Token): "foo" # 0..3 - Period (Token): "." # 3..4 - Identifier (Token): "bar" # 4..7 - - AsKeyword (Token): "as" # 8..10 - - Slash (Token): "/" # 11..12 + - UsingAlias (Rule): # 7..12 " as /" + - AsKeyword (Token): "as" # 8..10 + - Slash (Token): "/" # 11..12 diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/generated/0.8.19-success.yml b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/generated/0.8.19-success.yml index 1a7220e058..f07a96997b 100644 --- a/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/generated/0.8.19-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/generated/0.8.19-success.yml @@ -9,5 +9,6 @@ Tree: - UsingDirectiveSymbol (Rule): # 0..8 "foo as /" - IdentifierPath (Rule): # 0..3 "foo" - Identifier (Token): "foo" # 0..3 - - AsKeyword (Token): "as" # 4..6 - - Slash (Token): "/" # 7..8 + - UsingAlias (Rule): # 3..8 " as /" + - AsKeyword (Token): "as" # 4..6 + - Slash (Token): "/" # 7..8 diff --git a/crates/solidity/testing/snapshots/cst_output/VariableDeclarationStatement/var/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/VariableDeclarationStatement/var/generated/0.4.11-success.yml index 09c154a164..f9de5be514 100644 --- a/crates/solidity/testing/snapshots/cst_output/VariableDeclarationStatement/var/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/VariableDeclarationStatement/var/generated/0.4.11-success.yml @@ -10,8 +10,9 @@ Tree: - VariableDeclaration (Rule): # 0..5 "var z" - VarKeyword (Token): "var" # 0..3 - Identifier (Token): "z" # 4..5 - - Equal (Token): "=" # 6..7 - - Expression (Rule): # 7..9 " 0" - - DecimalNumberExpression (Rule): # 7..9 " 0" - - DecimalLiteral (Token): "0" # 8..9 + - VariableDeclarationValue (Rule): # 5..9 " = 0" + - Equal (Token): "=" # 6..7 + - Expression (Rule): # 7..9 " 0" + - DecimalNumberExpression (Rule): # 7..9 " 0" + - DecimalLiteral (Token): "0" # 8..9 - Semicolon (Token): ";" # 9..10 diff --git a/crates/solidity/testing/snapshots/cst_output/YulBlock/function_def/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/YulBlock/function_def/generated/0.4.11-success.yml index fe9a3141f3..137149717b 100644 --- a/crates/solidity/testing/snapshots/cst_output/YulBlock/function_def/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/YulBlock/function_def/generated/0.4.11-success.yml @@ -15,7 +15,7 @@ Tree: - YulStatementsList (Rule): # 2..60 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - YulStatement (Rule): # 2..60 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - YulFunctionDefinition (Rule): # 2..60 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - - FunctionKeyword (Token): "function" # 3..11 + - YulFunctionKeyword (Token): "function" # 3..11 - YulIdentifier (Token): "mult" # 12..16 - YulParametersDeclaration (Rule): # 16..22 "(a, b)" - OpenParen (Token): "(" # 16..17 diff --git a/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.4.11-failure.yml index c500e1419c..e93ea0c4be 100644 --- a/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.4.11-failure.yml @@ -10,7 +10,7 @@ Source: > Errors: # 1 total - > - Error: Expected AsciiStringLiteral or BreakKeyword or CloseBrace or ContinueKeyword or FalseKeyword or ForKeyword or FunctionKeyword or HexStringLiteral or IfKeyword or LetKeyword or OpenBrace or SwitchKeyword or TrueKeyword or YulDecimalLiteral or YulHexLiteral or YulIdentifier. + Error: Expected AsciiStringLiteral or CloseBrace or HexStringLiteral or OpenBrace or YulBreakKeyword or YulContinueKeyword or YulDecimalLiteral or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulLetKeyword or YulSwitchKeyword or YulTrueKeyword. ╭─[crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/input.sol:4:10] │ 4 │ ╭─▶ result := [mul(a, b) @@ -25,7 +25,7 @@ Tree: - YulStatementsList (Rule): # 2..83 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - YulStatement (Rule): # 2..83 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - YulFunctionDefinition (Rule): # 2..83 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - - FunctionKeyword (Token): "function" # 3..11 + - YulFunctionKeyword (Token): "function" # 3..11 - YulIdentifier (Token): "mult" # 12..16 - YulParametersDeclaration (Rule): # 16..22 "(a, b)" - OpenParen (Token): "(" # 16..17 diff --git a/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.6.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.6.0-failure.yml index 39dab865c2..69452c37d1 100644 --- a/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.6.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/generated/0.6.0-failure.yml @@ -10,7 +10,7 @@ Source: > Errors: # 1 total - > - Error: Expected AsciiStringLiteral or BreakKeyword or CloseBrace or ContinueKeyword or FalseKeyword or ForKeyword or FunctionKeyword or HexStringLiteral or IfKeyword or LeaveKeyword or LetKeyword or OpenBrace or SwitchKeyword or TrueKeyword or YulDecimalLiteral or YulHexLiteral or YulIdentifier. + Error: Expected AsciiStringLiteral or CloseBrace or HexStringLiteral or OpenBrace or YulBreakKeyword or YulContinueKeyword or YulDecimalLiteral or YulFalseKeyword or YulForKeyword or YulFunctionKeyword or YulHexLiteral or YulIdentifier or YulIfKeyword or YulLeaveKeyword or YulLetKeyword or YulSwitchKeyword or YulTrueKeyword. ╭─[crates/solidity/testing/snapshots/cst_output/YulBlock/ignore_unknown_delim/input.sol:4:10] │ 4 │ ╭─▶ result := [mul(a, b) @@ -25,7 +25,7 @@ Tree: - YulStatementsList (Rule): # 2..83 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - YulStatement (Rule): # 2..83 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - YulFunctionDefinition (Rule): # 2..83 "\tfunction mult(a, b) -> result {\n\t\tresult := mul(a..." - - FunctionKeyword (Token): "function" # 3..11 + - YulFunctionKeyword (Token): "function" # 3..11 - YulIdentifier (Token): "mult" # 12..16 - YulParametersDeclaration (Rule): # 16..22 "(a, b)" - OpenParen (Token): "(" # 16..17 diff --git a/crates/solidity/testing/snapshots/cst_output/YulExpression/decimal_trailing_ident_start/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/YulExpression/decimal_trailing_ident_start/generated/0.4.11-failure.yml index 5ef6e83d6d..49dfe38937 100644 --- a/crates/solidity/testing/snapshots/cst_output/YulExpression/decimal_trailing_ident_start/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/YulExpression/decimal_trailing_ident_start/generated/0.4.11-failure.yml @@ -5,7 +5,7 @@ Source: > Errors: # 1 total - > - Error: Expected AsciiStringLiteral or FalseKeyword or HexStringLiteral or TrueKeyword or YulDecimalLiteral or YulHexLiteral or YulIdentifier. + Error: Expected AsciiStringLiteral or HexStringLiteral or YulDecimalLiteral or YulFalseKeyword or YulHexLiteral or YulIdentifier or YulTrueKeyword. ╭─[crates/solidity/testing/snapshots/cst_output/YulExpression/decimal_trailing_ident_start/input.sol:1:1] │ 1 │ 1a diff --git a/crates/solidity/testing/snapshots/cst_output/YulExpression/hex_trailing_ident_start/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/YulExpression/hex_trailing_ident_start/generated/0.4.11-failure.yml index a3f3ae7d13..5ac4586226 100644 --- a/crates/solidity/testing/snapshots/cst_output/YulExpression/hex_trailing_ident_start/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/YulExpression/hex_trailing_ident_start/generated/0.4.11-failure.yml @@ -5,7 +5,7 @@ Source: > Errors: # 1 total - > - Error: Expected AsciiStringLiteral or FalseKeyword or HexStringLiteral or TrueKeyword or YulDecimalLiteral or YulHexLiteral or YulIdentifier. + Error: Expected AsciiStringLiteral or HexStringLiteral or YulDecimalLiteral or YulFalseKeyword or YulHexLiteral or YulIdentifier or YulTrueKeyword. ╭─[crates/solidity/testing/snapshots/cst_output/YulExpression/hex_trailing_ident_start/input.sol:1:1] │ 1 │ 0x1$ diff --git a/crates/solidity/testing/snapshots/cst_output/YulStatement/leave/generated/0.6.0-success.yml b/crates/solidity/testing/snapshots/cst_output/YulStatement/leave/generated/0.6.0-success.yml index c8bb0d30e7..c0aab82168 100644 --- a/crates/solidity/testing/snapshots/cst_output/YulStatement/leave/generated/0.6.0-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/YulStatement/leave/generated/0.6.0-success.yml @@ -8,4 +8,4 @@ Errors: [] Tree: - YulStatement (Rule): # 0..5 "leave" - YulLeaveStatement (Rule): # 0..5 "leave" - - LeaveKeyword (Token): "leave" # 0..5 + - YulLeaveKeyword (Token): "leave" # 0..5