diff --git a/.changeset/shy-pets-attack.md b/.changeset/shy-pets-attack.md new file mode 100644 index 0000000000..99782dc84a --- /dev/null +++ b/.changeset/shy-pets-attack.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": patch +--- + +allow call options as a post-fix expression diff --git a/crates/codegen/grammar/src/constructor.rs b/crates/codegen/grammar/src/constructor.rs index 9847ec9eb4..5534fa391d 100644 --- a/crates/codegen/grammar/src/constructor.rs +++ b/crates/codegen/grammar/src/constructor.rs @@ -10,11 +10,11 @@ use codegen_language_definition::model::{self, FieldsErrorRecovery, Identifier, use indexmap::IndexMap; use crate::{ - Grammar, GrammarElement, KeywordScannerDefinition, KeywordScannerDefinitionNode, - KeywordScannerDefinitionVersionedNode, Labeled, ParserDefinition, ParserDefinitionNode, - PrecedenceOperatorModel, PrecedenceParserDefinition, PrecedenceParserDefinitionNode, - ScannerDefinition, ScannerDefinitionNode, TriviaParserDefinition, VersionQuality, - VersionQualityRange, + DelimitedRecoveryTokenThreshold, Grammar, GrammarElement, KeywordScannerDefinition, + KeywordScannerDefinitionNode, KeywordScannerDefinitionVersionedNode, Labeled, ParserDefinition, + ParserDefinitionNode, PrecedenceOperatorModel, PrecedenceParserDefinition, + PrecedenceParserDefinitionNode, ScannerDefinition, ScannerDefinitionNode, + TriviaParserDefinition, VersionQuality, VersionQualityRange, }; /// Materializes the DSL v2 model ([`model::Language`]) into [`Grammar`]. @@ -610,7 +610,8 @@ fn resolve_sequence_like( let open = delims.next().unwrap(); let close = delims.next().unwrap(); - ParserDefinitionNode::DelimitedBy(open, Box::new(delimited_body), close) + let threshold = DelimitedRecoveryTokenThreshold::from(delimiters); + ParserDefinitionNode::DelimitedBy(open, Box::new(delimited_body), close, threshold) }; // Replace with a new delimited node fields.insert( diff --git a/crates/codegen/grammar/src/parser_definition.rs b/crates/codegen/grammar/src/parser_definition.rs index 4efcf12f88..60804a4d1b 100644 --- a/crates/codegen/grammar/src/parser_definition.rs +++ b/crates/codegen/grammar/src/parser_definition.rs @@ -1,6 +1,8 @@ use std::fmt::Debug; use std::rc::Rc; +use codegen_language_definition::model; + use crate::visitor::{GrammarVisitor, Visitable}; use crate::{ KeywordScannerDefinitionRef, PrecedenceParserDefinitionRef, ScannerDefinitionRef, @@ -53,6 +55,25 @@ impl Visitable for TriviaParserDefinitionRef { } } +/// How many tokens have to be matched to trigger the error recovery. +/// For ambiguous syntaxes this needs to be set to at least N, where N +/// is the token lookahead required to disambiguate the syntax. +/// +// By default, we assume no lookahead (0) is required to recover from +// unrecognized body between delimiters, so it's always triggered. +#[derive(Clone, Debug, Default)] +pub struct DelimitedRecoveryTokenThreshold(pub u8); + +impl From for DelimitedRecoveryTokenThreshold { + fn from(delimiters: model::FieldDelimiters) -> Self { + Self( + delimiters + .tokens_matched_acceptance_threshold + .unwrap_or(DelimitedRecoveryTokenThreshold::default().0), + ) + } +} + #[derive(Clone, Debug)] pub enum ParserDefinitionNode { Versioned(Box, Vec), @@ -66,7 +87,12 @@ pub enum ParserDefinitionNode { TriviaParserDefinition(TriviaParserDefinitionRef), ParserDefinition(ParserDefinitionRef), PrecedenceParserDefinition(PrecedenceParserDefinitionRef), - DelimitedBy(Labeled>, Box, Labeled>), + DelimitedBy( + Labeled>, + Box, + Labeled>, + DelimitedRecoveryTokenThreshold, + ), SeparatedBy(Labeled>, Labeled>), TerminatedBy(Box, Labeled>), } @@ -115,7 +141,7 @@ impl Visitable for ParserDefinitionNode { } } - Self::DelimitedBy(open, body, close) => { + Self::DelimitedBy(open, body, close, ..) => { open.accept_visitor(visitor); body.accept_visitor(visitor); close.accept_visitor(visitor); diff --git a/crates/codegen/language/definition/src/internals/parse_input_tokens/external_types.rs b/crates/codegen/language/definition/src/internals/parse_input_tokens/external_types.rs index b674402754..6f9a17d844 100644 --- a/crates/codegen/language/definition/src/internals/parse_input_tokens/external_types.rs +++ b/crates/codegen/language/definition/src/internals/parse_input_tokens/external_types.rs @@ -140,6 +140,15 @@ impl ParseInputTokens for usize { } } +impl ParseInputTokens for u8 { + fn parse_value(input: ParseStream<'_>, _: &mut ErrorsCollection) -> Result { + let literal = ParseHelpers::syn::(input)?; + let value = literal.base10_parse::()?; + + Ok(value) + } +} + impl ParseInputTokens for Vec { fn parse_value(input: ParseStream<'_>, errors: &mut ErrorsCollection) -> Result { Ok(ParseHelpers::sequence(input, errors)) diff --git a/crates/codegen/language/definition/src/internals/write_output_tokens/external_types.rs b/crates/codegen/language/definition/src/internals/write_output_tokens/external_types.rs index fc477476bb..ac4fa8f48e 100644 --- a/crates/codegen/language/definition/src/internals/write_output_tokens/external_types.rs +++ b/crates/codegen/language/definition/src/internals/write_output_tokens/external_types.rs @@ -119,6 +119,16 @@ impl WriteOutputTokens for usize { } } +impl WriteOutputTokens for u8 { + fn write_output_tokens(&self) -> TokenStream { + let value = Literal::u8_suffixed(*self); + + quote! { + #value.into() + } + } +} + impl WriteOutputTokens for Vec { fn write_output_tokens(&self) -> TokenStream { let items = self.iter().map(T::write_output_tokens); diff --git a/crates/codegen/language/definition/src/model/non_terminals/field.rs b/crates/codegen/language/definition/src/model/non_terminals/field.rs index 73f889084b..3318099dee 100644 --- a/crates/codegen/language/definition/src/model/non_terminals/field.rs +++ b/crates/codegen/language/definition/src/model/non_terminals/field.rs @@ -15,6 +15,13 @@ pub struct FieldsErrorRecovery { pub struct FieldDelimiters { pub open: Identifier, pub close: Identifier, + /// How many tokens have to be matched to trigger the error recovery. + /// For ambiguous syntaxes this needs to be set to at least N, where N + /// is the token lookahead required to disambiguate the syntax. + /// + /// By default, we assume no lookahead (0) is required to recover from + /// unrecognized body between delimiters, so it's always triggered. + pub tokens_matched_acceptance_threshold: Option, } #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] diff --git a/crates/codegen/language/internal_macros/src/derive/spanned.rs b/crates/codegen/language/internal_macros/src/derive/spanned.rs index f83fa812a3..79e1a4b7eb 100644 --- a/crates/codegen/language/internal_macros/src/derive/spanned.rs +++ b/crates/codegen/language/internal_macros/src/derive/spanned.rs @@ -159,7 +159,7 @@ fn get_spanned_type(input: Type) -> Type { } // External types should also be wrapped in 'Spanned': - "bool" | "char" | "PathBuf" | "String" | "Version" => { + "bool" | "char" | "PathBuf" | "String" | "u8" | "Version" => { parse_quote! { crate::internals::Spanned<#input> } diff --git a/crates/codegen/parser/generator/src/parser_definition.rs b/crates/codegen/parser/generator/src/parser_definition.rs index 0fc1eac44a..486c583bc5 100644 --- a/crates/codegen/parser/generator/src/parser_definition.rs +++ b/crates/codegen/parser/generator/src/parser_definition.rs @@ -191,7 +191,7 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { quote! { self.#function_name(input) } } - Self::DelimitedBy(open, body, close) => { + Self::DelimitedBy(open, body, close, threshold) => { let open_label = format_ident!("{}", open.label.to_pascal_case()); let close_label = format_ident!("{}", close.label.to_pascal_case()); let [open_delim, close_delim] = match (open.as_ref(), close.as_ref()) { @@ -201,6 +201,7 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { ) => [open, close].map(|scanner| format_ident!("{}", scanner.name())), _ => unreachable!("Only tokens are permitted as delimiters"), }; + let threshold = threshold.0; let parser = body.to_parser_code(context_name, is_trivia); let body_parser = body.applicable_version_quality_ranges().wrap_code( @@ -209,7 +210,7 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { .recover_until_with_nested_delims::<_, #lex_ctx>(input, self, TokenKind::#close_delim, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(#threshold), ) )?; }, @@ -275,7 +276,8 @@ impl ParserDefinitionNodeExtensions for ParserDefinitionNode { .recover_until_with_nested_delims::<_, #lex_ctx>(input, self, TokenKind::#terminator, - RecoverFromNoMatch::No, + // Requires at least a partial match not to risk misparsing + TokenAcceptanceThreshold(1u8), ) )?; }, diff --git a/crates/codegen/parser/generator/src/rust_generator.rs b/crates/codegen/parser/generator/src/rust_generator.rs index 5a6c9a6f52..4edff07c41 100644 --- a/crates/codegen/parser/generator/src/rust_generator.rs +++ b/crates/codegen/parser/generator/src/rust_generator.rs @@ -421,7 +421,7 @@ impl GrammarVisitor for RustGenerator { } // Collect delimiters for each context - ParserDefinitionNode::DelimitedBy(open, _, close) => { + ParserDefinitionNode::DelimitedBy(open, _, close, ..) => { self.labels.insert(open.label.clone()); self.labels.insert(close.label.clone()); diff --git a/crates/codegen/parser/runtime/src/parser_support/mod.rs b/crates/codegen/parser/runtime/src/parser_support/mod.rs index 8c3d83af20..2673e34ebf 100644 --- a/crates/codegen/parser/runtime/src/parser_support/mod.rs +++ b/crates/codegen/parser/runtime/src/parser_support/mod.rs @@ -26,7 +26,7 @@ pub(crate) use parser_result::ParserResult; #[allow(unused_imports)] pub(crate) use precedence_helper::PrecedenceHelper; #[allow(unused_imports)] -pub(crate) use recovery::RecoverFromNoMatch; +pub(crate) use recovery::TokenAcceptanceThreshold; #[allow(unused_imports)] pub(crate) use repetition_helper::{OneOrMoreHelper, ZeroOrMoreHelper}; #[allow(unused_imports)] diff --git a/crates/codegen/parser/runtime/src/parser_support/parser_result.rs b/crates/codegen/parser/runtime/src/parser_support/parser_result.rs index 9c6b44adc3..094cdbc373 100644 --- a/crates/codegen/parser/runtime/src/parser_support/parser_result.rs +++ b/crates/codegen/parser/runtime/src/parser_support/parser_result.rs @@ -1,6 +1,6 @@ use std::ops::ControlFlow; -use crate::cst::{self, LabeledNode}; +use crate::cst::{self, LabeledNode, Node}; use crate::kinds::{NodeLabel, RuleKind, TokenKind}; use crate::text_index::TextIndex; @@ -201,6 +201,33 @@ impl IncompleteMatch { expected_tokens, } } + + /// Whether this prefix-matched at least `n` (non-skipped) significant tokens. + pub fn matches_at_least_n_tokens(&self, n: u8) -> bool { + let result = self + .nodes + .iter() + .flat_map(|node| node.cursor_with_offset(TextIndex::ZERO)) + .try_fold(0u8, |mut acc, node| { + match node { + Node::Token(tok) if tok.kind != TokenKind::SKIPPED && !tok.kind.is_trivia() => { + acc += 1; + } + _ => {} + } + + // Short-circuit not to walk the whole tree if we've already matched enough + if acc >= n { + ControlFlow::Break(acc) + } else { + ControlFlow::Continue(acc) + } + }); + + match result { + ControlFlow::Continue(value) | ControlFlow::Break(value) => value >= n, + } + } } #[derive(PartialEq, Eq, Clone, Debug)] diff --git a/crates/codegen/parser/runtime/src/parser_support/recovery.rs b/crates/codegen/parser/runtime/src/parser_support/recovery.rs index 94b52036c9..2e62815e55 100644 --- a/crates/codegen/parser/runtime/src/parser_support/recovery.rs +++ b/crates/codegen/parser/runtime/src/parser_support/recovery.rs @@ -7,18 +7,11 @@ use crate::parser_support::parser_result::SkippedUntil; use crate::parser_support::ParserResult; use crate::text_index::{TextRange, TextRangeExtensions as _}; -/// An explicit parameter for the [`ParserResult::recover_until_with_nested_delims`] method. +/// How many tokens have to be matched to trigger the error recovery. +/// For ambiguous syntaxes this needs to be set to at least N, where N +/// is the token lookahead required to disambiguate the syntax. #[derive(Clone, Copy)] -pub(crate) enum RecoverFromNoMatch { - Yes, - No, -} - -impl RecoverFromNoMatch { - pub fn as_bool(self) -> bool { - matches!(self, RecoverFromNoMatch::Yes) - } -} +pub(crate) struct TokenAcceptanceThreshold(pub(crate) u8); fn opt_parse( input: &mut ParserContext<'_>, @@ -46,7 +39,7 @@ impl ParserResult { input: &mut ParserContext<'_>, lexer: &L, expected: TokenKind, - recover_from_no_match: RecoverFromNoMatch, + acceptance_threshold: TokenAcceptanceThreshold, ) -> ParserResult { enum ParseResultKind { Match, @@ -57,11 +50,15 @@ impl ParserResult { let before_recovery = input.position(); let (mut nodes, mut expected_tokens, result_kind) = match self { - ParserResult::IncompleteMatch(result) => ( - result.nodes, - result.expected_tokens, - ParseResultKind::Incomplete, - ), + ParserResult::IncompleteMatch(result) + if result.matches_at_least_n_tokens(acceptance_threshold.0) => + { + ( + result.nodes, + result.expected_tokens, + ParseResultKind::Incomplete, + ) + } ParserResult::Match(result) if lexer .peek_token_with_trivia::(input) @@ -70,7 +67,7 @@ impl ParserResult { { (result.nodes, result.expected_tokens, ParseResultKind::Match) } - ParserResult::NoMatch(result) if recover_from_no_match.as_bool() => { + ParserResult::NoMatch(result) if acceptance_threshold.0 == 0 => { (vec![], result.expected_tokens, ParseResultKind::NoMatch) } // No need to recover, so just return as-is. diff --git a/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 b/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 index 6a00f566b5..95c6ad98d9 100644 --- a/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 +++ b/crates/codegen/parser/runtime/src/templates/language.rs.jinja2 @@ -22,7 +22,7 @@ use crate::napi_interface::parse_output::ParseOutput as NAPIParseOutput; use crate::parse_output::ParseOutput; use crate::parser_support::{ ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, - PrecedenceHelper, RecoverFromNoMatch, SeparatedHelper, SequenceHelper, ZeroOrMoreHelper, + PrecedenceHelper, SeparatedHelper, SequenceHelper, TokenAcceptanceThreshold, ZeroOrMoreHelper, }; #[derive(Debug)] diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 4e6dd0d2df..87cf7611b8 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -3378,12 +3378,29 @@ codegen_language_macros::compile!(Language( name = FunctionCallExpression, operators = [PrecedenceOperator( model = Postfix, + fields = (arguments = Required(ArgumentsDeclaration)) + )] + ), + PrecedenceExpression( + name = CallOptionsExpression, + operators = [PrecedenceOperator( + model = Postfix, + enabled = From("0.6.2"), + error_recovery = FieldsErrorRecovery( + delimiters = FieldDelimiters( + open = open_brace, + close = close_brace, + // NOTE: Despite `CallOptions` requiring at least one element, + // we can only recover if we found at least two tokens (`ident:`) + // in the body, as this may be otherwise ambiguous with + // `try { func() } catch {}`. + tokens_matched_acceptance_threshold = 2 + ) + ), fields = ( - options = Optional( - reference = FunctionCallOptions, - enabled = From("0.6.2") - ), - arguments = Required(ArgumentsDeclaration) + open_brace = Required(OpenBrace), + options = Required(CallOptions), + close_brace = Required(CloseBrace) ) )] ), @@ -3456,20 +3473,6 @@ codegen_language_macros::compile!(Language( Topic( title = "Function Calls", items = [ - Enum( - name = FunctionCallOptions, - enabled = From("0.6.2"), - variants = [ - EnumVariant( - reference = NamedArgumentGroups, - enabled = Range(from = "0.6.2", till = "0.8.0") - ), - EnumVariant( - reference = NamedArgumentGroup, - enabled = From("0.8.0") - ) - ] - ), Enum( name = ArgumentsDeclaration, variants = [ @@ -3507,11 +3510,6 @@ codegen_language_macros::compile!(Language( close_paren = Required(CloseParen) ) ), - Repeated( - name = NamedArgumentGroups, - reference = NamedArgumentGroup, - enabled = Range(from = "0.6.2", till = "0.8.0") - ), Struct( name = NamedArgumentGroup, error_recovery = FieldsErrorRecovery( @@ -3530,6 +3528,14 @@ codegen_language_macros::compile!(Language( separator = Comma, allow_empty = true ), + Separated( + name = CallOptions, + reference = NamedArgument, + separator = Comma, + enabled = From("0.6.2"), + // These cannot be empty as they're ambiguous with `try {} catch {}` + allow_empty = false + ), Struct( name = NamedArgument, fields = ( diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/kinds.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/kinds.rs index 993237e2cd..e23165eaa6 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/kinds.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/kinds.rs @@ -35,6 +35,8 @@ pub enum RuleKind { BitwiseXorExpression, Block, BreakStatement, + CallOptions, + CallOptionsExpression, CatchClause, CatchClauseError, CatchClauses, @@ -80,7 +82,6 @@ pub enum RuleKind { FunctionAttributes, FunctionBody, FunctionCallExpression, - FunctionCallOptions, FunctionDefinition, FunctionName, FunctionType, @@ -119,7 +120,6 @@ pub enum RuleKind { MultiplicativeExpression, NamedArgument, NamedArgumentGroup, - NamedArgumentGroups, NamedArguments, NamedArgumentsDeclaration, NamedImport, diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/language.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/language.rs index c163fe8582..23ddd3ac31 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/language.rs @@ -24,7 +24,7 @@ use crate::napi_interface::parse_output::ParseOutput as NAPIParseOutput; use crate::parse_output::ParseOutput; use crate::parser_support::{ ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, - PrecedenceHelper, RecoverFromNoMatch, SeparatedHelper, SequenceHelper, ZeroOrMoreHelper, + PrecedenceHelper, SeparatedHelper, SequenceHelper, TokenAcceptanceThreshold, ZeroOrMoreHelper, }; #[derive(Debug)] @@ -329,7 +329,7 @@ impl Language { input, self, TokenKind::CloseBracket, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -410,7 +410,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -560,7 +560,7 @@ impl Language { input, self, TokenKind::CloseBrace, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -588,7 +588,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -603,6 +603,45 @@ impl Language { .with_kind(RuleKind::BreakStatement) } + #[allow(unused_assignments, unused_parens)] + fn call_options(&self, input: &mut ParserContext<'_>) -> ParserResult { + if self.version_is_at_least_0_6_2 { + SeparatedHelper::run::<_, LexicalContextType::Default>( + input, + self, + |input| self.named_argument(input).with_label(NodeLabel::Item), + TokenKind::Comma, + NodeLabel::Separator, + ) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::CallOptions) + } + + #[allow(unused_assignments, unused_parens)] + fn call_options_expression(&self, input: &mut ParserContext<'_>) -> ParserResult { + let result = self.expression(input); + let ParserResult::Match(r#match) = &result else { + return result; + }; + match &r#match.nodes[..] { + [cst::LabeledNode { + label: _, + node: cst::Node::Rule(node), + }] if node.kind == RuleKind::Expression => match &node.children[..] { + [inner @ cst::LabeledNode { + label: _, + node: cst::Node::Rule(rule), + }] if rule.kind == RuleKind::CallOptionsExpression => { + ParserResult::r#match(vec![inner.clone()], r#match.expected_tokens.clone()) + } + _ => ParserResult::no_match(vec![]), + }, + _ => ParserResult::no_match(vec![]), + } + } + #[allow(unused_assignments, unused_parens)] fn catch_clause(&self, input: &mut ParserContext<'_>) -> ParserResult { if self.version_is_at_least_0_6_0 { @@ -742,7 +781,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -852,7 +891,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -916,7 +955,7 @@ impl Language { input, self, TokenKind::CloseBrace, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -1026,7 +1065,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -1078,7 +1117,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -1096,7 +1135,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -1201,7 +1240,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -1253,7 +1292,7 @@ impl Language { input, self, TokenKind::CloseBrace, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -1341,7 +1380,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -1417,7 +1456,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -1473,7 +1512,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -1546,7 +1585,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -2060,22 +2099,46 @@ impl Language { PrecedenceHelper::to_postfix_operator( RuleKind::FunctionCallExpression, 33u8, - SequenceHelper::run(|mut seq| { + self.arguments_declaration(input) + .with_label(NodeLabel::Arguments), + ) + }; + let parse_postfix_call_options_expression = |input: &mut ParserContext<'_>| { + PrecedenceHelper::to_postfix_operator( + RuleKind::CallOptionsExpression, + 35u8, + ChoiceHelper::run(input, |mut choice, input| { if self.version_is_at_least_0_6_2 { - seq.elem_labeled( - NodeLabel::Options, - OptionalHelper::transform(self.function_call_options(input)), - )?; + let result = SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseBrace); + let input = delim_guard.ctx(); + seq.elem_labeled( + NodeLabel::OpenBrace, + self.parse_token_with_trivia::( + input, + TokenKind::OpenBrace, + ), + )?; + seq . elem (self . call_options (input) . with_label (NodeLabel :: Options) . recover_until_with_nested_delims :: < _ , LexicalContextType :: Default > (input , self , TokenKind :: CloseBrace , TokenAcceptanceThreshold (2u8) ,)) ? ; + seq.elem_labeled( + NodeLabel::CloseBrace, + self.parse_token_with_trivia::( + input, + TokenKind::CloseBrace, + ), + )?; + seq.finish() + }); + choice.consider(input, result)?; } - seq.elem_labeled(NodeLabel::Arguments, self.arguments_declaration(input))?; - seq.finish() + choice.finish(input) }), ) }; let parse_postfix_member_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::MemberAccessExpression, - 35u8, + 37u8, SequenceHelper::run(|mut seq| { seq.elem_labeled( NodeLabel::Period, @@ -2092,7 +2155,7 @@ impl Language { let parse_postfix_index_access_expression = |input: &mut ParserContext<'_>| { PrecedenceHelper::to_postfix_operator( RuleKind::IndexAccessExpression, - 37u8, + 39u8, SequenceHelper::run(|mut seq| { let mut delim_guard = input.open_delim(TokenKind::CloseBracket); let input = delim_guard.ctx(); @@ -2119,7 +2182,7 @@ impl Language { input, self, TokenKind::CloseBracket, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -2194,6 +2257,8 @@ impl Language { choice.consider(input, result)?; let result = parse_postfix_function_call_expression(input); choice.consider(input, result)?; + let result = parse_postfix_call_options_expression(input); + choice.consider(input, result)?; let result = parse_postfix_member_access_expression(input); choice.consider(input, result)?; let result = parse_postfix_index_access_expression(input); @@ -2270,7 +2335,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -2409,7 +2474,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -2572,27 +2637,6 @@ impl Language { } } - #[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.named_argument_groups(input); - 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) - }) - .with_label(NodeLabel::Variant) - } else { - ParserResult::disabled() - } - .with_kind(RuleKind::FunctionCallOptions) - } - #[allow(unused_assignments, unused_parens)] fn function_definition(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { @@ -2811,7 +2855,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -2890,7 +2934,7 @@ impl Language { input, self, TokenKind::CloseBrace, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -2968,7 +3012,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -3104,7 +3148,7 @@ impl Language { input, self, TokenKind::CloseBrace, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -3163,7 +3207,7 @@ impl Language { input, self, TokenKind::CloseBrace, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -3258,7 +3302,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -3469,7 +3513,7 @@ impl Language { input, self, TokenKind::CloseBrace, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -3484,18 +3528,6 @@ impl Language { .with_kind(RuleKind::NamedArgumentGroup) } - #[allow(unused_assignments, unused_parens)] - fn named_argument_groups(&self, input: &mut ParserContext<'_>) -> ParserResult { - if self.version_is_at_least_0_6_2 && !self.version_is_at_least_0_8_0 { - OneOrMoreHelper::run(input, |input| { - self.named_argument_group(input).with_label(NodeLabel::Item) - }) - } else { - ParserResult::disabled() - } - .with_kind(RuleKind::NamedArgumentGroups) - } - #[allow(unused_assignments, unused_parens)] fn named_arguments(&self, input: &mut ParserContext<'_>) -> ParserResult { OptionalHelper::transform(SeparatedHelper::run::<_, LexicalContextType::Default>( @@ -3527,7 +3559,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -3708,7 +3740,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -3795,7 +3827,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -3854,7 +3886,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -3926,7 +3958,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -4056,7 +4088,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -4111,7 +4143,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -4289,7 +4321,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -4503,7 +4535,7 @@ impl Language { input, self, TokenKind::CloseBrace, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -4539,7 +4571,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -4576,7 +4608,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -4675,7 +4707,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -4701,7 +4733,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -4735,7 +4767,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -4810,7 +4842,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -4853,7 +4885,7 @@ impl Language { input, self, TokenKind::CloseBracket, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -5127,7 +5159,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -5200,7 +5232,7 @@ impl Language { input, self, TokenKind::CloseBrace, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -5294,7 +5326,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -5437,7 +5469,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -5760,7 +5792,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -5836,7 +5868,7 @@ impl Language { input, self, TokenKind::CloseBrace, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -6336,7 +6368,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -6613,7 +6645,7 @@ impl Language { input, self, TokenKind::CloseParen, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( @@ -8930,6 +8962,8 @@ impl Language { RuleKind::BitwiseXorExpression => Self::bitwise_xor_expression.parse(self, input), RuleKind::Block => Self::block.parse(self, input), RuleKind::BreakStatement => Self::break_statement.parse(self, input), + RuleKind::CallOptions => Self::call_options.parse(self, input), + RuleKind::CallOptionsExpression => Self::call_options_expression.parse(self, input), RuleKind::CatchClause => Self::catch_clause.parse(self, input), RuleKind::CatchClauseError => Self::catch_clause_error.parse(self, input), RuleKind::CatchClauses => Self::catch_clauses.parse(self, input), @@ -8989,7 +9023,6 @@ impl Language { RuleKind::FunctionAttributes => Self::function_attributes.parse(self, input), RuleKind::FunctionBody => Self::function_body.parse(self, input), RuleKind::FunctionCallExpression => Self::function_call_expression.parse(self, input), - RuleKind::FunctionCallOptions => Self::function_call_options.parse(self, input), RuleKind::FunctionDefinition => Self::function_definition.parse(self, input), RuleKind::FunctionName => Self::function_name.parse(self, input), RuleKind::FunctionType => Self::function_type.parse(self, input), @@ -9034,7 +9067,6 @@ impl Language { } RuleKind::NamedArgument => Self::named_argument.parse(self, input), RuleKind::NamedArgumentGroup => Self::named_argument_group.parse(self, input), - RuleKind::NamedArgumentGroups => Self::named_argument_groups.parse(self, input), RuleKind::NamedArguments => Self::named_arguments.parse(self, input), RuleKind::NamedArgumentsDeclaration => { Self::named_arguments_declaration.parse(self, input) diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/ast_selectors.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/ast_selectors.rs index 256e0bd650..0b8684ffff 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/ast_selectors.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/ast_selectors.rs @@ -124,6 +124,7 @@ pub fn select_sequence( RuleKind::PostfixExpression => selector.postfix_expression()?, RuleKind::PrefixExpression => selector.prefix_expression()?, RuleKind::FunctionCallExpression => selector.function_call_expression()?, + RuleKind::CallOptionsExpression => selector.call_options_expression()?, RuleKind::MemberAccessExpression => selector.member_access_expression()?, RuleKind::IndexAccessExpression => selector.index_access_expression()?, RuleKind::IndexAccessEnd => selector.index_access_end()?, @@ -1161,12 +1162,22 @@ impl Selector { fn function_call_expression(&mut self) -> Result>> { Ok(vec![ Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), - self.try_select(|node| node.is_rule_with_kind(RuleKind::FunctionCallOptions))?, Some(self.select(|node| node.is_rule_with_kind(RuleKind::ArgumentsDeclaration))?), ]) } } +impl Selector { + fn call_options_expression(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(|node| node.is_rule_with_kind(RuleKind::Expression))?), + Some(self.select(|node| node.is_token_with_kind(TokenKind::OpenBrace))?), + Some(self.select(|node| node.is_rule_with_kind(RuleKind::CallOptions))?), + Some(self.select(|node| node.is_token_with_kind(TokenKind::CloseBrace))?), + ]) + } +} + impl Selector { fn member_access_expression(&mut self) -> Result>> { Ok(vec![ @@ -1520,7 +1531,6 @@ pub fn select_choice( RuleKind::ForStatementCondition => selector.for_statement_condition()?, RuleKind::Expression => selector.expression()?, RuleKind::MemberAccess => selector.member_access()?, - RuleKind::FunctionCallOptions => selector.function_call_options()?, RuleKind::ArgumentsDeclaration => selector.arguments_declaration()?, RuleKind::NumberUnit => selector.number_unit()?, RuleKind::StringExpression => selector.string_expression()?, @@ -1949,6 +1959,7 @@ impl Selector { RuleKind::PostfixExpression, RuleKind::PrefixExpression, RuleKind::FunctionCallExpression, + RuleKind::CallOptionsExpression, RuleKind::MemberAccessExpression, RuleKind::IndexAccessExpression, RuleKind::NewExpression, @@ -1977,14 +1988,6 @@ impl Selector { } } -impl Selector { - fn function_call_options(&mut self) -> Result { - self.select(|node| { - node.is_rule_with_kinds(&[RuleKind::NamedArgumentGroups, RuleKind::NamedArgumentGroup]) - }) - } -} - impl Selector { fn arguments_declaration(&mut self) -> Result { self.select(|node| { @@ -2245,7 +2248,6 @@ pub fn select_repeated( RuleKind::FunctionTypeAttributes => selector.function_type_attributes()?, RuleKind::Statements => selector.statements()?, RuleKind::CatchClauses => selector.catch_clauses()?, - RuleKind::NamedArgumentGroups => selector.named_argument_groups()?, RuleKind::StringLiterals => selector.string_literals()?, RuleKind::HexStringLiterals => selector.hex_string_literals()?, RuleKind::UnicodeStringLiterals => selector.unicode_string_literals()?, @@ -2484,20 +2486,6 @@ impl Selector { } } -impl Selector { - fn named_argument_groups(&mut self) -> Result> { - let mut items = vec![]; - - while let Some(item) = - self.try_select(|node| node.is_rule_with_kind(RuleKind::NamedArgumentGroup))? - { - items.push(item); - } - - Ok(items) - } -} - impl Selector { fn string_literals(&mut self) -> Result> { let mut items = vec![]; @@ -2597,6 +2585,7 @@ pub fn select_separated( RuleKind::TupleDeconstructionElements => selector.tuple_deconstruction_elements()?, RuleKind::PositionalArguments => selector.positional_arguments()?, RuleKind::NamedArguments => selector.named_arguments()?, + RuleKind::CallOptions => selector.call_options()?, RuleKind::TupleValues => selector.tuple_values()?, RuleKind::ArrayValues => selector.array_values()?, RuleKind::IdentifierPath => selector.identifier_path()?, @@ -2929,6 +2918,30 @@ impl Selector { } } +impl Selector { + fn call_options(&mut self) -> Result>> { + let mut separated = vec![]; + let mut separators = vec![]; + + if let Some(first) = + self.try_select(|node| node.is_rule_with_kind(RuleKind::NamedArgument))? + { + separated.push(first); + + while let Some(separator) = + self.try_select(|node| node.is_token_with_kind(TokenKind::Comma))? + { + separators.push(separator); + + separated + .push(self.select(|node| node.is_rule_with_kind(RuleKind::NamedArgument))?); + } + } + + Ok(vec![separated, separators]) + } +} + impl Selector { fn tuple_values(&mut self) -> Result>> { let mut separated = vec![]; diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/mod.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/mod.rs index cf8ccbaad9..2d005d87d3 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/mod.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/mod.rs @@ -28,7 +28,7 @@ pub(crate) use parser_result::ParserResult; #[allow(unused_imports)] pub(crate) use precedence_helper::PrecedenceHelper; #[allow(unused_imports)] -pub(crate) use recovery::RecoverFromNoMatch; +pub(crate) use recovery::TokenAcceptanceThreshold; #[allow(unused_imports)] pub(crate) use repetition_helper::{OneOrMoreHelper, ZeroOrMoreHelper}; #[allow(unused_imports)] diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/parser_result.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/parser_result.rs index 21b61c668e..16e59411fa 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/parser_result.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/parser_result.rs @@ -2,7 +2,7 @@ use std::ops::ControlFlow; -use crate::cst::{self, LabeledNode}; +use crate::cst::{self, LabeledNode, Node}; use crate::kinds::{NodeLabel, RuleKind, TokenKind}; use crate::text_index::TextIndex; @@ -203,6 +203,33 @@ impl IncompleteMatch { expected_tokens, } } + + /// Whether this prefix-matched at least `n` (non-skipped) significant tokens. + pub fn matches_at_least_n_tokens(&self, n: u8) -> bool { + let result = self + .nodes + .iter() + .flat_map(|node| node.cursor_with_offset(TextIndex::ZERO)) + .try_fold(0u8, |mut acc, node| { + match node { + Node::Token(tok) if tok.kind != TokenKind::SKIPPED && !tok.kind.is_trivia() => { + acc += 1; + } + _ => {} + } + + // Short-circuit not to walk the whole tree if we've already matched enough + if acc >= n { + ControlFlow::Break(acc) + } else { + ControlFlow::Continue(acc) + } + }); + + match result { + ControlFlow::Continue(value) | ControlFlow::Break(value) => value >= n, + } + } } #[derive(PartialEq, Eq, Clone, Debug)] diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/recovery.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/recovery.rs index 563d3a60bf..2a53c35945 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/recovery.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser_support/recovery.rs @@ -9,18 +9,11 @@ use crate::parser_support::parser_result::SkippedUntil; use crate::parser_support::ParserResult; use crate::text_index::{TextRange, TextRangeExtensions as _}; -/// An explicit parameter for the [`ParserResult::recover_until_with_nested_delims`] method. +/// How many tokens have to be matched to trigger the error recovery. +/// For ambiguous syntaxes this needs to be set to at least N, where N +/// is the token lookahead required to disambiguate the syntax. #[derive(Clone, Copy)] -pub(crate) enum RecoverFromNoMatch { - Yes, - No, -} - -impl RecoverFromNoMatch { - pub fn as_bool(self) -> bool { - matches!(self, RecoverFromNoMatch::Yes) - } -} +pub(crate) struct TokenAcceptanceThreshold(pub(crate) u8); fn opt_parse( input: &mut ParserContext<'_>, @@ -48,7 +41,7 @@ impl ParserResult { input: &mut ParserContext<'_>, lexer: &L, expected: TokenKind, - recover_from_no_match: RecoverFromNoMatch, + acceptance_threshold: TokenAcceptanceThreshold, ) -> ParserResult { enum ParseResultKind { Match, @@ -59,11 +52,15 @@ impl ParserResult { let before_recovery = input.position(); let (mut nodes, mut expected_tokens, result_kind) = match self { - ParserResult::IncompleteMatch(result) => ( - result.nodes, - result.expected_tokens, - ParseResultKind::Incomplete, - ), + ParserResult::IncompleteMatch(result) + if result.matches_at_least_n_tokens(acceptance_threshold.0) => + { + ( + result.nodes, + result.expected_tokens, + ParseResultKind::Incomplete, + ) + } ParserResult::Match(result) if lexer .peek_token_with_trivia::(input) @@ -72,7 +69,7 @@ impl ParserResult { { (result.nodes, result.expected_tokens, ParseResultKind::Match) } - ParserResult::NoMatch(result) if recover_from_no_match.as_bool() => { + ParserResult::NoMatch(result) if acceptance_threshold.0 == 0 => { (vec![], result.expected_tokens, ParseResultKind::NoMatch) } // No need to recover, so just return as-is. diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/expression.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/expression.rs index d0b4c45d5a..8ef483ab2b 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/expression.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/expression.rs @@ -262,11 +262,31 @@ fn member_access_index_access() -> Result<()> { run("Expression", "member_access_index_access") } +#[test] +fn member_access_options() -> Result<()> { + run("Expression", "member_access_options") +} + +#[test] +fn new_expression() -> Result<()> { + run("Expression", "new_expression") +} + +#[test] +fn new_expression_options() -> Result<()> { + run("Expression", "new_expression_options") +} + #[test] fn overlapping_operators() -> Result<()> { run("Expression", "overlapping_operators") } +#[test] +fn paren_expression_options() -> Result<()> { + run("Expression", "paren_expression_options") +} + #[test] fn postfix_decrement() -> Result<()> { run("Expression", "postfix_decrement") diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/function_call_expression.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/function_call_expression.rs index e74ab48b1d..47e199330a 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/function_call_expression.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/function_call_expression.rs @@ -4,6 +4,11 @@ use anyhow::Result; use crate::cst_output::runner::run; +#[test] +fn empty_named_arguments() -> Result<()> { + run("FunctionCallExpression", "empty_named_arguments") +} + #[test] fn payable_conversion() -> Result<()> { run("FunctionCallExpression", "payable_conversion") diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/try_statement.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/try_statement.rs index 237a42c724..6ae9c14cd1 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/try_statement.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/try_statement.rs @@ -8,3 +8,13 @@ use crate::cst_output::runner::run; fn try_catch() -> Result<()> { run("TryStatement", "try_catch") } + +#[test] +fn try_catch_empty_body() -> Result<()> { + run("TryStatement", "try_catch_empty_body") +} + +#[test] +fn try_expr_call_options() -> Result<()> { + run("TryStatement", "try_expr_call_options") +} diff --git a/crates/solidity/outputs/npm/package/src/ast/generated/ast_types.ts b/crates/solidity/outputs/npm/package/src/ast/generated/ast_types.ts index 98070fa44c..784dd163cd 100644 --- a/crates/solidity/outputs/npm/package/src/ast/generated/ast_types.ts +++ b/crates/solidity/outputs/npm/package/src/ast/generated/ast_types.ts @@ -2860,11 +2860,10 @@ export class PrefixExpression { export class FunctionCallExpression { private readonly fetch = once(() => { - const [$operand, $options, $arguments] = ast_internal.selectSequence(this.cst); + const [$operand, $arguments] = ast_internal.selectSequence(this.cst); return { operand: new Expression($operand as RuleNode), - options: $options === null ? undefined : new FunctionCallOptions($options as RuleNode), arguments: new ArgumentsDeclaration($arguments as RuleNode), }; }); @@ -2877,12 +2876,41 @@ export class FunctionCallExpression { return this.fetch().operand; } - public get options(): FunctionCallOptions | undefined { + public get arguments(): ArgumentsDeclaration { + return this.fetch().arguments; + } +} + +export class CallOptionsExpression { + private readonly fetch = once(() => { + const [$operand, $openBrace, $options, $closeBrace] = ast_internal.selectSequence(this.cst); + + return { + operand: new Expression($operand as RuleNode), + openBrace: $openBrace as TokenNode, + options: new CallOptions($options as RuleNode), + closeBrace: $closeBrace as TokenNode, + }; + }); + + public constructor(public readonly cst: RuleNode) { + assertKind(this.cst.kind, RuleKind.CallOptionsExpression); + } + + public get operand(): Expression { + return this.fetch().operand; + } + + public get openBrace(): TokenNode { + return this.fetch().openBrace; + } + + public get options(): CallOptions { return this.fetch().options; } - public get arguments(): ArgumentsDeclaration { - return this.fetch().arguments; + public get closeBrace(): TokenNode { + return this.fetch().closeBrace; } } @@ -4700,6 +4728,7 @@ export class Expression { | PostfixExpression | PrefixExpression | FunctionCallExpression + | CallOptionsExpression | MemberAccessExpression | IndexAccessExpression | NewExpression @@ -4746,6 +4775,8 @@ export class Expression { return new PrefixExpression(variant as RuleNode); case RuleKind.FunctionCallExpression: return new FunctionCallExpression(variant as RuleNode); + case RuleKind.CallOptionsExpression: + return new CallOptionsExpression(variant as RuleNode); case RuleKind.MemberAccessExpression: return new MemberAccessExpression(variant as RuleNode); case RuleKind.IndexAccessExpression: @@ -4799,6 +4830,7 @@ export class Expression { | PostfixExpression | PrefixExpression | FunctionCallExpression + | CallOptionsExpression | MemberAccessExpression | IndexAccessExpression | NewExpression @@ -4837,30 +4869,6 @@ export class MemberAccess { } } -export class FunctionCallOptions { - private readonly fetch: () => NamedArgumentGroups | NamedArgumentGroup = once(() => { - const variant = ast_internal.selectChoice(this.cst); - - switch (variant.kind) { - case RuleKind.NamedArgumentGroups: - return new NamedArgumentGroups(variant as RuleNode); - case RuleKind.NamedArgumentGroup: - return new NamedArgumentGroup(variant as RuleNode); - - default: - assert.fail(`Unexpected variant: ${variant.kind}`); - } - }); - - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.FunctionCallOptions); - } - - public get variant(): NamedArgumentGroups | NamedArgumentGroup { - return this.fetch(); - } -} - export class ArgumentsDeclaration { private readonly fetch: () => PositionalArgumentsDeclaration | NamedArgumentsDeclaration = once(() => { const variant = ast_internal.selectChoice(this.cst); @@ -5539,21 +5547,6 @@ export class CatchClauses { } } -export class NamedArgumentGroups { - private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); - return items.map((item) => new NamedArgumentGroup(item as RuleNode)); - }); - - public constructor(public readonly cst: RuleNode) { - assertKind(this.cst.kind, RuleKind.NamedArgumentGroups); - } - - public get items(): readonly NamedArgumentGroup[] { - return this.fetch(); - } -} - export class StringLiterals { private readonly fetch = once(() => { const items = ast_internal.selectRepeated(this.cst); @@ -5902,6 +5895,26 @@ export class NamedArguments { } } +export class CallOptions { + private readonly fetch = once(() => { + const [items, separators] = ast_internal.selectSeparated(this.cst); + + return { items: items.map((item) => new NamedArgument(item as RuleNode)), separators: separators as TokenNode[] }; + }); + + public constructor(public readonly cst: RuleNode) { + assertKind(this.cst.kind, RuleKind.CallOptions); + } + + public get items(): readonly NamedArgument[] { + return this.fetch().items; + } + + public get separators(): readonly TokenNode[] { + return this.fetch().separators; + } +} + export class TupleValues { private readonly fetch = once(() => { const [items, separators] = ast_internal.selectSeparated(this.cst); diff --git a/crates/solidity/outputs/npm/package/src/generated/index.d.ts b/crates/solidity/outputs/npm/package/src/generated/index.d.ts index 7de064fefe..3333f7a433 100644 --- a/crates/solidity/outputs/npm/package/src/generated/index.d.ts +++ b/crates/solidity/outputs/npm/package/src/generated/index.d.ts @@ -27,6 +27,8 @@ export namespace kinds { BitwiseXorExpression = "BitwiseXorExpression", Block = "Block", BreakStatement = "BreakStatement", + CallOptions = "CallOptions", + CallOptionsExpression = "CallOptionsExpression", CatchClause = "CatchClause", CatchClauseError = "CatchClauseError", CatchClauses = "CatchClauses", @@ -72,7 +74,6 @@ export namespace kinds { FunctionAttributes = "FunctionAttributes", FunctionBody = "FunctionBody", FunctionCallExpression = "FunctionCallExpression", - FunctionCallOptions = "FunctionCallOptions", FunctionDefinition = "FunctionDefinition", FunctionName = "FunctionName", FunctionType = "FunctionType", @@ -111,7 +112,6 @@ export namespace kinds { MultiplicativeExpression = "MultiplicativeExpression", NamedArgument = "NamedArgument", NamedArgumentGroup = "NamedArgumentGroup", - NamedArgumentGroups = "NamedArgumentGroups", NamedArguments = "NamedArguments", NamedArgumentsDeclaration = "NamedArgumentsDeclaration", NamedImport = "NamedImport", diff --git a/crates/solidity/outputs/spec/generated/grammar.ebnf b/crates/solidity/outputs/spec/generated/grammar.ebnf index 62a6570895..df8d0e3256 100644 --- a/crates/solidity/outputs/spec/generated/grammar.ebnf +++ b/crates/solidity/outputs/spec/generated/grammar.ebnf @@ -1123,6 +1123,7 @@ Expression = AssignmentExpression | PostfixExpression | PrefixExpression | FunctionCallExpression + | CallOptionsExpression | MemberAccessExpression | IndexAccessExpression | NewExpression @@ -1146,10 +1147,6 @@ IndexAccessEnd = COLON (* 5.2. Function Calls: *) -(* Introduced in 0.6.2 *) -FunctionCallOptions = NamedArgumentGroups (* Introduced in 0.6.2 and deprecated in 0.8.0. *) - | NamedArgumentGroup; (* Introduced in 0.8.0 *) - ArgumentsDeclaration = PositionalArgumentsDeclaration | NamedArgumentsDeclaration; @@ -1163,15 +1160,15 @@ NamedArgumentsDeclaration = OPEN_PAREN NamedArgumentGroup? CLOSE_PAREN; -(* Introduced in 0.6.2 and deprecated in 0.8.0. *) -NamedArgumentGroups = NamedArgumentGroup+; - NamedArgumentGroup = OPEN_BRACE NamedArguments CLOSE_BRACE; NamedArguments = (NamedArgument (COMMA NamedArgument)*)?; +(* Introduced in 0.6.2 *) +CallOptions = NamedArgument (COMMA NamedArgument)*; + NamedArgument = IDENTIFIER COLON Expression; diff --git a/crates/solidity/outputs/spec/generated/public/05-expressions/01-base-expressions.md b/crates/solidity/outputs/spec/generated/public/05-expressions/01-base-expressions.md index efe8e490c4..126e467a3d 100644 --- a/crates/solidity/outputs/spec/generated/public/05-expressions/01-base-expressions.md +++ b/crates/solidity/outputs/spec/generated/public/05-expressions/01-base-expressions.md @@ -8,7 +8,7 @@ ``` -
Expression = AssignmentExpression
| ConditionalExpression
| OrExpression
| AndExpression
| EqualityExpression
| ComparisonExpression
| BitwiseOrExpression
| BitwiseXorExpression
| BitwiseAndExpression
| ShiftExpression
| AdditiveExpression
| MultiplicativeExpression
| ExponentiationExpression
| PostfixExpression
| PrefixExpression
| FunctionCallExpression
| MemberAccessExpression
| IndexAccessExpression
| NewExpression
| TupleExpression
| TypeExpression (* Introduced in 0.5.3 *)
| ArrayExpression
| HexNumberExpression
| DecimalNumberExpression
| StringExpression
| ElementaryType
| PAYABLE_KEYWORD (* Introduced in 0.6.0 *)
| TRUE_KEYWORD
| FALSE_KEYWORD
| IDENTIFIER;
+
Expression = AssignmentExpression
| ConditionalExpression
| OrExpression
| AndExpression
| EqualityExpression
| ComparisonExpression
| BitwiseOrExpression
| BitwiseXorExpression
| BitwiseAndExpression
| ShiftExpression
| AdditiveExpression
| MultiplicativeExpression
| ExponentiationExpression
| PostfixExpression
| PrefixExpression
| FunctionCallExpression
| CallOptionsExpression
| MemberAccessExpression
| IndexAccessExpression
| NewExpression
| TupleExpression
| TypeExpression (* Introduced in 0.5.3 *)
| ArrayExpression
| HexNumberExpression
| DecimalNumberExpression
| StringExpression
| ElementaryType
| PAYABLE_KEYWORD (* Introduced in 0.6.0 *)
| TRUE_KEYWORD
| FALSE_KEYWORD
| IDENTIFIER;
```{ .ebnf #MemberAccess } diff --git a/crates/solidity/outputs/spec/generated/public/05-expressions/02-function-calls.md b/crates/solidity/outputs/spec/generated/public/05-expressions/02-function-calls.md index c204852e94..54916576bc 100644 --- a/crates/solidity/outputs/spec/generated/public/05-expressions/02-function-calls.md +++ b/crates/solidity/outputs/spec/generated/public/05-expressions/02-function-calls.md @@ -4,12 +4,6 @@ ## Syntax -```{ .ebnf #FunctionCallOptions } - -``` - -
(* Introduced in 0.6.2 *)
FunctionCallOptions = NamedArgumentGroups (* Introduced in 0.6.2 and deprecated in 0.8.0. *)
| NamedArgumentGroup; (* Introduced in 0.8.0 *)
- ```{ .ebnf #ArgumentsDeclaration } ``` @@ -34,12 +28,6 @@
NamedArgumentsDeclaration = OPEN_PAREN
NamedArgumentGroup?
CLOSE_PAREN;
-```{ .ebnf #NamedArgumentGroups } - -``` - -
(* Introduced in 0.6.2 and deprecated in 0.8.0. *)
NamedArgumentGroups = NamedArgumentGroup+;
- ```{ .ebnf #NamedArgumentGroup } ``` @@ -52,6 +40,12 @@
NamedArguments = (NamedArgument (COMMA NamedArgument)*)?;
+```{ .ebnf #CallOptions } + +``` + +
(* Introduced in 0.6.2 *)
CallOptions = NamedArgument (COMMA NamedArgument)*;
+ ```{ .ebnf #NamedArgument } ``` diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.6.2-success.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.6.2-success.yml index 1a1e50058d..a09ea50f07 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.6.2-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.6.2-success.yml @@ -105,25 +105,24 @@ Tree: - (leading_trivia꞉ Whitespace): " " # (222..223) - (equal꞉ Equal): "=" # (223..224) - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # ' recipient.call{ value: amount }("")' (224..260) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " recipient.call" (224..239) - - (operand꞉ Expression): # " recipient" (224..234) - - (leading_trivia꞉ Whitespace): " " # (224..225) - - (variant꞉ Identifier): "recipient" # (225..234) - - (period꞉ Period): "." # (234..235) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (235..239) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroups): # "{ value: amount }" (239..256) - - (item꞉ NamedArgumentGroup): # "{ value: amount }" (239..256) - - (open_brace꞉ OpenBrace): "{" # (239..240) - - (arguments꞉ NamedArguments): # " value: amount" (240..254) - - (item꞉ NamedArgument): # " value: amount" (240..254) - - (leading_trivia꞉ Whitespace): " " # (240..241) - - (name꞉ Identifier): "value" # (241..246) - - (colon꞉ Colon): ":" # (246..247) - - (value꞉ Expression): # " amount" (247..254) - - (leading_trivia꞉ Whitespace): " " # (247..248) - - (variant꞉ Identifier): "amount" # (248..254) - - (leading_trivia꞉ Whitespace): " " # (254..255) - - (close_brace꞉ CloseBrace): "}" # (255..256) + - (operand꞉ Expression) ► (variant꞉ CallOptionsExpression): # " recipient.call{ value: amount }" (224..256) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " recipient.call" (224..239) + - (operand꞉ Expression): # " recipient" (224..234) + - (leading_trivia꞉ Whitespace): " " # (224..225) + - (variant꞉ Identifier): "recipient" # (225..234) + - (period꞉ Period): "." # (234..235) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (235..239) + - (open_brace꞉ OpenBrace): "{" # (239..240) + - (options꞉ CallOptions): # " value: amount" (240..254) + - (item꞉ NamedArgument): # " value: amount" (240..254) + - (leading_trivia꞉ Whitespace): " " # (240..241) + - (name꞉ Identifier): "value" # (241..246) + - (colon꞉ Colon): ":" # (246..247) + - (value꞉ Expression): # " amount" (247..254) + - (leading_trivia꞉ Whitespace): " " # (247..248) + - (variant꞉ Identifier): "amount" # (248..254) + - (leading_trivia꞉ Whitespace): " " # (254..255) + - (close_brace꞉ CloseBrace): "}" # (255..256) - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # '("")' (256..260) - (open_paren꞉ OpenParen): "(" # (256..257) - (arguments꞉ PositionalArguments): # '""' (257..259) diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.8.0-success.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.8.0-success.yml deleted file mode 100644 index 2cdfca46d0..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/function_multiple_delimiters/generated/0.8.0-success.yml +++ /dev/null @@ -1,155 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ // SPDX-License-Identifier: MIT │ 0..31 - 2 │ contract ABC { │ 32..46 - 3 │ function sendValue(address payable recipient, uint256 amount) internal { │ 47..121 - 4 │ require(address(this).balance >= amount, "Address: insufficient balance"); │ 122..200 - 5 │ │ 201..201 - 6 │ (bool success, ) = recipient.call{ value: amount }(""); │ 202..261 - 7 │ require(success, "Address: unable to send value, recipient may have reverted"); │ 262..345 - 8 │ } │ 346..349 - 9 │ } │ 350..351 - -Errors: [] - -Tree: - - (ContractDefinition): # "// SPDX-License-Identifier: MIT\ncontract ABC {\n f..." (0..352) - - (leading_trivia꞉ SingleLineComment): "// SPDX-License-Identifier: MIT" # (0..31) - - (leading_trivia꞉ EndOfLine): "\n" # (31..32) - - (contract_keyword꞉ ContractKeyword): "contract" # (32..40) - - (leading_trivia꞉ Whitespace): " " # (40..41) - - (name꞉ Identifier): "ABC" # (41..44) - - (leading_trivia꞉ Whitespace): " " # (44..45) - - (open_brace꞉ OpenBrace): "{" # (45..46) - - (trailing_trivia꞉ EndOfLine): "\n" # (46..47) - - (members꞉ ContractMembers): # " function sendValue(address payable recipient, ui..." (47..350) - - (item꞉ ContractMember) ► (variant꞉ FunctionDefinition): # " function sendValue(address payable recipient, ui..." (47..350) - - (leading_trivia꞉ Whitespace): " " # (47..49) - - (function_keyword꞉ FunctionKeyword): "function" # (49..57) - - (name꞉ FunctionName): # " sendValue" (57..67) - - (leading_trivia꞉ Whitespace): " " # (57..58) - - (variant꞉ Identifier): "sendValue" # (58..67) - - (parameters꞉ ParametersDeclaration): # "(address payable recipient, uint256 amount)" (67..110) - - (open_paren꞉ OpenParen): "(" # (67..68) - - (parameters꞉ Parameters): # "address payable recipient, uint256 amount" (68..109) - - (item꞉ Parameter): # "address payable recipient" (68..93) - - (type_name꞉ TypeName) ► (variant꞉ ElementaryType) ► (variant꞉ AddressType): # "address payable" (68..83) - - (address_keyword꞉ AddressKeyword): "address" # (68..75) - - (leading_trivia꞉ Whitespace): " " # (75..76) - - (payable_keyword꞉ PayableKeyword): "payable" # (76..83) - - (leading_trivia꞉ Whitespace): " " # (83..84) - - (name꞉ Identifier): "recipient" # (84..93) - - (separator꞉ Comma): "," # (93..94) - - (item꞉ Parameter): # " uint256 amount" (94..109) - - (type_name꞉ TypeName) ► (variant꞉ ElementaryType): # " uint256" (94..102) - - (leading_trivia꞉ Whitespace): " " # (94..95) - - (variant꞉ UintKeyword): "uint256" # (95..102) - - (leading_trivia꞉ Whitespace): " " # (102..103) - - (name꞉ Identifier): "amount" # (103..109) - - (close_paren꞉ CloseParen): ")" # (109..110) - - (attributes꞉ FunctionAttributes): # " internal" (110..119) - - (item꞉ FunctionAttribute): # " internal" (110..119) - - (leading_trivia꞉ Whitespace): " " # (110..111) - - (variant꞉ InternalKeyword): "internal" # (111..119) - - (body꞉ FunctionBody) ► (variant꞉ Block): # ' {\n require(address(this).balance >= amount, "A...' (119..350) - - (leading_trivia꞉ Whitespace): " " # (119..120) - - (open_brace꞉ OpenBrace): "{" # (120..121) - - (trailing_trivia꞉ EndOfLine): "\n" # (121..122) - - (statements꞉ Statements): # ' require(address(this).balance >= amount, "Addr...' (122..346) - - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # ' require(address(this).balance >= amount, "Addr...' (122..201) - - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # ' require(address(this).balance >= amount, "Addr...' (122..199) - - (operand꞉ Expression): # " require" (122..133) - - (leading_trivia꞉ Whitespace): " " # (122..126) - - (variant꞉ Identifier): "require" # (126..133) - - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # '(address(this).balance >= amount, "Address: insuff...' (133..199) - - (open_paren꞉ OpenParen): "(" # (133..134) - - (arguments꞉ PositionalArguments): # 'address(this).balance >= amount, "Address: insuffi...' (134..198) - - (item꞉ Expression) ► (variant꞉ ComparisonExpression): # "address(this).balance >= amount" (134..165) - - (left_operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # "address(this).balance" (134..155) - - (operand꞉ Expression) ► (variant꞉ FunctionCallExpression): # "address(this)" (134..147) - - (operand꞉ Expression) ► (variant꞉ ElementaryType) ► (variant꞉ AddressType) ► (address_keyword꞉ AddressKeyword): "address" # (134..141) - - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "(this)" (141..147) - - (open_paren꞉ OpenParen): "(" # (141..142) - - (arguments꞉ PositionalArguments): # "this" (142..146) - - (item꞉ Expression) ► (variant꞉ Identifier): "this" # (142..146) - - (close_paren꞉ CloseParen): ")" # (146..147) - - (period꞉ Period): "." # (147..148) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "balance" # (148..155) - - (leading_trivia꞉ Whitespace): " " # (155..156) - - (operator꞉ GreaterThanEqual): ">=" # (156..158) - - (right_operand꞉ Expression): # " amount" (158..165) - - (leading_trivia꞉ Whitespace): " " # (158..159) - - (variant꞉ Identifier): "amount" # (159..165) - - (separator꞉ Comma): "," # (165..166) - - (item꞉ Expression) ► (variant꞉ StringExpression) ► (variant꞉ StringLiterals): # ' "Address: insufficient balance"' (166..198) - - (item꞉ StringLiteral): # ' "Address: insufficient balance"' (166..198) - - (leading_trivia꞉ Whitespace): " " # (166..167) - - (variant꞉ DoubleQuotedStringLiteral): '"Address: insufficient balance"' # (167..198) - - (close_paren꞉ CloseParen): ")" # (198..199) - - (semicolon꞉ Semicolon): ";" # (199..200) - - (trailing_trivia꞉ EndOfLine): "\n" # (200..201) - - (item꞉ Statement) ► (variant꞉ TupleDeconstructionStatement): # "\n (bool success, ) = recipient.call{ value: amo..." (201..262) - - (leading_trivia꞉ EndOfLine): "\n" # (201..202) - - (leading_trivia꞉ Whitespace): " " # (202..206) - - (open_paren꞉ OpenParen): "(" # (206..207) - - (elements꞉ TupleDeconstructionElements): # "bool success," (207..220) - - (item꞉ TupleDeconstructionElement) ► (member꞉ TupleMember) ► (variant꞉ TypedTupleMember): # "bool success" (207..219) - - (type_name꞉ TypeName) ► (variant꞉ ElementaryType) ► (variant꞉ BoolKeyword): "bool" # (207..211) - - (leading_trivia꞉ Whitespace): " " # (211..212) - - (name꞉ Identifier): "success" # (212..219) - - (separator꞉ Comma): "," # (219..220) - - (item꞉ TupleDeconstructionElement): [] # (220..220) - - (leading_trivia꞉ Whitespace): " " # (220..221) - - (close_paren꞉ CloseParen): ")" # (221..222) - - (leading_trivia꞉ Whitespace): " " # (222..223) - - (equal꞉ Equal): "=" # (223..224) - - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # ' recipient.call{ value: amount }("")' (224..260) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " recipient.call" (224..239) - - (operand꞉ Expression): # " recipient" (224..234) - - (leading_trivia꞉ Whitespace): " " # (224..225) - - (variant꞉ Identifier): "recipient" # (225..234) - - (period꞉ Period): "." # (234..235) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (235..239) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroup): # "{ value: amount }" (239..256) - - (open_brace꞉ OpenBrace): "{" # (239..240) - - (arguments꞉ NamedArguments): # " value: amount" (240..254) - - (item꞉ NamedArgument): # " value: amount" (240..254) - - (leading_trivia꞉ Whitespace): " " # (240..241) - - (name꞉ Identifier): "value" # (241..246) - - (colon꞉ Colon): ":" # (246..247) - - (value꞉ Expression): # " amount" (247..254) - - (leading_trivia꞉ Whitespace): " " # (247..248) - - (variant꞉ Identifier): "amount" # (248..254) - - (leading_trivia꞉ Whitespace): " " # (254..255) - - (close_brace꞉ CloseBrace): "}" # (255..256) - - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # '("")' (256..260) - - (open_paren꞉ OpenParen): "(" # (256..257) - - (arguments꞉ PositionalArguments): # '""' (257..259) - - (item꞉ Expression) ► (variant꞉ StringExpression) ► (variant꞉ StringLiterals): # '""' (257..259) - - (item꞉ StringLiteral) ► (variant꞉ DoubleQuotedStringLiteral): '""' # (257..259) - - (close_paren꞉ CloseParen): ")" # (259..260) - - (semicolon꞉ Semicolon): ";" # (260..261) - - (trailing_trivia꞉ EndOfLine): "\n" # (261..262) - - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # ' require(success, "Address: unable to send valu...' (262..346) - - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # ' require(success, "Address: unable to send valu...' (262..344) - - (operand꞉ Expression): # " require" (262..273) - - (leading_trivia꞉ Whitespace): " " # (262..266) - - (variant꞉ Identifier): "require" # (266..273) - - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # '(success, "Address: unable to send value, recipien...' (273..344) - - (open_paren꞉ OpenParen): "(" # (273..274) - - (arguments꞉ PositionalArguments): # 'success, "Address: unable to send value, recipient...' (274..343) - - (item꞉ Expression) ► (variant꞉ Identifier): "success" # (274..281) - - (separator꞉ Comma): "," # (281..282) - - (item꞉ Expression) ► (variant꞉ StringExpression) ► (variant꞉ StringLiterals): # ' "Address: unable to send value, recipient may hav...' (282..343) - - (item꞉ StringLiteral): # ' "Address: unable to send value, recipient may hav...' (282..343) - - (leading_trivia꞉ Whitespace): " " # (282..283) - - (variant꞉ DoubleQuotedStringLiteral): '"Address: unable to send value, recipient may have...' # (283..343) - - (close_paren꞉ CloseParen): ")" # (343..344) - - (semicolon꞉ Semicolon): ";" # (344..345) - - (trailing_trivia꞉ EndOfLine): "\n" # (345..346) - - (leading_trivia꞉ Whitespace): " " # (346..348) - - (close_brace꞉ CloseBrace): "}" # (348..349) - - (trailing_trivia꞉ EndOfLine): "\n" # (349..350) - - (close_brace꞉ CloseBrace): "}" # (350..351) - - (trailing_trivia꞉ EndOfLine): "\n" # (351..352) diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.6.2-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.6.2-failure.yml index d1fa18b8e7..e6c75ef472 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.6.2-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.6.2-failure.yml @@ -24,20 +24,20 @@ Errors: # 12 total │ ╰───────────────────── Error occurred here. ───╯ - > - Error: Expected CloseBrace or Identifier. - ╭─[crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/input.sol:2:19] + Error: Expected Semicolon. + ╭─[crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/input.sol:2:18] │ 2 │ msg.sender.call{do: 1, arg: 1 }(); - │ ───────┬────── - │ ╰──────── Error occurred here. + │ ─────────┬──────── + │ ╰────────── Error occurred here. ───╯ - > - Error: Expected CloseBrace or Identifier. - ╭─[crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/input.sol:3:19] + Error: Expected Semicolon. + ╭─[crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/input.sol:3:18] │ 3 │ msg.sender.call{, empty: 1, parse: 2 }(); - │ ──────────┬────────── - │ ╰──────────── Error occurred here. + │ ────────────┬──────────── + │ ╰────────────── Error occurred here. ───╯ - > Error: Expected AddressKeyword or BoolKeyword or ByteKeyword or BytesKeyword or DecimalLiteral or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or FalseKeyword or FixedKeyword or HexLiteral or Identifier or IntKeyword or NewKeyword or OpenBracket or OpenParen or PayableKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or TrueKeyword or TypeKeyword or UfixedKeyword or UintKeyword. @@ -146,87 +146,66 @@ Tree: - (trailing_trivia꞉ EndOfLine): "\n" # (85..86) - (statements꞉ Statements): # " msg.sender.call{do: 1, arg: 1 }();\n msg.sender...." (86..306) - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " msg.sender.call{do: 1, arg: 1 }();\n" (86..123) - - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " msg.sender.call{do: 1, arg: 1 }()" (86..121) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (86..103) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (86..98) - - (operand꞉ Expression): # " msg" (86..91) - - (leading_trivia꞉ Whitespace): " " # (86..88) - - (variant꞉ Identifier): "msg" # (88..91) - - (period꞉ Period): "." # (91..92) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (92..98) - - (period꞉ Period): "." # (98..99) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (99..103) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroups): # "{do: 1, arg: 1 }" (103..119) - - (item꞉ NamedArgumentGroup): # "{do: 1, arg: 1 }" (103..119) - - (open_brace꞉ OpenBrace): "{" # (103..104) - - (arguments꞉ NamedArguments): [] # (104..104) - - (SKIPPED): "do: 1, arg: 1 " # (104..118) - - (close_brace꞉ CloseBrace): "}" # (118..119) - - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (119..121) - - (open_paren꞉ OpenParen): "(" # (119..120) - - (arguments꞉ PositionalArguments): [] # (120..120) - - (close_paren꞉ CloseParen): ")" # (120..121) + - (expression꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (86..103) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (86..98) + - (operand꞉ Expression): # " msg" (86..91) + - (leading_trivia꞉ Whitespace): " " # (86..88) + - (variant꞉ Identifier): "msg" # (88..91) + - (period꞉ Period): "." # (91..92) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (92..98) + - (period꞉ Period): "." # (98..99) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (99..103) + - (SKIPPED): "{do: 1, arg: 1 }()" # (103..121) - (semicolon꞉ Semicolon): ";" # (121..122) - (trailing_trivia꞉ EndOfLine): "\n" # (122..123) - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " msg.sender.call{, empty: 1, parse: 2 }();\n" (123..167) - - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " msg.sender.call{, empty: 1, parse: 2 }()" (123..165) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (123..140) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (123..135) - - (operand꞉ Expression): # " msg" (123..128) - - (leading_trivia꞉ Whitespace): " " # (123..125) - - (variant꞉ Identifier): "msg" # (125..128) - - (period꞉ Period): "." # (128..129) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (129..135) - - (period꞉ Period): "." # (135..136) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (136..140) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroups): # "{, empty: 1, parse: 2 }" (140..163) - - (item꞉ NamedArgumentGroup): # "{, empty: 1, parse: 2 }" (140..163) - - (open_brace꞉ OpenBrace): "{" # (140..141) - - (arguments꞉ NamedArguments): [] # (141..141) - - (SKIPPED): ", empty: 1, parse: 2 " # (141..162) - - (close_brace꞉ CloseBrace): "}" # (162..163) - - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (163..165) - - (open_paren꞉ OpenParen): "(" # (163..164) - - (arguments꞉ PositionalArguments): [] # (164..164) - - (close_paren꞉ CloseParen): ")" # (164..165) + - (expression꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (123..140) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (123..135) + - (operand꞉ Expression): # " msg" (123..128) + - (leading_trivia꞉ Whitespace): " " # (123..125) + - (variant꞉ Identifier): "msg" # (125..128) + - (period꞉ Period): "." # (128..129) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (129..135) + - (period꞉ Period): "." # (135..136) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (136..140) + - (SKIPPED): "{, empty: 1, parse: 2 }()" # (140..165) - (semicolon꞉ Semicolon): ";" # (165..166) - (trailing_trivia꞉ EndOfLine): "\n" # (166..167) - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " msg.sender.call{arg: 1, missing_expr: , no_semic..." (167..230) - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " msg.sender.call{arg: 1, missing_expr: , no_semic..." (167..228) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (167..184) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (167..179) - - (operand꞉ Expression): # " msg" (167..172) - - (leading_trivia꞉ Whitespace): " " # (167..169) - - (variant꞉ Identifier): "msg" # (169..172) - - (period꞉ Period): "." # (172..173) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (173..179) - - (period꞉ Period): "." # (179..180) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (180..184) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroups): # "{arg: 1, missing_expr: , no_semicolon, , }" (184..226) - - (item꞉ NamedArgumentGroup): # "{arg: 1, missing_expr: , no_semicolon, , }" (184..226) - - (open_brace꞉ OpenBrace): "{" # (184..185) - - (arguments꞉ NamedArguments): # "arg: 1, missing_expr: , no_semicolon," (185..222) - - (item꞉ NamedArgument): # "arg: 1" (185..191) - - (name꞉ Identifier): "arg" # (185..188) - - (colon꞉ Colon): ":" # (188..189) - - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (189..191) - - (leading_trivia꞉ Whitespace): " " # (189..190) - - (literal꞉ DecimalLiteral): "1" # (190..191) - - (separator꞉ Comma): "," # (191..192) - - (item꞉ NamedArgument): # " missing_expr:" (192..206) - - (leading_trivia꞉ Whitespace): " " # (192..193) - - (name꞉ Identifier): "missing_expr" # (193..205) - - (colon꞉ Colon): ":" # (205..206) - - (SKIPPED): " " # (206..207) - - (Comma): "," # (207..208) - - (item꞉ NamedArgument): # " no_semicolon" (208..221) - - (leading_trivia꞉ Whitespace): " " # (208..209) - - (name꞉ Identifier): "no_semicolon" # (209..221) - - (SKIPPED): "" # (221..221) - - (Comma): "," # (221..222) - - (leading_trivia꞉ Whitespace): " " # (222..223) - - (SKIPPED): ", " # (223..225) - - (close_brace꞉ CloseBrace): "}" # (225..226) + - (operand꞉ Expression) ► (variant꞉ CallOptionsExpression): # " msg.sender.call{arg: 1, missing_expr: , no_semic..." (167..226) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (167..184) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (167..179) + - (operand꞉ Expression): # " msg" (167..172) + - (leading_trivia꞉ Whitespace): " " # (167..169) + - (variant꞉ Identifier): "msg" # (169..172) + - (period꞉ Period): "." # (172..173) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (173..179) + - (period꞉ Period): "." # (179..180) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (180..184) + - (open_brace꞉ OpenBrace): "{" # (184..185) + - (options꞉ CallOptions): # "arg: 1, missing_expr: , no_semicolon," (185..222) + - (item꞉ NamedArgument): # "arg: 1" (185..191) + - (name꞉ Identifier): "arg" # (185..188) + - (colon꞉ Colon): ":" # (188..189) + - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (189..191) + - (leading_trivia꞉ Whitespace): " " # (189..190) + - (literal꞉ DecimalLiteral): "1" # (190..191) + - (separator꞉ Comma): "," # (191..192) + - (item꞉ NamedArgument): # " missing_expr:" (192..206) + - (leading_trivia꞉ Whitespace): " " # (192..193) + - (name꞉ Identifier): "missing_expr" # (193..205) + - (colon꞉ Colon): ":" # (205..206) + - (SKIPPED): " " # (206..207) + - (Comma): "," # (207..208) + - (item꞉ NamedArgument): # " no_semicolon" (208..221) + - (leading_trivia꞉ Whitespace): " " # (208..209) + - (name꞉ Identifier): "no_semicolon" # (209..221) + - (SKIPPED): "" # (221..221) + - (Comma): "," # (221..222) + - (leading_trivia꞉ Whitespace): " " # (222..223) + - (SKIPPED): ", " # (223..225) + - (close_brace꞉ CloseBrace): "}" # (225..226) - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (226..228) - (open_paren꞉ OpenParen): "(" # (226..227) - (arguments꞉ PositionalArguments): [] # (227..227) @@ -235,28 +214,27 @@ Tree: - (trailing_trivia꞉ EndOfLine): "\n" # (229..230) - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " msg.sender.call{arg: 1 unexpected tokens, not: 2..." (230..306) - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " msg.sender.call{arg: 1 unexpected tokens, not: 2..." (230..304) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (230..247) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (230..242) - - (operand꞉ Expression): # " msg" (230..235) - - (leading_trivia꞉ Whitespace): " " # (230..232) - - (variant꞉ Identifier): "msg" # (232..235) - - (period꞉ Period): "." # (235..236) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (236..242) - - (period꞉ Period): "." # (242..243) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (243..247) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroups): # "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." (247..302) - - (item꞉ NamedArgumentGroup): # "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." (247..302) - - (open_brace꞉ OpenBrace): "{" # (247..248) - - (arguments꞉ NamedArguments): # "arg: 1" (248..254) - - (item꞉ NamedArgument): # "arg: 1" (248..254) - - (name꞉ Identifier): "arg" # (248..251) - - (colon꞉ Colon): ":" # (251..252) - - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (252..254) - - (leading_trivia꞉ Whitespace): " " # (252..253) - - (literal꞉ DecimalLiteral): "1" # (253..254) - - (leading_trivia꞉ Whitespace): " " # (254..255) - - (SKIPPED): "unexpected tokens, not: 2, recovered, yet: 3, " # (255..301) - - (close_brace꞉ CloseBrace): "}" # (301..302) + - (operand꞉ Expression) ► (variant꞉ CallOptionsExpression): # " msg.sender.call{arg: 1 unexpected tokens, not: 2..." (230..302) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (230..247) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (230..242) + - (operand꞉ Expression): # " msg" (230..235) + - (leading_trivia꞉ Whitespace): " " # (230..232) + - (variant꞉ Identifier): "msg" # (232..235) + - (period꞉ Period): "." # (235..236) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (236..242) + - (period꞉ Period): "." # (242..243) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (243..247) + - (open_brace꞉ OpenBrace): "{" # (247..248) + - (options꞉ CallOptions): # "arg: 1" (248..254) + - (item꞉ NamedArgument): # "arg: 1" (248..254) + - (name꞉ Identifier): "arg" # (248..251) + - (colon꞉ Colon): ":" # (251..252) + - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (252..254) + - (leading_trivia꞉ Whitespace): " " # (252..253) + - (literal꞉ DecimalLiteral): "1" # (253..254) + - (leading_trivia꞉ Whitespace): " " # (254..255) + - (SKIPPED): "unexpected tokens, not: 2, recovered, yet: 3, " # (255..301) + - (close_brace꞉ CloseBrace): "}" # (301..302) - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (302..304) - (open_paren꞉ OpenParen): "(" # (302..303) - (arguments꞉ PositionalArguments): [] # (303..303) diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.7.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.7.0-failure.yml index 4db10b2404..b3b56f6370 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.7.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.7.0-failure.yml @@ -24,20 +24,20 @@ Errors: # 12 total │ ╰───────────────────── Error occurred here. ───╯ - > - Error: Expected CloseBrace or Identifier. - ╭─[crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/input.sol:2:19] + Error: Expected Semicolon. + ╭─[crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/input.sol:2:18] │ 2 │ msg.sender.call{do: 1, arg: 1 }(); - │ ───────┬────── - │ ╰──────── Error occurred here. + │ ─────────┬──────── + │ ╰────────── Error occurred here. ───╯ - > - Error: Expected CloseBrace or Identifier. - ╭─[crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/input.sol:3:19] + Error: Expected Semicolon. + ╭─[crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/input.sol:3:18] │ 3 │ msg.sender.call{, empty: 1, parse: 2 }(); - │ ──────────┬────────── - │ ╰──────────── Error occurred here. + │ ────────────┬──────────── + │ ╰────────────── Error occurred here. ───╯ - > Error: Expected AddressKeyword or BoolKeyword or ByteKeyword or BytesKeyword or DecimalLiteral or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or DoubleQuotedUnicodeStringLiteral or FalseKeyword or FixedKeyword or HexLiteral or Identifier or IntKeyword or NewKeyword or OpenBracket or OpenParen or PayableKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or SingleQuotedUnicodeStringLiteral or StringKeyword or TrueKeyword or TypeKeyword or UfixedKeyword or UintKeyword. @@ -146,87 +146,66 @@ Tree: - (trailing_trivia꞉ EndOfLine): "\n" # (85..86) - (statements꞉ Statements): # " msg.sender.call{do: 1, arg: 1 }();\n msg.sender...." (86..306) - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " msg.sender.call{do: 1, arg: 1 }();\n" (86..123) - - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " msg.sender.call{do: 1, arg: 1 }()" (86..121) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (86..103) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (86..98) - - (operand꞉ Expression): # " msg" (86..91) - - (leading_trivia꞉ Whitespace): " " # (86..88) - - (variant꞉ Identifier): "msg" # (88..91) - - (period꞉ Period): "." # (91..92) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (92..98) - - (period꞉ Period): "." # (98..99) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (99..103) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroups): # "{do: 1, arg: 1 }" (103..119) - - (item꞉ NamedArgumentGroup): # "{do: 1, arg: 1 }" (103..119) - - (open_brace꞉ OpenBrace): "{" # (103..104) - - (arguments꞉ NamedArguments): [] # (104..104) - - (SKIPPED): "do: 1, arg: 1 " # (104..118) - - (close_brace꞉ CloseBrace): "}" # (118..119) - - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (119..121) - - (open_paren꞉ OpenParen): "(" # (119..120) - - (arguments꞉ PositionalArguments): [] # (120..120) - - (close_paren꞉ CloseParen): ")" # (120..121) + - (expression꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (86..103) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (86..98) + - (operand꞉ Expression): # " msg" (86..91) + - (leading_trivia꞉ Whitespace): " " # (86..88) + - (variant꞉ Identifier): "msg" # (88..91) + - (period꞉ Period): "." # (91..92) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (92..98) + - (period꞉ Period): "." # (98..99) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (99..103) + - (SKIPPED): "{do: 1, arg: 1 }()" # (103..121) - (semicolon꞉ Semicolon): ";" # (121..122) - (trailing_trivia꞉ EndOfLine): "\n" # (122..123) - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " msg.sender.call{, empty: 1, parse: 2 }();\n" (123..167) - - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " msg.sender.call{, empty: 1, parse: 2 }()" (123..165) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (123..140) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (123..135) - - (operand꞉ Expression): # " msg" (123..128) - - (leading_trivia꞉ Whitespace): " " # (123..125) - - (variant꞉ Identifier): "msg" # (125..128) - - (period꞉ Period): "." # (128..129) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (129..135) - - (period꞉ Period): "." # (135..136) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (136..140) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroups): # "{, empty: 1, parse: 2 }" (140..163) - - (item꞉ NamedArgumentGroup): # "{, empty: 1, parse: 2 }" (140..163) - - (open_brace꞉ OpenBrace): "{" # (140..141) - - (arguments꞉ NamedArguments): [] # (141..141) - - (SKIPPED): ", empty: 1, parse: 2 " # (141..162) - - (close_brace꞉ CloseBrace): "}" # (162..163) - - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (163..165) - - (open_paren꞉ OpenParen): "(" # (163..164) - - (arguments꞉ PositionalArguments): [] # (164..164) - - (close_paren꞉ CloseParen): ")" # (164..165) + - (expression꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (123..140) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (123..135) + - (operand꞉ Expression): # " msg" (123..128) + - (leading_trivia꞉ Whitespace): " " # (123..125) + - (variant꞉ Identifier): "msg" # (125..128) + - (period꞉ Period): "." # (128..129) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (129..135) + - (period꞉ Period): "." # (135..136) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (136..140) + - (SKIPPED): "{, empty: 1, parse: 2 }()" # (140..165) - (semicolon꞉ Semicolon): ";" # (165..166) - (trailing_trivia꞉ EndOfLine): "\n" # (166..167) - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " msg.sender.call{arg: 1, missing_expr: , no_semic..." (167..230) - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " msg.sender.call{arg: 1, missing_expr: , no_semic..." (167..228) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (167..184) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (167..179) - - (operand꞉ Expression): # " msg" (167..172) - - (leading_trivia꞉ Whitespace): " " # (167..169) - - (variant꞉ Identifier): "msg" # (169..172) - - (period꞉ Period): "." # (172..173) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (173..179) - - (period꞉ Period): "." # (179..180) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (180..184) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroups): # "{arg: 1, missing_expr: , no_semicolon, , }" (184..226) - - (item꞉ NamedArgumentGroup): # "{arg: 1, missing_expr: , no_semicolon, , }" (184..226) - - (open_brace꞉ OpenBrace): "{" # (184..185) - - (arguments꞉ NamedArguments): # "arg: 1, missing_expr: , no_semicolon," (185..222) - - (item꞉ NamedArgument): # "arg: 1" (185..191) - - (name꞉ Identifier): "arg" # (185..188) - - (colon꞉ Colon): ":" # (188..189) - - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (189..191) - - (leading_trivia꞉ Whitespace): " " # (189..190) - - (literal꞉ DecimalLiteral): "1" # (190..191) - - (separator꞉ Comma): "," # (191..192) - - (item꞉ NamedArgument): # " missing_expr:" (192..206) - - (leading_trivia꞉ Whitespace): " " # (192..193) - - (name꞉ Identifier): "missing_expr" # (193..205) - - (colon꞉ Colon): ":" # (205..206) - - (SKIPPED): " " # (206..207) - - (Comma): "," # (207..208) - - (item꞉ NamedArgument): # " no_semicolon" (208..221) - - (leading_trivia꞉ Whitespace): " " # (208..209) - - (name꞉ Identifier): "no_semicolon" # (209..221) - - (SKIPPED): "" # (221..221) - - (Comma): "," # (221..222) - - (leading_trivia꞉ Whitespace): " " # (222..223) - - (SKIPPED): ", " # (223..225) - - (close_brace꞉ CloseBrace): "}" # (225..226) + - (operand꞉ Expression) ► (variant꞉ CallOptionsExpression): # " msg.sender.call{arg: 1, missing_expr: , no_semic..." (167..226) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (167..184) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (167..179) + - (operand꞉ Expression): # " msg" (167..172) + - (leading_trivia꞉ Whitespace): " " # (167..169) + - (variant꞉ Identifier): "msg" # (169..172) + - (period꞉ Period): "." # (172..173) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (173..179) + - (period꞉ Period): "." # (179..180) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (180..184) + - (open_brace꞉ OpenBrace): "{" # (184..185) + - (options꞉ CallOptions): # "arg: 1, missing_expr: , no_semicolon," (185..222) + - (item꞉ NamedArgument): # "arg: 1" (185..191) + - (name꞉ Identifier): "arg" # (185..188) + - (colon꞉ Colon): ":" # (188..189) + - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (189..191) + - (leading_trivia꞉ Whitespace): " " # (189..190) + - (literal꞉ DecimalLiteral): "1" # (190..191) + - (separator꞉ Comma): "," # (191..192) + - (item꞉ NamedArgument): # " missing_expr:" (192..206) + - (leading_trivia꞉ Whitespace): " " # (192..193) + - (name꞉ Identifier): "missing_expr" # (193..205) + - (colon꞉ Colon): ":" # (205..206) + - (SKIPPED): " " # (206..207) + - (Comma): "," # (207..208) + - (item꞉ NamedArgument): # " no_semicolon" (208..221) + - (leading_trivia꞉ Whitespace): " " # (208..209) + - (name꞉ Identifier): "no_semicolon" # (209..221) + - (SKIPPED): "" # (221..221) + - (Comma): "," # (221..222) + - (leading_trivia꞉ Whitespace): " " # (222..223) + - (SKIPPED): ", " # (223..225) + - (close_brace꞉ CloseBrace): "}" # (225..226) - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (226..228) - (open_paren꞉ OpenParen): "(" # (226..227) - (arguments꞉ PositionalArguments): [] # (227..227) @@ -235,28 +214,27 @@ Tree: - (trailing_trivia꞉ EndOfLine): "\n" # (229..230) - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " msg.sender.call{arg: 1 unexpected tokens, not: 2..." (230..306) - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " msg.sender.call{arg: 1 unexpected tokens, not: 2..." (230..304) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (230..247) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (230..242) - - (operand꞉ Expression): # " msg" (230..235) - - (leading_trivia꞉ Whitespace): " " # (230..232) - - (variant꞉ Identifier): "msg" # (232..235) - - (period꞉ Period): "." # (235..236) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (236..242) - - (period꞉ Period): "." # (242..243) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (243..247) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroups): # "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." (247..302) - - (item꞉ NamedArgumentGroup): # "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." (247..302) - - (open_brace꞉ OpenBrace): "{" # (247..248) - - (arguments꞉ NamedArguments): # "arg: 1" (248..254) - - (item꞉ NamedArgument): # "arg: 1" (248..254) - - (name꞉ Identifier): "arg" # (248..251) - - (colon꞉ Colon): ":" # (251..252) - - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (252..254) - - (leading_trivia꞉ Whitespace): " " # (252..253) - - (literal꞉ DecimalLiteral): "1" # (253..254) - - (leading_trivia꞉ Whitespace): " " # (254..255) - - (SKIPPED): "unexpected tokens, not: 2, recovered, yet: 3, " # (255..301) - - (close_brace꞉ CloseBrace): "}" # (301..302) + - (operand꞉ Expression) ► (variant꞉ CallOptionsExpression): # " msg.sender.call{arg: 1 unexpected tokens, not: 2..." (230..302) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (230..247) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (230..242) + - (operand꞉ Expression): # " msg" (230..235) + - (leading_trivia꞉ Whitespace): " " # (230..232) + - (variant꞉ Identifier): "msg" # (232..235) + - (period꞉ Period): "." # (235..236) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (236..242) + - (period꞉ Period): "." # (242..243) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (243..247) + - (open_brace꞉ OpenBrace): "{" # (247..248) + - (options꞉ CallOptions): # "arg: 1" (248..254) + - (item꞉ NamedArgument): # "arg: 1" (248..254) + - (name꞉ Identifier): "arg" # (248..251) + - (colon꞉ Colon): ":" # (251..252) + - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (252..254) + - (leading_trivia꞉ Whitespace): " " # (252..253) + - (literal꞉ DecimalLiteral): "1" # (253..254) + - (leading_trivia꞉ Whitespace): " " # (254..255) + - (SKIPPED): "unexpected tokens, not: 2, recovered, yet: 3, " # (255..301) + - (close_brace꞉ CloseBrace): "}" # (301..302) - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (302..304) - (open_paren꞉ OpenParen): "(" # (302..303) - (arguments꞉ PositionalArguments): [] # (303..303) diff --git a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.8.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.8.0-failure.yml index c7d724ec07..0a3eba3530 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.8.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/generated/0.8.0-failure.yml @@ -24,20 +24,20 @@ Errors: # 12 total │ ╰───────────────────── Error occurred here. ───╯ - > - Error: Expected CloseBrace or Identifier. - ╭─[crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/input.sol:2:19] + Error: Expected Semicolon. + ╭─[crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/input.sol:2:18] │ 2 │ msg.sender.call{do: 1, arg: 1 }(); - │ ───────┬────── - │ ╰──────── Error occurred here. + │ ─────────┬──────── + │ ╰────────── Error occurred here. ───╯ - > - Error: Expected CloseBrace or Identifier. - ╭─[crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/input.sol:3:19] + Error: Expected Semicolon. + ╭─[crates/solidity/testing/snapshots/cst_output/ContractMembers/separated_recovery/input.sol:3:18] │ 3 │ msg.sender.call{, empty: 1, parse: 2 }(); - │ ──────────┬────────── - │ ╰──────────── Error occurred here. + │ ────────────┬──────────── + │ ╰────────────── Error occurred here. ───╯ - > Error: Expected AddressKeyword or BoolKeyword or BytesKeyword or DecimalLiteral or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or DoubleQuotedUnicodeStringLiteral or FalseKeyword or FixedKeyword or HexLiteral or Identifier or IntKeyword or NewKeyword or OpenBracket or OpenParen or PayableKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or SingleQuotedUnicodeStringLiteral or StringKeyword or TrueKeyword or TypeKeyword or UfixedKeyword or UintKeyword. @@ -146,63 +146,45 @@ Tree: - (trailing_trivia꞉ EndOfLine): "\n" # (85..86) - (statements꞉ Statements): # " msg.sender.call{do: 1, arg: 1 }();\n msg.sender...." (86..306) - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " msg.sender.call{do: 1, arg: 1 }();\n" (86..123) - - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " msg.sender.call{do: 1, arg: 1 }()" (86..121) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (86..103) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (86..98) - - (operand꞉ Expression): # " msg" (86..91) - - (leading_trivia꞉ Whitespace): " " # (86..88) - - (variant꞉ Identifier): "msg" # (88..91) - - (period꞉ Period): "." # (91..92) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (92..98) - - (period꞉ Period): "." # (98..99) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (99..103) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroup): # "{do: 1, arg: 1 }" (103..119) - - (open_brace꞉ OpenBrace): "{" # (103..104) - - (arguments꞉ NamedArguments): [] # (104..104) - - (SKIPPED): "do: 1, arg: 1 " # (104..118) - - (close_brace꞉ CloseBrace): "}" # (118..119) - - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (119..121) - - (open_paren꞉ OpenParen): "(" # (119..120) - - (arguments꞉ PositionalArguments): [] # (120..120) - - (close_paren꞉ CloseParen): ")" # (120..121) + - (expression꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (86..103) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (86..98) + - (operand꞉ Expression): # " msg" (86..91) + - (leading_trivia꞉ Whitespace): " " # (86..88) + - (variant꞉ Identifier): "msg" # (88..91) + - (period꞉ Period): "." # (91..92) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (92..98) + - (period꞉ Period): "." # (98..99) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (99..103) + - (SKIPPED): "{do: 1, arg: 1 }()" # (103..121) - (semicolon꞉ Semicolon): ";" # (121..122) - (trailing_trivia꞉ EndOfLine): "\n" # (122..123) - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " msg.sender.call{, empty: 1, parse: 2 }();\n" (123..167) - - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " msg.sender.call{, empty: 1, parse: 2 }()" (123..165) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (123..140) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (123..135) - - (operand꞉ Expression): # " msg" (123..128) - - (leading_trivia꞉ Whitespace): " " # (123..125) - - (variant꞉ Identifier): "msg" # (125..128) - - (period꞉ Period): "." # (128..129) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (129..135) - - (period꞉ Period): "." # (135..136) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (136..140) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroup): # "{, empty: 1, parse: 2 }" (140..163) - - (open_brace꞉ OpenBrace): "{" # (140..141) - - (arguments꞉ NamedArguments): [] # (141..141) - - (SKIPPED): ", empty: 1, parse: 2 " # (141..162) - - (close_brace꞉ CloseBrace): "}" # (162..163) - - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (163..165) - - (open_paren꞉ OpenParen): "(" # (163..164) - - (arguments꞉ PositionalArguments): [] # (164..164) - - (close_paren꞉ CloseParen): ")" # (164..165) + - (expression꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (123..140) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (123..135) + - (operand꞉ Expression): # " msg" (123..128) + - (leading_trivia꞉ Whitespace): " " # (123..125) + - (variant꞉ Identifier): "msg" # (125..128) + - (period꞉ Period): "." # (128..129) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (129..135) + - (period꞉ Period): "." # (135..136) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (136..140) + - (SKIPPED): "{, empty: 1, parse: 2 }()" # (140..165) - (semicolon꞉ Semicolon): ";" # (165..166) - (trailing_trivia꞉ EndOfLine): "\n" # (166..167) - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " msg.sender.call{arg: 1, missing_expr: , no_semic..." (167..230) - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " msg.sender.call{arg: 1, missing_expr: , no_semic..." (167..228) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (167..184) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (167..179) - - (operand꞉ Expression): # " msg" (167..172) - - (leading_trivia꞉ Whitespace): " " # (167..169) - - (variant꞉ Identifier): "msg" # (169..172) - - (period꞉ Period): "." # (172..173) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (173..179) - - (period꞉ Period): "." # (179..180) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (180..184) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroup): # "{arg: 1, missing_expr: , no_semicolon, , }" (184..226) + - (operand꞉ Expression) ► (variant꞉ CallOptionsExpression): # " msg.sender.call{arg: 1, missing_expr: , no_semic..." (167..226) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (167..184) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (167..179) + - (operand꞉ Expression): # " msg" (167..172) + - (leading_trivia꞉ Whitespace): " " # (167..169) + - (variant꞉ Identifier): "msg" # (169..172) + - (period꞉ Period): "." # (172..173) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (173..179) + - (period꞉ Period): "." # (179..180) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (180..184) - (open_brace꞉ OpenBrace): "{" # (184..185) - - (arguments꞉ NamedArguments): # "arg: 1, missing_expr: , no_semicolon," (185..222) + - (options꞉ CallOptions): # "arg: 1, missing_expr: , no_semicolon," (185..222) - (item꞉ NamedArgument): # "arg: 1" (185..191) - (name꞉ Identifier): "arg" # (185..188) - (colon꞉ Colon): ":" # (188..189) @@ -232,18 +214,18 @@ Tree: - (trailing_trivia꞉ EndOfLine): "\n" # (229..230) - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " msg.sender.call{arg: 1 unexpected tokens, not: 2..." (230..306) - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " msg.sender.call{arg: 1 unexpected tokens, not: 2..." (230..304) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (230..247) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (230..242) - - (operand꞉ Expression): # " msg" (230..235) - - (leading_trivia꞉ Whitespace): " " # (230..232) - - (variant꞉ Identifier): "msg" # (232..235) - - (period꞉ Period): "." # (235..236) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (236..242) - - (period꞉ Period): "." # (242..243) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (243..247) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroup): # "{arg: 1 unexpected tokens, not: 2, recovered, yet:..." (247..302) + - (operand꞉ Expression) ► (variant꞉ CallOptionsExpression): # " msg.sender.call{arg: 1 unexpected tokens, not: 2..." (230..302) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender.call" (230..247) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " msg.sender" (230..242) + - (operand꞉ Expression): # " msg" (230..235) + - (leading_trivia꞉ Whitespace): " " # (230..232) + - (variant꞉ Identifier): "msg" # (232..235) + - (period꞉ Period): "." # (235..236) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "sender" # (236..242) + - (period꞉ Period): "." # (242..243) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "call" # (243..247) - (open_brace꞉ OpenBrace): "{" # (247..248) - - (arguments꞉ NamedArguments): # "arg: 1" (248..254) + - (options꞉ CallOptions): # "arg: 1" (248..254) - (item꞉ NamedArgument): # "arg: 1" (248..254) - (name꞉ Identifier): "arg" # (248..251) - (colon꞉ Colon): ":" # (251..252) diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options/generated/0.6.2-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options/generated/0.6.2-success.yml index 295fc1d89e..973e0ec28c 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options/generated/0.6.2-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options/generated/0.6.2-success.yml @@ -7,29 +7,28 @@ Errors: [] Tree: - (Expression) ► (variant꞉ FunctionCallExpression): # 'a.b{value: 0, gas: 1}("")' (0..25) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # "a.b" (0..3) - - (operand꞉ Expression) ► (variant꞉ Identifier): "a" # (0..1) - - (period꞉ Period): "." # (1..2) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "b" # (2..3) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroups): # "{value: 0, gas: 1}" (3..21) - - (item꞉ NamedArgumentGroup): # "{value: 0, gas: 1}" (3..21) - - (open_brace꞉ OpenBrace): "{" # (3..4) - - (arguments꞉ NamedArguments): # "value: 0, gas: 1" (4..20) - - (item꞉ NamedArgument): # "value: 0" (4..12) - - (name꞉ Identifier): "value" # (4..9) - - (colon꞉ Colon): ":" # (9..10) - - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 0" (10..12) - - (leading_trivia꞉ Whitespace): " " # (10..11) - - (literal꞉ DecimalLiteral): "0" # (11..12) - - (separator꞉ Comma): "," # (12..13) - - (item꞉ NamedArgument): # " gas: 1" (13..20) - - (leading_trivia꞉ Whitespace): " " # (13..14) - - (name꞉ Identifier): "gas" # (14..17) - - (colon꞉ Colon): ":" # (17..18) - - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (18..20) - - (leading_trivia꞉ Whitespace): " " # (18..19) - - (literal꞉ DecimalLiteral): "1" # (19..20) - - (close_brace꞉ CloseBrace): "}" # (20..21) + - (operand꞉ Expression) ► (variant꞉ CallOptionsExpression): # "a.b{value: 0, gas: 1}" (0..21) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # "a.b" (0..3) + - (operand꞉ Expression) ► (variant꞉ Identifier): "a" # (0..1) + - (period꞉ Period): "." # (1..2) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "b" # (2..3) + - (open_brace꞉ OpenBrace): "{" # (3..4) + - (options꞉ CallOptions): # "value: 0, gas: 1" (4..20) + - (item꞉ NamedArgument): # "value: 0" (4..12) + - (name꞉ Identifier): "value" # (4..9) + - (colon꞉ Colon): ":" # (9..10) + - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 0" (10..12) + - (leading_trivia꞉ Whitespace): " " # (10..11) + - (literal꞉ DecimalLiteral): "0" # (11..12) + - (separator꞉ Comma): "," # (12..13) + - (item꞉ NamedArgument): # " gas: 1" (13..20) + - (leading_trivia꞉ Whitespace): " " # (13..14) + - (name꞉ Identifier): "gas" # (14..17) + - (colon꞉ Colon): ":" # (17..18) + - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (18..20) + - (leading_trivia꞉ Whitespace): " " # (18..19) + - (literal꞉ DecimalLiteral): "1" # (19..20) + - (close_brace꞉ CloseBrace): "}" # (20..21) - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # '("")' (21..25) - (open_paren꞉ OpenParen): "(" # (21..22) - (arguments꞉ PositionalArguments): # '""' (22..24) diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options/generated/0.8.0-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options/generated/0.8.0-success.yml deleted file mode 100644 index 2d91599569..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options/generated/0.8.0-success.yml +++ /dev/null @@ -1,37 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ a.b{value: 0, gas: 1}("") │ 0..25 - -Errors: [] - -Tree: - - (Expression) ► (variant꞉ FunctionCallExpression): # 'a.b{value: 0, gas: 1}("")' (0..25) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # "a.b" (0..3) - - (operand꞉ Expression) ► (variant꞉ Identifier): "a" # (0..1) - - (period꞉ Period): "." # (1..2) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "b" # (2..3) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroup): # "{value: 0, gas: 1}" (3..21) - - (open_brace꞉ OpenBrace): "{" # (3..4) - - (arguments꞉ NamedArguments): # "value: 0, gas: 1" (4..20) - - (item꞉ NamedArgument): # "value: 0" (4..12) - - (name꞉ Identifier): "value" # (4..9) - - (colon꞉ Colon): ":" # (9..10) - - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 0" (10..12) - - (leading_trivia꞉ Whitespace): " " # (10..11) - - (literal꞉ DecimalLiteral): "0" # (11..12) - - (separator꞉ Comma): "," # (12..13) - - (item꞉ NamedArgument): # " gas: 1" (13..20) - - (leading_trivia꞉ Whitespace): " " # (13..14) - - (name꞉ Identifier): "gas" # (14..17) - - (colon꞉ Colon): ":" # (17..18) - - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (18..20) - - (leading_trivia꞉ Whitespace): " " # (18..19) - - (literal꞉ DecimalLiteral): "1" # (19..20) - - (close_brace꞉ CloseBrace): "}" # (20..21) - - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # '("")' (21..25) - - (open_paren꞉ OpenParen): "(" # (21..22) - - (arguments꞉ PositionalArguments): # '""' (22..24) - - (item꞉ Expression) ► (variant꞉ StringExpression) ► (variant꞉ StringLiterals): # '""' (22..24) - - (item꞉ StringLiteral) ► (variant꞉ DoubleQuotedStringLiteral): '""' # (22..24) - - (close_paren꞉ CloseParen): ")" # (24..25) diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/generated/0.6.2-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/generated/0.6.2-success.yml index bc187d23fd..8501876f8c 100644 --- a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/generated/0.6.2-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/generated/0.6.2-success.yml @@ -7,14 +7,14 @@ Errors: [] Tree: - (Expression) ► (variant꞉ FunctionCallExpression): # 'a.b{value: 0}{gas: 1}("")' (0..25) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # "a.b" (0..3) - - (operand꞉ Expression) ► (variant꞉ Identifier): "a" # (0..1) - - (period꞉ Period): "." # (1..2) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "b" # (2..3) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroups): # "{value: 0}{gas: 1}" (3..21) - - (item꞉ NamedArgumentGroup): # "{value: 0}" (3..13) + - (operand꞉ Expression) ► (variant꞉ CallOptionsExpression): # "a.b{value: 0}{gas: 1}" (0..21) + - (operand꞉ Expression) ► (variant꞉ CallOptionsExpression): # "a.b{value: 0}" (0..13) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # "a.b" (0..3) + - (operand꞉ Expression) ► (variant꞉ Identifier): "a" # (0..1) + - (period꞉ Period): "." # (1..2) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "b" # (2..3) - (open_brace꞉ OpenBrace): "{" # (3..4) - - (arguments꞉ NamedArguments): # "value: 0" (4..12) + - (options꞉ CallOptions): # "value: 0" (4..12) - (item꞉ NamedArgument): # "value: 0" (4..12) - (name꞉ Identifier): "value" # (4..9) - (colon꞉ Colon): ":" # (9..10) @@ -22,16 +22,15 @@ Tree: - (leading_trivia꞉ Whitespace): " " # (10..11) - (literal꞉ DecimalLiteral): "0" # (11..12) - (close_brace꞉ CloseBrace): "}" # (12..13) - - (item꞉ NamedArgumentGroup): # "{gas: 1}" (13..21) - - (open_brace꞉ OpenBrace): "{" # (13..14) - - (arguments꞉ NamedArguments): # "gas: 1" (14..20) - - (item꞉ NamedArgument): # "gas: 1" (14..20) - - (name꞉ Identifier): "gas" # (14..17) - - (colon꞉ Colon): ":" # (17..18) - - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (18..20) - - (leading_trivia꞉ Whitespace): " " # (18..19) - - (literal꞉ DecimalLiteral): "1" # (19..20) - - (close_brace꞉ CloseBrace): "}" # (20..21) + - (open_brace꞉ OpenBrace): "{" # (13..14) + - (options꞉ CallOptions): # "gas: 1" (14..20) + - (item꞉ NamedArgument): # "gas: 1" (14..20) + - (name꞉ Identifier): "gas" # (14..17) + - (colon꞉ Colon): ":" # (17..18) + - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (18..20) + - (leading_trivia꞉ Whitespace): " " # (18..19) + - (literal꞉ DecimalLiteral): "1" # (19..20) + - (close_brace꞉ CloseBrace): "}" # (20..21) - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # '("")' (21..25) - (open_paren꞉ OpenParen): "(" # (21..22) - (arguments꞉ PositionalArguments): # '""' (22..24) diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/generated/0.8.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/generated/0.8.0-failure.yml deleted file mode 100644 index 24e79a2ed9..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/generated/0.8.0-failure.yml +++ /dev/null @@ -1,22 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ a.b{value: 0}{gas: 1}("") │ 0..25 - -Errors: # 1 total - - > - Error: Expected end of file. - ╭─[crates/solidity/testing/snapshots/cst_output/Expression/function_call_options_split/input.sol:1:4] - │ - 1 │ a.b{value: 0}{gas: 1}("") - │ ───────────┬────────── - │ ╰──────────── Error occurred here. - ───╯ - -Tree: - - (Expression): # 'a.b{value: 0}{gas: 1}("")' (0..25) - - (variant꞉ MemberAccessExpression): # "a.b" (0..3) - - (operand꞉ Expression) ► (variant꞉ Identifier): "a" # (0..1) - - (period꞉ Period): "." # (1..2) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "b" # (2..3) - - (SKIPPED): '{value: 0}{gas: 1}("")' # (3..25) diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/member_access_options/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/Expression/member_access_options/generated/0.4.11-failure.yml new file mode 100644 index 0000000000..af5eb1163a --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/Expression/member_access_options/generated/0.4.11-failure.yml @@ -0,0 +1,22 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ foo.deposit{value: 100} │ 0..23 + +Errors: # 1 total + - > + Error: Expected end of file. + ╭─[crates/solidity/testing/snapshots/cst_output/Expression/member_access_options/input.sol:1:12] + │ + 1 │ foo.deposit{value: 100} + │ ──────┬────── + │ ╰──────── Error occurred here. + ───╯ + +Tree: + - (Expression): # "foo.deposit{value: 100}\n" (0..24) + - (variant꞉ MemberAccessExpression): # "foo.deposit" (0..11) + - (operand꞉ Expression) ► (variant꞉ Identifier): "foo" # (0..3) + - (period꞉ Period): "." # (3..4) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "deposit" # (4..11) + - (SKIPPED): "{value: 100}\n" # (11..24) diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/member_access_options/generated/0.6.2-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/member_access_options/generated/0.6.2-success.yml new file mode 100644 index 0000000000..b49ad4de7b --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/Expression/member_access_options/generated/0.6.2-success.yml @@ -0,0 +1,23 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ foo.deposit{value: 100} │ 0..23 + +Errors: [] + +Tree: + - (Expression) ► (variant꞉ CallOptionsExpression): # "foo.deposit{value: 100}\n" (0..24) + - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # "foo.deposit" (0..11) + - (operand꞉ Expression) ► (variant꞉ Identifier): "foo" # (0..3) + - (period꞉ Period): "." # (3..4) + - (member꞉ MemberAccess) ► (variant꞉ Identifier): "deposit" # (4..11) + - (open_brace꞉ OpenBrace): "{" # (11..12) + - (options꞉ CallOptions): # "value: 100" (12..22) + - (item꞉ NamedArgument): # "value: 100" (12..22) + - (name꞉ Identifier): "value" # (12..17) + - (colon꞉ Colon): ":" # (17..18) + - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 100" (18..22) + - (leading_trivia꞉ Whitespace): " " # (18..19) + - (literal꞉ DecimalLiteral): "100" # (19..22) + - (close_brace꞉ CloseBrace): "}" # (22..23) + - (trailing_trivia꞉ EndOfLine): "\n" # (23..24) diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/member_access_options/input.sol b/crates/solidity/testing/snapshots/cst_output/Expression/member_access_options/input.sol new file mode 100644 index 0000000000..d20ef9a018 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/Expression/member_access_options/input.sol @@ -0,0 +1 @@ +foo.deposit{value: 100} diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/new_expression/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/new_expression/generated/0.4.11-success.yml new file mode 100644 index 0000000000..dfd6415b00 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/Expression/new_expression/generated/0.4.11-success.yml @@ -0,0 +1,14 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ new Foo │ 0..7 + +Errors: [] + +Tree: + - (Expression) ► (variant꞉ NewExpression): # "new Foo\n" (0..8) + - (new_keyword꞉ NewKeyword): "new" # (0..3) + - (type_name꞉ TypeName) ► (variant꞉ IdentifierPath): # " Foo\n" (3..8) + - (leading_trivia꞉ Whitespace): " " # (3..4) + - (item꞉ Identifier): "Foo" # (4..7) + - (trailing_trivia꞉ EndOfLine): "\n" # (7..8) diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/new_expression/input.sol b/crates/solidity/testing/snapshots/cst_output/Expression/new_expression/input.sol new file mode 100644 index 0000000000..24bb3f869f --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/Expression/new_expression/input.sol @@ -0,0 +1 @@ +new Foo diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/new_expression_options/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/Expression/new_expression_options/generated/0.4.11-failure.yml new file mode 100644 index 0000000000..aa12c60446 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/Expression/new_expression_options/generated/0.4.11-failure.yml @@ -0,0 +1,23 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ new Foo{value: 10} │ 0..18 + +Errors: # 1 total + - > + Error: Expected Ampersand or AmpersandAmpersand or AmpersandEqual or Asterisk or AsteriskAsterisk or AsteriskEqual or BangEqual or Bar or BarBar or BarEqual or Caret or CaretEqual or Equal or EqualEqual or GreaterThan or GreaterThanEqual or GreaterThanGreaterThan or GreaterThanGreaterThanEqual or GreaterThanGreaterThanGreaterThan or GreaterThanGreaterThanGreaterThanEqual or LessThan or LessThanEqual or LessThanLessThan or LessThanLessThanEqual or Minus or MinusEqual or Percent or PercentEqual or Plus or PlusEqual or Slash or SlashEqual. + ╭─[crates/solidity/testing/snapshots/cst_output/Expression/new_expression_options/input.sol:1:8] + │ + 1 │ new Foo{value: 10} + │ ──────┬───── + │ ╰─────── Error occurred here. + ───╯ + +Tree: + - (Expression): # "new Foo{value: 10}\n" (0..19) + - (variant꞉ NewExpression): # "new Foo" (0..7) + - (new_keyword꞉ NewKeyword): "new" # (0..3) + - (type_name꞉ TypeName) ► (variant꞉ IdentifierPath): # " Foo" (3..7) + - (leading_trivia꞉ Whitespace): " " # (3..4) + - (item꞉ Identifier): "Foo" # (4..7) + - (SKIPPED): "{value: 10}\n" # (7..19) diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/new_expression_options/generated/0.6.2-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/new_expression_options/generated/0.6.2-success.yml new file mode 100644 index 0000000000..a3a58b5788 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/Expression/new_expression_options/generated/0.6.2-success.yml @@ -0,0 +1,24 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ new Foo{value: 10} │ 0..18 + +Errors: [] + +Tree: + - (Expression) ► (variant꞉ CallOptionsExpression): # "new Foo{value: 10}\n" (0..19) + - (operand꞉ Expression) ► (variant꞉ NewExpression): # "new Foo" (0..7) + - (new_keyword꞉ NewKeyword): "new" # (0..3) + - (type_name꞉ TypeName) ► (variant꞉ IdentifierPath): # " Foo" (3..7) + - (leading_trivia꞉ Whitespace): " " # (3..4) + - (item꞉ Identifier): "Foo" # (4..7) + - (open_brace꞉ OpenBrace): "{" # (7..8) + - (options꞉ CallOptions): # "value: 10" (8..17) + - (item꞉ NamedArgument): # "value: 10" (8..17) + - (name꞉ Identifier): "value" # (8..13) + - (colon꞉ Colon): ":" # (13..14) + - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 10" (14..17) + - (leading_trivia꞉ Whitespace): " " # (14..15) + - (literal꞉ DecimalLiteral): "10" # (15..17) + - (close_brace꞉ CloseBrace): "}" # (17..18) + - (trailing_trivia꞉ EndOfLine): "\n" # (18..19) diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/new_expression_options/input.sol b/crates/solidity/testing/snapshots/cst_output/Expression/new_expression_options/input.sol new file mode 100644 index 0000000000..1f6500441c --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/Expression/new_expression_options/input.sol @@ -0,0 +1 @@ +new Foo{value: 10} diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/paren_expression_options/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/Expression/paren_expression_options/generated/0.4.11-failure.yml new file mode 100644 index 0000000000..d445aec31f --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/Expression/paren_expression_options/generated/0.4.11-failure.yml @@ -0,0 +1,28 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ (new FooBar){value: 5}() │ 0..25 + +Errors: # 1 total + - > + Error: Expected Ampersand or AmpersandAmpersand or AmpersandEqual or Asterisk or AsteriskAsterisk or AsteriskEqual or BangEqual or Bar or BarBar or BarEqual or Caret or CaretEqual or Equal or EqualEqual or GreaterThan or GreaterThanEqual or GreaterThanGreaterThan or GreaterThanGreaterThanEqual or GreaterThanGreaterThanGreaterThan or GreaterThanGreaterThanGreaterThanEqual or LessThan or LessThanEqual or LessThanLessThan or LessThanLessThanEqual or Minus or MinusEqual or Percent or PercentEqual or Plus or PlusEqual or Slash or SlashEqual. + ╭─[crates/solidity/testing/snapshots/cst_output/Expression/paren_expression_options/input.sol:1:14] + │ + 1 │ (new FooBar){value: 5}() + │ ──────┬────── + │ ╰──────── Error occurred here. + ───╯ + +Tree: + - (Expression): # " (new FooBar){value: 5}()\n" (0..26) + - (variant꞉ TupleExpression): # " (new FooBar)" (0..13) + - (leading_trivia꞉ Whitespace): " " # (0..1) + - (open_paren꞉ OpenParen): "(" # (1..2) + - (items꞉ TupleValues): # "new FooBar" (2..12) + - (item꞉ TupleValue) ► (expression꞉ Expression) ► (variant꞉ NewExpression): # "new FooBar" (2..12) + - (new_keyword꞉ NewKeyword): "new" # (2..5) + - (type_name꞉ TypeName) ► (variant꞉ IdentifierPath): # " FooBar" (5..12) + - (leading_trivia꞉ Whitespace): " " # (5..6) + - (item꞉ Identifier): "FooBar" # (6..12) + - (close_paren꞉ CloseParen): ")" # (12..13) + - (SKIPPED): "{value: 5}()\n" # (13..26) diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/paren_expression_options/generated/0.6.2-success.yml b/crates/solidity/testing/snapshots/cst_output/Expression/paren_expression_options/generated/0.6.2-success.yml new file mode 100644 index 0000000000..d3202c8fa2 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/Expression/paren_expression_options/generated/0.6.2-success.yml @@ -0,0 +1,34 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ (new FooBar){value: 5}() │ 0..25 + +Errors: [] + +Tree: + - (Expression) ► (variant꞉ FunctionCallExpression): # " (new FooBar){value: 5}()\n" (0..26) + - (operand꞉ Expression) ► (variant꞉ CallOptionsExpression): # " (new FooBar){value: 5}" (0..23) + - (operand꞉ Expression) ► (variant꞉ TupleExpression): # " (new FooBar)" (0..13) + - (leading_trivia꞉ Whitespace): " " # (0..1) + - (open_paren꞉ OpenParen): "(" # (1..2) + - (items꞉ TupleValues): # "new FooBar" (2..12) + - (item꞉ TupleValue) ► (expression꞉ Expression) ► (variant꞉ NewExpression): # "new FooBar" (2..12) + - (new_keyword꞉ NewKeyword): "new" # (2..5) + - (type_name꞉ TypeName) ► (variant꞉ IdentifierPath): # " FooBar" (5..12) + - (leading_trivia꞉ Whitespace): " " # (5..6) + - (item꞉ Identifier): "FooBar" # (6..12) + - (close_paren꞉ CloseParen): ")" # (12..13) + - (open_brace꞉ OpenBrace): "{" # (13..14) + - (options꞉ CallOptions): # "value: 5" (14..22) + - (item꞉ NamedArgument): # "value: 5" (14..22) + - (name꞉ Identifier): "value" # (14..19) + - (colon꞉ Colon): ":" # (19..20) + - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 5" (20..22) + - (leading_trivia꞉ Whitespace): " " # (20..21) + - (literal꞉ DecimalLiteral): "5" # (21..22) + - (close_brace꞉ CloseBrace): "}" # (22..23) + - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()\n" (23..26) + - (open_paren꞉ OpenParen): "(" # (23..24) + - (arguments꞉ PositionalArguments): [] # (24..24) + - (close_paren꞉ CloseParen): ")" # (24..25) + - (trailing_trivia꞉ EndOfLine): "\n" # (25..26) diff --git a/crates/solidity/testing/snapshots/cst_output/Expression/paren_expression_options/input.sol b/crates/solidity/testing/snapshots/cst_output/Expression/paren_expression_options/input.sol new file mode 100644 index 0000000000..2265ff9e9a --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/Expression/paren_expression_options/input.sol @@ -0,0 +1 @@ + (new FooBar){value: 5}() diff --git a/crates/solidity/testing/snapshots/cst_output/FunctionCallExpression/empty_named_arguments/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/FunctionCallExpression/empty_named_arguments/generated/0.4.11-success.yml new file mode 100644 index 0000000000..86e9737fc5 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/FunctionCallExpression/empty_named_arguments/generated/0.4.11-success.yml @@ -0,0 +1,22 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ // Named arguments can be empty │ 0..31 + 2 │ someFunc({}) │ 32..44 + +Errors: [] + +Tree: + - (FunctionCallExpression): # "// Named arguments can be empty\nsomeFunc({})\n" (0..45) + - (operand꞉ Expression): # "// Named arguments can be empty\nsomeFunc" (0..40) + - (leading_trivia꞉ SingleLineComment): "// Named arguments can be empty" # (0..31) + - (leading_trivia꞉ EndOfLine): "\n" # (31..32) + - (variant꞉ Identifier): "someFunc" # (32..40) + - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ NamedArgumentsDeclaration): # "({})\n" (40..45) + - (open_paren꞉ OpenParen): "(" # (40..41) + - (arguments꞉ NamedArgumentGroup): # "{}" (41..43) + - (open_brace꞉ OpenBrace): "{" # (41..42) + - (arguments꞉ NamedArguments): [] # (42..42) + - (close_brace꞉ CloseBrace): "}" # (42..43) + - (close_paren꞉ CloseParen): ")" # (43..44) + - (trailing_trivia꞉ EndOfLine): "\n" # (44..45) diff --git a/crates/solidity/testing/snapshots/cst_output/FunctionCallExpression/empty_named_arguments/input.sol b/crates/solidity/testing/snapshots/cst_output/FunctionCallExpression/empty_named_arguments/input.sol new file mode 100644 index 0000000000..ce0d2324e1 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/FunctionCallExpression/empty_named_arguments/input.sol @@ -0,0 +1,2 @@ +// Named arguments can be empty +someFunc({}) diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/generated/0.4.11-failure.yml index a5fe50f628..96bbcc78a5 100644 --- a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/generated/0.4.11-failure.yml @@ -1,17 +1,25 @@ # This file is generated automatically by infrastructure scripts. Please don't edit by hand. Source: > - 1 │ try a.b() {} catch {} │ 0..21 + 1 │ // Make sure that error recovery won't lead to misparsing │ 0..57 + 2 │ // ambiguous function call options with the block following the try expression │ 58..136 + 3 │ │ 137..137 + 4 │ try foo() { │ 138..149 + 5 │ bar(); │ 150..158 + 6 │ } catch { │ 159..168 + 7 │ } │ 169..170 Errors: # 1 total - > Error: Expected end of file. ╭─[crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/input.sol:1:1] │ - 1 │ try a.b() {} catch {} - │ ──────────┬────────── - │ ╰──────────── Error occurred here. + 1 │ ╭─▶ // Make sure that error recovery won't lead to misparsing + ┆ ┆ + 7 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. ───╯ Tree: - - (SKIPPED): "try a.b() {} catch {}" # (0..21) + - (SKIPPED): "// Make sure that error recovery won't lead to mis..." # (0..171) diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/generated/0.6.0-success.yml b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/generated/0.6.0-success.yml index 0bb595928b..1be022868a 100644 --- a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/generated/0.6.0-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/generated/0.6.0-success.yml @@ -1,35 +1,57 @@ # This file is generated automatically by infrastructure scripts. Please don't edit by hand. Source: > - 1 │ try a.b() {} catch {} │ 0..21 + 1 │ // Make sure that error recovery won't lead to misparsing │ 0..57 + 2 │ // ambiguous function call options with the block following the try expression │ 58..136 + 3 │ │ 137..137 + 4 │ try foo() { │ 138..149 + 5 │ bar(); │ 150..158 + 6 │ } catch { │ 159..168 + 7 │ } │ 169..170 Errors: [] Tree: - - (TryStatement): # "try a.b() {} catch {}" (0..21) - - (try_keyword꞉ TryKeyword): "try" # (0..3) - - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " a.b()" (3..9) - - (operand꞉ Expression) ► (variant꞉ MemberAccessExpression): # " a.b" (3..7) - - (operand꞉ Expression): # " a" (3..5) - - (leading_trivia꞉ Whitespace): " " # (3..4) - - (variant꞉ Identifier): "a" # (4..5) - - (period꞉ Period): "." # (5..6) - - (member꞉ MemberAccess) ► (variant꞉ Identifier): "b" # (6..7) - - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (7..9) - - (open_paren꞉ OpenParen): "(" # (7..8) - - (arguments꞉ PositionalArguments): [] # (8..8) - - (close_paren꞉ CloseParen): ")" # (8..9) - - (body꞉ Block): # " {}" (9..12) - - (leading_trivia꞉ Whitespace): " " # (9..10) - - (open_brace꞉ OpenBrace): "{" # (10..11) - - (statements꞉ Statements): [] # (11..11) - - (close_brace꞉ CloseBrace): "}" # (11..12) - - (catch_clauses꞉ CatchClauses): # " catch {}" (12..21) - - (item꞉ CatchClause): # " catch {}" (12..21) - - (leading_trivia꞉ Whitespace): " " # (12..13) - - (catch_keyword꞉ CatchKeyword): "catch" # (13..18) - - (body꞉ Block): # " {}" (18..21) - - (leading_trivia꞉ Whitespace): " " # (18..19) - - (open_brace꞉ OpenBrace): "{" # (19..20) - - (statements꞉ Statements): [] # (20..20) - - (close_brace꞉ CloseBrace): "}" # (20..21) + - (TryStatement): # "// Make sure that error recovery won't lead to mis..." (0..171) + - (leading_trivia꞉ SingleLineComment): "// Make sure that error recovery won't lead to mis..." # (0..57) + - (leading_trivia꞉ EndOfLine): "\n" # (57..58) + - (leading_trivia꞉ SingleLineComment): "// ambiguous function call options with the block ..." # (58..136) + - (leading_trivia꞉ EndOfLine): "\n" # (136..137) + - (leading_trivia꞉ EndOfLine): "\n" # (137..138) + - (try_keyword꞉ TryKeyword): "try" # (138..141) + - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " foo()" (141..147) + - (operand꞉ Expression): # " foo" (141..145) + - (leading_trivia꞉ Whitespace): " " # (141..142) + - (variant꞉ Identifier): "foo" # (142..145) + - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (145..147) + - (open_paren꞉ OpenParen): "(" # (145..146) + - (arguments꞉ PositionalArguments): [] # (146..146) + - (close_paren꞉ CloseParen): ")" # (146..147) + - (body꞉ Block): # " {\n bar();\n}" (147..160) + - (leading_trivia꞉ Whitespace): " " # (147..148) + - (open_brace꞉ OpenBrace): "{" # (148..149) + - (trailing_trivia꞉ EndOfLine): "\n" # (149..150) + - (statements꞉ Statements): # " bar();\n" (150..159) + - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " bar();\n" (150..159) + - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " bar()" (150..157) + - (operand꞉ Expression): # " bar" (150..155) + - (leading_trivia꞉ Whitespace): " " # (150..152) + - (variant꞉ Identifier): "bar" # (152..155) + - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (155..157) + - (open_paren꞉ OpenParen): "(" # (155..156) + - (arguments꞉ PositionalArguments): [] # (156..156) + - (close_paren꞉ CloseParen): ")" # (156..157) + - (semicolon꞉ Semicolon): ";" # (157..158) + - (trailing_trivia꞉ EndOfLine): "\n" # (158..159) + - (close_brace꞉ CloseBrace): "}" # (159..160) + - (catch_clauses꞉ CatchClauses): # " catch {\n}\n" (160..171) + - (item꞉ CatchClause): # " catch {\n}\n" (160..171) + - (leading_trivia꞉ Whitespace): " " # (160..161) + - (catch_keyword꞉ CatchKeyword): "catch" # (161..166) + - (body꞉ Block): # " {\n}\n" (166..171) + - (leading_trivia꞉ Whitespace): " " # (166..167) + - (open_brace꞉ OpenBrace): "{" # (167..168) + - (trailing_trivia꞉ EndOfLine): "\n" # (168..169) + - (statements꞉ Statements): [] # (169..169) + - (close_brace꞉ CloseBrace): "}" # (169..170) + - (trailing_trivia꞉ EndOfLine): "\n" # (170..171) diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/input.sol b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/input.sol index 912150cb1a..9777b18b2f 100644 --- a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/input.sol +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch/input.sol @@ -1 +1,7 @@ -try a.b() {} catch {} \ No newline at end of file +// Make sure that error recovery won't lead to misparsing +// ambiguous function call options with the block following the try expression + +try foo() { + bar(); +} catch { +} diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch_empty_body/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch_empty_body/generated/0.4.11-failure.yml new file mode 100644 index 0000000000..b85e67bd2c --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch_empty_body/generated/0.4.11-failure.yml @@ -0,0 +1,21 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ try foo() { │ 0..11 + 2 │ } catch { │ 12..21 + 3 │ } │ 22..23 + +Errors: # 1 total + - > + Error: Expected end of file. + ╭─[crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch_empty_body/input.sol:1:1] + │ + 1 │ ╭─▶ try foo() { + ┆ ┆ + 3 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. + ───╯ + +Tree: + - (SKIPPED): "try foo() {\n} catch {\n}\n" # (0..24) diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch_empty_body/generated/0.6.0-success.yml b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch_empty_body/generated/0.6.0-success.yml new file mode 100644 index 0000000000..310b3c66d7 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch_empty_body/generated/0.6.0-success.yml @@ -0,0 +1,37 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ try foo() { │ 0..11 + 2 │ } catch { │ 12..21 + 3 │ } │ 22..23 + +Errors: [] + +Tree: + - (TryStatement): # "try foo() {\n} catch {\n}\n" (0..24) + - (try_keyword꞉ TryKeyword): "try" # (0..3) + - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " foo()" (3..9) + - (operand꞉ Expression): # " foo" (3..7) + - (leading_trivia꞉ Whitespace): " " # (3..4) + - (variant꞉ Identifier): "foo" # (4..7) + - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (7..9) + - (open_paren꞉ OpenParen): "(" # (7..8) + - (arguments꞉ PositionalArguments): [] # (8..8) + - (close_paren꞉ CloseParen): ")" # (8..9) + - (body꞉ Block): # " {\n}" (9..13) + - (leading_trivia꞉ Whitespace): " " # (9..10) + - (open_brace꞉ OpenBrace): "{" # (10..11) + - (trailing_trivia꞉ EndOfLine): "\n" # (11..12) + - (statements꞉ Statements): [] # (12..12) + - (close_brace꞉ CloseBrace): "}" # (12..13) + - (catch_clauses꞉ CatchClauses): # " catch {\n}\n" (13..24) + - (item꞉ CatchClause): # " catch {\n}\n" (13..24) + - (leading_trivia꞉ Whitespace): " " # (13..14) + - (catch_keyword꞉ CatchKeyword): "catch" # (14..19) + - (body꞉ Block): # " {\n}\n" (19..24) + - (leading_trivia꞉ Whitespace): " " # (19..20) + - (open_brace꞉ OpenBrace): "{" # (20..21) + - (trailing_trivia꞉ EndOfLine): "\n" # (21..22) + - (statements꞉ Statements): [] # (22..22) + - (close_brace꞉ CloseBrace): "}" # (22..23) + - (trailing_trivia꞉ EndOfLine): "\n" # (23..24) diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch_empty_body/input.sol b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch_empty_body/input.sol new file mode 100644 index 0000000000..8b5084ef00 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_catch_empty_body/input.sol @@ -0,0 +1,3 @@ +try foo() { +} catch { +} diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.4.11-failure.yml new file mode 100644 index 0000000000..5c51b74598 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.4.11-failure.yml @@ -0,0 +1,22 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ try foo() { x: 1 } { │ 0..20 + 2 │ bar(); │ 21..29 + 3 │ } catch { │ 30..39 + 4 │ } │ 40..41 + +Errors: # 1 total + - > + Error: Expected end of file. + ╭─[crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/input.sol:1:1] + │ + 1 │ ╭─▶ try foo() { x: 1 } { + ┆ ┆ + 4 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. + ───╯ + +Tree: + - (SKIPPED): "try foo() { x: 1 } {\n bar();\n} catch {\n}\n" # (0..42) diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.6.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.6.0-failure.yml new file mode 100644 index 0000000000..128f8da911 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.6.0-failure.yml @@ -0,0 +1,49 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ try foo() { x: 1 } { │ 0..20 + 2 │ bar(); │ 21..29 + 3 │ } catch { │ 30..39 + 4 │ } │ 40..41 + +Errors: # 2 total + - > + Error: Expected Ampersand or AmpersandAmpersand or AmpersandEqual or Asterisk or AsteriskAsterisk or AsteriskEqual or BangEqual or Bar or BarBar or BarEqual or Caret or CaretEqual or Equal or EqualEqual or GreaterThan or GreaterThanEqual or GreaterThanGreaterThan or GreaterThanGreaterThanEqual or GreaterThanGreaterThanGreaterThan or GreaterThanGreaterThanGreaterThanEqual or LessThan or LessThanEqual or LessThanLessThan or LessThanLessThanEqual or Minus or MinusEqual or Percent or PercentEqual or Plus or PlusEqual or Semicolon or Slash or SlashEqual. + ╭─[crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/input.sol:1:14] + │ + 1 │ try foo() { x: 1 } { + │ ──┬─ + │ ╰─── Error occurred here. + ───╯ + - > + Error: Expected CatchKeyword. + ╭─[crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/input.sol:1:19] + │ + 1 │ ╭─▶ try foo() { x: 1 } { + ┆ ┆ + 4 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. + ───╯ + +Tree: + - (TryStatement): # "try foo() { x: 1 } {\n bar();\n} catch {\n}\n" (0..42) + - (try_keyword꞉ TryKeyword): "try" # (0..3) + - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " foo()" (3..9) + - (operand꞉ Expression): # " foo" (3..7) + - (leading_trivia꞉ Whitespace): " " # (3..4) + - (variant꞉ Identifier): "foo" # (4..7) + - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (7..9) + - (open_paren꞉ OpenParen): "(" # (7..8) + - (arguments꞉ PositionalArguments): [] # (8..8) + - (close_paren꞉ CloseParen): ")" # (8..9) + - (body꞉ Block): # " { x: 1 }" (9..18) + - (leading_trivia꞉ Whitespace): " " # (9..10) + - (open_brace꞉ OpenBrace): "{" # (10..11) + - (statements꞉ Statements): # " x" (11..13) + - (item꞉ Statement) ► (variant꞉ ExpressionStatement) ► (expression꞉ Expression): # " x" (11..13) + - (leading_trivia꞉ Whitespace): " " # (11..12) + - (variant꞉ Identifier): "x" # (12..13) + - (SKIPPED): ": 1 " # (13..17) + - (close_brace꞉ CloseBrace): "}" # (17..18) + - (SKIPPED): " {\n bar();\n} catch {\n}\n" # (18..42) diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.6.2-success.yml b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.6.2-success.yml new file mode 100644 index 0000000000..a82b0fed6a --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.6.2-success.yml @@ -0,0 +1,62 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ try foo() { x: 1 } { │ 0..20 + 2 │ bar(); │ 21..29 + 3 │ } catch { │ 30..39 + 4 │ } │ 40..41 + +Errors: [] + +Tree: + - (TryStatement): # "try foo() { x: 1 } {\n bar();\n} catch {\n}\n" (0..42) + - (try_keyword꞉ TryKeyword): "try" # (0..3) + - (expression꞉ Expression) ► (variant꞉ CallOptionsExpression): # " foo() { x: 1 }" (3..18) + - (operand꞉ Expression) ► (variant꞉ FunctionCallExpression): # " foo()" (3..9) + - (operand꞉ Expression): # " foo" (3..7) + - (leading_trivia꞉ Whitespace): " " # (3..4) + - (variant꞉ Identifier): "foo" # (4..7) + - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (7..9) + - (open_paren꞉ OpenParen): "(" # (7..8) + - (arguments꞉ PositionalArguments): [] # (8..8) + - (close_paren꞉ CloseParen): ")" # (8..9) + - (leading_trivia꞉ Whitespace): " " # (9..10) + - (open_brace꞉ OpenBrace): "{" # (10..11) + - (options꞉ CallOptions): # " x: 1" (11..16) + - (item꞉ NamedArgument): # " x: 1" (11..16) + - (leading_trivia꞉ Whitespace): " " # (11..12) + - (name꞉ Identifier): "x" # (12..13) + - (colon꞉ Colon): ":" # (13..14) + - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (14..16) + - (leading_trivia꞉ Whitespace): " " # (14..15) + - (literal꞉ DecimalLiteral): "1" # (15..16) + - (leading_trivia꞉ Whitespace): " " # (16..17) + - (close_brace꞉ CloseBrace): "}" # (17..18) + - (body꞉ Block): # " {\n bar();\n}" (18..31) + - (leading_trivia꞉ Whitespace): " " # (18..19) + - (open_brace꞉ OpenBrace): "{" # (19..20) + - (trailing_trivia꞉ EndOfLine): "\n" # (20..21) + - (statements꞉ Statements): # " bar();\n" (21..30) + - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " bar();\n" (21..30) + - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " bar()" (21..28) + - (operand꞉ Expression): # " bar" (21..26) + - (leading_trivia꞉ Whitespace): " " # (21..23) + - (variant꞉ Identifier): "bar" # (23..26) + - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (26..28) + - (open_paren꞉ OpenParen): "(" # (26..27) + - (arguments꞉ PositionalArguments): [] # (27..27) + - (close_paren꞉ CloseParen): ")" # (27..28) + - (semicolon꞉ Semicolon): ";" # (28..29) + - (trailing_trivia꞉ EndOfLine): "\n" # (29..30) + - (close_brace꞉ CloseBrace): "}" # (30..31) + - (catch_clauses꞉ CatchClauses): # " catch {\n}\n" (31..42) + - (item꞉ CatchClause): # " catch {\n}\n" (31..42) + - (leading_trivia꞉ Whitespace): " " # (31..32) + - (catch_keyword꞉ CatchKeyword): "catch" # (32..37) + - (body꞉ Block): # " {\n}\n" (37..42) + - (leading_trivia꞉ Whitespace): " " # (37..38) + - (open_brace꞉ OpenBrace): "{" # (38..39) + - (trailing_trivia꞉ EndOfLine): "\n" # (39..40) + - (statements꞉ Statements): [] # (40..40) + - (close_brace꞉ CloseBrace): "}" # (40..41) + - (trailing_trivia꞉ EndOfLine): "\n" # (41..42) diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/input.sol b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/input.sol new file mode 100644 index 0000000000..502285c359 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/input.sol @@ -0,0 +1,4 @@ +try foo() { x: 1 } { + bar(); +} catch { +} diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.6.2-failure.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.6.2-failure.yml index eadd1d91ab..e7a7996009 100644 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.6.2-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.6.2-failure.yml @@ -7,7 +7,7 @@ Source: > Errors: # 1 total - > - Error: Expected CloseBrace or Identifier. + Error: Expected Identifier. ╭─[crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/input.sol:3:3] │ 3 │ { throw; @@ -39,12 +39,9 @@ Tree: - (literal꞉ DecimalLiteral): "135" # (15..18) - (close_paren꞉ CloseParen): ")" # (18..19) - (trailing_trivia꞉ EndOfLine): "\n" # (19..20) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroups): # "/**/\n{" (20..26) - - (item꞉ NamedArgumentGroup): # "/**/\n{" (20..26) - - (leading_trivia꞉ MultiLineComment): "/**/" # (20..24) - - (leading_trivia꞉ EndOfLine): "\n" # (24..25) - - (open_brace꞉ OpenBrace): "{" # (25..26) - - (arguments꞉ NamedArguments): [] # (26..26) + - (leading_trivia꞉ MultiLineComment): "/**/" # (20..24) + - (leading_trivia꞉ EndOfLine): "\n" # (24..25) + - (open_brace꞉ OpenBrace): "{" # (25..26) - (leading_trivia꞉ Whitespace): " " # (26..27) - (SKIPPED): "throw" # (27..32) - (semicolon꞉ Semicolon): ";" # (32..33) diff --git a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.8.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.8.0-failure.yml deleted file mode 100644 index b7193eab8c..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/generated/0.8.0-failure.yml +++ /dev/null @@ -1,51 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ (a, b) = (123, 135) │ 0..19 - 2 │ /**/ │ 20..24 - 3 │ { throw; │ 25..34 - -Errors: # 1 total - - > - Error: Expected CloseBrace or Identifier. - ╭─[crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/input.sol:3:3] - │ - 3 │ { throw; - │ ──┬── - │ ╰──── Error occurred here. - ───╯ - -Tree: - - (TupleDeconstructionStatement): # "(a, b) = (123, 135)\n/**/\n{ throw; \n" (0..35) - - (open_paren꞉ OpenParen): "(" # (0..1) - - (elements꞉ TupleDeconstructionElements): # "a, b" (1..5) - - (item꞉ TupleDeconstructionElement) ► (member꞉ TupleMember) ► (variant꞉ UntypedTupleMember) ► (name꞉ Identifier): "a" # (1..2) - - (separator꞉ Comma): "," # (2..3) - - (item꞉ TupleDeconstructionElement) ► (member꞉ TupleMember) ► (variant꞉ UntypedTupleMember): # " b" (3..5) - - (leading_trivia꞉ Whitespace): " " # (3..4) - - (name꞉ Identifier): "b" # (4..5) - - (close_paren꞉ CloseParen): ")" # (5..6) - - (leading_trivia꞉ Whitespace): " " # (6..7) - - (equal꞉ Equal): "=" # (7..8) - - (expression꞉ Expression): # " (123, 135)\n/**/\n{" (8..26) - - (variant꞉ TupleExpression): # " (123, 135)\n" (8..20) - - (leading_trivia꞉ Whitespace): " " # (8..9) - - (open_paren꞉ OpenParen): "(" # (9..10) - - (items꞉ TupleValues): # "123, 135" (10..18) - - (item꞉ TupleValue) ► (expression꞉ Expression) ► (variant꞉ DecimalNumberExpression) ► (literal꞉ DecimalLiteral): "123" # (10..13) - - (separator꞉ Comma): "," # (13..14) - - (item꞉ TupleValue) ► (expression꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 135" (14..18) - - (leading_trivia꞉ Whitespace): " " # (14..15) - - (literal꞉ DecimalLiteral): "135" # (15..18) - - (close_paren꞉ CloseParen): ")" # (18..19) - - (trailing_trivia꞉ EndOfLine): "\n" # (19..20) - - (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroup): # "/**/\n{" (20..26) - - (leading_trivia꞉ MultiLineComment): "/**/" # (20..24) - - (leading_trivia꞉ EndOfLine): "\n" # (24..25) - - (open_brace꞉ OpenBrace): "{" # (25..26) - - (arguments꞉ NamedArguments): [] # (26..26) - - (leading_trivia꞉ Whitespace): " " # (26..27) - - (SKIPPED): "throw" # (27..32) - - (semicolon꞉ Semicolon): ";" # (32..33) - - (trailing_trivia꞉ Whitespace): " " # (33..34) - - (trailing_trivia꞉ EndOfLine): "\n" # (34..35) diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/language.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/language.rs index a3ce22cc71..c08d4546cc 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/language.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/language.rs @@ -24,7 +24,7 @@ use crate::napi_interface::parse_output::ParseOutput as NAPIParseOutput; use crate::parse_output::ParseOutput; use crate::parser_support::{ ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, - PrecedenceHelper, RecoverFromNoMatch, SeparatedHelper, SequenceHelper, ZeroOrMoreHelper, + PrecedenceHelper, SeparatedHelper, SequenceHelper, TokenAcceptanceThreshold, ZeroOrMoreHelper, }; #[derive(Debug)] @@ -350,7 +350,7 @@ impl Language { input, self, TokenKind::Semicolon, - RecoverFromNoMatch::No, + TokenAcceptanceThreshold(1u8), ), )?; seq.elem_labeled( @@ -384,7 +384,7 @@ impl Language { input, self, TokenKind::CloseBracket, - RecoverFromNoMatch::Yes, + TokenAcceptanceThreshold(0u8), ), )?; seq.elem_labeled( diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/mod.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/mod.rs index cf8ccbaad9..2d005d87d3 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/mod.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/mod.rs @@ -28,7 +28,7 @@ pub(crate) use parser_result::ParserResult; #[allow(unused_imports)] pub(crate) use precedence_helper::PrecedenceHelper; #[allow(unused_imports)] -pub(crate) use recovery::RecoverFromNoMatch; +pub(crate) use recovery::TokenAcceptanceThreshold; #[allow(unused_imports)] pub(crate) use repetition_helper::{OneOrMoreHelper, ZeroOrMoreHelper}; #[allow(unused_imports)] diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/parser_result.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/parser_result.rs index 21b61c668e..16e59411fa 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/parser_result.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/parser_result.rs @@ -2,7 +2,7 @@ use std::ops::ControlFlow; -use crate::cst::{self, LabeledNode}; +use crate::cst::{self, LabeledNode, Node}; use crate::kinds::{NodeLabel, RuleKind, TokenKind}; use crate::text_index::TextIndex; @@ -203,6 +203,33 @@ impl IncompleteMatch { expected_tokens, } } + + /// Whether this prefix-matched at least `n` (non-skipped) significant tokens. + pub fn matches_at_least_n_tokens(&self, n: u8) -> bool { + let result = self + .nodes + .iter() + .flat_map(|node| node.cursor_with_offset(TextIndex::ZERO)) + .try_fold(0u8, |mut acc, node| { + match node { + Node::Token(tok) if tok.kind != TokenKind::SKIPPED && !tok.kind.is_trivia() => { + acc += 1; + } + _ => {} + } + + // Short-circuit not to walk the whole tree if we've already matched enough + if acc >= n { + ControlFlow::Break(acc) + } else { + ControlFlow::Continue(acc) + } + }); + + match result { + ControlFlow::Continue(value) | ControlFlow::Break(value) => value >= n, + } + } } #[derive(PartialEq, Eq, Clone, Debug)] diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/recovery.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/recovery.rs index 563d3a60bf..2a53c35945 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/recovery.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser_support/recovery.rs @@ -9,18 +9,11 @@ use crate::parser_support::parser_result::SkippedUntil; use crate::parser_support::ParserResult; use crate::text_index::{TextRange, TextRangeExtensions as _}; -/// An explicit parameter for the [`ParserResult::recover_until_with_nested_delims`] method. +/// How many tokens have to be matched to trigger the error recovery. +/// For ambiguous syntaxes this needs to be set to at least N, where N +/// is the token lookahead required to disambiguate the syntax. #[derive(Clone, Copy)] -pub(crate) enum RecoverFromNoMatch { - Yes, - No, -} - -impl RecoverFromNoMatch { - pub fn as_bool(self) -> bool { - matches!(self, RecoverFromNoMatch::Yes) - } -} +pub(crate) struct TokenAcceptanceThreshold(pub(crate) u8); fn opt_parse( input: &mut ParserContext<'_>, @@ -48,7 +41,7 @@ impl ParserResult { input: &mut ParserContext<'_>, lexer: &L, expected: TokenKind, - recover_from_no_match: RecoverFromNoMatch, + acceptance_threshold: TokenAcceptanceThreshold, ) -> ParserResult { enum ParseResultKind { Match, @@ -59,11 +52,15 @@ impl ParserResult { let before_recovery = input.position(); let (mut nodes, mut expected_tokens, result_kind) = match self { - ParserResult::IncompleteMatch(result) => ( - result.nodes, - result.expected_tokens, - ParseResultKind::Incomplete, - ), + ParserResult::IncompleteMatch(result) + if result.matches_at_least_n_tokens(acceptance_threshold.0) => + { + ( + result.nodes, + result.expected_tokens, + ParseResultKind::Incomplete, + ) + } ParserResult::Match(result) if lexer .peek_token_with_trivia::(input) @@ -72,7 +69,7 @@ impl ParserResult { { (result.nodes, result.expected_tokens, ParseResultKind::Match) } - ParserResult::NoMatch(result) if recover_from_no_match.as_bool() => { + ParserResult::NoMatch(result) if acceptance_threshold.0 == 0 => { (vec![], result.expected_tokens, ParseResultKind::NoMatch) } // No need to recover, so just return as-is.