From cabc5984707465ffb9265a71ccb48042290d752e Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 8 Nov 2023 10:47:00 +0100 Subject: [PATCH] Use disambiguated DecimalLiteral sub-rules in DSL v1 So that we minimize the parsing diff once migrate to DSL v2. --- crates/solidity/inputs/language/src/dsl.rs | 7 ++-- .../cargo/crate/src/generated/language.rs | 36 ++++++++----------- .../npm/crate/src/generated/language.rs | 36 ++++++++----------- .../generated/0.5.0-failure.yml | 10 +++--- .../generated/0.6.11-failure.yml | 19 ---------- .../generated/0.7.0-failure.yml | 19 ---------- 6 files changed, 38 insertions(+), 89 deletions(-) delete mode 100644 crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/generated/0.6.11-failure.yml delete mode 100644 crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/generated/0.7.0-failure.yml diff --git a/crates/solidity/inputs/language/src/dsl.rs b/crates/solidity/inputs/language/src/dsl.rs index 441472a904..547454c05b 100644 --- a/crates/solidity/inputs/language/src/dsl.rs +++ b/crates/solidity/inputs/language/src/dsl.rs @@ -820,9 +820,10 @@ slang_grammar! { scanner DecimalLiteral = ( ( ( - { removed in "0.5.0" (DecimalDigits (("." (DecimalDigits ?) ) ?)) } | - { introduced in "0.5.0" (DecimalDigits (("." DecimalDigits ) ?)) } | - ('.' DecimalDigits) + (DecimalDigits not followed by '.') | + { removed in "0.5.0" ((DecimalDigits '.') not followed by DecimalDigits) } | + ('.' DecimalDigits) | + (DecimalDigits '.' DecimalDigits) ) (DecimalExponent ?) ) not followed by IdentifierStart diff --git a/crates/solidity/outputs/cargo/crate/src/generated/language.rs b/crates/solidity/outputs/cargo/crate/src/generated/language.rs index 17ffb593ce..abe126780e 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/language.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/language.rs @@ -5098,32 +5098,26 @@ impl Language { scan_sequence!( scan_choice!( input, + scan_not_followed_by!( + input, + self.decimal_digits(input), + scan_chars!(input, '.') + ), if !self.version_is_at_least_0_5_0 { - scan_sequence!( - self.decimal_digits(input), - scan_optional!( - input, - scan_sequence!( - scan_chars!(input, '.'), - scan_optional!(input, self.decimal_digits(input)) - ) - ) - ) - } else { - false - }, - if self.version_is_at_least_0_5_0 { - scan_sequence!( - self.decimal_digits(input), - scan_optional!( - input, - scan_sequence!(scan_chars!(input, '.'), self.decimal_digits(input)) - ) + scan_not_followed_by!( + input, + scan_sequence!(self.decimal_digits(input), scan_chars!(input, '.')), + self.decimal_digits(input) ) } else { false }, - scan_sequence!(scan_chars!(input, '.'), self.decimal_digits(input)) + scan_sequence!(scan_chars!(input, '.'), self.decimal_digits(input)), + scan_sequence!( + self.decimal_digits(input), + scan_chars!(input, '.'), + self.decimal_digits(input) + ) ), scan_optional!(input, self.decimal_exponent(input)) ), diff --git a/crates/solidity/outputs/npm/crate/src/generated/language.rs b/crates/solidity/outputs/npm/crate/src/generated/language.rs index 17ffb593ce..abe126780e 100644 --- a/crates/solidity/outputs/npm/crate/src/generated/language.rs +++ b/crates/solidity/outputs/npm/crate/src/generated/language.rs @@ -5098,32 +5098,26 @@ impl Language { scan_sequence!( scan_choice!( input, + scan_not_followed_by!( + input, + self.decimal_digits(input), + scan_chars!(input, '.') + ), if !self.version_is_at_least_0_5_0 { - scan_sequence!( - self.decimal_digits(input), - scan_optional!( - input, - scan_sequence!( - scan_chars!(input, '.'), - scan_optional!(input, self.decimal_digits(input)) - ) - ) - ) - } else { - false - }, - if self.version_is_at_least_0_5_0 { - scan_sequence!( - self.decimal_digits(input), - scan_optional!( - input, - scan_sequence!(scan_chars!(input, '.'), self.decimal_digits(input)) - ) + scan_not_followed_by!( + input, + scan_sequence!(self.decimal_digits(input), scan_chars!(input, '.')), + self.decimal_digits(input) ) } else { false }, - scan_sequence!(scan_chars!(input, '.'), self.decimal_digits(input)) + scan_sequence!(scan_chars!(input, '.'), self.decimal_digits(input)), + scan_sequence!( + self.decimal_digits(input), + scan_chars!(input, '.'), + self.decimal_digits(input) + ) ), scan_optional!(input, self.decimal_exponent(input)) ), diff --git a/crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/generated/0.5.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/generated/0.5.0-failure.yml index 981dd9997d..39bf9bced7 100644 --- a/crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/generated/0.5.0-failure.yml +++ b/crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/generated/0.5.0-failure.yml @@ -5,15 +5,13 @@ Source: > Errors: # 1 total - > - Error: Expected DaysKeyword or EtherKeyword or FinneyKeyword or HoursKeyword or MinutesKeyword or SecondsKeyword or SzaboKeyword or WeeksKeyword or WeiKeyword. - ╭─[crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/input.sol:1:2] + Error: Expected DecimalLiteral or HexLiteral. + ╭─[crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/input.sol:1:1] │ 1 │ 1. - │ ┬ + │ ─┬ │ ╰── Error occurred here. ───╯ Tree: - - NumericExpression (Rule): # 0..2 "1." - - DecimalLiteral (Token): "1" # 0..1 - - SKIPPED (Token): "." # 1..2 + - SKIPPED (Token): "1." # 0..2 diff --git a/crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/generated/0.6.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/generated/0.6.11-failure.yml deleted file mode 100644 index b7fc6f7487..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/generated/0.6.11-failure.yml +++ /dev/null @@ -1,19 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ 1. │ 0..2 - -Errors: # 1 total - - > - Error: Expected DaysKeyword or EtherKeyword or FinneyKeyword or GweiKeyword or HoursKeyword or MinutesKeyword or SecondsKeyword or SzaboKeyword or WeeksKeyword or WeiKeyword. - ╭─[crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/input.sol:1:2] - │ - 1 │ 1. - │ ┬ - │ ╰── Error occurred here. - ───╯ - -Tree: - - NumericExpression (Rule): # 0..2 "1." - - DecimalLiteral (Token): "1" # 0..1 - - SKIPPED (Token): "." # 1..2 diff --git a/crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/generated/0.7.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/generated/0.7.0-failure.yml deleted file mode 100644 index 8f7b83d06b..0000000000 --- a/crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/generated/0.7.0-failure.yml +++ /dev/null @@ -1,19 +0,0 @@ -# This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -Source: > - 1 │ 1. │ 0..2 - -Errors: # 1 total - - > - Error: Expected DaysKeyword or EtherKeyword or GweiKeyword or HoursKeyword or MinutesKeyword or SecondsKeyword or WeeksKeyword or WeiKeyword. - ╭─[crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/input.sol:1:2] - │ - 1 │ 1. - │ ┬ - │ ╰── Error occurred here. - ───╯ - -Tree: - - NumericExpression (Rule): # 0..2 "1." - - DecimalLiteral (Token): "1" # 0..1 - - SKIPPED (Token): "." # 1..2