diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index fc0f3ff117..37461250a9 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -1,3 +1,4 @@ +use std::cell::OnceCell; use std::collections::BTreeSet; use std::collections::HashMap; use std::rc::Rc; @@ -62,12 +63,8 @@ impl codegen_grammar::TriviaParserDefinition for NamedTriviaParser { } #[derive(Debug)] -struct NamedParser( - &'static str, - &'static str, - codegen_grammar::ParserDefinitionNode, -); -impl codegen_grammar::ParserDefinition for NamedParser { +struct NamedParserThunk(&'static str, &'static str, OnceCell); +impl codegen_grammar::ParserDefinition for NamedParserThunk { fn name(&self) -> &'static str { self.0 } @@ -82,7 +79,7 @@ impl codegen_grammar::ParserDefinition for NamedParser { } fn node(&self) -> &codegen_grammar::ParserDefinitionNode { - &self.2 + self.2.get().expect("Thunk to be resolved") } } @@ -427,74 +424,200 @@ fn resolve_grammar_element(ident: &Identifier, ctx: &mut ResolveCtx) -> GrammarE let (lex_ctx, elem) = ctx.items.get(ident).expect("Missing item"); - let path = RESOLVE_PATH.with(|path| path.borrow().clone().join(" -> ")); - // eprint!("{path}: "); - // Can't use the entry API because of the borrow checker - if let Some(resolved) = ctx.resolved.get(ident) { - eprintln!("{path}: Reusing {}.", ident); - resolved.clone() - } else { - eprintln!("{path}: Resolving {}...", ident); - RESOLVE_PATH.with(|path| path.borrow_mut().push(ident.to_string())); + // FIXME: Don't leak + let lex_ctx = lex_ctx + .as_ref() + .map(|l| l.to_string().leak() as &_) + .unwrap_or("Default"); - let resolved: GrammarElement = match elem.as_ref() { - Item::Trivia { item } => (Rc::new(NamedScanner( - ident.to_string().leak(), - resolve_scanner(item.scanner.clone(), ctx), - )) as Rc) - .into(), - Item::Fragment { item } => (Rc::new(NamedScanner( - ident.to_string().leak(), - resolve_fragment(item.clone(), ctx), - )) - as Rc) - .into(), - Item::Token { item } => (Rc::new(NamedScanner( - ident.to_string().leak(), - resolve_token(item.clone(), ctx), - )) as Rc) - .into(), - Item::Keyword { item } => (Rc::new(NamedScanner( - ident.to_string().leak(), - resolve_keyword(item.clone()), - )) - as Rc) - .into(), - // TODO: - Item::Struct { item } => (Rc::new(NamedParser( + // The non-terminals are mutually recursive, and so will be the resolution of their definitions, + // so make sure to insert a thunk for non-terminals to resolve to break the cycle. + let inserted_thunk = match (elem.as_ref(), ctx.resolved.get(ident)) { + ( + Item::Struct { .. } + | Item::Enum { .. } + | Item::Repeated { .. } + | Item::Separated { .. }, + None, + ) => { + let thunk = Rc::new(NamedParserThunk( ident.to_string().leak(), - lex_ctx - .as_ref() - .map(|l| l.to_string().leak() as &_) - .unwrap_or("Default"), - resolve_sequence(item.clone(), ctx), - )) as Rc) - .into(), - Item::Enum { item } => (Rc::new(NamedParser( + lex_ctx, + OnceCell::new(), + )); + ctx.resolved.insert( + ident.clone(), + (thunk.clone() as Rc).into(), + ); + Some(thunk) + } + (Item::Precedence { .. }, None) => { + // TODO: Properly handle precedence parser + let thunk = Rc::new(NamedParserThunk( ident.to_string().leak(), - lex_ctx - .as_ref() - .map(|l| l.to_string().leak() as &_) - .unwrap_or("Default"), - resolve_choice(item.clone(), ctx), - )) as Rc) - .into(), - Item::Repeated { .. } | Item::Separated { .. } | Item::Precedence { .. } => { - (Rc::new(NamedScanner( - "dummy", - codegen_grammar::ScannerDefinitionNode::Literal("dummy".to_string()), - )) as Rc) - .into() - } - }; + lex_ctx, + OnceCell::new(), + )); + ctx.resolved.insert( + ident.clone(), + (thunk.clone() as Rc).into(), + ); + Some(thunk) + } + _ => None, + }; - ctx.resolved.insert(ident.clone(), resolved.clone()); + let path = RESOLVE_PATH.with(|path| path.borrow().clone().join(" -> ")); - eprintln!("{path}: Resolved {}!", ident); - RESOLVE_PATH.with(|path| path.borrow_mut().pop()); + // 1. If we inserted the thunk, then we surely need to resolve those items as usual + // 2. If we did not insert the thunk, it means: + // a) we're resolving a terminal and we need to return the resolved element + // b) we're in a recursive non-terminal resolution and we need to return the thunk - resolved + // We can only return the memoized element, if it's not just a thunk (that we just inserted) + match (inserted_thunk, ctx.resolved.get(ident)) { + (None, Some(resolved)) => { + eprintln!("{path}: Reusing {}.", ident); + return resolved.clone(); + } + (Some(..), None) => unreachable!("We just inserted a thunk!"), + // If we're here, it means that we need to either resolve the thunk or the terminal + // 1. If it's the inserted thunk to resolve, we fill the cell and return the thunk + // 2. If it's the terminal to resolve, we resolve it and return the resolved element + (Some(thunk), Some(..)) => { + /* First time resolving non-terminal `ident` */ + eprintln!("{path}: Resolving non-terminal {}...", ident); + + match elem.as_ref() { + Item::Struct { item } => { + thunk.2.set(resolve_sequence(item.clone(), ctx)).unwrap(); + } + Item::Enum { item } => { + thunk.2.set(resolve_choice(item.clone(), ctx)).unwrap(); + } + + Item::Repeated { .. } | Item::Separated { .. } | Item::Precedence { .. } => { + ctx.resolved.insert( + ident.clone(), + (Rc::new(NamedScanner( + "dummy", + codegen_grammar::ScannerDefinitionNode::Literal("dummy".to_string()), + )) as Rc) + .into(), + ); + } + _ => unreachable!("Only non-terminals can be resolved here"), + }; + + // ctx.resolved.insert(ident.clone(), resolved.clone()); + + eprintln!("{path}: Resolved {}!", ident); + RESOLVE_PATH.with(|path| path.borrow_mut().pop()); + + ctx.resolved.get(ident).cloned().unwrap() + } + (None, None) => { + /* First time resolving terminal `ident` */ + eprintln!("{path}: Resolving terminal {}...", ident); + + let resolved: GrammarElement = match elem.as_ref() { + Item::Trivia { item } => (Rc::new(NamedScanner( + ident.to_string().leak(), + resolve_scanner(item.scanner.clone(), ctx), + )) + as Rc) + .into(), + Item::Fragment { item } => (Rc::new(NamedScanner( + ident.to_string().leak(), + resolve_fragment(item.clone(), ctx), + )) + as Rc) + .into(), + Item::Token { item } => (Rc::new(NamedScanner( + ident.to_string().leak(), + resolve_token(item.clone(), ctx), + )) + as Rc) + .into(), + Item::Keyword { item } => (Rc::new(NamedScanner( + ident.to_string().leak(), + resolve_keyword(item.clone()), + )) + as Rc) + .into(), + _ => unreachable!("Only terminals can be resolved here"), + }; + + ctx.resolved.insert(ident.clone(), resolved.clone()); + + eprintln!("{path}: Resolved {}!", ident); + RESOLVE_PATH.with(|path| path.borrow_mut().pop()); + + resolved + } } + + // // If we're here, it means that we need to either resolve the thunk or the terminal + // // 1. If it's the inserted thunk to resolve, we fill the cell and return the thunk + // // 2. If it's the terminal to resolve, we resolve it and return the resolved element + // eprintln!("{path}: Resolving {}...", ident); + // RESOLVE_PATH.with(|path| path.borrow_mut().push(ident.to_string())); + + // let resolved: GrammarElement = match elem.as_ref() { + // Item::Trivia { item } => (Rc::new(NamedScanner( + // ident.to_string().leak(), + // resolve_scanner(item.scanner.clone(), ctx), + // )) as Rc) + // .into(), + // Item::Fragment { item } => (Rc::new(NamedScanner( + // ident.to_string().leak(), + // resolve_fragment(item.clone(), ctx), + // )) as Rc) + // .into(), + // Item::Token { item } => (Rc::new(NamedScanner( + // ident.to_string().leak(), + // resolve_token(item.clone(), ctx), + // )) as Rc) + // .into(), + // Item::Keyword { item } => (Rc::new(NamedScanner( + // ident.to_string().leak(), + // resolve_keyword(item.clone()), + // )) as Rc) + // .into(), + // // TODO: + // Item::Struct { item } => (Rc::new(NamedParserThunk( + // ident.to_string().leak(), + // lex_ctx + // .as_ref() + // .map(|l| l.to_string().leak() as &_) + // .unwrap_or("Default"), + // resolve_sequence(item.clone(), ctx), + // )) as Rc) + // .into(), + // Item::Enum { item } => (Rc::new(NamedParserThunk( + // ident.to_string().leak(), + // lex_ctx + // .as_ref() + // .map(|l| l.to_string().leak() as &_) + // .unwrap_or("Default"), + // resolve_choice(item.clone(), ctx), + // )) as Rc) + // .into(), + // Item::Repeated { .. } | Item::Separated { .. } | Item::Precedence { .. } => { + // (Rc::new(NamedScanner( + // "dummy", + // codegen_grammar::ScannerDefinitionNode::Literal("dummy".to_string()), + // )) as Rc) + // .into() + // } + // }; + + // ctx.resolved.insert(ident.clone(), resolved.clone()); + + // eprintln!("{path}: Resolved {}!", ident); + // RESOLVE_PATH.with(|path| path.borrow_mut().pop()); + + // resolved } struct ResolveCtx<'a> { diff --git a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs index 3d25904331..5c069774ff 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs @@ -19,6 +19,7 @@ use {napi::bindgen_prelude::*, napi_derive::napi}; pub enum ProductionKind { ABICoderPragma, AddressType, + ArgumentsDeclaration, ArrayExpression, ArrayValuesList, AsciiStringLiteralsList, @@ -31,10 +32,12 @@ pub enum ProductionKind { CatchClauseError, CatchClausesList, ConstantDefinition, + ConstructorAttribute, ConstructorAttributesList, ConstructorDefinition, ContinueStatement, ContractDefinition, + ContractMember, ContractMembersList, DecimalNumberExpression, DeconstructionImport, @@ -42,6 +45,7 @@ pub enum ProductionKind { DeconstructionImportSymbolsList, DeleteStatement, DoWhileStatement, + ElementaryType, ElseBranch, EmitStatement, EndOfFileTrivia, @@ -54,15 +58,22 @@ pub enum ProductionKind { EventParameter, EventParametersDeclaration, EventParametersList, + ExperimentalFeature, ExperimentalPragma, ExpressionStatement, + FallbackFunctionAttribute, FallbackFunctionAttributesList, FallbackFunctionDefinition, ForStatement, + ForStatementCondition, + ForStatementInitialization, + FunctionAttribute, FunctionAttributesList, + FunctionBody, FunctionCallOptions, FunctionDefinition, FunctionType, + FunctionTypeAttribute, FunctionTypeAttributesList, HexNumberExpression, HexStringLiteralsList, @@ -72,6 +83,7 @@ pub enum ProductionKind { ImportAlias, ImportDeconstructionField, ImportDirective, + ImportSymbol, ImportSymbolDeconstruction, IndexAccessEnd, InheritanceSpecifier, @@ -83,9 +95,11 @@ pub enum ProductionKind { LibraryDefinition, LibraryMembersList, MappingKey, + MappingKeyType, MappingType, MappingValue, MappingValueType, + ModifierAttribute, ModifierAttributesList, ModifierDefinition, ModifierInvocation, @@ -96,6 +110,7 @@ pub enum ProductionKind { NamedImport, NamedImportSymbol, NewExpression, + NumberUnit, NumericExpression, OverrideSpecifier, Parameter, @@ -105,18 +120,25 @@ pub enum ProductionKind { PathImportSymbol, PositionalArgumentsDeclaration, PositionalArgumentsList, + Pragma, PragmaDirective, + ReceiveFunctionAttribute, ReceiveFunctionAttributesList, ReceiveFunctionDefinition, ReturnStatement, ReturnsDeclaration, RevertStatement, SourceUnit, + SourceUnitMember, SourceUnitMembersList, + StateVariableAttribute, StateVariableAttributesList, StateVariableDefinition, StateVariableDefinitionValue, + Statement, StatementsList, + StorageLocation, + StringExpression, StructDefinition, StructMember, StructMembersList, @@ -125,6 +147,7 @@ pub enum ProductionKind { TryStatement, TupleDeconstructionStatement, TupleExpression, + TupleMember, TupleMemberDeconstruction, TupleMembersList, TupleValue, @@ -133,6 +156,7 @@ pub enum ProductionKind { TypedTupleMember, UncheckedBlock, UnicodeStringLiteralsList, + UnnamedFunctionAttribute, UnnamedFunctionAttributesList, UnnamedFunctionDefinition, UntypedTupleMember, @@ -144,9 +168,12 @@ pub enum ProductionKind { UsingDirectivePath, UsingDirectiveSymbol, UsingDirectiveSymbolsList, + UsingSymbol, UsingSymbolDeconstruction, + UsingTarget, VariableDeclaration, VariableDeclarationStatement, + VariableDeclarationType, VariableDeclarationValue, VersionPragma, VersionPragmaExpression, @@ -167,6 +194,7 @@ pub enum ProductionKind { YulIdentifiersList, YulIfStatement, YulLeaveStatement, + YulLiteral, YulParametersDeclaration, YulReturnsDeclaration, YulStatement, @@ -195,6 +223,7 @@ pub enum ProductionKind { pub enum RuleKind { ABICoderPragma, AddressType, + ArgumentsDeclaration, ArrayExpression, ArrayValuesList, AsciiStringLiteralsList, @@ -207,10 +236,12 @@ pub enum RuleKind { CatchClauseError, CatchClausesList, ConstantDefinition, + ConstructorAttribute, ConstructorAttributesList, ConstructorDefinition, ContinueStatement, ContractDefinition, + ContractMember, ContractMembersList, DecimalNumberExpression, DeconstructionImport, @@ -218,6 +249,7 @@ pub enum RuleKind { DeconstructionImportSymbolsList, DeleteStatement, DoWhileStatement, + ElementaryType, ElseBranch, EmitStatement, EndOfFileTrivia, @@ -230,15 +262,22 @@ pub enum RuleKind { EventParameter, EventParametersDeclaration, EventParametersList, + ExperimentalFeature, ExperimentalPragma, ExpressionStatement, + FallbackFunctionAttribute, FallbackFunctionAttributesList, FallbackFunctionDefinition, ForStatement, + ForStatementCondition, + ForStatementInitialization, + FunctionAttribute, FunctionAttributesList, + FunctionBody, FunctionCallOptions, FunctionDefinition, FunctionType, + FunctionTypeAttribute, FunctionTypeAttributesList, HexNumberExpression, HexStringLiteralsList, @@ -248,6 +287,7 @@ pub enum RuleKind { ImportAlias, ImportDeconstructionField, ImportDirective, + ImportSymbol, ImportSymbolDeconstruction, IndexAccessEnd, InheritanceSpecifier, @@ -259,9 +299,11 @@ pub enum RuleKind { LibraryDefinition, LibraryMembersList, MappingKey, + MappingKeyType, MappingType, MappingValue, MappingValueType, + ModifierAttribute, ModifierAttributesList, ModifierDefinition, ModifierInvocation, @@ -272,6 +314,7 @@ pub enum RuleKind { NamedImport, NamedImportSymbol, NewExpression, + NumberUnit, NumericExpression, OverrideSpecifier, Parameter, @@ -281,18 +324,25 @@ pub enum RuleKind { PathImportSymbol, PositionalArgumentsDeclaration, PositionalArgumentsList, + Pragma, PragmaDirective, + ReceiveFunctionAttribute, ReceiveFunctionAttributesList, ReceiveFunctionDefinition, ReturnStatement, ReturnsDeclaration, RevertStatement, SourceUnit, + SourceUnitMember, SourceUnitMembersList, + StateVariableAttribute, StateVariableAttributesList, StateVariableDefinition, StateVariableDefinitionValue, + Statement, StatementsList, + StorageLocation, + StringExpression, StructDefinition, StructMember, StructMembersList, @@ -301,6 +351,7 @@ pub enum RuleKind { TryStatement, TupleDeconstructionStatement, TupleExpression, + TupleMember, TupleMemberDeconstruction, TupleMembersList, TupleValue, @@ -309,6 +360,7 @@ pub enum RuleKind { TypedTupleMember, UncheckedBlock, UnicodeStringLiteralsList, + UnnamedFunctionAttribute, UnnamedFunctionAttributesList, UnnamedFunctionDefinition, UntypedTupleMember, @@ -320,9 +372,12 @@ pub enum RuleKind { UsingDirectivePath, UsingDirectiveSymbol, UsingDirectiveSymbolsList, + UsingSymbol, UsingSymbolDeconstruction, + UsingTarget, VariableDeclaration, VariableDeclarationStatement, + VariableDeclarationType, VariableDeclarationValue, VersionPragma, VersionPragmaBinaryExpression, @@ -345,6 +400,7 @@ pub enum RuleKind { YulIdentifiersList, YulIfStatement, YulLeaveStatement, + YulLiteral, YulParametersDeclaration, YulReturnsDeclaration, YulStatement, @@ -409,6 +465,8 @@ pub enum TokenKind { BoolKeyword, BreakKeyword, ByteKeyword, + BytesKeyword, + CallDataKeyword, CalldataKeyword, Caret, CaretEqual, @@ -447,6 +505,7 @@ pub enum TokenKind { FalseKeyword, FinalKeyword, FinneyKeyword, + FixedKeyword, ForKeyword, FromKeyword, FunctionKeyword, @@ -470,6 +529,7 @@ pub enum TokenKind { InKeyword, IndexedKeyword, InlineKeyword, + IntKeyword, InterfaceKeyword, InternalKeyword, IsKeyword, @@ -541,6 +601,8 @@ pub enum TokenKind { TypeKeyword, TypedefKeyword, TypeofKeyword, + UfixedKeyword, + UintKeyword, UncheckedKeyword, UnicodeStringLiteral, UsingKeyword, @@ -556,14 +618,18 @@ pub enum TokenKind { YulBreakKeyword, YulCaseKeyword, YulContinueKeyword, + YulDecimalLiteral, YulDefaultKeyword, + YulFalseKeyword, YulForKeyword, YulFunctionKeyword, + YulHexLiteral, YulIdentifier, YulIfKeyword, YulLeaveKeyword, YulLetKeyword, YulSwitchKeyword, + YulTrueKeyword, dummy, } diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index 1a406d3b77..cc92d2af96 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -31,6 +31,7 @@ pub struct Language { 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, pub(crate) version_is_at_least_0_7_4: bool, @@ -150,6 +151,7 @@ impl Language { 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, version_is_at_least_0_7_4: Version::new(0, 7, 4) <= version, @@ -208,6 +210,18 @@ impl Language { .with_kind(RuleKind::AddressType) } + #[allow(unused_assignments, unused_parens)] + fn arguments_declaration(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.positional_arguments_declaration(input); + choice.consider(input, result)?; + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::ArgumentsDeclaration) + } + #[allow(unused_assignments, unused_parens)] fn array_expression(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -434,6 +448,32 @@ impl Language { .with_kind(RuleKind::ConstantDefinition) } + #[allow(unused_assignments, unused_parens)] + fn constructor_attribute(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_4_22 { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(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::PublicKeyword, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::ConstructorAttribute) + } + #[allow(unused_assignments, unused_parens)] fn constructor_attributes_list(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_4_22 { @@ -546,6 +586,52 @@ impl Language { .with_kind(RuleKind::ContractDefinition) } + #[allow(unused_assignments, unused_parens)] + fn contract_member(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.using_directive(input); + choice.consider(input, result)?; + let result = self.function_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 = 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)?; + } + if self.version_is_at_least_0_8_8 { + let result = self.user_defined_value_type_definition(input); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::ContractMember) + } + #[allow(unused_assignments, unused_parens)] fn contract_members_list(&self, input: &mut ParserContext) -> ParserResult { OneOrMoreHelper::run(input, |input| { @@ -603,12 +689,7 @@ impl Language { input, TokenKind::DecimalLiteral, ))?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.number_unit(input)))?; seq.finish() }) .with_kind(RuleKind::DecimalNumberExpression) @@ -715,12 +796,7 @@ impl Language { input, TokenKind::DoKeyword, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.statement(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::WhileKeyword, @@ -748,6 +824,63 @@ impl Language { .with_kind(RuleKind::DoWhileStatement) } + #[allow(unused_assignments, unused_parens)] + fn elementary_type(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.parse_token_with_trivia::( + input, + 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, + ); + 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::BytesKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::IntKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::UintKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::FixedKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::UfixedKeyword, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::ElementaryType) + } + #[allow(unused_assignments, unused_parens)] fn else_branch(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -757,12 +890,7 @@ impl Language { TokenKind::ElseKeyword, ), ))?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.statement(input)))?; seq.finish() }) .with_kind(RuleKind::ElseBranch) @@ -780,10 +908,7 @@ impl Language { input, TokenKind::dummy, ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ))?; + seq.elem(self.arguments_declaration(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Semicolon, @@ -1024,6 +1149,24 @@ impl Language { .with_kind(RuleKind::EventParametersList) } + #[allow(unused_assignments, unused_parens)] + fn experimental_feature(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.parse_token_with_trivia::( + input, + TokenKind::Identifier, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::AsciiStringLiteral, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::ExperimentalFeature) + } + #[allow(unused_assignments, unused_parens)] fn experimental_pragma(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -1031,9 +1174,7 @@ impl Language { input, TokenKind::ExperimentalKeyword, ))?; - seq.elem( - self.parse_token_with_trivia::(input, TokenKind::dummy), - )?; + seq.elem(self.experimental_feature(input))?; seq.finish() }) .with_kind(RuleKind::ExperimentalPragma) @@ -1057,6 +1198,47 @@ impl Language { .with_kind(RuleKind::ExpressionStatement) } + #[allow(unused_assignments, unused_parens)] + fn fallback_function_attribute(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_6_0 { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(input); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ExternalKeyword, + ); + 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::PureKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ViewKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::VirtualKeyword, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::FallbackFunctionAttribute) + } + #[allow(unused_assignments, unused_parens)] fn fallback_function_attributes_list(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { @@ -1118,10 +1300,7 @@ impl Language { TokenKind::dummy, ))?; seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ))?; + seq.elem(self.function_body(input))?; seq.finish() }) } else { @@ -1141,18 +1320,8 @@ impl Language { input, TokenKind::OpenParen, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.for_statement_initialization(input))?; + seq.elem(self.for_statement_condition(input))?; seq.elem(OptionalHelper::transform( self.parse_token_with_trivia::( input, @@ -1163,17 +1332,107 @@ impl Language { input, TokenKind::CloseParen, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.statement(input))?; seq.finish() }) .with_kind(RuleKind::ForStatement) } + #[allow(unused_assignments, unused_parens)] + fn for_statement_condition(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.expression_statement(input); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Semicolon, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::ForStatementCondition) + } + + #[allow(unused_assignments, unused_parens)] + fn for_statement_initialization(&self, input: &mut ParserContext) -> ParserResult { + 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)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Semicolon, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::ForStatementInitialization) + } + + #[allow(unused_assignments, unused_parens)] + fn function_attribute(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(input); + choice.consider(input, result)?; + 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, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::InternalKeyword, + ); + 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::PrivateKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PublicKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PureKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ViewKeyword, + ); + choice.consider(input, result)?; + if self.version_is_at_least_0_6_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::VirtualKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::FunctionAttribute) + } + #[allow(unused_assignments, unused_parens)] fn function_attributes_list(&self, input: &mut ParserContext) -> ParserResult { OneOrMoreHelper::run(input, |input| { @@ -1238,19 +1497,40 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn function_call_options(&self, input: &mut ParserContext) -> ParserResult { + fn function_body(&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)?; - } + let result = self.block(input); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Semicolon, + ); + choice.consider(input, result)?; choice.finish(input) }) + .with_kind(RuleKind::FunctionBody) + } + + #[allow(unused_assignments, unused_parens)] + fn function_call_options(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_6_2 { + 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 = self.parse_token_with_trivia::( + input, + TokenKind::dummy, + ); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_8_0 { + let result = self.named_argument_group(input); + choice.consider(input, result)?; + } + choice.finish(input) + }) + } else { + ParserResult::disabled() + } .with_kind(RuleKind::FunctionCallOptions) } @@ -1287,12 +1567,7 @@ impl Language { ), )?; seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.function_body(input))?; seq.finish() }) .with_kind(RuleKind::FunctionDefinition) @@ -1315,7 +1590,50 @@ impl Language { seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; seq.finish() }) - .with_kind(RuleKind::FunctionType) + .with_kind(RuleKind::FunctionType) + } + + #[allow(unused_assignments, unused_parens)] + fn function_type_attribute(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.parse_token_with_trivia::( + input, + TokenKind::InternalKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ExternalKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PrivateKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PublicKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PureKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ViewKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::FunctionTypeAttribute) } #[allow(unused_assignments, unused_parens)] @@ -1371,12 +1689,7 @@ impl Language { TokenKind::HexLiteral, ))?; if !self.version_is_at_least_0_5_0 { - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.number_unit(input)))?; } seq.finish() }) @@ -1442,12 +1755,7 @@ impl Language { input, TokenKind::CloseParen, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.statement(input))?; seq.elem(OptionalHelper::transform(self.else_branch(input)))?; seq.finish() }) @@ -1490,12 +1798,7 @@ impl Language { input, TokenKind::ImportKeyword, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.import_symbol(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Semicolon, @@ -1505,6 +1808,20 @@ impl Language { .with_kind(RuleKind::ImportDirective) } + #[allow(unused_assignments, unused_parens)] + fn import_symbol(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.path_import_symbol(input); + choice.consider(input, result)?; + let result = self.named_import_symbol(input); + choice.consider(input, result)?; + let result = self.import_symbol_deconstruction(input); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::ImportSymbol) + } + #[allow(unused_assignments, unused_parens)] fn import_symbol_deconstruction(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -1582,12 +1899,7 @@ impl Language { TokenKind::dummy, ), )?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; seq.finish() }) .with_kind(RuleKind::InheritanceType) @@ -1792,12 +2104,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn mapping_key(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.mapping_key_type(input))?; if self.version_is_at_least_0_8_18 { seq.elem(OptionalHelper::transform( self.parse_token_with_trivia::( @@ -1811,6 +2118,19 @@ impl Language { .with_kind(RuleKind::MappingKey) } + #[allow(unused_assignments, unused_parens)] + fn mapping_key_type(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.elementary_type(input); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::dummy); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::MappingKeyType) + } + #[allow(unused_assignments, unused_parens)] fn mapping_type(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -1876,6 +2196,23 @@ impl Language { .with_kind(RuleKind::MappingValueType) } + #[allow(unused_assignments, unused_parens)] + fn modifier_attribute(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.override_specifier(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_6_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::VirtualKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::ModifierAttribute) + } + #[allow(unused_assignments, unused_parens)] fn modifier_attributes_list(&self, input: &mut ParserContext) -> ParserResult { OneOrMoreHelper::run(input, |input| { @@ -1915,12 +2252,7 @@ impl Language { TokenKind::dummy, ), )?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.function_body(input))?; seq.finish() }) .with_kind(RuleKind::ModifierDefinition) @@ -1935,12 +2267,7 @@ impl Language { TokenKind::dummy, ), )?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; seq.finish() }) .with_kind(RuleKind::ModifierInvocation) @@ -2087,6 +2414,77 @@ impl Language { .with_kind(RuleKind::NewExpression) } + #[allow(unused_assignments, unused_parens)] + fn number_unit(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.parse_token_with_trivia::( + input, + 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, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::SecondsKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::MinutesKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::HoursKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::DaysKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::WeeksKeyword, + ); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::YearsKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::NumberUnit) + } + #[allow(unused_assignments, unused_parens)] fn numeric_expression(&self, input: &mut ParserContext) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { @@ -2305,12 +2703,7 @@ impl Language { TokenKind::dummy, ), )?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.storage_location(input)))?; seq.elem(OptionalHelper::transform( self.parse_token_with_trivia::( input, @@ -2424,6 +2817,20 @@ impl Language { .with_kind(RuleKind::PositionalArgumentsList) } + #[allow(unused_assignments, unused_parens)] + fn pragma(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.abi_coder_pragma(input); + choice.consider(input, result)?; + let result = self.experimental_pragma(input); + choice.consider(input, result)?; + let result = self.version_pragma(input); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::Pragma) + } + #[allow(unused_assignments, unused_parens)] fn pragma_directive(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2431,9 +2838,7 @@ impl Language { input, TokenKind::PragmaKeyword, ))?; - seq.elem( - self.parse_token_with_trivia::(input, TokenKind::dummy), - )?; + seq.elem(self.pragma(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Semicolon, @@ -2443,6 +2848,37 @@ impl Language { .with_kind(RuleKind::PragmaDirective) } + #[allow(unused_assignments, unused_parens)] + fn receive_function_attribute(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_6_0 { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(input); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ExternalKeyword, + ); + 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::VirtualKeyword, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::ReceiveFunctionAttribute) + } + #[allow(unused_assignments, unused_parens)] fn receive_function_attributes_list(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { @@ -2493,10 +2929,7 @@ impl Language { input, TokenKind::dummy, ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ))?; + seq.elem(self.function_body(input))?; seq.finish() }) } else { @@ -2554,10 +2987,7 @@ impl Language { TokenKind::dummy, ), ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ))?; + seq.elem(self.arguments_declaration(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Semicolon, @@ -2576,6 +3006,52 @@ impl Language { .with_kind(RuleKind::SourceUnit) } + #[allow(unused_assignments, unused_parens)] + fn source_unit_member(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.pragma_directive(input); + choice.consider(input, result)?; + let result = self.import_directive(input); + choice.consider(input, result)?; + let result = self.contract_definition(input); + choice.consider(input, result)?; + let result = self.interface_definition(input); + choice.consider(input, result)?; + let result = self.library_definition(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_6_0 { + 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 { + let result = self.function_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_7_4 { + let result = self.constant_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)?; + } + if self.version_is_at_least_0_8_8 { + let result = self.user_defined_value_type_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_8_13 { + let result = self.using_directive(input); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::SourceUnitMember) + } + #[allow(unused_assignments, unused_parens)] fn source_unit_members_list(&self, input: &mut ParserContext) -> ParserResult { OneOrMoreHelper::run(input, |input| { @@ -2626,6 +3102,43 @@ impl Language { .with_kind(RuleKind::SourceUnitMembersList) } + #[allow(unused_assignments, unused_parens)] + fn state_variable_attribute(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.override_specifier(input); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ConstantKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::InternalKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PrivateKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PublicKeyword, + ); + choice.consider(input, result)?; + if self.version_is_at_least_0_6_5 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ImmutableKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::StateVariableAttribute) + } + #[allow(unused_assignments, unused_parens)] fn state_variable_attributes_list(&self, input: &mut ParserContext) -> ParserResult { OneOrMoreHelper::run(input, |input| { @@ -2713,7 +3226,61 @@ impl Language { )?; seq.finish() }) - .with_kind(RuleKind::StateVariableDefinitionValue) + .with_kind(RuleKind::StateVariableDefinitionValue) + } + + #[allow(unused_assignments, unused_parens)] + fn statement(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.variable_declaration_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)?; + } + 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_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)?; + } + let result = self.assembly_statement(input); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_8_0 { + let result = self.unchecked_block(input); + choice.consider(input, result)?; + } + let result = self.expression_statement(input); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::Statement) } #[allow(unused_assignments, unused_parens)] @@ -2722,6 +3289,52 @@ impl Language { .with_kind(RuleKind::StatementsList) } + #[allow(unused_assignments, unused_parens)] + fn storage_location(&self, input: &mut ParserContext) -> ParserResult { + 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) + }) + .with_kind(RuleKind::StorageLocation) + } + + #[allow(unused_assignments, unused_parens)] + fn string_expression(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self + .parse_token_with_trivia::(input, TokenKind::dummy); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::dummy); + choice.consider(input, result)?; + if self.version_is_at_least_0_7_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::dummy, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::StringExpression) + } + #[allow(unused_assignments, unused_parens)] fn struct_definition(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2904,12 +3517,22 @@ impl Language { .with_kind(RuleKind::TupleExpression) } + #[allow(unused_assignments, unused_parens)] + fn tuple_member(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.typed_tuple_member(input); + choice.consider(input, result)?; + let result = self.untyped_tuple_member(input); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::TupleMember) + } + #[allow(unused_assignments, unused_parens)] fn tuple_member_deconstruction(&self, input: &mut ParserContext) -> ParserResult { - OptionalHelper::transform( - self.parse_token_with_trivia::(input, TokenKind::dummy), - ) - .with_kind(RuleKind::TupleMemberDeconstruction) + OptionalHelper::transform(self.tuple_member(input)) + .with_kind(RuleKind::TupleMemberDeconstruction) } #[allow(unused_assignments, unused_parens)] @@ -2979,12 +3602,7 @@ impl Language { TokenKind::dummy, ), )?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.storage_location(input)))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Identifier, @@ -3026,6 +3644,42 @@ impl Language { .with_kind(RuleKind::UnicodeStringLiteralsList) } + #[allow(unused_assignments, unused_parens)] + fn unnamed_function_attribute(&self, input: &mut ParserContext) -> ParserResult { + if !self.version_is_at_least_0_6_0 { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(input); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ExternalKeyword, + ); + 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::PureKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ViewKeyword, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::UnnamedFunctionAttribute) + } + #[allow(unused_assignments, unused_parens)] fn unnamed_function_attributes_list(&self, input: &mut ParserContext) -> ParserResult { if !self.version_is_at_least_0_6_0 { @@ -3081,10 +3735,7 @@ impl Language { input, TokenKind::dummy, ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ))?; + seq.elem(self.function_body(input))?; seq.finish() }) } else { @@ -3096,12 +3747,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn untyped_tuple_member(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.storage_location(input)))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Identifier, @@ -3127,10 +3773,7 @@ impl Language { input, TokenKind::IsKeyword, ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ))?; + seq.elem(self.elementary_type(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Semicolon, @@ -3263,22 +3906,12 @@ impl Language { input, TokenKind::UsingKeyword, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.using_symbol(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::ForKeyword, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.using_target(input))?; if self.version_is_at_least_0_8_13 { seq.elem(OptionalHelper::transform( self.parse_token_with_trivia::( @@ -3455,6 +4088,21 @@ impl Language { .with_kind(RuleKind::UsingDirectiveSymbolsList) } + #[allow(unused_assignments, unused_parens)] + fn using_symbol(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self + .parse_token_with_trivia::(input, TokenKind::dummy); + choice.consider(input, result)?; + if self.version_is_at_least_0_8_13 { + let result = self.using_symbol_deconstruction(input); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::UsingSymbol) + } + #[allow(unused_assignments, unused_parens)] fn using_symbol_deconstruction(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_8_13 { @@ -3479,6 +4127,20 @@ impl Language { .with_kind(RuleKind::UsingSymbolDeconstruction) } + #[allow(unused_assignments, unused_parens)] + fn using_target(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self + .parse_token_with_trivia::(input, TokenKind::dummy); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::Asterisk); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::UsingTarget) + } + #[allow(unused_assignments, unused_parens)] fn variable_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -3529,18 +4191,8 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn variable_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(self.variable_declaration_type(input))?; + seq.elem(OptionalHelper::transform(self.storage_location(input)))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Identifier, @@ -3557,6 +4209,24 @@ impl Language { .with_kind(RuleKind::VariableDeclarationStatement) } + #[allow(unused_assignments, unused_parens)] + fn variable_declaration_type(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self + .parse_token_with_trivia::(input, TokenKind::dummy); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::VarKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::VariableDeclarationType) + } + #[allow(unused_assignments, unused_parens)] fn variable_declaration_value(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -3747,12 +4417,7 @@ impl Language { input, TokenKind::CloseParen, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.statement(input))?; seq.finish() }) .with_kind(RuleKind::WhileStatement) @@ -3974,6 +4639,44 @@ impl Language { .with_kind(RuleKind::YulLeaveStatement) } + #[allow(unused_assignments, unused_parens)] + fn yul_literal(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.parse_token_with_trivia::( + input, + TokenKind::YulTrueKeyword, + ); + choice.consider(input, result)?; + 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) + }) + .with_kind(RuleKind::YulLiteral) + } + #[allow(unused_assignments, unused_parens)] fn yul_parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -4019,7 +4722,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)?; @@ -4029,16 +4732,17 @@ impl Language { choice.consider(input, result)?; let result = self.yul_switch_statement(input); choice.consider(input, result)?; + if self.version_is_at_least_0_6_0 { + let result = self.yul_leave_statement(input); + choice.consider(input, result)?; + } let result = self.yul_break_statement(input); choice.consider(input, result)?; let result = self.yul_continue_statement(input); choice.consider(input, result)?; - let result = self.yul_expression(input); + let result = + self.parse_token_with_trivia::(input, TokenKind::dummy); choice.consider(input, result)?; - if self.version_is_at_least_0_6_0 { - let result = self.yul_leave_statement(input); - choice.consider(input, result)?; - } choice.finish(input) }) .with_kind(RuleKind::YulStatement) @@ -4052,58 +4756,12 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_switch_case(&self, input: &mut ParserContext) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::DefaultKeyword, - ); - 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() - }); - choice.consider(input, result)?; - choice.finish(input) - }))?; - seq.elem(self.yul_block(input))?; - seq.finish() + 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::YulSwitchCase) } @@ -4139,9 +4797,7 @@ impl Language { input, TokenKind::YulCaseKeyword, ))?; - seq.elem( - self.parse_token_with_trivia::(input, TokenKind::dummy), - )?; + seq.elem(self.yul_literal(input))?; seq.elem(self.yul_block(input))?; seq.finish() }) @@ -4305,15 +4961,6 @@ impl Language { ) } - #[allow(unused_assignments, unused_parens)] - fn call_data_keyword(&self, input: &mut ParserContext) -> bool { - if self.version_is_at_least_0_5_0 { - scan_chars!(input, 'c', 'a', 'l', 'l', 'd', 'a', 't', 'a') - } else { - false - } - } - #[allow(unused_assignments, unused_parens)] fn caret(&self, input: &mut ParserContext) -> bool { scan_not_followed_by!(input, scan_chars!(input, '^'), scan_chars!(input, '=')) @@ -6006,11 +6653,6 @@ impl Language { } } - #[allow(unused_assignments, unused_parens)] - fn yul_false_keyword(&self, input: &mut ParserContext) -> bool { - scan_chars!(input, 'f', 'a', 'l', 's', 'e') - } - #[allow(unused_assignments, unused_parens)] fn yul_final_keyword(&self, input: &mut ParserContext) -> bool { if !self.version_is_at_least_0_7_1 { @@ -6801,11 +7443,6 @@ impl Language { } } - #[allow(unused_assignments, unused_parens)] - fn yul_true_keyword(&self, input: &mut ParserContext) -> bool { - scan_chars!(input, 't', 'r', 'u', 'e') - } - #[allow(unused_assignments, unused_parens)] fn yul_try_keyword(&self, input: &mut ParserContext) -> bool { if !self.version_is_at_least_0_7_1 { @@ -7284,6 +7921,7 @@ impl Language { match production_kind { ProductionKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), ProductionKind::AddressType => Self::address_type.parse(self, input), + ProductionKind::ArgumentsDeclaration => Self::arguments_declaration.parse(self, input), ProductionKind::ArrayExpression => Self::array_expression.parse(self, input), ProductionKind::ArrayValuesList => Self::array_values_list.parse(self, input), ProductionKind::AsciiStringLiteralsList => { @@ -7300,6 +7938,7 @@ impl Language { ProductionKind::CatchClauseError => Self::catch_clause_error.parse(self, input), ProductionKind::CatchClausesList => Self::catch_clauses_list.parse(self, input), ProductionKind::ConstantDefinition => Self::constant_definition.parse(self, input), + ProductionKind::ConstructorAttribute => Self::constructor_attribute.parse(self, input), ProductionKind::ConstructorAttributesList => { Self::constructor_attributes_list.parse(self, input) } @@ -7308,6 +7947,7 @@ impl Language { } ProductionKind::ContinueStatement => Self::continue_statement.parse(self, input), ProductionKind::ContractDefinition => Self::contract_definition.parse(self, input), + ProductionKind::ContractMember => Self::contract_member.parse(self, input), ProductionKind::ContractMembersList => Self::contract_members_list.parse(self, input), ProductionKind::DecimalNumberExpression => { Self::decimal_number_expression.parse(self, input) @@ -7321,6 +7961,7 @@ impl Language { } ProductionKind::DeleteStatement => Self::delete_statement.parse(self, input), ProductionKind::DoWhileStatement => Self::do_while_statement.parse(self, input), + ProductionKind::ElementaryType => Self::elementary_type.parse(self, input), ProductionKind::ElseBranch => Self::else_branch.parse(self, input), ProductionKind::EmitStatement => Self::emit_statement.parse(self, input), ProductionKind::EndOfFileTrivia => Self::end_of_file_trivia.parse(self, input), @@ -7337,8 +7978,12 @@ impl Language { Self::event_parameters_declaration.parse(self, input) } ProductionKind::EventParametersList => Self::event_parameters_list.parse(self, input), + ProductionKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), ProductionKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), ProductionKind::ExpressionStatement => Self::expression_statement.parse(self, input), + ProductionKind::FallbackFunctionAttribute => { + Self::fallback_function_attribute.parse(self, input) + } ProductionKind::FallbackFunctionAttributesList => { Self::fallback_function_attributes_list.parse(self, input) } @@ -7346,12 +7991,23 @@ impl Language { Self::fallback_function_definition.parse(self, input) } ProductionKind::ForStatement => Self::for_statement.parse(self, input), + ProductionKind::ForStatementCondition => { + Self::for_statement_condition.parse(self, input) + } + ProductionKind::ForStatementInitialization => { + Self::for_statement_initialization.parse(self, input) + } + ProductionKind::FunctionAttribute => Self::function_attribute.parse(self, input), ProductionKind::FunctionAttributesList => { Self::function_attributes_list.parse(self, input) } + ProductionKind::FunctionBody => Self::function_body.parse(self, input), ProductionKind::FunctionCallOptions => Self::function_call_options.parse(self, input), ProductionKind::FunctionDefinition => Self::function_definition.parse(self, input), ProductionKind::FunctionType => Self::function_type.parse(self, input), + ProductionKind::FunctionTypeAttribute => { + Self::function_type_attribute.parse(self, input) + } ProductionKind::FunctionTypeAttributesList => { Self::function_type_attributes_list.parse(self, input) } @@ -7367,6 +8023,7 @@ impl Language { Self::import_deconstruction_field.parse(self, input) } ProductionKind::ImportDirective => Self::import_directive.parse(self, input), + ProductionKind::ImportSymbol => Self::import_symbol.parse(self, input), ProductionKind::ImportSymbolDeconstruction => { Self::import_symbol_deconstruction.parse(self, input) } @@ -7380,9 +8037,11 @@ impl Language { ProductionKind::LibraryDefinition => Self::library_definition.parse(self, input), ProductionKind::LibraryMembersList => Self::library_members_list.parse(self, input), ProductionKind::MappingKey => Self::mapping_key.parse(self, input), + ProductionKind::MappingKeyType => Self::mapping_key_type.parse(self, input), ProductionKind::MappingType => Self::mapping_type.parse(self, input), ProductionKind::MappingValue => Self::mapping_value.parse(self, input), ProductionKind::MappingValueType => Self::mapping_value_type.parse(self, input), + ProductionKind::ModifierAttribute => Self::modifier_attribute.parse(self, input), ProductionKind::ModifierAttributesList => { Self::modifier_attributes_list.parse(self, input) } @@ -7397,6 +8056,7 @@ impl Language { ProductionKind::NamedImport => Self::named_import.parse(self, input), ProductionKind::NamedImportSymbol => Self::named_import_symbol.parse(self, input), ProductionKind::NewExpression => Self::new_expression.parse(self, input), + ProductionKind::NumberUnit => Self::number_unit.parse(self, input), ProductionKind::NumericExpression => Self::numeric_expression.parse(self, input), ProductionKind::OverrideSpecifier => Self::override_specifier.parse(self, input), ProductionKind::Parameter => Self::parameter.parse(self, input), @@ -7412,7 +8072,11 @@ impl Language { ProductionKind::PositionalArgumentsList => { Self::positional_arguments_list.parse(self, input) } + ProductionKind::Pragma => Self::pragma.parse(self, input), ProductionKind::PragmaDirective => Self::pragma_directive.parse(self, input), + ProductionKind::ReceiveFunctionAttribute => { + Self::receive_function_attribute.parse(self, input) + } ProductionKind::ReceiveFunctionAttributesList => { Self::receive_function_attributes_list.parse(self, input) } @@ -7423,9 +8087,13 @@ impl Language { ProductionKind::ReturnsDeclaration => Self::returns_declaration.parse(self, input), ProductionKind::RevertStatement => Self::revert_statement.parse(self, input), ProductionKind::SourceUnit => Self::source_unit.parse(self, input), + ProductionKind::SourceUnitMember => Self::source_unit_member.parse(self, input), ProductionKind::SourceUnitMembersList => { Self::source_unit_members_list.parse(self, input) } + ProductionKind::StateVariableAttribute => { + Self::state_variable_attribute.parse(self, input) + } ProductionKind::StateVariableAttributesList => { Self::state_variable_attributes_list.parse(self, input) } @@ -7435,7 +8103,10 @@ impl Language { 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::StorageLocation => Self::storage_location.parse(self, input), + ProductionKind::StringExpression => Self::string_expression.parse(self, input), ProductionKind::StructDefinition => Self::struct_definition.parse(self, input), ProductionKind::StructMember => Self::struct_member.parse(self, input), ProductionKind::StructMembersList => Self::struct_members_list.parse(self, input), @@ -7446,6 +8117,7 @@ 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) } @@ -7458,6 +8130,9 @@ impl Language { ProductionKind::UnicodeStringLiteralsList => { Self::unicode_string_literals_list.parse(self, input) } + ProductionKind::UnnamedFunctionAttribute => { + Self::unnamed_function_attribute.parse(self, input) + } ProductionKind::UnnamedFunctionAttributesList => { Self::unnamed_function_attributes_list.parse(self, input) } @@ -7481,13 +8156,18 @@ impl Language { ProductionKind::UsingDirectiveSymbolsList => { Self::using_directive_symbols_list.parse(self, input) } + ProductionKind::UsingSymbol => Self::using_symbol.parse(self, input), ProductionKind::UsingSymbolDeconstruction => { Self::using_symbol_deconstruction.parse(self, input) } + ProductionKind::UsingTarget => Self::using_target.parse(self, input), ProductionKind::VariableDeclaration => Self::variable_declaration.parse(self, input), ProductionKind::VariableDeclarationStatement => { Self::variable_declaration_statement.parse(self, input) } + ProductionKind::VariableDeclarationType => { + Self::variable_declaration_type.parse(self, input) + } ProductionKind::VariableDeclarationValue => { Self::variable_declaration_value.parse(self, input) } @@ -7524,6 +8204,7 @@ impl Language { ProductionKind::YulIdentifiersList => Self::yul_identifiers_list.parse(self, input), ProductionKind::YulIfStatement => Self::yul_if_statement.parse(self, input), ProductionKind::YulLeaveStatement => Self::yul_leave_statement.parse(self, input), + ProductionKind::YulLiteral => Self::yul_literal.parse(self, input), ProductionKind::YulParametersDeclaration => { Self::yul_parameters_declaration.parse(self, input) } @@ -8486,16 +9167,19 @@ impl Lexer for Language { { Asterisk = asterisk } { Bang = bang } { Bar = bar } + { BytesKeyword = bytes_keyword } { Caret = caret } { Colon = colon } { DecimalLiteral = decimal_literal } { EndOfLine = end_of_line } { Equal = equal } + { FixedKeyword = fixed_keyword } { GreaterThan = greater_than } { GreaterThanGreaterThan = greater_than_greater_than } { GreaterThanGreaterThanGreaterThan = greater_than_greater_than_greater_than } { HexLiteral = hex_literal } { HexStringLiteral = hex_string_literal } + { IntKeyword = int_keyword } { LessThan = less_than } { LessThanLessThan = less_than_less_than } { Minus = minus } @@ -8504,6 +9188,8 @@ impl Lexer for Language { { Plus = plus } { SingleLineComment = single_line_comment } { Slash = slash } + { UfixedKeyword = ufixed_keyword } + { UintKeyword = uint_keyword } { UnicodeStringLiteral = unicode_string_literal } { Whitespace = whitespace } { Identifier = identifier } @@ -8567,6 +9253,7 @@ impl Lexer for Language { input.set_position(save); longest_match! { + { AsciiStringLiteral = ascii_string_literal } { Caret = caret } { Equal = equal } { GreaterThan = greater_than } @@ -8619,7 +9306,7 @@ impl Lexer for Language { }, Some('f') => match input.next() { Some('a') => { - scan_chars!(input, 'l', 's', 'e').then_some(TokenKind::FalseKeyword) + scan_chars!(input, 'l', 's', 'e').then_some(TokenKind::YulFalseKeyword) } Some('o') => scan_chars!(input, 'r').then_some(TokenKind::YulForKeyword), Some('u') => scan_chars!(input, 'n', 'c', 't', 'i', 'o', 'n') @@ -8657,7 +9344,7 @@ impl Lexer for Language { Some('s') => scan_chars!(input, 'w', 'i', 't', 'c', 'h') .then_some(TokenKind::YulSwitchKeyword), Some('t') => { - scan_chars!(input, 'r', 'u', 'e').then_some(TokenKind::TrueKeyword) + scan_chars!(input, 'r', 'u', 'e').then_some(TokenKind::YulTrueKeyword) } Some(_) => { input.undo(); @@ -8693,6 +9380,9 @@ impl Lexer for Language { longest_match! { { AsciiStringLiteral = ascii_string_literal } + { HexStringLiteral = hex_string_literal } + { YulDecimalLiteral = yul_decimal_literal } + { YulHexLiteral = yul_hex_literal } { YulIdentifier = yul_identifier } } } diff --git a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs index 3d25904331..5c069774ff 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs @@ -19,6 +19,7 @@ use {napi::bindgen_prelude::*, napi_derive::napi}; pub enum ProductionKind { ABICoderPragma, AddressType, + ArgumentsDeclaration, ArrayExpression, ArrayValuesList, AsciiStringLiteralsList, @@ -31,10 +32,12 @@ pub enum ProductionKind { CatchClauseError, CatchClausesList, ConstantDefinition, + ConstructorAttribute, ConstructorAttributesList, ConstructorDefinition, ContinueStatement, ContractDefinition, + ContractMember, ContractMembersList, DecimalNumberExpression, DeconstructionImport, @@ -42,6 +45,7 @@ pub enum ProductionKind { DeconstructionImportSymbolsList, DeleteStatement, DoWhileStatement, + ElementaryType, ElseBranch, EmitStatement, EndOfFileTrivia, @@ -54,15 +58,22 @@ pub enum ProductionKind { EventParameter, EventParametersDeclaration, EventParametersList, + ExperimentalFeature, ExperimentalPragma, ExpressionStatement, + FallbackFunctionAttribute, FallbackFunctionAttributesList, FallbackFunctionDefinition, ForStatement, + ForStatementCondition, + ForStatementInitialization, + FunctionAttribute, FunctionAttributesList, + FunctionBody, FunctionCallOptions, FunctionDefinition, FunctionType, + FunctionTypeAttribute, FunctionTypeAttributesList, HexNumberExpression, HexStringLiteralsList, @@ -72,6 +83,7 @@ pub enum ProductionKind { ImportAlias, ImportDeconstructionField, ImportDirective, + ImportSymbol, ImportSymbolDeconstruction, IndexAccessEnd, InheritanceSpecifier, @@ -83,9 +95,11 @@ pub enum ProductionKind { LibraryDefinition, LibraryMembersList, MappingKey, + MappingKeyType, MappingType, MappingValue, MappingValueType, + ModifierAttribute, ModifierAttributesList, ModifierDefinition, ModifierInvocation, @@ -96,6 +110,7 @@ pub enum ProductionKind { NamedImport, NamedImportSymbol, NewExpression, + NumberUnit, NumericExpression, OverrideSpecifier, Parameter, @@ -105,18 +120,25 @@ pub enum ProductionKind { PathImportSymbol, PositionalArgumentsDeclaration, PositionalArgumentsList, + Pragma, PragmaDirective, + ReceiveFunctionAttribute, ReceiveFunctionAttributesList, ReceiveFunctionDefinition, ReturnStatement, ReturnsDeclaration, RevertStatement, SourceUnit, + SourceUnitMember, SourceUnitMembersList, + StateVariableAttribute, StateVariableAttributesList, StateVariableDefinition, StateVariableDefinitionValue, + Statement, StatementsList, + StorageLocation, + StringExpression, StructDefinition, StructMember, StructMembersList, @@ -125,6 +147,7 @@ pub enum ProductionKind { TryStatement, TupleDeconstructionStatement, TupleExpression, + TupleMember, TupleMemberDeconstruction, TupleMembersList, TupleValue, @@ -133,6 +156,7 @@ pub enum ProductionKind { TypedTupleMember, UncheckedBlock, UnicodeStringLiteralsList, + UnnamedFunctionAttribute, UnnamedFunctionAttributesList, UnnamedFunctionDefinition, UntypedTupleMember, @@ -144,9 +168,12 @@ pub enum ProductionKind { UsingDirectivePath, UsingDirectiveSymbol, UsingDirectiveSymbolsList, + UsingSymbol, UsingSymbolDeconstruction, + UsingTarget, VariableDeclaration, VariableDeclarationStatement, + VariableDeclarationType, VariableDeclarationValue, VersionPragma, VersionPragmaExpression, @@ -167,6 +194,7 @@ pub enum ProductionKind { YulIdentifiersList, YulIfStatement, YulLeaveStatement, + YulLiteral, YulParametersDeclaration, YulReturnsDeclaration, YulStatement, @@ -195,6 +223,7 @@ pub enum ProductionKind { pub enum RuleKind { ABICoderPragma, AddressType, + ArgumentsDeclaration, ArrayExpression, ArrayValuesList, AsciiStringLiteralsList, @@ -207,10 +236,12 @@ pub enum RuleKind { CatchClauseError, CatchClausesList, ConstantDefinition, + ConstructorAttribute, ConstructorAttributesList, ConstructorDefinition, ContinueStatement, ContractDefinition, + ContractMember, ContractMembersList, DecimalNumberExpression, DeconstructionImport, @@ -218,6 +249,7 @@ pub enum RuleKind { DeconstructionImportSymbolsList, DeleteStatement, DoWhileStatement, + ElementaryType, ElseBranch, EmitStatement, EndOfFileTrivia, @@ -230,15 +262,22 @@ pub enum RuleKind { EventParameter, EventParametersDeclaration, EventParametersList, + ExperimentalFeature, ExperimentalPragma, ExpressionStatement, + FallbackFunctionAttribute, FallbackFunctionAttributesList, FallbackFunctionDefinition, ForStatement, + ForStatementCondition, + ForStatementInitialization, + FunctionAttribute, FunctionAttributesList, + FunctionBody, FunctionCallOptions, FunctionDefinition, FunctionType, + FunctionTypeAttribute, FunctionTypeAttributesList, HexNumberExpression, HexStringLiteralsList, @@ -248,6 +287,7 @@ pub enum RuleKind { ImportAlias, ImportDeconstructionField, ImportDirective, + ImportSymbol, ImportSymbolDeconstruction, IndexAccessEnd, InheritanceSpecifier, @@ -259,9 +299,11 @@ pub enum RuleKind { LibraryDefinition, LibraryMembersList, MappingKey, + MappingKeyType, MappingType, MappingValue, MappingValueType, + ModifierAttribute, ModifierAttributesList, ModifierDefinition, ModifierInvocation, @@ -272,6 +314,7 @@ pub enum RuleKind { NamedImport, NamedImportSymbol, NewExpression, + NumberUnit, NumericExpression, OverrideSpecifier, Parameter, @@ -281,18 +324,25 @@ pub enum RuleKind { PathImportSymbol, PositionalArgumentsDeclaration, PositionalArgumentsList, + Pragma, PragmaDirective, + ReceiveFunctionAttribute, ReceiveFunctionAttributesList, ReceiveFunctionDefinition, ReturnStatement, ReturnsDeclaration, RevertStatement, SourceUnit, + SourceUnitMember, SourceUnitMembersList, + StateVariableAttribute, StateVariableAttributesList, StateVariableDefinition, StateVariableDefinitionValue, + Statement, StatementsList, + StorageLocation, + StringExpression, StructDefinition, StructMember, StructMembersList, @@ -301,6 +351,7 @@ pub enum RuleKind { TryStatement, TupleDeconstructionStatement, TupleExpression, + TupleMember, TupleMemberDeconstruction, TupleMembersList, TupleValue, @@ -309,6 +360,7 @@ pub enum RuleKind { TypedTupleMember, UncheckedBlock, UnicodeStringLiteralsList, + UnnamedFunctionAttribute, UnnamedFunctionAttributesList, UnnamedFunctionDefinition, UntypedTupleMember, @@ -320,9 +372,12 @@ pub enum RuleKind { UsingDirectivePath, UsingDirectiveSymbol, UsingDirectiveSymbolsList, + UsingSymbol, UsingSymbolDeconstruction, + UsingTarget, VariableDeclaration, VariableDeclarationStatement, + VariableDeclarationType, VariableDeclarationValue, VersionPragma, VersionPragmaBinaryExpression, @@ -345,6 +400,7 @@ pub enum RuleKind { YulIdentifiersList, YulIfStatement, YulLeaveStatement, + YulLiteral, YulParametersDeclaration, YulReturnsDeclaration, YulStatement, @@ -409,6 +465,8 @@ pub enum TokenKind { BoolKeyword, BreakKeyword, ByteKeyword, + BytesKeyword, + CallDataKeyword, CalldataKeyword, Caret, CaretEqual, @@ -447,6 +505,7 @@ pub enum TokenKind { FalseKeyword, FinalKeyword, FinneyKeyword, + FixedKeyword, ForKeyword, FromKeyword, FunctionKeyword, @@ -470,6 +529,7 @@ pub enum TokenKind { InKeyword, IndexedKeyword, InlineKeyword, + IntKeyword, InterfaceKeyword, InternalKeyword, IsKeyword, @@ -541,6 +601,8 @@ pub enum TokenKind { TypeKeyword, TypedefKeyword, TypeofKeyword, + UfixedKeyword, + UintKeyword, UncheckedKeyword, UnicodeStringLiteral, UsingKeyword, @@ -556,14 +618,18 @@ pub enum TokenKind { YulBreakKeyword, YulCaseKeyword, YulContinueKeyword, + YulDecimalLiteral, YulDefaultKeyword, + YulFalseKeyword, YulForKeyword, YulFunctionKeyword, + YulHexLiteral, YulIdentifier, YulIfKeyword, YulLeaveKeyword, YulLetKeyword, YulSwitchKeyword, + YulTrueKeyword, dummy, } diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index 1a406d3b77..cc92d2af96 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -31,6 +31,7 @@ pub struct Language { 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, pub(crate) version_is_at_least_0_7_4: bool, @@ -150,6 +151,7 @@ impl Language { 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, version_is_at_least_0_7_4: Version::new(0, 7, 4) <= version, @@ -208,6 +210,18 @@ impl Language { .with_kind(RuleKind::AddressType) } + #[allow(unused_assignments, unused_parens)] + fn arguments_declaration(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.positional_arguments_declaration(input); + choice.consider(input, result)?; + let result = self.named_arguments_declaration(input); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::ArgumentsDeclaration) + } + #[allow(unused_assignments, unused_parens)] fn array_expression(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -434,6 +448,32 @@ impl Language { .with_kind(RuleKind::ConstantDefinition) } + #[allow(unused_assignments, unused_parens)] + fn constructor_attribute(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_4_22 { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(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::PublicKeyword, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::ConstructorAttribute) + } + #[allow(unused_assignments, unused_parens)] fn constructor_attributes_list(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_4_22 { @@ -546,6 +586,52 @@ impl Language { .with_kind(RuleKind::ContractDefinition) } + #[allow(unused_assignments, unused_parens)] + fn contract_member(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.using_directive(input); + choice.consider(input, result)?; + let result = self.function_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 = 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)?; + } + if self.version_is_at_least_0_8_8 { + let result = self.user_defined_value_type_definition(input); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::ContractMember) + } + #[allow(unused_assignments, unused_parens)] fn contract_members_list(&self, input: &mut ParserContext) -> ParserResult { OneOrMoreHelper::run(input, |input| { @@ -603,12 +689,7 @@ impl Language { input, TokenKind::DecimalLiteral, ))?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.number_unit(input)))?; seq.finish() }) .with_kind(RuleKind::DecimalNumberExpression) @@ -715,12 +796,7 @@ impl Language { input, TokenKind::DoKeyword, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.statement(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::WhileKeyword, @@ -748,6 +824,63 @@ impl Language { .with_kind(RuleKind::DoWhileStatement) } + #[allow(unused_assignments, unused_parens)] + fn elementary_type(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.parse_token_with_trivia::( + input, + 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, + ); + 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::BytesKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::IntKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::UintKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::FixedKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::UfixedKeyword, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::ElementaryType) + } + #[allow(unused_assignments, unused_parens)] fn else_branch(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -757,12 +890,7 @@ impl Language { TokenKind::ElseKeyword, ), ))?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.statement(input)))?; seq.finish() }) .with_kind(RuleKind::ElseBranch) @@ -780,10 +908,7 @@ impl Language { input, TokenKind::dummy, ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ))?; + seq.elem(self.arguments_declaration(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Semicolon, @@ -1024,6 +1149,24 @@ impl Language { .with_kind(RuleKind::EventParametersList) } + #[allow(unused_assignments, unused_parens)] + fn experimental_feature(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.parse_token_with_trivia::( + input, + TokenKind::Identifier, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::AsciiStringLiteral, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::ExperimentalFeature) + } + #[allow(unused_assignments, unused_parens)] fn experimental_pragma(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -1031,9 +1174,7 @@ impl Language { input, TokenKind::ExperimentalKeyword, ))?; - seq.elem( - self.parse_token_with_trivia::(input, TokenKind::dummy), - )?; + seq.elem(self.experimental_feature(input))?; seq.finish() }) .with_kind(RuleKind::ExperimentalPragma) @@ -1057,6 +1198,47 @@ impl Language { .with_kind(RuleKind::ExpressionStatement) } + #[allow(unused_assignments, unused_parens)] + fn fallback_function_attribute(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_6_0 { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(input); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ExternalKeyword, + ); + 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::PureKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ViewKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::VirtualKeyword, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::FallbackFunctionAttribute) + } + #[allow(unused_assignments, unused_parens)] fn fallback_function_attributes_list(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { @@ -1118,10 +1300,7 @@ impl Language { TokenKind::dummy, ))?; seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ))?; + seq.elem(self.function_body(input))?; seq.finish() }) } else { @@ -1141,18 +1320,8 @@ impl Language { input, TokenKind::OpenParen, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.for_statement_initialization(input))?; + seq.elem(self.for_statement_condition(input))?; seq.elem(OptionalHelper::transform( self.parse_token_with_trivia::( input, @@ -1163,17 +1332,107 @@ impl Language { input, TokenKind::CloseParen, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.statement(input))?; seq.finish() }) .with_kind(RuleKind::ForStatement) } + #[allow(unused_assignments, unused_parens)] + fn for_statement_condition(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.expression_statement(input); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Semicolon, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::ForStatementCondition) + } + + #[allow(unused_assignments, unused_parens)] + fn for_statement_initialization(&self, input: &mut ParserContext) -> ParserResult { + 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)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Semicolon, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::ForStatementInitialization) + } + + #[allow(unused_assignments, unused_parens)] + fn function_attribute(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(input); + choice.consider(input, result)?; + 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, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::InternalKeyword, + ); + 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::PrivateKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PublicKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PureKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ViewKeyword, + ); + choice.consider(input, result)?; + if self.version_is_at_least_0_6_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::VirtualKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::FunctionAttribute) + } + #[allow(unused_assignments, unused_parens)] fn function_attributes_list(&self, input: &mut ParserContext) -> ParserResult { OneOrMoreHelper::run(input, |input| { @@ -1238,19 +1497,40 @@ impl Language { } #[allow(unused_assignments, unused_parens)] - fn function_call_options(&self, input: &mut ParserContext) -> ParserResult { + fn function_body(&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)?; - } + let result = self.block(input); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::Semicolon, + ); + choice.consider(input, result)?; choice.finish(input) }) + .with_kind(RuleKind::FunctionBody) + } + + #[allow(unused_assignments, unused_parens)] + fn function_call_options(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_6_2 { + 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 = self.parse_token_with_trivia::( + input, + TokenKind::dummy, + ); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_8_0 { + let result = self.named_argument_group(input); + choice.consider(input, result)?; + } + choice.finish(input) + }) + } else { + ParserResult::disabled() + } .with_kind(RuleKind::FunctionCallOptions) } @@ -1287,12 +1567,7 @@ impl Language { ), )?; seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.function_body(input))?; seq.finish() }) .with_kind(RuleKind::FunctionDefinition) @@ -1315,7 +1590,50 @@ impl Language { seq.elem(OptionalHelper::transform(self.returns_declaration(input)))?; seq.finish() }) - .with_kind(RuleKind::FunctionType) + .with_kind(RuleKind::FunctionType) + } + + #[allow(unused_assignments, unused_parens)] + fn function_type_attribute(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.parse_token_with_trivia::( + input, + TokenKind::InternalKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ExternalKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PrivateKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PublicKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PureKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ViewKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PayableKeyword, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::FunctionTypeAttribute) } #[allow(unused_assignments, unused_parens)] @@ -1371,12 +1689,7 @@ impl Language { TokenKind::HexLiteral, ))?; if !self.version_is_at_least_0_5_0 { - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.number_unit(input)))?; } seq.finish() }) @@ -1442,12 +1755,7 @@ impl Language { input, TokenKind::CloseParen, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.statement(input))?; seq.elem(OptionalHelper::transform(self.else_branch(input)))?; seq.finish() }) @@ -1490,12 +1798,7 @@ impl Language { input, TokenKind::ImportKeyword, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.import_symbol(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Semicolon, @@ -1505,6 +1808,20 @@ impl Language { .with_kind(RuleKind::ImportDirective) } + #[allow(unused_assignments, unused_parens)] + fn import_symbol(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.path_import_symbol(input); + choice.consider(input, result)?; + let result = self.named_import_symbol(input); + choice.consider(input, result)?; + let result = self.import_symbol_deconstruction(input); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::ImportSymbol) + } + #[allow(unused_assignments, unused_parens)] fn import_symbol_deconstruction(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -1582,12 +1899,7 @@ impl Language { TokenKind::dummy, ), )?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; seq.finish() }) .with_kind(RuleKind::InheritanceType) @@ -1792,12 +2104,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn mapping_key(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.mapping_key_type(input))?; if self.version_is_at_least_0_8_18 { seq.elem(OptionalHelper::transform( self.parse_token_with_trivia::( @@ -1811,6 +2118,19 @@ impl Language { .with_kind(RuleKind::MappingKey) } + #[allow(unused_assignments, unused_parens)] + fn mapping_key_type(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.elementary_type(input); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::dummy); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::MappingKeyType) + } + #[allow(unused_assignments, unused_parens)] fn mapping_type(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -1876,6 +2196,23 @@ impl Language { .with_kind(RuleKind::MappingValueType) } + #[allow(unused_assignments, unused_parens)] + fn modifier_attribute(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.override_specifier(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_6_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::VirtualKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::ModifierAttribute) + } + #[allow(unused_assignments, unused_parens)] fn modifier_attributes_list(&self, input: &mut ParserContext) -> ParserResult { OneOrMoreHelper::run(input, |input| { @@ -1915,12 +2252,7 @@ impl Language { TokenKind::dummy, ), )?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.function_body(input))?; seq.finish() }) .with_kind(RuleKind::ModifierDefinition) @@ -1935,12 +2267,7 @@ impl Language { TokenKind::dummy, ), )?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.arguments_declaration(input)))?; seq.finish() }) .with_kind(RuleKind::ModifierInvocation) @@ -2087,6 +2414,77 @@ impl Language { .with_kind(RuleKind::NewExpression) } + #[allow(unused_assignments, unused_parens)] + fn number_unit(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.parse_token_with_trivia::( + input, + 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, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::SecondsKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::MinutesKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::HoursKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::DaysKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::WeeksKeyword, + ); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::YearsKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::NumberUnit) + } + #[allow(unused_assignments, unused_parens)] fn numeric_expression(&self, input: &mut ParserContext) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { @@ -2305,12 +2703,7 @@ impl Language { TokenKind::dummy, ), )?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.storage_location(input)))?; seq.elem(OptionalHelper::transform( self.parse_token_with_trivia::( input, @@ -2424,6 +2817,20 @@ impl Language { .with_kind(RuleKind::PositionalArgumentsList) } + #[allow(unused_assignments, unused_parens)] + fn pragma(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.abi_coder_pragma(input); + choice.consider(input, result)?; + let result = self.experimental_pragma(input); + choice.consider(input, result)?; + let result = self.version_pragma(input); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::Pragma) + } + #[allow(unused_assignments, unused_parens)] fn pragma_directive(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2431,9 +2838,7 @@ impl Language { input, TokenKind::PragmaKeyword, ))?; - seq.elem( - self.parse_token_with_trivia::(input, TokenKind::dummy), - )?; + seq.elem(self.pragma(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Semicolon, @@ -2443,6 +2848,37 @@ impl Language { .with_kind(RuleKind::PragmaDirective) } + #[allow(unused_assignments, unused_parens)] + fn receive_function_attribute(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_6_0 { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(input); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ExternalKeyword, + ); + 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::VirtualKeyword, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::ReceiveFunctionAttribute) + } + #[allow(unused_assignments, unused_parens)] fn receive_function_attributes_list(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_6_0 { @@ -2493,10 +2929,7 @@ impl Language { input, TokenKind::dummy, ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ))?; + seq.elem(self.function_body(input))?; seq.finish() }) } else { @@ -2554,10 +2987,7 @@ impl Language { TokenKind::dummy, ), ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ))?; + seq.elem(self.arguments_declaration(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Semicolon, @@ -2576,6 +3006,52 @@ impl Language { .with_kind(RuleKind::SourceUnit) } + #[allow(unused_assignments, unused_parens)] + fn source_unit_member(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.pragma_directive(input); + choice.consider(input, result)?; + let result = self.import_directive(input); + choice.consider(input, result)?; + let result = self.contract_definition(input); + choice.consider(input, result)?; + let result = self.interface_definition(input); + choice.consider(input, result)?; + let result = self.library_definition(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_6_0 { + 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 { + let result = self.function_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_7_4 { + let result = self.constant_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)?; + } + if self.version_is_at_least_0_8_8 { + let result = self.user_defined_value_type_definition(input); + choice.consider(input, result)?; + } + if self.version_is_at_least_0_8_13 { + let result = self.using_directive(input); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::SourceUnitMember) + } + #[allow(unused_assignments, unused_parens)] fn source_unit_members_list(&self, input: &mut ParserContext) -> ParserResult { OneOrMoreHelper::run(input, |input| { @@ -2626,6 +3102,43 @@ impl Language { .with_kind(RuleKind::SourceUnitMembersList) } + #[allow(unused_assignments, unused_parens)] + fn state_variable_attribute(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.override_specifier(input); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ConstantKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::InternalKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PrivateKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::PublicKeyword, + ); + choice.consider(input, result)?; + if self.version_is_at_least_0_6_5 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::ImmutableKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::StateVariableAttribute) + } + #[allow(unused_assignments, unused_parens)] fn state_variable_attributes_list(&self, input: &mut ParserContext) -> ParserResult { OneOrMoreHelper::run(input, |input| { @@ -2713,7 +3226,61 @@ impl Language { )?; seq.finish() }) - .with_kind(RuleKind::StateVariableDefinitionValue) + .with_kind(RuleKind::StateVariableDefinitionValue) + } + + #[allow(unused_assignments, unused_parens)] + fn statement(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.tuple_deconstruction_statement(input); + choice.consider(input, result)?; + let result = self.variable_declaration_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)?; + } + 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_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)?; + } + let result = self.assembly_statement(input); + choice.consider(input, result)?; + let result = self.block(input); + choice.consider(input, result)?; + if self.version_is_at_least_0_8_0 { + let result = self.unchecked_block(input); + choice.consider(input, result)?; + } + let result = self.expression_statement(input); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::Statement) } #[allow(unused_assignments, unused_parens)] @@ -2722,6 +3289,52 @@ impl Language { .with_kind(RuleKind::StatementsList) } + #[allow(unused_assignments, unused_parens)] + fn storage_location(&self, input: &mut ParserContext) -> ParserResult { + 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) + }) + .with_kind(RuleKind::StorageLocation) + } + + #[allow(unused_assignments, unused_parens)] + fn string_expression(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self + .parse_token_with_trivia::(input, TokenKind::dummy); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::dummy); + choice.consider(input, result)?; + if self.version_is_at_least_0_7_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::dummy, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::StringExpression) + } + #[allow(unused_assignments, unused_parens)] fn struct_definition(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2904,12 +3517,22 @@ impl Language { .with_kind(RuleKind::TupleExpression) } + #[allow(unused_assignments, unused_parens)] + fn tuple_member(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.typed_tuple_member(input); + choice.consider(input, result)?; + let result = self.untyped_tuple_member(input); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::TupleMember) + } + #[allow(unused_assignments, unused_parens)] fn tuple_member_deconstruction(&self, input: &mut ParserContext) -> ParserResult { - OptionalHelper::transform( - self.parse_token_with_trivia::(input, TokenKind::dummy), - ) - .with_kind(RuleKind::TupleMemberDeconstruction) + OptionalHelper::transform(self.tuple_member(input)) + .with_kind(RuleKind::TupleMemberDeconstruction) } #[allow(unused_assignments, unused_parens)] @@ -2979,12 +3602,7 @@ impl Language { TokenKind::dummy, ), )?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.storage_location(input)))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Identifier, @@ -3026,6 +3644,42 @@ impl Language { .with_kind(RuleKind::UnicodeStringLiteralsList) } + #[allow(unused_assignments, unused_parens)] + fn unnamed_function_attribute(&self, input: &mut ParserContext) -> ParserResult { + if !self.version_is_at_least_0_6_0 { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.modifier_invocation(input); + choice.consider(input, result)?; + let result = self.override_specifier(input); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ExternalKeyword, + ); + 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::PureKeyword, + ); + choice.consider(input, result)?; + let result = self.parse_token_with_trivia::( + input, + TokenKind::ViewKeyword, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::UnnamedFunctionAttribute) + } + #[allow(unused_assignments, unused_parens)] fn unnamed_function_attributes_list(&self, input: &mut ParserContext) -> ParserResult { if !self.version_is_at_least_0_6_0 { @@ -3081,10 +3735,7 @@ impl Language { input, TokenKind::dummy, ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ))?; + seq.elem(self.function_body(input))?; seq.finish() }) } else { @@ -3096,12 +3747,7 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn untyped_tuple_member(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(OptionalHelper::transform(self.storage_location(input)))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Identifier, @@ -3127,10 +3773,7 @@ impl Language { input, TokenKind::IsKeyword, ))?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ))?; + seq.elem(self.elementary_type(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Semicolon, @@ -3263,22 +3906,12 @@ impl Language { input, TokenKind::UsingKeyword, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.using_symbol(input))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::ForKeyword, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.using_target(input))?; if self.version_is_at_least_0_8_13 { seq.elem(OptionalHelper::transform( self.parse_token_with_trivia::( @@ -3455,6 +4088,21 @@ impl Language { .with_kind(RuleKind::UsingDirectiveSymbolsList) } + #[allow(unused_assignments, unused_parens)] + fn using_symbol(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self + .parse_token_with_trivia::(input, TokenKind::dummy); + choice.consider(input, result)?; + if self.version_is_at_least_0_8_13 { + let result = self.using_symbol_deconstruction(input); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::UsingSymbol) + } + #[allow(unused_assignments, unused_parens)] fn using_symbol_deconstruction(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_8_13 { @@ -3479,6 +4127,20 @@ impl Language { .with_kind(RuleKind::UsingSymbolDeconstruction) } + #[allow(unused_assignments, unused_parens)] + fn using_target(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self + .parse_token_with_trivia::(input, TokenKind::dummy); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::(input, TokenKind::Asterisk); + choice.consider(input, result)?; + choice.finish(input) + }) + .with_kind(RuleKind::UsingTarget) + } + #[allow(unused_assignments, unused_parens)] fn variable_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -3529,18 +4191,8 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn variable_declaration_statement(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; - seq.elem(OptionalHelper::transform( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - ))?; + seq.elem(self.variable_declaration_type(input))?; + seq.elem(OptionalHelper::transform(self.storage_location(input)))?; seq.elem(self.parse_token_with_trivia::( input, TokenKind::Identifier, @@ -3557,6 +4209,24 @@ impl Language { .with_kind(RuleKind::VariableDeclarationStatement) } + #[allow(unused_assignments, unused_parens)] + fn variable_declaration_type(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self + .parse_token_with_trivia::(input, TokenKind::dummy); + choice.consider(input, result)?; + if !self.version_is_at_least_0_5_0 { + let result = self.parse_token_with_trivia::( + input, + TokenKind::VarKeyword, + ); + choice.consider(input, result)?; + } + choice.finish(input) + }) + .with_kind(RuleKind::VariableDeclarationType) + } + #[allow(unused_assignments, unused_parens)] fn variable_declaration_value(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -3747,12 +4417,7 @@ impl Language { input, TokenKind::CloseParen, ))?; - seq.elem( - self.parse_token_with_trivia::( - input, - TokenKind::dummy, - ), - )?; + seq.elem(self.statement(input))?; seq.finish() }) .with_kind(RuleKind::WhileStatement) @@ -3974,6 +4639,44 @@ impl Language { .with_kind(RuleKind::YulLeaveStatement) } + #[allow(unused_assignments, unused_parens)] + fn yul_literal(&self, input: &mut ParserContext) -> ParserResult { + ChoiceHelper::run(input, |mut choice, input| { + let result = self.parse_token_with_trivia::( + input, + TokenKind::YulTrueKeyword, + ); + choice.consider(input, result)?; + 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) + }) + .with_kind(RuleKind::YulLiteral) + } + #[allow(unused_assignments, unused_parens)] fn yul_parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -4019,7 +4722,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)?; @@ -4029,16 +4732,17 @@ impl Language { choice.consider(input, result)?; let result = self.yul_switch_statement(input); choice.consider(input, result)?; + if self.version_is_at_least_0_6_0 { + let result = self.yul_leave_statement(input); + choice.consider(input, result)?; + } let result = self.yul_break_statement(input); choice.consider(input, result)?; let result = self.yul_continue_statement(input); choice.consider(input, result)?; - let result = self.yul_expression(input); + let result = + self.parse_token_with_trivia::(input, TokenKind::dummy); choice.consider(input, result)?; - if self.version_is_at_least_0_6_0 { - let result = self.yul_leave_statement(input); - choice.consider(input, result)?; - } choice.finish(input) }) .with_kind(RuleKind::YulStatement) @@ -4052,58 +4756,12 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn yul_switch_case(&self, input: &mut ParserContext) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem(ChoiceHelper::run(input, |mut choice, input| { - let result = self.parse_token_with_trivia::( - input, - TokenKind::DefaultKeyword, - ); - 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() - }); - choice.consider(input, result)?; - choice.finish(input) - }))?; - seq.elem(self.yul_block(input))?; - seq.finish() + 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::YulSwitchCase) } @@ -4139,9 +4797,7 @@ impl Language { input, TokenKind::YulCaseKeyword, ))?; - seq.elem( - self.parse_token_with_trivia::(input, TokenKind::dummy), - )?; + seq.elem(self.yul_literal(input))?; seq.elem(self.yul_block(input))?; seq.finish() }) @@ -4305,15 +4961,6 @@ impl Language { ) } - #[allow(unused_assignments, unused_parens)] - fn call_data_keyword(&self, input: &mut ParserContext) -> bool { - if self.version_is_at_least_0_5_0 { - scan_chars!(input, 'c', 'a', 'l', 'l', 'd', 'a', 't', 'a') - } else { - false - } - } - #[allow(unused_assignments, unused_parens)] fn caret(&self, input: &mut ParserContext) -> bool { scan_not_followed_by!(input, scan_chars!(input, '^'), scan_chars!(input, '=')) @@ -6006,11 +6653,6 @@ impl Language { } } - #[allow(unused_assignments, unused_parens)] - fn yul_false_keyword(&self, input: &mut ParserContext) -> bool { - scan_chars!(input, 'f', 'a', 'l', 's', 'e') - } - #[allow(unused_assignments, unused_parens)] fn yul_final_keyword(&self, input: &mut ParserContext) -> bool { if !self.version_is_at_least_0_7_1 { @@ -6801,11 +7443,6 @@ impl Language { } } - #[allow(unused_assignments, unused_parens)] - fn yul_true_keyword(&self, input: &mut ParserContext) -> bool { - scan_chars!(input, 't', 'r', 'u', 'e') - } - #[allow(unused_assignments, unused_parens)] fn yul_try_keyword(&self, input: &mut ParserContext) -> bool { if !self.version_is_at_least_0_7_1 { @@ -7284,6 +7921,7 @@ impl Language { match production_kind { ProductionKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), ProductionKind::AddressType => Self::address_type.parse(self, input), + ProductionKind::ArgumentsDeclaration => Self::arguments_declaration.parse(self, input), ProductionKind::ArrayExpression => Self::array_expression.parse(self, input), ProductionKind::ArrayValuesList => Self::array_values_list.parse(self, input), ProductionKind::AsciiStringLiteralsList => { @@ -7300,6 +7938,7 @@ impl Language { ProductionKind::CatchClauseError => Self::catch_clause_error.parse(self, input), ProductionKind::CatchClausesList => Self::catch_clauses_list.parse(self, input), ProductionKind::ConstantDefinition => Self::constant_definition.parse(self, input), + ProductionKind::ConstructorAttribute => Self::constructor_attribute.parse(self, input), ProductionKind::ConstructorAttributesList => { Self::constructor_attributes_list.parse(self, input) } @@ -7308,6 +7947,7 @@ impl Language { } ProductionKind::ContinueStatement => Self::continue_statement.parse(self, input), ProductionKind::ContractDefinition => Self::contract_definition.parse(self, input), + ProductionKind::ContractMember => Self::contract_member.parse(self, input), ProductionKind::ContractMembersList => Self::contract_members_list.parse(self, input), ProductionKind::DecimalNumberExpression => { Self::decimal_number_expression.parse(self, input) @@ -7321,6 +7961,7 @@ impl Language { } ProductionKind::DeleteStatement => Self::delete_statement.parse(self, input), ProductionKind::DoWhileStatement => Self::do_while_statement.parse(self, input), + ProductionKind::ElementaryType => Self::elementary_type.parse(self, input), ProductionKind::ElseBranch => Self::else_branch.parse(self, input), ProductionKind::EmitStatement => Self::emit_statement.parse(self, input), ProductionKind::EndOfFileTrivia => Self::end_of_file_trivia.parse(self, input), @@ -7337,8 +7978,12 @@ impl Language { Self::event_parameters_declaration.parse(self, input) } ProductionKind::EventParametersList => Self::event_parameters_list.parse(self, input), + ProductionKind::ExperimentalFeature => Self::experimental_feature.parse(self, input), ProductionKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), ProductionKind::ExpressionStatement => Self::expression_statement.parse(self, input), + ProductionKind::FallbackFunctionAttribute => { + Self::fallback_function_attribute.parse(self, input) + } ProductionKind::FallbackFunctionAttributesList => { Self::fallback_function_attributes_list.parse(self, input) } @@ -7346,12 +7991,23 @@ impl Language { Self::fallback_function_definition.parse(self, input) } ProductionKind::ForStatement => Self::for_statement.parse(self, input), + ProductionKind::ForStatementCondition => { + Self::for_statement_condition.parse(self, input) + } + ProductionKind::ForStatementInitialization => { + Self::for_statement_initialization.parse(self, input) + } + ProductionKind::FunctionAttribute => Self::function_attribute.parse(self, input), ProductionKind::FunctionAttributesList => { Self::function_attributes_list.parse(self, input) } + ProductionKind::FunctionBody => Self::function_body.parse(self, input), ProductionKind::FunctionCallOptions => Self::function_call_options.parse(self, input), ProductionKind::FunctionDefinition => Self::function_definition.parse(self, input), ProductionKind::FunctionType => Self::function_type.parse(self, input), + ProductionKind::FunctionTypeAttribute => { + Self::function_type_attribute.parse(self, input) + } ProductionKind::FunctionTypeAttributesList => { Self::function_type_attributes_list.parse(self, input) } @@ -7367,6 +8023,7 @@ impl Language { Self::import_deconstruction_field.parse(self, input) } ProductionKind::ImportDirective => Self::import_directive.parse(self, input), + ProductionKind::ImportSymbol => Self::import_symbol.parse(self, input), ProductionKind::ImportSymbolDeconstruction => { Self::import_symbol_deconstruction.parse(self, input) } @@ -7380,9 +8037,11 @@ impl Language { ProductionKind::LibraryDefinition => Self::library_definition.parse(self, input), ProductionKind::LibraryMembersList => Self::library_members_list.parse(self, input), ProductionKind::MappingKey => Self::mapping_key.parse(self, input), + ProductionKind::MappingKeyType => Self::mapping_key_type.parse(self, input), ProductionKind::MappingType => Self::mapping_type.parse(self, input), ProductionKind::MappingValue => Self::mapping_value.parse(self, input), ProductionKind::MappingValueType => Self::mapping_value_type.parse(self, input), + ProductionKind::ModifierAttribute => Self::modifier_attribute.parse(self, input), ProductionKind::ModifierAttributesList => { Self::modifier_attributes_list.parse(self, input) } @@ -7397,6 +8056,7 @@ impl Language { ProductionKind::NamedImport => Self::named_import.parse(self, input), ProductionKind::NamedImportSymbol => Self::named_import_symbol.parse(self, input), ProductionKind::NewExpression => Self::new_expression.parse(self, input), + ProductionKind::NumberUnit => Self::number_unit.parse(self, input), ProductionKind::NumericExpression => Self::numeric_expression.parse(self, input), ProductionKind::OverrideSpecifier => Self::override_specifier.parse(self, input), ProductionKind::Parameter => Self::parameter.parse(self, input), @@ -7412,7 +8072,11 @@ impl Language { ProductionKind::PositionalArgumentsList => { Self::positional_arguments_list.parse(self, input) } + ProductionKind::Pragma => Self::pragma.parse(self, input), ProductionKind::PragmaDirective => Self::pragma_directive.parse(self, input), + ProductionKind::ReceiveFunctionAttribute => { + Self::receive_function_attribute.parse(self, input) + } ProductionKind::ReceiveFunctionAttributesList => { Self::receive_function_attributes_list.parse(self, input) } @@ -7423,9 +8087,13 @@ impl Language { ProductionKind::ReturnsDeclaration => Self::returns_declaration.parse(self, input), ProductionKind::RevertStatement => Self::revert_statement.parse(self, input), ProductionKind::SourceUnit => Self::source_unit.parse(self, input), + ProductionKind::SourceUnitMember => Self::source_unit_member.parse(self, input), ProductionKind::SourceUnitMembersList => { Self::source_unit_members_list.parse(self, input) } + ProductionKind::StateVariableAttribute => { + Self::state_variable_attribute.parse(self, input) + } ProductionKind::StateVariableAttributesList => { Self::state_variable_attributes_list.parse(self, input) } @@ -7435,7 +8103,10 @@ impl Language { 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::StorageLocation => Self::storage_location.parse(self, input), + ProductionKind::StringExpression => Self::string_expression.parse(self, input), ProductionKind::StructDefinition => Self::struct_definition.parse(self, input), ProductionKind::StructMember => Self::struct_member.parse(self, input), ProductionKind::StructMembersList => Self::struct_members_list.parse(self, input), @@ -7446,6 +8117,7 @@ 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) } @@ -7458,6 +8130,9 @@ impl Language { ProductionKind::UnicodeStringLiteralsList => { Self::unicode_string_literals_list.parse(self, input) } + ProductionKind::UnnamedFunctionAttribute => { + Self::unnamed_function_attribute.parse(self, input) + } ProductionKind::UnnamedFunctionAttributesList => { Self::unnamed_function_attributes_list.parse(self, input) } @@ -7481,13 +8156,18 @@ impl Language { ProductionKind::UsingDirectiveSymbolsList => { Self::using_directive_symbols_list.parse(self, input) } + ProductionKind::UsingSymbol => Self::using_symbol.parse(self, input), ProductionKind::UsingSymbolDeconstruction => { Self::using_symbol_deconstruction.parse(self, input) } + ProductionKind::UsingTarget => Self::using_target.parse(self, input), ProductionKind::VariableDeclaration => Self::variable_declaration.parse(self, input), ProductionKind::VariableDeclarationStatement => { Self::variable_declaration_statement.parse(self, input) } + ProductionKind::VariableDeclarationType => { + Self::variable_declaration_type.parse(self, input) + } ProductionKind::VariableDeclarationValue => { Self::variable_declaration_value.parse(self, input) } @@ -7524,6 +8204,7 @@ impl Language { ProductionKind::YulIdentifiersList => Self::yul_identifiers_list.parse(self, input), ProductionKind::YulIfStatement => Self::yul_if_statement.parse(self, input), ProductionKind::YulLeaveStatement => Self::yul_leave_statement.parse(self, input), + ProductionKind::YulLiteral => Self::yul_literal.parse(self, input), ProductionKind::YulParametersDeclaration => { Self::yul_parameters_declaration.parse(self, input) } @@ -8486,16 +9167,19 @@ impl Lexer for Language { { Asterisk = asterisk } { Bang = bang } { Bar = bar } + { BytesKeyword = bytes_keyword } { Caret = caret } { Colon = colon } { DecimalLiteral = decimal_literal } { EndOfLine = end_of_line } { Equal = equal } + { FixedKeyword = fixed_keyword } { GreaterThan = greater_than } { GreaterThanGreaterThan = greater_than_greater_than } { GreaterThanGreaterThanGreaterThan = greater_than_greater_than_greater_than } { HexLiteral = hex_literal } { HexStringLiteral = hex_string_literal } + { IntKeyword = int_keyword } { LessThan = less_than } { LessThanLessThan = less_than_less_than } { Minus = minus } @@ -8504,6 +9188,8 @@ impl Lexer for Language { { Plus = plus } { SingleLineComment = single_line_comment } { Slash = slash } + { UfixedKeyword = ufixed_keyword } + { UintKeyword = uint_keyword } { UnicodeStringLiteral = unicode_string_literal } { Whitespace = whitespace } { Identifier = identifier } @@ -8567,6 +9253,7 @@ impl Lexer for Language { input.set_position(save); longest_match! { + { AsciiStringLiteral = ascii_string_literal } { Caret = caret } { Equal = equal } { GreaterThan = greater_than } @@ -8619,7 +9306,7 @@ impl Lexer for Language { }, Some('f') => match input.next() { Some('a') => { - scan_chars!(input, 'l', 's', 'e').then_some(TokenKind::FalseKeyword) + scan_chars!(input, 'l', 's', 'e').then_some(TokenKind::YulFalseKeyword) } Some('o') => scan_chars!(input, 'r').then_some(TokenKind::YulForKeyword), Some('u') => scan_chars!(input, 'n', 'c', 't', 'i', 'o', 'n') @@ -8657,7 +9344,7 @@ impl Lexer for Language { Some('s') => scan_chars!(input, 'w', 'i', 't', 'c', 'h') .then_some(TokenKind::YulSwitchKeyword), Some('t') => { - scan_chars!(input, 'r', 'u', 'e').then_some(TokenKind::TrueKeyword) + scan_chars!(input, 'r', 'u', 'e').then_some(TokenKind::YulTrueKeyword) } Some(_) => { input.undo(); @@ -8693,6 +9380,9 @@ impl Lexer for Language { longest_match! { { AsciiStringLiteral = ascii_string_literal } + { HexStringLiteral = hex_string_literal } + { YulDecimalLiteral = yul_decimal_literal } + { YulHexLiteral = yul_hex_literal } { YulIdentifier = yul_identifier } } }