From 465c8974cc73b84b2e29e3c6d238d7c6d3b852ac Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Mon, 13 Nov 2023 09:30:12 +0100 Subject: [PATCH 01/12] fix: Mark UsingDirectiveSymbol as introduced in 0.8.13 in DSL v1 This is only used as part of deconstruction, which was introduced in 0.8.13, so it was impossible to use this before - this fixes the tests by marking the 0.4.11 as failing. --- crates/solidity/inputs/language/src/dsl.rs | 6 +- .../cargo/crate/src/generated/language.rs | 224 +++++++++--------- .../npm/crate/src/generated/language.rs | 224 +++++++++--------- .../generated/0.4.11-failure.yml | 17 ++ ...{0.4.11-success.yml => 0.8.13-success.yml} | 0 .../generated/0.4.11-failure.yml | 15 +- .../generated/0.8.13-failure.yml | 22 ++ .../single_id/generated/0.4.11-failure.yml | 17 ++ ...{0.4.11-success.yml => 0.8.13-success.yml} | 0 .../generated/0.4.11-failure.yml | 13 +- .../generated/0.8.13-failure.yml | 20 ++ 11 files changed, 317 insertions(+), 241 deletions(-) create mode 100644 crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path/generated/0.4.11-failure.yml rename crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path/generated/{0.4.11-success.yml => 0.8.13-success.yml} (100%) create mode 100644 crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/generated/0.8.13-failure.yml create mode 100644 crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id/generated/0.4.11-failure.yml rename crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id/generated/{0.4.11-success.yml => 0.8.13-success.yml} (100%) create mode 100644 crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/generated/0.8.13-failure.yml diff --git a/crates/solidity/inputs/language/src/dsl.rs b/crates/solidity/inputs/language/src/dsl.rs index a7faf1c95f..a76c2f8349 100644 --- a/crates/solidity/inputs/language/src/dsl.rs +++ b/crates/solidity/inputs/language/src/dsl.rs @@ -554,9 +554,9 @@ slang_grammar! { parser UsingDirectivePath = IdentifierPath ; - parser UsingDirectiveSymbol = ( - IdentifierPath { introduced in "0.8.19" ((AsKeyword UsingDirectiveOperator) ?) } - ) ; + parser UsingDirectiveSymbol = { + introduced in "0.8.13" (IdentifierPath { introduced in "0.8.19" ((AsKeyword UsingDirectiveOperator) ?) } ) + } ; parser UsingDirectiveSymbolsList = (UsingDirectiveSymbol separated by Comma) ; diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index 5068f4002e..ad81d06e92 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -4161,116 +4161,120 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn using_directive_symbol(&self, input: &mut ParserContext) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem(self.identifier_path(input))?; - if self.version_is_at_least_0_8_19 { - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(if self.version_is_at_least_0_8_19 { - ChoiceHelper::run(input, |mut choice, input| { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Ampersand, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Bar, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - } else { - ParserResult::disabled() - })?; - seq.finish() - })))?; - } - seq.finish() - }) + if self.version_is_at_least_0_8_13 { + SequenceHelper::run(|mut seq| { + seq.elem(self.identifier_path(input))?; + if self.version_is_at_least_0_8_19 { + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::AsKeyword, + ))?; + seq.elem(if self.version_is_at_least_0_8_19 { + ChoiceHelper::run(input, |mut choice, input| { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Ampersand, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Asterisk, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::BangEqual, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Bar, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Caret, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::EqualEqual, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::GreaterThan, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::GreaterThanEqual, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::LessThan, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::LessThanEqual, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Minus, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Percent, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Plus, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Slash, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Tilde, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + } else { + ParserResult::disabled() + })?; + seq.finish() + })))?; + } + seq.finish() + }) + } else { + ParserResult::disabled() + } .with_kind(RuleKind::UsingDirectiveSymbol) } diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index 5068f4002e..ad81d06e92 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -4161,116 +4161,120 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn using_directive_symbol(&self, input: &mut ParserContext) -> ParserResult { - SequenceHelper::run(|mut seq| { - seq.elem(self.identifier_path(input))?; - if self.version_is_at_least_0_8_19 { - seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::AsKeyword, - ))?; - seq.elem(if self.version_is_at_least_0_8_19 { - ChoiceHelper::run(input, |mut choice, input| { - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Ampersand, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Asterisk, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::BangEqual, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Bar, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Caret, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::EqualEqual, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::GreaterThan, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::GreaterThanEqual, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::LessThan, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::LessThanEqual, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Minus, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Percent, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Plus, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Slash, - ); - choice.consider(input, result)?; - let result = self - .parse_token_with_trivia::( - input, - TokenKind::Tilde, - ); - choice.consider(input, result)?; - choice.finish(input) - }) - } else { - ParserResult::disabled() - })?; - seq.finish() - })))?; - } - seq.finish() - }) + if self.version_is_at_least_0_8_13 { + SequenceHelper::run(|mut seq| { + seq.elem(self.identifier_path(input))?; + if self.version_is_at_least_0_8_19 { + seq.elem(OptionalHelper::transform(SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::AsKeyword, + ))?; + seq.elem(if self.version_is_at_least_0_8_19 { + ChoiceHelper::run(input, |mut choice, input| { + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Ampersand, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Asterisk, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::BangEqual, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Bar, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Caret, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::EqualEqual, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::GreaterThan, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::GreaterThanEqual, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::LessThan, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::LessThanEqual, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Minus, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Percent, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Plus, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Slash, + ); + choice.consider(input, result)?; + let result = self + .parse_token_with_trivia::( + input, + TokenKind::Tilde, + ); + choice.consider(input, result)?; + choice.finish(input) + }) + } else { + ParserResult::disabled() + })?; + seq.finish() + })))?; + } + seq.finish() + }) + } else { + ParserResult::disabled() + } .with_kind(RuleKind::UsingDirectiveSymbol) } diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path/generated/0.4.11-failure.yml new file mode 100644 index 0000000000..8b19b10df8 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path/generated/0.4.11-failure.yml @@ -0,0 +1,17 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ foo.bar │ 0..7 + +Errors: # 1 total + - > + Error: Expected end of file. + ╭─[crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path/input.sol:1:1] + │ + 1 │ foo.bar + │ ───┬─── + │ ╰───── Error occurred here. + ───╯ + +Tree: + - SKIPPED (Token): "foo.bar" # 0..7 diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path/generated/0.8.13-success.yml similarity index 100% rename from crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path/generated/0.4.11-success.yml rename to crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path/generated/0.8.13-success.yml diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/generated/0.4.11-failure.yml index acafdfb3ec..a035f715e0 100644 --- a/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/generated/0.4.11-failure.yml @@ -5,18 +5,13 @@ Source: > Errors: # 1 total - > - Error: Expected Period. - ╭─[crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/input.sol:1:8] + Error: Expected end of file. + ╭─[crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/input.sol:1:1] │ 1 │ foo.bar as / - │ ──┬── - │ ╰──── Error occurred here. + │ ──────┬───── + │ ╰─────── Error occurred here. ───╯ Tree: - - UsingDirectiveSymbol (Rule): # 0..12 "foo.bar as /" - - IdentifierPath (Rule): # 0..7 "foo.bar" - - Identifier (Token): "foo" # 0..3 - - Period (Token): "." # 3..4 - - Identifier (Token): "bar" # 4..7 - - SKIPPED (Token): " as /" # 7..12 + - SKIPPED (Token): "foo.bar as /" # 0..12 diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/generated/0.8.13-failure.yml b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/generated/0.8.13-failure.yml new file mode 100644 index 0000000000..acafdfb3ec --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/generated/0.8.13-failure.yml @@ -0,0 +1,22 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ foo.bar as / │ 0..12 + +Errors: # 1 total + - > + Error: Expected Period. + ╭─[crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/identifier_path_as_operator/input.sol:1:8] + │ + 1 │ foo.bar as / + │ ──┬── + │ ╰──── Error occurred here. + ───╯ + +Tree: + - UsingDirectiveSymbol (Rule): # 0..12 "foo.bar as /" + - IdentifierPath (Rule): # 0..7 "foo.bar" + - Identifier (Token): "foo" # 0..3 + - Period (Token): "." # 3..4 + - Identifier (Token): "bar" # 4..7 + - SKIPPED (Token): " as /" # 7..12 diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id/generated/0.4.11-failure.yml new file mode 100644 index 0000000000..b446f82fa0 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id/generated/0.4.11-failure.yml @@ -0,0 +1,17 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ foo │ 0..3 + +Errors: # 1 total + - > + Error: Expected end of file. + ╭─[crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id/input.sol:1:1] + │ + 1 │ foo + │ ─┬─ + │ ╰─── Error occurred here. + ───╯ + +Tree: + - SKIPPED (Token): "foo" # 0..3 diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id/generated/0.8.13-success.yml similarity index 100% rename from crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id/generated/0.4.11-success.yml rename to crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id/generated/0.8.13-success.yml diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/generated/0.4.11-failure.yml index 8e056c58c5..bc5d88eef9 100644 --- a/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/generated/0.4.11-failure.yml @@ -5,16 +5,13 @@ Source: > Errors: # 1 total - > - Error: Expected Period. - ╭─[crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/input.sol:1:4] + Error: Expected end of file. + ╭─[crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/input.sol:1:1] │ 1 │ foo as / - │ ──┬── - │ ╰──── Error occurred here. + │ ────┬─── + │ ╰───── Error occurred here. ───╯ Tree: - - UsingDirectiveSymbol (Rule): # 0..8 "foo as /" - - IdentifierPath (Rule): # 0..3 "foo" - - Identifier (Token): "foo" # 0..3 - - SKIPPED (Token): " as /" # 3..8 + - SKIPPED (Token): "foo as /" # 0..8 diff --git a/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/generated/0.8.13-failure.yml b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/generated/0.8.13-failure.yml new file mode 100644 index 0000000000..8e056c58c5 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/generated/0.8.13-failure.yml @@ -0,0 +1,20 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ foo as / │ 0..8 + +Errors: # 1 total + - > + Error: Expected Period. + ╭─[crates/solidity/testing/snapshots/cst_output/UsingDirectiveSymbol/single_id_as_operator/input.sol:1:4] + │ + 1 │ foo as / + │ ──┬── + │ ╰──── Error occurred here. + ───╯ + +Tree: + - UsingDirectiveSymbol (Rule): # 0..8 "foo as /" + - IdentifierPath (Rule): # 0..3 "foo" + - Identifier (Token): "foo" # 0..3 + - SKIPPED (Token): " as /" # 3..8 From a0eb099a21bd4dcd659fa76ccd770d87424a3a55 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sun, 12 Nov 2023 19:58:44 +0100 Subject: [PATCH 02/12] fix: Ensure the same ordered choice for Statement across lang defs --- .../04-statements/01-blocks/productions.yml | 2 +- crates/solidity/inputs/language/src/definition.rs | 14 ++++++++------ .../01-blocks/control-statement/0.8.4.md | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/crates/solidity/inputs/language/definition/04-statements/01-blocks/productions.yml b/crates/solidity/inputs/language/definition/04-statements/01-blocks/productions.yml index 0b44122bba..16fcd03d03 100644 --- a/crates/solidity/inputs/language/definition/04-statements/01-blocks/productions.yml +++ b/crates/solidity/inputs/language/definition/04-statements/01-blocks/productions.yml @@ -100,9 +100,9 @@ - reference: "BreakStatement" - reference: "DeleteStatement" - reference: "ReturnStatement" - - reference: "RevertStatement" - reference: "EmitStatement" - reference: "TryStatement" + - reference: "RevertStatement" - name: "SimpleStatement" kind: "Parser" diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index d24a009903..0c177082f3 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -2865,14 +2865,17 @@ codegen_language_macros::compile!(Language( Enum( name = Statement, variants = [ - EnumVariant( - name = TupleDeconstruction, - reference = TupleDeconstructionStatement - ), + // Simple statements + EnumVariant(name = Expression, reference = ExpressionStatement), EnumVariant( name = VariableDeclaration, reference = VariableDeclarationStatement ), + EnumVariant( + name = TupleDeconstruction, + reference = TupleDeconstructionStatement + ), + // Control statements EnumVariant(name = If, reference = IfStatement), EnumVariant(name = For, reference = ForStatement), EnumVariant(name = While, reference = WhileStatement), @@ -2907,8 +2910,7 @@ codegen_language_macros::compile!(Language( name = UncheckedBlock, enabled = From("0.8.0"), reference = UncheckedBlock - ), - EnumVariant(name = Expression, reference = ExpressionStatement) + ) ] ), Struct( diff --git a/crates/solidity/outputs/spec/generated/ebnf/04-statements/01-blocks/control-statement/0.8.4.md b/crates/solidity/outputs/spec/generated/ebnf/04-statements/01-blocks/control-statement/0.8.4.md index c59144ce13..8e304ec056 100644 --- a/crates/solidity/outputs/spec/generated/ebnf/04-statements/01-blocks/control-statement/0.8.4.md +++ b/crates/solidity/outputs/spec/generated/ebnf/04-statements/01-blocks/control-statement/0.8.4.md @@ -9,7 +9,7 @@ | BreakStatement | DeleteStatement | ReturnStatement - | RevertStatement | EmitStatement - | TryStatement; + | TryStatement + | RevertStatement; ``` From b0d0659c62d2079b569e984d6de8d73e9c280881 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sun, 12 Nov 2023 20:09:33 +0100 Subject: [PATCH 03/12] fix: Ensure same ordered choice for YulStatement across lang defs --- crates/solidity/inputs/language/src/dsl.rs | 4 ++-- .../outputs/cargo/crate/src/generated/language.rs | 8 ++++---- .../solidity/outputs/npm/crate/src/generated/language.rs | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/solidity/inputs/language/src/dsl.rs b/crates/solidity/inputs/language/src/dsl.rs index a76c2f8349..b5f90905b4 100644 --- a/crates/solidity/inputs/language/src/dsl.rs +++ b/crates/solidity/inputs/language/src/dsl.rs @@ -664,8 +664,8 @@ slang_grammar! { parser YulStatement = ( YulBlock | YulFunctionDefinition | YulDeclarationStatement | YulAssignmentStatement | YulIfStatement | - YulForStatement | YulSwitchStatement | YulBreakStatement | YulContinueStatement | YulExpression | - { introduced in "0.6.0" YulLeaveStatement } + YulForStatement | YulSwitchStatement | { introduced in "0.6.0" YulLeaveStatement } | + YulBreakStatement | YulContinueStatement | YulExpression ) ; parser YulStatementsList = (YulStatement +) ; diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index ad81d06e92..1b710c7fd0 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -4929,16 +4929,16 @@ impl Language { choice.consider(input, result)?; let result = self.yul_switch_statement(input); choice.consider(input, result)?; + if self.version_is_at_least_0_6_0 { + let result = self.yul_leave_statement(input); + choice.consider(input, result)?; + } let result = self.yul_break_statement(input); choice.consider(input, result)?; let result = self.yul_continue_statement(input); choice.consider(input, result)?; let result = self.yul_expression(input); choice.consider(input, result)?; - if self.version_is_at_least_0_6_0 { - let result = self.yul_leave_statement(input); - choice.consider(input, result)?; - } choice.finish(input) }) .with_kind(RuleKind::YulStatement) diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index ad81d06e92..1b710c7fd0 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -4929,16 +4929,16 @@ impl Language { choice.consider(input, result)?; let result = self.yul_switch_statement(input); choice.consider(input, result)?; + if self.version_is_at_least_0_6_0 { + let result = self.yul_leave_statement(input); + choice.consider(input, result)?; + } let result = self.yul_break_statement(input); choice.consider(input, result)?; let result = self.yul_continue_statement(input); choice.consider(input, result)?; let result = self.yul_expression(input); choice.consider(input, result)?; - if self.version_is_at_least_0_6_0 { - let result = self.yul_leave_statement(input); - choice.consider(input, result)?; - } choice.finish(input) }) .with_kind(RuleKind::YulStatement) From 7a2eb843c6570f2ff4ad7288921e862f66c488f3 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Mon, 13 Nov 2023 17:29:23 +0100 Subject: [PATCH 04/12] fix: Mark parentheses in event parameters as required in DSL v2 --- .../inputs/language/src/definition.rs | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 0c177082f3..f10d1c1ab7 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -2603,26 +2603,19 @@ codegen_language_macros::compile!(Language( items = [ Struct( name = EventDefinition, - error_recovery = FieldsErrorRecovery(terminator = semicolon), - fields = ( - event_keyword = Required(Terminal([EventKeyword])), - name = Required(Terminal([Identifier])), - parameters = - Optional(kind = NonTerminal(EventParametersDeclaration)), - anonymous_keyword = Optional(kind = Terminal([AnonymousKeyword])), - semicolon = Required(Terminal([Semicolon])) - ) - ), - Struct( - name = EventParametersDeclaration, error_recovery = FieldsErrorRecovery( + terminator = semicolon, delimiters = FieldDelimiters(open = open_paren, close = close_paren) ), fields = ( + event_keyword = Required(Terminal([EventKeyword])), + name = Required(Terminal([Identifier])), open_paren = Required(Terminal([OpenParen])), - parameters = Required(NonTerminal(EventParameters)), - close_paren = Required(Terminal([CloseParen])) + parameters = Optional(kind = NonTerminal(EventParameters)), + close_paren = Required(Terminal([CloseParen])), + anonymous_keyword = Optional(kind = Terminal([AnonymousKeyword])), + semicolon = Required(Terminal([Semicolon])) ) ), Separated( From e22d6a0350b6f0bbe03aa9c8bd631e283b46932b Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Mon, 13 Nov 2023 17:21:22 +0100 Subject: [PATCH 05/12] Add a regression test for event definition with no parentheses --- .../cst_output/generated/EventDefinition.rs | 5 +++++ .../no_parens/generated/0.4.11-failure.yml | 21 +++++++++++++++++++ .../EventDefinition/no_parens/input.sol | 1 + 3 files changed, 27 insertions(+) create mode 100644 crates/solidity/testing/snapshots/cst_output/EventDefinition/no_parens/generated/0.4.11-failure.yml create mode 100644 crates/solidity/testing/snapshots/cst_output/EventDefinition/no_parens/input.sol diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/EventDefinition.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/EventDefinition.rs index f47b3938b6..2b07fe8293 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/EventDefinition.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/EventDefinition.rs @@ -3,6 +3,11 @@ use crate::cst_output::runner::run; use anyhow::Result; +#[test] +fn no_parens() -> Result<()> { + return run("EventDefinition", "no_parens"); +} + #[test] fn transfer() -> Result<()> { return run("EventDefinition", "transfer"); diff --git a/crates/solidity/testing/snapshots/cst_output/EventDefinition/no_parens/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/EventDefinition/no_parens/generated/0.4.11-failure.yml new file mode 100644 index 0000000000..d647d84e61 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/EventDefinition/no_parens/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 │ event MyEvent; │ 0..14 + +Errors: # 1 total + - > + Error: Expected OpenParen. + ╭─[crates/solidity/testing/snapshots/cst_output/EventDefinition/no_parens/input.sol:1:14] + │ + 1 │ event MyEvent; + │ │ + │ ╰─ Error occurred here. + ───╯ + +Tree: + - EventDefinition (Rule): # 0..15 "event MyEvent;\n" + - EventKeyword (Token): "event" # 0..5 + - Identifier (Token): "MyEvent" # 6..13 + - SKIPPED (Token): "" # 13..13 + - Semicolon (Token): ";" # 13..14 diff --git a/crates/solidity/testing/snapshots/cst_output/EventDefinition/no_parens/input.sol b/crates/solidity/testing/snapshots/cst_output/EventDefinition/no_parens/input.sol new file mode 100644 index 0000000000..1435cff2be --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/EventDefinition/no_parens/input.sol @@ -0,0 +1 @@ +event MyEvent; From 2df2c49e0ac8ec107e279f3812d9c7ae7f6488c6 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Tue, 14 Nov 2023 10:18:52 +0100 Subject: [PATCH 06/12] fix: Mark ElseBranch fields in DSL v2 as required The sequence elements itself are required, it's the whole sequence that's optional, like in v0/v1 --- crates/solidity/inputs/language/src/definition.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index f10d1c1ab7..8aeebc22ae 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -3039,8 +3039,8 @@ codegen_language_macros::compile!(Language( Struct( name = ElseBranch, fields = ( - else_keyword = Optional(kind = Terminal([ElseKeyword])), - body = Optional(kind = NonTerminal(Statement)) + else_keyword = Required(Terminal([ElseKeyword])), + body = Required(NonTerminal(Statement)) ) ), Struct( From 294d4d06e4dc004d55663be684d9b1f69cfbf564 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Tue, 14 Nov 2023 11:15:09 +0100 Subject: [PATCH 07/12] nit: Make AbicoderKeyword casing in DSL v1 consistent with v0 --- crates/solidity/inputs/language/src/dsl.rs | 6 +++--- crates/solidity/outputs/cargo/crate/src/generated/kinds.rs | 2 +- .../solidity/outputs/cargo/crate/src/generated/language.rs | 4 ++-- crates/solidity/outputs/npm/crate/src/generated/kinds.rs | 2 +- crates/solidity/outputs/npm/crate/src/generated/language.rs | 4 ++-- .../PragmaDirective/abi_coder/generated/0.4.11-success.yml | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/solidity/inputs/language/src/dsl.rs b/crates/solidity/inputs/language/src/dsl.rs index b5f90905b4..db18fd5a07 100644 --- a/crates/solidity/inputs/language/src/dsl.rs +++ b/crates/solidity/inputs/language/src/dsl.rs @@ -35,7 +35,7 @@ slang_grammar! { lexical context Default = { inline parser SolidityKeywordsOverAllVersions = ( - ABICoderKeyword + AbicoderKeyword | AbstractKeyword | AddressKeyword | AfterKeyword @@ -165,7 +165,7 @@ slang_grammar! { | GlobalKeyword ) ; - parser ABICoderPragma = (ABICoderKeyword Identifier) ; + parser ABICoderPragma = (AbicoderKeyword Identifier) ; inline parser AddSubOperator = (Plus | Minus) ; @@ -852,7 +852,7 @@ slang_grammar! { // Keywords - scanner ABICoderKeyword = "abicoder" ; + scanner AbicoderKeyword = "abicoder" ; scanner AbstractKeyword = "abstract" ; scanner AddressKeyword = "address" ; scanner AfterKeyword = "after" ; diff --git a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs index 2907502d19..f18d3bb7c9 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs @@ -350,7 +350,7 @@ impl RuleKind { #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] pub enum TokenKind { SKIPPED, - ABICoderKeyword, + AbicoderKeyword, AbstractKeyword, AddressKeyword, AfterKeyword, diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index 1b710c7fd0..f21b15fd2e 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -180,7 +180,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, - TokenKind::ABICoderKeyword, + TokenKind::AbicoderKeyword, ))?; seq.elem(self.parse_token_with_trivia::( input, @@ -5868,7 +5868,7 @@ impl Lexer for Language { Some('a') => match input.next() { Some('b') => match input.next() { Some('i') => scan_chars!(input, 'c', 'o', 'd', 'e', 'r') - .then_some(TokenKind::ABICoderKeyword), + .then_some(TokenKind::AbicoderKeyword), Some('s') => scan_chars!(input, 't', 'r', 'a', 'c', 't') .then_some(TokenKind::AbstractKeyword), Some(_) => { diff --git a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs index 2907502d19..f18d3bb7c9 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs @@ -350,7 +350,7 @@ impl RuleKind { #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] pub enum TokenKind { SKIPPED, - ABICoderKeyword, + AbicoderKeyword, AbstractKeyword, AddressKeyword, AfterKeyword, diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index 1b710c7fd0..f21b15fd2e 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -180,7 +180,7 @@ impl Language { SequenceHelper::run(|mut seq| { seq.elem(self.parse_token_with_trivia::( input, - TokenKind::ABICoderKeyword, + TokenKind::AbicoderKeyword, ))?; seq.elem(self.parse_token_with_trivia::( input, @@ -5868,7 +5868,7 @@ impl Lexer for Language { Some('a') => match input.next() { Some('b') => match input.next() { Some('i') => scan_chars!(input, 'c', 'o', 'd', 'e', 'r') - .then_some(TokenKind::ABICoderKeyword), + .then_some(TokenKind::AbicoderKeyword), Some('s') => scan_chars!(input, 't', 'r', 'a', 'c', 't') .then_some(TokenKind::AbstractKeyword), Some(_) => { diff --git a/crates/solidity/testing/snapshots/cst_output/PragmaDirective/abi_coder/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/PragmaDirective/abi_coder/generated/0.4.11-success.yml index 7727faf7a8..a962905b2b 100644 --- a/crates/solidity/testing/snapshots/cst_output/PragmaDirective/abi_coder/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/PragmaDirective/abi_coder/generated/0.4.11-success.yml @@ -9,6 +9,6 @@ Tree: - PragmaDirective (Rule): # 0..20 "pragma abicoder foo;" - PragmaKeyword (Token): "pragma" # 0..6 - ABICoderPragma (Rule): # 6..19 " abicoder foo" - - ABICoderKeyword (Token): "abicoder" # 7..15 + - AbicoderKeyword (Token): "abicoder" # 7..15 - Identifier (Token): "foo" # 16..19 - Semicolon (Token): ";" # 19..20 From 4d87ae9ea1d0bebf96d06adcfea79edf9c799919 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Tue, 14 Nov 2023 13:50:59 +0100 Subject: [PATCH 08/12] fixup: Update the generated typings --- crates/solidity/outputs/npm/package/src/generated/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 614b4bad76..c762fddc77 100644 --- a/crates/solidity/outputs/npm/package/src/generated/index.d.ts +++ b/crates/solidity/outputs/npm/package/src/generated/index.d.ts @@ -306,7 +306,7 @@ export namespace kinds { } export enum TokenKind { SKIPPED = "SKIPPED", - ABICoderKeyword = "ABICoderKeyword", + AbicoderKeyword = "AbicoderKeyword", AbstractKeyword = "AbstractKeyword", AddressKeyword = "AddressKeyword", AfterKeyword = "AfterKeyword", From 935a9ef23b459d5a95d4353a46338faad69cd44a Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 15 Nov 2023 10:09:34 +0100 Subject: [PATCH 09/12] fix: Mark EventParameters as allow_empty = false in DSL v2 --- crates/solidity/inputs/language/src/definition.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 8aeebc22ae..4bfb5817d3 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -2621,8 +2621,7 @@ codegen_language_macros::compile!(Language( Separated( name = EventParameters, separated = EventParameter, - separator = Comma, - allow_empty = true + separator = Comma ), Struct( name = EventParameter, From 18a8962c76d3ad0206854efede9b74a8033cab75 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 15 Nov 2023 11:51:49 +0100 Subject: [PATCH 10/12] Bring back EventParametersDeclaration in DSL v2 --- .../solidity/inputs/language/src/definition.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index 4bfb5817d3..17b49f69a0 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -2603,19 +2603,25 @@ codegen_language_macros::compile!(Language( items = [ Struct( name = EventDefinition, + error_recovery = FieldsErrorRecovery(terminator = semicolon), + fields = ( + event_keyword = Required(Terminal([EventKeyword])), + name = Required(Terminal([Identifier])), + parameters = Required(NonTerminal(EventParametersDeclaration)), + anonymous_keyword = Optional(kind = Terminal([AnonymousKeyword])), + semicolon = Required(Terminal([Semicolon])) + ) + ), + Struct( + name = EventParametersDeclaration, error_recovery = FieldsErrorRecovery( - terminator = semicolon, delimiters = FieldDelimiters(open = open_paren, close = close_paren) ), fields = ( - event_keyword = Required(Terminal([EventKeyword])), - name = Required(Terminal([Identifier])), open_paren = Required(Terminal([OpenParen])), parameters = Optional(kind = NonTerminal(EventParameters)), - close_paren = Required(Terminal([CloseParen])), - anonymous_keyword = Optional(kind = Terminal([AnonymousKeyword])), - semicolon = Required(Terminal([Semicolon])) + close_paren = Required(Terminal([CloseParen])) ) ), Separated( From b716ed00617fc6140beb2ae7caa64f7180487cbc Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 15 Nov 2023 12:13:50 +0100 Subject: [PATCH 11/12] Introduce EventParametersDeclaration in v0/v1 --- .../02-definitions/10-events/productions.yml | 21 +++++--- crates/solidity/inputs/language/src/dsl.rs | 4 +- .../cargo/crate/src/generated/kinds.rs | 2 + .../cargo/crate/src/generated/language.rs | 53 +++++++++++-------- .../outputs/npm/crate/src/generated/kinds.rs | 2 + .../npm/crate/src/generated/language.rs | 53 +++++++++++-------- .../npm/package/src/generated/index.d.ts | 2 + .../10-events/event-definition/unversioned.md | 2 +- .../unversioned.md | 5 ++ .../generated/public/grammar/v0.4.11/index.md | 1 + .../generated/public/grammar/v0.4.21/index.md | 1 + .../generated/public/grammar/v0.4.22/index.md | 1 + .../generated/public/grammar/v0.5.0/index.md | 1 + .../generated/public/grammar/v0.5.3/index.md | 1 + .../generated/public/grammar/v0.6.0/index.md | 1 + .../generated/public/grammar/v0.6.11/index.md | 1 + .../generated/public/grammar/v0.6.2/index.md | 1 + .../generated/public/grammar/v0.6.5/index.md | 1 + .../generated/public/grammar/v0.7.0/index.md | 1 + .../generated/public/grammar/v0.7.1/index.md | 1 + .../generated/public/grammar/v0.7.4/index.md | 1 + .../generated/public/grammar/v0.8.0/index.md | 1 + .../generated/public/grammar/v0.8.13/index.md | 1 + .../generated/public/grammar/v0.8.18/index.md | 1 + .../generated/public/grammar/v0.8.19/index.md | 1 + .../generated/public/grammar/v0.8.22/index.md | 1 + .../generated/public/grammar/v0.8.4/index.md | 1 + .../generated/public/grammar/v0.8.8/index.md | 1 + .../generated/0.4.11-success.yml | 29 +++++----- .../transfer/generated/0.4.11-failure.yml | 19 +++---- .../everything/generated/0.8.22-success.yml | 15 +++--- .../generated/0.8.22-success.yml | 15 +++--- 32 files changed, 150 insertions(+), 91 deletions(-) create mode 100644 crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md diff --git a/crates/solidity/inputs/language/definition/02-definitions/10-events/productions.yml b/crates/solidity/inputs/language/definition/02-definitions/10-events/productions.yml index 8109d5768e..5d8f74e8cd 100644 --- a/crates/solidity/inputs/language/definition/02-definitions/10-events/productions.yml +++ b/crates/solidity/inputs/language/definition/02-definitions/10-events/productions.yml @@ -8,19 +8,24 @@ sequence: - reference: "EventKeyword" - reference: "Identifier" - - delimitedBy: - open: - reference: "OpenParen" - parser: - optional: - reference: "EventParametersList" - close: - reference: "CloseParen" + - reference: "EventParametersDeclaration" - optional: reference: "AnonymousKeyword" terminator: reference: "Semicolon" +- name: "EventParametersDeclaration" + kind: "Parser" + unversioned: + delimitedBy: + open: + reference: "OpenParen" + parser: + optional: + reference: "EventParametersList" + close: + reference: "CloseParen" + - name: "EventParametersList" kind: "Parser" unversioned: diff --git a/crates/solidity/inputs/language/src/dsl.rs b/crates/solidity/inputs/language/src/dsl.rs index db18fd5a07..89b66d4aa5 100644 --- a/crates/solidity/inputs/language/src/dsl.rs +++ b/crates/solidity/inputs/language/src/dsl.rs @@ -277,7 +277,9 @@ slang_grammar! { parser ErrorParametersList = { introduced in "0.8.4" (ErrorParameter separated by Comma) } ; - parser EventDefinition = ((EventKeyword Identifier ((EventParametersList ?) delimited by OpenParen and CloseParen) (AnonymousKeyword ?)) terminated by Semicolon) ; + parser EventDefinition = ((EventKeyword Identifier EventParametersDeclaration (AnonymousKeyword ?)) terminated by Semicolon) ; + + parser EventParametersDeclaration = ((EventParametersList ?) delimited by OpenParen and CloseParen); parser EventParameter = (TypeName (IndexedKeyword ?) (Identifier ?)) ; diff --git a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs index f18d3bb7c9..61d3cc349f 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs @@ -49,6 +49,7 @@ pub enum ProductionKind { ErrorParametersList, EventDefinition, EventParameter, + EventParametersDeclaration, EventParametersList, ExperimentalPragma, Expression, @@ -207,6 +208,7 @@ pub enum RuleKind { ErrorParametersList, EventDefinition, EventParameter, + EventParametersDeclaration, EventParametersList, ExperimentalPragma, Expression, diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index f21b15fd2e..e1e10e21f4 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -974,28 +974,7 @@ impl Language { input, TokenKind::Identifier, ))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenParen, - ))?; - seq.elem( - OptionalHelper::transform(self.event_parameters_list(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, - ))?; - seq.finish() - }))?; + seq.elem(self.event_parameters_declaration(input))?; seq.elem(OptionalHelper::transform( self.parse_token_with_trivia::( input, @@ -1041,6 +1020,33 @@ impl Language { .with_kind(RuleKind::EventParameter) } + #[allow(unused_assignments, unused_parens)] + fn event_parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenParen, + ))?; + seq.elem( + OptionalHelper::transform(self.event_parameters_list(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseParen, + ))?; + seq.finish() + }) + .with_kind(RuleKind::EventParametersDeclaration) + } + #[allow(unused_assignments, unused_parens)] fn event_parameters_list(&self, input: &mut ParserContext) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( @@ -5648,6 +5654,9 @@ impl Language { ProductionKind::ErrorParametersList => Self::error_parameters_list.parse(self, input), ProductionKind::EventDefinition => Self::event_definition.parse(self, input), ProductionKind::EventParameter => Self::event_parameter.parse(self, input), + ProductionKind::EventParametersDeclaration => { + Self::event_parameters_declaration.parse(self, input) + } ProductionKind::EventParametersList => Self::event_parameters_list.parse(self, input), ProductionKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), ProductionKind::Expression => Self::expression.parse(self, input), diff --git a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs index f18d3bb7c9..61d3cc349f 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs @@ -49,6 +49,7 @@ pub enum ProductionKind { ErrorParametersList, EventDefinition, EventParameter, + EventParametersDeclaration, EventParametersList, ExperimentalPragma, Expression, @@ -207,6 +208,7 @@ pub enum RuleKind { ErrorParametersList, EventDefinition, EventParameter, + EventParametersDeclaration, EventParametersList, ExperimentalPragma, Expression, diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index f21b15fd2e..e1e10e21f4 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -974,28 +974,7 @@ impl Language { input, TokenKind::Identifier, ))?; - seq.elem(SequenceHelper::run(|mut seq| { - let mut delim_guard = input.open_delim(TokenKind::CloseParen); - let input = delim_guard.ctx(); - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::OpenParen, - ))?; - seq.elem( - OptionalHelper::transform(self.event_parameters_list(input)) - .recover_until_with_nested_delims::<_, LexicalContextType::Default>( - input, - self, - TokenKind::CloseParen, - RecoverFromNoMatch::Yes, - ), - )?; - seq.elem(self.parse_token_with_trivia::( - input, - TokenKind::CloseParen, - ))?; - seq.finish() - }))?; + seq.elem(self.event_parameters_declaration(input))?; seq.elem(OptionalHelper::transform( self.parse_token_with_trivia::( input, @@ -1041,6 +1020,33 @@ impl Language { .with_kind(RuleKind::EventParameter) } + #[allow(unused_assignments, unused_parens)] + fn event_parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { + SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenParen, + ))?; + seq.elem( + OptionalHelper::transform(self.event_parameters_list(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseParen, + ))?; + seq.finish() + }) + .with_kind(RuleKind::EventParametersDeclaration) + } + #[allow(unused_assignments, unused_parens)] fn event_parameters_list(&self, input: &mut ParserContext) -> ParserResult { SeparatedHelper::run::<_, LexicalContextType::Default>( @@ -5648,6 +5654,9 @@ impl Language { ProductionKind::ErrorParametersList => Self::error_parameters_list.parse(self, input), ProductionKind::EventDefinition => Self::event_definition.parse(self, input), ProductionKind::EventParameter => Self::event_parameter.parse(self, input), + ProductionKind::EventParametersDeclaration => { + Self::event_parameters_declaration.parse(self, input) + } ProductionKind::EventParametersList => Self::event_parameters_list.parse(self, input), ProductionKind::ExperimentalPragma => Self::experimental_pragma.parse(self, input), ProductionKind::Expression => Self::expression.parse(self, input), 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 c762fddc77..ba538a80f8 100644 --- a/crates/solidity/outputs/npm/package/src/generated/index.d.ts +++ b/crates/solidity/outputs/npm/package/src/generated/index.d.ts @@ -44,6 +44,7 @@ export namespace kinds { ErrorParametersList = "ErrorParametersList", EventDefinition = "EventDefinition", EventParameter = "EventParameter", + EventParametersDeclaration = "EventParametersDeclaration", EventParametersList = "EventParametersList", ExperimentalPragma = "ExperimentalPragma", Expression = "Expression", @@ -188,6 +189,7 @@ export namespace kinds { ErrorParametersList = "ErrorParametersList", EventDefinition = "EventDefinition", EventParameter = "EventParameter", + EventParametersDeclaration = "EventParametersDeclaration", EventParametersList = "EventParametersList", ExperimentalPragma = "ExperimentalPragma", Expression = "Expression", diff --git a/crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md b/crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md index 80bf375614..96da22f2cc 100644 --- a/crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md +++ b/crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md @@ -1,5 +1,5 @@ ```{ .ebnf .slang-ebnf #EventDefinition } -EventDefinition = EVENT_KEYWORD IDENTIFIER OPEN_PAREN EventParametersList? CLOSE_PAREN ANONYMOUS_KEYWORD? SEMICOLON; +EventDefinition = EVENT_KEYWORD IDENTIFIER EventParametersDeclaration ANONYMOUS_KEYWORD? SEMICOLON; ``` diff --git a/crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md b/crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md new file mode 100644 index 0000000000..382b8cc5c6 --- /dev/null +++ b/crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md @@ -0,0 +1,5 @@ + + +```{ .ebnf .slang-ebnf #EventParametersDeclaration } +EventParametersDeclaration = OPEN_PAREN EventParametersList? CLOSE_PAREN; +``` diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.4.11/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.4.11/index.md index 1422761512..ec6c73dc77 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.4.11/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.4.11/index.md @@ -229,6 +229,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.4.21/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.4.21/index.md index c669fb264a..595ae4adac 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.4.21/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.4.21/index.md @@ -230,6 +230,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.4.22/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.4.22/index.md index 4e06d60864..8150f3f2b6 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.4.22/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.4.22/index.md @@ -234,6 +234,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.5.0/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.5.0/index.md index 24ec8336b5..d6b8b4047a 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.5.0/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.5.0/index.md @@ -232,6 +232,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.5.3/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.5.3/index.md index 8731178f54..85ab6d9533 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.5.3/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.5.3/index.md @@ -233,6 +233,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.6.0/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.6.0/index.md index 48b41e4a09..b3ff55bf5d 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.6.0/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.6.0/index.md @@ -241,6 +241,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.6.11/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.6.11/index.md index 3fcccc56bc..4c1f27447b 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.6.11/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.6.11/index.md @@ -243,6 +243,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.6.2/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.6.2/index.md index d75232ced0..3dad53ad5d 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.6.2/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.6.2/index.md @@ -241,6 +241,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.6.5/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.6.5/index.md index bba2cd6ad3..2dcf6056cd 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.6.5/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.6.5/index.md @@ -242,6 +242,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.7.0/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.7.0/index.md index a02ec4d70e..9c5413ffc4 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.7.0/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.7.0/index.md @@ -241,6 +241,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.7.1/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.7.1/index.md index 70dff7e73b..1f05491c2f 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.7.1/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.7.1/index.md @@ -241,6 +241,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.7.4/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.7.4/index.md index a2e0398701..d637dec03a 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.7.4/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.7.4/index.md @@ -245,6 +245,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.0/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.0/index.md index 5988e2eeea..8def06be35 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.0/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.0/index.md @@ -245,6 +245,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.13/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.13/index.md index 7fe95d83e1..7faf116776 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.13/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.13/index.md @@ -251,6 +251,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.18/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.18/index.md index 2f1ad73860..7c4c0ca75d 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.18/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.18/index.md @@ -251,6 +251,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.19/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.19/index.md index c0894ad45a..81351c0981 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.19/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.19/index.md @@ -252,6 +252,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.22/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.22/index.md index cffd967a11..4f360f112c 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.22/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.22/index.md @@ -252,6 +252,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.4/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.4/index.md index b78de2587a..797109141c 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.4/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.4/index.md @@ -247,6 +247,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.8/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.8/index.md index b7bbc10032..94a344f29d 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.8/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.8/index.md @@ -247,6 +247,7 @@ ### 2.10 Events --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-definition/unversioned.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-declaration/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameters-list/unversioned.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/10-events/event-parameter/unversioned.md" diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/member_event_definition/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/member_event_definition/generated/0.4.11-success.yml index 7a880a0155..54bec3dc36 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/member_event_definition/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/member_event_definition/generated/0.4.11-success.yml @@ -16,19 +16,20 @@ Tree: - EventDefinition (Rule): # 18..69 " event Log(uint256 indexed a, uint256 indexed b);..." - EventKeyword (Token): "event" # 20..25 - Identifier (Token): "Log" # 26..29 - - OpenParen (Token): "(" # 29..30 - - EventParametersList (Rule): # 30..66 "uint256 indexed a, uint256 indexed b" - - EventParameter (Rule): # 30..47 "uint256 indexed a" - - TypeName (Rule): # 30..37 "uint256" - - UnsignedIntegerType (Token): "uint256" # 30..37 - - IndexedKeyword (Token): "indexed" # 38..45 - - Identifier (Token): "a" # 46..47 - - Comma (Token): "," # 47..48 - - EventParameter (Rule): # 48..66 " uint256 indexed b" - - TypeName (Rule): # 48..56 " uint256" - - UnsignedIntegerType (Token): "uint256" # 49..56 - - IndexedKeyword (Token): "indexed" # 57..64 - - Identifier (Token): "b" # 65..66 - - CloseParen (Token): ")" # 66..67 + - EventParametersDeclaration (Rule): # 29..67 "(uint256 indexed a, uint256 indexed b)" + - OpenParen (Token): "(" # 29..30 + - EventParametersList (Rule): # 30..66 "uint256 indexed a, uint256 indexed b" + - EventParameter (Rule): # 30..47 "uint256 indexed a" + - TypeName (Rule): # 30..37 "uint256" + - UnsignedIntegerType (Token): "uint256" # 30..37 + - IndexedKeyword (Token): "indexed" # 38..45 + - Identifier (Token): "a" # 46..47 + - Comma (Token): "," # 47..48 + - EventParameter (Rule): # 48..66 " uint256 indexed b" + - TypeName (Rule): # 48..56 " uint256" + - UnsignedIntegerType (Token): "uint256" # 49..56 + - IndexedKeyword (Token): "indexed" # 57..64 + - Identifier (Token): "b" # 65..66 + - CloseParen (Token): ")" # 66..67 - Semicolon (Token): ";" # 67..68 - CloseBrace (Token): "}" # 69..70 diff --git a/crates/solidity/testing/snapshots/cst_output/EventDefinition/transfer/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/EventDefinition/transfer/generated/0.4.11-failure.yml index 589149e0e6..a5f92dac8e 100644 --- a/crates/solidity/testing/snapshots/cst_output/EventDefinition/transfer/generated/0.4.11-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/EventDefinition/transfer/generated/0.4.11-failure.yml @@ -17,13 +17,14 @@ Tree: - EventDefinition (Rule): # 0..73 "event Transfer(address indexed from, address index..." - EventKeyword (Token): "event" # 0..5 - Identifier (Token): "Transfer" # 6..14 - - OpenParen (Token): "(" # 14..15 - - EventParametersList (Rule): # 15..30 "address indexed" - - EventParameter (Rule): # 15..30 "address indexed" - - TypeName (Rule): # 15..22 "address" - - AddressType (Rule): # 15..22 "address" - - AddressKeyword (Token): "address" # 15..22 - - IndexedKeyword (Token): "indexed" # 23..30 - - SKIPPED (Token): "from, address indexed to, uint256 value" # 31..70 - - CloseParen (Token): ")" # 70..71 + - EventParametersDeclaration (Rule): # 14..71 "(address indexed from, address indexed to, uint256..." + - OpenParen (Token): "(" # 14..15 + - EventParametersList (Rule): # 15..30 "address indexed" + - EventParameter (Rule): # 15..30 "address indexed" + - TypeName (Rule): # 15..22 "address" + - AddressType (Rule): # 15..22 "address" + - AddressKeyword (Token): "address" # 15..22 + - IndexedKeyword (Token): "indexed" # 23..30 + - SKIPPED (Token): "from, address indexed to, uint256 value" # 31..70 + - CloseParen (Token): ")" # 70..71 - Semicolon (Token): ";" # 71..72 diff --git a/crates/solidity/testing/snapshots/cst_output/SourceUnit/everything/generated/0.8.22-success.yml b/crates/solidity/testing/snapshots/cst_output/SourceUnit/everything/generated/0.8.22-success.yml index 681f4e6046..50a27d4fe5 100644 --- a/crates/solidity/testing/snapshots/cst_output/SourceUnit/everything/generated/0.8.22-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/SourceUnit/everything/generated/0.8.22-success.yml @@ -125,11 +125,12 @@ Tree: - EventDefinition (Rule): # 217..243 "\nevent E1(uint256 value);\n" - EventKeyword (Token): "event" # 218..223 - Identifier (Token): "E1" # 224..226 - - OpenParen (Token): "(" # 226..227 - - EventParametersList (Rule): # 227..240 "uint256 value" - - EventParameter (Rule): # 227..240 "uint256 value" - - TypeName (Rule): # 227..234 "uint256" - - UnsignedIntegerType (Token): "uint256" # 227..234 - - Identifier (Token): "value" # 235..240 - - CloseParen (Token): ")" # 240..241 + - EventParametersDeclaration (Rule): # 226..241 "(uint256 value)" + - OpenParen (Token): "(" # 226..227 + - EventParametersList (Rule): # 227..240 "uint256 value" + - EventParameter (Rule): # 227..240 "uint256 value" + - TypeName (Rule): # 227..234 "uint256" + - UnsignedIntegerType (Token): "uint256" # 227..234 + - Identifier (Token): "value" # 235..240 + - CloseParen (Token): ")" # 240..241 - Semicolon (Token): ";" # 241..242 diff --git a/crates/solidity/testing/snapshots/cst_output/SourceUnit/top_level_event/generated/0.8.22-success.yml b/crates/solidity/testing/snapshots/cst_output/SourceUnit/top_level_event/generated/0.8.22-success.yml index d0a39be628..e201ec4fb1 100644 --- a/crates/solidity/testing/snapshots/cst_output/SourceUnit/top_level_event/generated/0.8.22-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/SourceUnit/top_level_event/generated/0.8.22-success.yml @@ -11,11 +11,12 @@ Tree: - EventDefinition (Rule): # 0..25 "event E1(uint256 value);\n" - EventKeyword (Token): "event" # 0..5 - Identifier (Token): "E1" # 6..8 - - OpenParen (Token): "(" # 8..9 - - EventParametersList (Rule): # 9..22 "uint256 value" - - EventParameter (Rule): # 9..22 "uint256 value" - - TypeName (Rule): # 9..16 "uint256" - - UnsignedIntegerType (Token): "uint256" # 9..16 - - Identifier (Token): "value" # 17..22 - - CloseParen (Token): ")" # 22..23 + - EventParametersDeclaration (Rule): # 8..23 "(uint256 value)" + - OpenParen (Token): "(" # 8..9 + - EventParametersList (Rule): # 9..22 "uint256 value" + - EventParameter (Rule): # 9..22 "uint256 value" + - TypeName (Rule): # 9..16 "uint256" + - UnsignedIntegerType (Token): "uint256" # 9..16 + - Identifier (Token): "value" # 17..22 + - CloseParen (Token): ")" # 22..23 - Semicolon (Token): ";" # 23..24 From 456f77c232cfd6eab0419f8214f57968ae7fd9ea Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 15 Nov 2023 12:30:26 +0100 Subject: [PATCH 12/12] Introduce ErrorParametersDeclaration in v0/v1 --- .../02-definitions/12-errors/productions.yml | 22 +++--- crates/solidity/inputs/language/src/dsl.rs | 4 +- .../cargo/crate/src/generated/kinds.rs | 2 + .../cargo/crate/src/generated/language.rs | 67 ++++++++++++++++++- .../outputs/npm/crate/src/generated/kinds.rs | 2 + .../npm/crate/src/generated/language.rs | 67 ++++++++++++++++++- .../npm/package/src/generated/index.d.ts | 2 + .../12-errors/error-definition/0.8.4.md | 2 +- .../error-parameters-declaration/0.8.4.md | 5 ++ .../generated/public/grammar/v0.8.13/index.md | 1 + .../generated/public/grammar/v0.8.18/index.md | 1 + .../generated/public/grammar/v0.8.19/index.md | 1 + .../generated/public/grammar/v0.8.22/index.md | 1 + .../generated/public/grammar/v0.8.4/index.md | 1 + .../generated/public/grammar/v0.8.8/index.md | 1 + .../generated/0.8.4-success.yml | 5 +- .../top_level/generated/0.8.4-success.yml | 5 +- .../everything/generated/0.8.13-failure.yml | 13 ++-- .../everything/generated/0.8.22-success.yml | 13 ++-- 19 files changed, 187 insertions(+), 28 deletions(-) create mode 100644 crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-declaration/0.8.4.md diff --git a/crates/solidity/inputs/language/definition/02-definitions/12-errors/productions.yml b/crates/solidity/inputs/language/definition/02-definitions/12-errors/productions.yml index a05b6e1da7..5aae375852 100644 --- a/crates/solidity/inputs/language/definition/02-definitions/12-errors/productions.yml +++ b/crates/solidity/inputs/language/definition/02-definitions/12-errors/productions.yml @@ -9,17 +9,23 @@ sequence: - reference: "ErrorKeyword" - reference: "Identifier" - - delimitedBy: - open: - reference: "OpenParen" - parser: - optional: - reference: "ErrorParametersList" - close: - reference: "CloseParen" + - reference: "ErrorParametersDeclaration" terminator: reference: "Semicolon" +- name: "ErrorParametersDeclaration" + kind: "Parser" + versioned: + 0.8.4: + delimitedBy: + open: + reference: "OpenParen" + parser: + optional: + reference: "ErrorParametersList" + close: + reference: "CloseParen" + - name: "ErrorParametersList" kind: "Parser" versioned: diff --git a/crates/solidity/inputs/language/src/dsl.rs b/crates/solidity/inputs/language/src/dsl.rs index 89b66d4aa5..4638dfea2a 100644 --- a/crates/solidity/inputs/language/src/dsl.rs +++ b/crates/solidity/inputs/language/src/dsl.rs @@ -271,7 +271,9 @@ slang_grammar! { inline parser EqualityComparisonOperator = (EqualEqual | BangEqual) ; - parser ErrorDefinition = { introduced in "0.8.4" ((ErrorKeyword Identifier ((ErrorParametersList ?) delimited by OpenParen and CloseParen)) terminated by Semicolon) } ; + parser ErrorDefinition = { introduced in "0.8.4" ((ErrorKeyword Identifier ErrorParametersDeclaration) terminated by Semicolon) } ; + + parser ErrorParametersDeclaration = { introduced in "0.8.4" ((ErrorParametersList ?) delimited by OpenParen and CloseParen) } ; parser ErrorParameter = { introduced in "0.8.4" (TypeName (Identifier ?)) } ; diff --git a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs index 61d3cc349f..56f5d805ac 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/kinds.rs @@ -46,6 +46,7 @@ pub enum ProductionKind { EnumDefinition, ErrorDefinition, ErrorParameter, + ErrorParametersDeclaration, ErrorParametersList, EventDefinition, EventParameter, @@ -205,6 +206,7 @@ pub enum RuleKind { EnumDefinition, ErrorDefinition, ErrorParameter, + ErrorParametersDeclaration, ErrorParametersList, EventDefinition, EventParameter, diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index e1e10e21f4..83a52f30f6 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -924,7 +924,38 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn error_definition(&self, input: &mut ParserContext) -> ParserResult { - if self . version_is_at_least_0_8_4 { SequenceHelper :: run (| mut seq | { seq . elem (SequenceHelper :: run (| mut seq | { seq . elem (self . parse_token_with_trivia :: < LexicalContextType :: Default > (input , TokenKind :: ErrorKeyword)) ? ; seq . elem (self . parse_token_with_trivia :: < LexicalContextType :: Default > (input , TokenKind :: Identifier)) ? ; seq . elem (SequenceHelper :: run (| mut seq | { let mut delim_guard = input . open_delim (TokenKind :: CloseParen) ; let input = delim_guard . ctx () ; seq . elem (self . parse_token_with_trivia :: < LexicalContextType :: Default > (input , TokenKind :: OpenParen)) ? ; seq . elem (OptionalHelper :: transform (self . error_parameters_list (input)) . recover_until_with_nested_delims :: < _ , LexicalContextType :: Default > (input , self , TokenKind :: CloseParen , RecoverFromNoMatch :: Yes ,)) ? ; seq . elem (self . parse_token_with_trivia :: < LexicalContextType :: Default > (input , TokenKind :: CloseParen)) ? ; seq . finish () })) ? ; seq . finish () }) . recover_until_with_nested_delims :: < _ , LexicalContextType :: Default > (input , self , TokenKind :: Semicolon , RecoverFromNoMatch :: No ,)) ? ; seq . elem (self . parse_token_with_trivia :: < LexicalContextType :: Default > (input , TokenKind :: Semicolon)) ? ; seq . finish () }) } else { ParserResult :: disabled () } . with_kind (RuleKind :: ErrorDefinition) + if self.version_is_at_least_0_8_4 { + SequenceHelper::run(|mut seq| { + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::ErrorKeyword, + ))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Identifier, + ))?; + seq.elem(self.error_parameters_declaration(input))?; + seq.finish() + }) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::Semicolon, + RecoverFromNoMatch::No, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Semicolon, + ))?; + seq.finish() + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::ErrorDefinition) } #[allow(unused_assignments, unused_parens)] @@ -946,6 +977,37 @@ impl Language { .with_kind(RuleKind::ErrorParameter) } + #[allow(unused_assignments, unused_parens)] + fn error_parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_8_4 { + SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenParen, + ))?; + seq.elem( + OptionalHelper::transform(self.error_parameters_list(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseParen, + ))?; + seq.finish() + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::ErrorParametersDeclaration) + } + #[allow(unused_assignments, unused_parens)] fn error_parameters_list(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_8_4 { @@ -5651,6 +5713,9 @@ impl Language { ProductionKind::EnumDefinition => Self::enum_definition.parse(self, input), ProductionKind::ErrorDefinition => Self::error_definition.parse(self, input), ProductionKind::ErrorParameter => Self::error_parameter.parse(self, input), + ProductionKind::ErrorParametersDeclaration => { + Self::error_parameters_declaration.parse(self, input) + } ProductionKind::ErrorParametersList => Self::error_parameters_list.parse(self, input), ProductionKind::EventDefinition => Self::event_definition.parse(self, input), ProductionKind::EventParameter => Self::event_parameter.parse(self, input), diff --git a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs index 61d3cc349f..56f5d805ac 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/kinds.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/kinds.rs @@ -46,6 +46,7 @@ pub enum ProductionKind { EnumDefinition, ErrorDefinition, ErrorParameter, + ErrorParametersDeclaration, ErrorParametersList, EventDefinition, EventParameter, @@ -205,6 +206,7 @@ pub enum RuleKind { EnumDefinition, ErrorDefinition, ErrorParameter, + ErrorParametersDeclaration, ErrorParametersList, EventDefinition, EventParameter, diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index e1e10e21f4..83a52f30f6 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -924,7 +924,38 @@ impl Language { #[allow(unused_assignments, unused_parens)] fn error_definition(&self, input: &mut ParserContext) -> ParserResult { - if self . version_is_at_least_0_8_4 { SequenceHelper :: run (| mut seq | { seq . elem (SequenceHelper :: run (| mut seq | { seq . elem (self . parse_token_with_trivia :: < LexicalContextType :: Default > (input , TokenKind :: ErrorKeyword)) ? ; seq . elem (self . parse_token_with_trivia :: < LexicalContextType :: Default > (input , TokenKind :: Identifier)) ? ; seq . elem (SequenceHelper :: run (| mut seq | { let mut delim_guard = input . open_delim (TokenKind :: CloseParen) ; let input = delim_guard . ctx () ; seq . elem (self . parse_token_with_trivia :: < LexicalContextType :: Default > (input , TokenKind :: OpenParen)) ? ; seq . elem (OptionalHelper :: transform (self . error_parameters_list (input)) . recover_until_with_nested_delims :: < _ , LexicalContextType :: Default > (input , self , TokenKind :: CloseParen , RecoverFromNoMatch :: Yes ,)) ? ; seq . elem (self . parse_token_with_trivia :: < LexicalContextType :: Default > (input , TokenKind :: CloseParen)) ? ; seq . finish () })) ? ; seq . finish () }) . recover_until_with_nested_delims :: < _ , LexicalContextType :: Default > (input , self , TokenKind :: Semicolon , RecoverFromNoMatch :: No ,)) ? ; seq . elem (self . parse_token_with_trivia :: < LexicalContextType :: Default > (input , TokenKind :: Semicolon)) ? ; seq . finish () }) } else { ParserResult :: disabled () } . with_kind (RuleKind :: ErrorDefinition) + if self.version_is_at_least_0_8_4 { + SequenceHelper::run(|mut seq| { + seq.elem( + SequenceHelper::run(|mut seq| { + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::ErrorKeyword, + ))?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Identifier, + ))?; + seq.elem(self.error_parameters_declaration(input))?; + seq.finish() + }) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::Semicolon, + RecoverFromNoMatch::No, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::Semicolon, + ))?; + seq.finish() + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::ErrorDefinition) } #[allow(unused_assignments, unused_parens)] @@ -946,6 +977,37 @@ impl Language { .with_kind(RuleKind::ErrorParameter) } + #[allow(unused_assignments, unused_parens)] + fn error_parameters_declaration(&self, input: &mut ParserContext) -> ParserResult { + if self.version_is_at_least_0_8_4 { + SequenceHelper::run(|mut seq| { + let mut delim_guard = input.open_delim(TokenKind::CloseParen); + let input = delim_guard.ctx(); + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::OpenParen, + ))?; + seq.elem( + OptionalHelper::transform(self.error_parameters_list(input)) + .recover_until_with_nested_delims::<_, LexicalContextType::Default>( + input, + self, + TokenKind::CloseParen, + RecoverFromNoMatch::Yes, + ), + )?; + seq.elem(self.parse_token_with_trivia::( + input, + TokenKind::CloseParen, + ))?; + seq.finish() + }) + } else { + ParserResult::disabled() + } + .with_kind(RuleKind::ErrorParametersDeclaration) + } + #[allow(unused_assignments, unused_parens)] fn error_parameters_list(&self, input: &mut ParserContext) -> ParserResult { if self.version_is_at_least_0_8_4 { @@ -5651,6 +5713,9 @@ impl Language { ProductionKind::EnumDefinition => Self::enum_definition.parse(self, input), ProductionKind::ErrorDefinition => Self::error_definition.parse(self, input), ProductionKind::ErrorParameter => Self::error_parameter.parse(self, input), + ProductionKind::ErrorParametersDeclaration => { + Self::error_parameters_declaration.parse(self, input) + } ProductionKind::ErrorParametersList => Self::error_parameters_list.parse(self, input), ProductionKind::EventDefinition => Self::event_definition.parse(self, input), ProductionKind::EventParameter => Self::event_parameter.parse(self, input), 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 ba538a80f8..67b77ad4a6 100644 --- a/crates/solidity/outputs/npm/package/src/generated/index.d.ts +++ b/crates/solidity/outputs/npm/package/src/generated/index.d.ts @@ -41,6 +41,7 @@ export namespace kinds { EnumDefinition = "EnumDefinition", ErrorDefinition = "ErrorDefinition", ErrorParameter = "ErrorParameter", + ErrorParametersDeclaration = "ErrorParametersDeclaration", ErrorParametersList = "ErrorParametersList", EventDefinition = "EventDefinition", EventParameter = "EventParameter", @@ -186,6 +187,7 @@ export namespace kinds { EnumDefinition = "EnumDefinition", ErrorDefinition = "ErrorDefinition", ErrorParameter = "ErrorParameter", + ErrorParametersDeclaration = "ErrorParametersDeclaration", ErrorParametersList = "ErrorParametersList", EventDefinition = "EventDefinition", EventParameter = "EventParameter", diff --git a/crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-definition/0.8.4.md b/crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-definition/0.8.4.md index 1e1c8c18af..f2100101f4 100644 --- a/crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-definition/0.8.4.md +++ b/crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-definition/0.8.4.md @@ -1,5 +1,5 @@ ```{ .ebnf .slang-ebnf #ErrorDefinition } -ErrorDefinition = ERROR_KEYWORD IDENTIFIER OPEN_PAREN ErrorParametersList? CLOSE_PAREN SEMICOLON; +ErrorDefinition = ERROR_KEYWORD IDENTIFIER ErrorParametersDeclaration SEMICOLON; ``` diff --git a/crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-declaration/0.8.4.md b/crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-declaration/0.8.4.md new file mode 100644 index 0000000000..8787f4a1aa --- /dev/null +++ b/crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-declaration/0.8.4.md @@ -0,0 +1,5 @@ + + +```{ .ebnf .slang-ebnf #ErrorParametersDeclaration } +ErrorParametersDeclaration = OPEN_PAREN ErrorParametersList? CLOSE_PAREN; +``` diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.13/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.13/index.md index 7faf116776..4266214cc8 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.13/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.13/index.md @@ -262,6 +262,7 @@ ### 2.12. Errors --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-definition/0.8.4.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-declaration/0.8.4.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-list/0.8.4.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameter/0.8.4.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.18/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.18/index.md index 7c4c0ca75d..ba0a2a4fd4 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.18/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.18/index.md @@ -262,6 +262,7 @@ ### 2.12. Errors --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-definition/0.8.4.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-declaration/0.8.4.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-list/0.8.4.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameter/0.8.4.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.19/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.19/index.md index 81351c0981..f80292a845 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.19/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.19/index.md @@ -263,6 +263,7 @@ ### 2.12. Errors --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-definition/0.8.4.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-declaration/0.8.4.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-list/0.8.4.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameter/0.8.4.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.22/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.22/index.md index 4f360f112c..3fe1791481 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.22/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.22/index.md @@ -263,6 +263,7 @@ ### 2.12. Errors --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-definition/0.8.4.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-declaration/0.8.4.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-list/0.8.4.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameter/0.8.4.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.4/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.4/index.md index 797109141c..1ee9b03529 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.4/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.4/index.md @@ -254,6 +254,7 @@ ### 2.12. Errors --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-definition/0.8.4.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-declaration/0.8.4.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-list/0.8.4.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameter/0.8.4.md" diff --git a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.8/index.md b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.8/index.md index 94a344f29d..d19d2a4917 100644 --- a/crates/solidity/outputs/spec/generated/public/grammar/v0.8.8/index.md +++ b/crates/solidity/outputs/spec/generated/public/grammar/v0.8.8/index.md @@ -258,6 +258,7 @@ ### 2.12. Errors --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-definition/0.8.4.md" +--8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-declaration/0.8.4.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameters-list/0.8.4.md" --8<-- "crates/solidity/outputs/spec/generated/ebnf/02-definitions/12-errors/error-parameter/0.8.4.md" diff --git a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/member_error_definition/generated/0.8.4-success.yml b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/member_error_definition/generated/0.8.4-success.yml index 0f50c271da..721a214d0e 100644 --- a/crates/solidity/testing/snapshots/cst_output/ContractDefinition/member_error_definition/generated/0.8.4-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ContractDefinition/member_error_definition/generated/0.8.4-success.yml @@ -16,7 +16,8 @@ Tree: - ErrorDefinition (Rule): # 18..36 " error Error1();\n" - ErrorKeyword (Token): "error" # 20..25 - Identifier (Token): "Error1" # 26..32 - - OpenParen (Token): "(" # 32..33 - - CloseParen (Token): ")" # 33..34 + - ErrorParametersDeclaration (Rule): # 32..34 "()" + - OpenParen (Token): "(" # 32..33 + - CloseParen (Token): ")" # 33..34 - Semicolon (Token): ";" # 34..35 - CloseBrace (Token): "}" # 36..37 diff --git a/crates/solidity/testing/snapshots/cst_output/ErrorDefinition/top_level/generated/0.8.4-success.yml b/crates/solidity/testing/snapshots/cst_output/ErrorDefinition/top_level/generated/0.8.4-success.yml index 40dc3a895e..e36c7601c6 100644 --- a/crates/solidity/testing/snapshots/cst_output/ErrorDefinition/top_level/generated/0.8.4-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/ErrorDefinition/top_level/generated/0.8.4-success.yml @@ -9,6 +9,7 @@ Tree: - ErrorDefinition (Rule): # 0..16 "error MyError();" - ErrorKeyword (Token): "error" # 0..5 - Identifier (Token): "MyError" # 6..13 - - OpenParen (Token): "(" # 13..14 - - CloseParen (Token): ")" # 14..15 + - ErrorParametersDeclaration (Rule): # 13..15 "()" + - OpenParen (Token): "(" # 13..14 + - CloseParen (Token): ")" # 14..15 - Semicolon (Token): ";" # 15..16 diff --git a/crates/solidity/testing/snapshots/cst_output/SourceUnit/everything/generated/0.8.13-failure.yml b/crates/solidity/testing/snapshots/cst_output/SourceUnit/everything/generated/0.8.13-failure.yml index 38199a8fc8..0a923cd879 100644 --- a/crates/solidity/testing/snapshots/cst_output/SourceUnit/everything/generated/0.8.13-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/SourceUnit/everything/generated/0.8.13-failure.yml @@ -117,12 +117,13 @@ Tree: - ErrorDefinition (Rule): # 181..200 "\nerror E1(string);\n" - ErrorKeyword (Token): "error" # 182..187 - Identifier (Token): "E1" # 188..190 - - OpenParen (Token): "(" # 190..191 - - ErrorParametersList (Rule): # 191..197 "string" - - ErrorParameter (Rule): # 191..197 "string" - - TypeName (Rule): # 191..197 "string" - - StringKeyword (Token): "string" # 191..197 - - CloseParen (Token): ")" # 197..198 + - ErrorParametersDeclaration (Rule): # 190..198 "(string)" + - OpenParen (Token): "(" # 190..191 + - ErrorParametersList (Rule): # 191..197 "string" + - ErrorParameter (Rule): # 191..197 "string" + - TypeName (Rule): # 191..197 "string" + - StringKeyword (Token): "string" # 191..197 + - CloseParen (Token): ")" # 197..198 - Semicolon (Token): ";" # 198..199 - UserDefinedValueTypeDefinition (Rule): # 200..217 "\ntype T is bool;\n" - TypeKeyword (Token): "type" # 201..205 diff --git a/crates/solidity/testing/snapshots/cst_output/SourceUnit/everything/generated/0.8.22-success.yml b/crates/solidity/testing/snapshots/cst_output/SourceUnit/everything/generated/0.8.22-success.yml index 50a27d4fe5..75668383be 100644 --- a/crates/solidity/testing/snapshots/cst_output/SourceUnit/everything/generated/0.8.22-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/SourceUnit/everything/generated/0.8.22-success.yml @@ -109,12 +109,13 @@ Tree: - ErrorDefinition (Rule): # 181..200 "\nerror E1(string);\n" - ErrorKeyword (Token): "error" # 182..187 - Identifier (Token): "E1" # 188..190 - - OpenParen (Token): "(" # 190..191 - - ErrorParametersList (Rule): # 191..197 "string" - - ErrorParameter (Rule): # 191..197 "string" - - TypeName (Rule): # 191..197 "string" - - StringKeyword (Token): "string" # 191..197 - - CloseParen (Token): ")" # 197..198 + - ErrorParametersDeclaration (Rule): # 190..198 "(string)" + - OpenParen (Token): "(" # 190..191 + - ErrorParametersList (Rule): # 191..197 "string" + - ErrorParameter (Rule): # 191..197 "string" + - TypeName (Rule): # 191..197 "string" + - StringKeyword (Token): "string" # 191..197 + - CloseParen (Token): ")" # 197..198 - Semicolon (Token): ";" # 198..199 - UserDefinedValueTypeDefinition (Rule): # 200..217 "\ntype T is bool;\n" - TypeKeyword (Token): "type" # 201..205