Skip to content

Commit

Permalink
fix: Ignore subsequent empty matches in a sequence when unwinding
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed May 11, 2024
1 parent 5ec9990 commit bcbf33d
Show file tree
Hide file tree
Showing 11 changed files with 273 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,9 @@ impl SequenceHelper {
}
// If the sequence is unwinding and and we didn't find a match, then it means
// that we recovered past it and we need to push the recovery up.
(ParserResult::SkippedUntil(_), ParserResult::NoMatch(next)) => {
assert!(
matches!(next.expected_tokens[..], [_]),
"Only a single token parse can immediately follow SkippedUntil in sequences"
);
(ParserResult::SkippedUntil(_), ParserResult::NoMatch(_)) => {
// Skip any possible subsequent expected elements in this sequence until
// we finally encounter the token we were looking for
}
(ParserResult::SkippedUntil(_), _) => unreachable!(
"Only a single token parse can immediately follow SkippedUntil in sequences and these can either be Match or NoMatch"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ for(int) │ 0..8
Errors: # 2 total
- >
Error: Expected Ampersand or AmpersandAmpersand or AmpersandEqual or Asterisk or AsteriskAsterisk or AsteriskEqual or BangEqual or Bar or BarBar or BarEqual or Caret or CaretEqual or Equal or EqualEqual or GreaterThan or GreaterThanEqual or GreaterThanGreaterThan or GreaterThanGreaterThanEqual or GreaterThanGreaterThanGreaterThan or GreaterThanGreaterThanGreaterThanEqual or LessThan or LessThanEqual or LessThanLessThan or LessThanLessThanEqual or Minus or MinusEqual or Percent or PercentEqual or Plus or PlusEqual or Semicolon or Slash or SlashEqual.
╭─[crates/solidity/testing/snapshots/cst_output/Statements/recovery_ignore_multiple_empty_matches/input.sol:1:8]
1 │ for(int)
│ │
│ ╰─ Error occurred here.
───╯
- >
Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or ThrowKeyword or TrueKeyword or UfixedKeyword or UintKeyword or VarKeyword or WhileKeyword.
╭─[crates/solidity/testing/snapshots/cst_output/Statements/recovery_ignore_multiple_empty_matches/input.sol:1:10]
1 │ for(int)
│ │
│ ╰─ Error occurred here.
───╯
Tree:
- (Statements): # "for(int)\n" (0..9)
- (item꞉ Statement) ► (variant꞉ ForStatement): # "for(int)\n" (0..9)
- (for_keyword꞉ ForKeyword): "for" # (0..3)
- (open_paren꞉ OpenParen): "(" # (3..4)
- (initialization꞉ ForStatementInitialization) ► (variant꞉ ExpressionStatement) ► (expression꞉ Expression) ► (variant꞉ ElementaryType) ► (variant꞉ IntKeyword): "int" # (4..7)
- (SKIPPED): "" # (7..7)
- (close_paren꞉ CloseParen): ")" # (7..8)
- (trailing_trivia꞉ EndOfLine): "\n" # (8..9)
- (SKIPPED): "" # (9..9)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ for(int) │ 0..8
Errors: # 2 total
- >
Error: Expected Ampersand or AmpersandAmpersand or AmpersandEqual or Asterisk or AsteriskAsterisk or AsteriskEqual or BangEqual or Bar or BarBar or BarEqual or Caret or CaretEqual or Equal or EqualEqual or GreaterThan or GreaterThanEqual or GreaterThanGreaterThan or GreaterThanGreaterThanEqual or GreaterThanGreaterThanGreaterThan or GreaterThanGreaterThanGreaterThanEqual or LessThan or LessThanEqual or LessThanLessThan or LessThanLessThanEqual or Minus or MinusEqual or Percent or PercentEqual or Plus or PlusEqual or Semicolon or Slash or SlashEqual.
╭─[crates/solidity/testing/snapshots/cst_output/Statements/recovery_ignore_multiple_empty_matches/input.sol:1:8]
1 │ for(int)
│ │
│ ╰─ Error occurred here.
───╯
- >
Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or ThrowKeyword or TrueKeyword or UfixedKeyword or UintKeyword or VarKeyword or WhileKeyword.
╭─[crates/solidity/testing/snapshots/cst_output/Statements/recovery_ignore_multiple_empty_matches/input.sol:1:10]
1 │ for(int)
│ │
│ ╰─ Error occurred here.
───╯
Tree:
- (Statements): # "for(int)\n" (0..9)
- (item꞉ Statement) ► (variant꞉ ForStatement): # "for(int)\n" (0..9)
- (for_keyword꞉ ForKeyword): "for" # (0..3)
- (open_paren꞉ OpenParen): "(" # (3..4)
- (initialization꞉ ForStatementInitialization) ► (variant꞉ ExpressionStatement) ► (expression꞉ Expression) ► (variant꞉ ElementaryType) ► (variant꞉ IntKeyword): "int" # (4..7)
- (SKIPPED): "" # (7..7)
- (close_paren꞉ CloseParen): ")" # (7..8)
- (trailing_trivia꞉ EndOfLine): "\n" # (8..9)
- (SKIPPED): "" # (9..9)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ for(int) │ 0..8
Errors: # 2 total
- >
Error: Expected Ampersand or AmpersandAmpersand or AmpersandEqual or Asterisk or AsteriskAsterisk or AsteriskEqual or BangEqual or Bar or BarBar or BarEqual or Caret or CaretEqual or Equal or EqualEqual or GreaterThan or GreaterThanEqual or GreaterThanGreaterThan or GreaterThanGreaterThanEqual or GreaterThanGreaterThanGreaterThan or GreaterThanGreaterThanGreaterThanEqual or LessThan or LessThanEqual or LessThanLessThan or LessThanLessThanEqual or Minus or MinusEqual or Percent or PercentEqual or Plus or PlusEqual or Semicolon or Slash or SlashEqual.
╭─[crates/solidity/testing/snapshots/cst_output/Statements/recovery_ignore_multiple_empty_matches/input.sol:1:8]
1 │ for(int)
│ │
│ ╰─ Error occurred here.
───╯
- >
Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or TrueKeyword or UfixedKeyword or UintKeyword or WhileKeyword.
╭─[crates/solidity/testing/snapshots/cst_output/Statements/recovery_ignore_multiple_empty_matches/input.sol:1:10]
1 │ for(int)
│ │
│ ╰─ Error occurred here.
───╯
Tree:
- (Statements): # "for(int)\n" (0..9)
- (item꞉ Statement) ► (variant꞉ ForStatement): # "for(int)\n" (0..9)
- (for_keyword꞉ ForKeyword): "for" # (0..3)
- (open_paren꞉ OpenParen): "(" # (3..4)
- (initialization꞉ ForStatementInitialization) ► (variant꞉ ExpressionStatement) ► (expression꞉ Expression) ► (variant꞉ ElementaryType) ► (variant꞉ IntKeyword): "int" # (4..7)
- (SKIPPED): "" # (7..7)
- (close_paren꞉ CloseParen): ")" # (7..8)
- (trailing_trivia꞉ EndOfLine): "\n" # (8..9)
- (SKIPPED): "" # (9..9)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ for(int) │ 0..8
Errors: # 2 total
- >
Error: Expected Ampersand or AmpersandAmpersand or AmpersandEqual or Asterisk or AsteriskAsterisk or AsteriskEqual or BangEqual or Bar or BarBar or BarEqual or Caret or CaretEqual or Equal or EqualEqual or GreaterThan or GreaterThanEqual or GreaterThanGreaterThan or GreaterThanGreaterThanEqual or GreaterThanGreaterThanGreaterThan or GreaterThanGreaterThanGreaterThanEqual or LessThan or LessThanEqual or LessThanLessThan or LessThanLessThanEqual or Minus or MinusEqual or Percent or PercentEqual or Plus or PlusEqual or Semicolon or Slash or SlashEqual.
╭─[crates/solidity/testing/snapshots/cst_output/Statements/recovery_ignore_multiple_empty_matches/input.sol:1:8]
1 │ for(int)
│ │
│ ╰─ Error occurred here.
───╯
- >
Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or TrueKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword.
╭─[crates/solidity/testing/snapshots/cst_output/Statements/recovery_ignore_multiple_empty_matches/input.sol:1:10]
1 │ for(int)
│ │
│ ╰─ Error occurred here.
───╯
Tree:
- (Statements): # "for(int)\n" (0..9)
- (item꞉ Statement) ► (variant꞉ ForStatement): # "for(int)\n" (0..9)
- (for_keyword꞉ ForKeyword): "for" # (0..3)
- (open_paren꞉ OpenParen): "(" # (3..4)
- (initialization꞉ ForStatementInitialization) ► (variant꞉ ExpressionStatement) ► (expression꞉ Expression) ► (variant꞉ ElementaryType) ► (variant꞉ IntKeyword): "int" # (4..7)
- (SKIPPED): "" # (7..7)
- (close_paren꞉ CloseParen): ")" # (7..8)
- (trailing_trivia꞉ EndOfLine): "\n" # (8..9)
- (SKIPPED): "" # (9..9)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ for(int) │ 0..8
Errors: # 2 total
- >
Error: Expected Ampersand or AmpersandAmpersand or AmpersandEqual or Asterisk or AsteriskAsterisk or AsteriskEqual or BangEqual or Bar or BarBar or BarEqual or Caret or CaretEqual or Equal or EqualEqual or GreaterThan or GreaterThanEqual or GreaterThanGreaterThan or GreaterThanGreaterThanEqual or GreaterThanGreaterThanGreaterThan or GreaterThanGreaterThanGreaterThanEqual or LessThan or LessThanEqual or LessThanLessThan or LessThanLessThanEqual or Minus or MinusEqual or Percent or PercentEqual or Plus or PlusEqual or Semicolon or Slash or SlashEqual.
╭─[crates/solidity/testing/snapshots/cst_output/Statements/recovery_ignore_multiple_empty_matches/input.sol:1:8]
1 │ for(int)
│ │
│ ╰─ Error occurred here.
───╯
- >
Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or PayableKeyword or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or StringKeyword or TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword.
╭─[crates/solidity/testing/snapshots/cst_output/Statements/recovery_ignore_multiple_empty_matches/input.sol:1:10]
1 │ for(int)
│ │
│ ╰─ Error occurred here.
───╯
Tree:
- (Statements): # "for(int)\n" (0..9)
- (item꞉ Statement) ► (variant꞉ ForStatement): # "for(int)\n" (0..9)
- (for_keyword꞉ ForKeyword): "for" # (0..3)
- (open_paren꞉ OpenParen): "(" # (3..4)
- (initialization꞉ ForStatementInitialization) ► (variant꞉ ExpressionStatement) ► (expression꞉ Expression) ► (variant꞉ ElementaryType) ► (variant꞉ IntKeyword): "int" # (4..7)
- (SKIPPED): "" # (7..7)
- (close_paren꞉ CloseParen): ")" # (7..8)
- (trailing_trivia꞉ EndOfLine): "\n" # (8..9)
- (SKIPPED): "" # (9..9)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ for(int) │ 0..8
Errors: # 2 total
- >
Error: Expected Ampersand or AmpersandAmpersand or AmpersandEqual or Asterisk or AsteriskAsterisk or AsteriskEqual or BangEqual or Bar or BarBar or BarEqual or Caret or CaretEqual or Equal or EqualEqual or GreaterThan or GreaterThanEqual or GreaterThanGreaterThan or GreaterThanGreaterThanEqual or GreaterThanGreaterThanGreaterThan or GreaterThanGreaterThanGreaterThanEqual or LessThan or LessThanEqual or LessThanLessThan or LessThanLessThanEqual or Minus or MinusEqual or Percent or PercentEqual or Plus or PlusEqual or Semicolon or Slash or SlashEqual.
╭─[crates/solidity/testing/snapshots/cst_output/Statements/recovery_ignore_multiple_empty_matches/input.sol:1:8]
1 │ for(int)
│ │
│ ╰─ Error occurred here.
───╯
- >
Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or ByteKeyword or BytesKeyword or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or DoubleQuotedUnicodeStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or PayableKeyword or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or SingleQuotedUnicodeStringLiteral or StringKeyword or TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or WhileKeyword.
╭─[crates/solidity/testing/snapshots/cst_output/Statements/recovery_ignore_multiple_empty_matches/input.sol:1:10]
1 │ for(int)
│ │
│ ╰─ Error occurred here.
───╯
Tree:
- (Statements): # "for(int)\n" (0..9)
- (item꞉ Statement) ► (variant꞉ ForStatement): # "for(int)\n" (0..9)
- (for_keyword꞉ ForKeyword): "for" # (0..3)
- (open_paren꞉ OpenParen): "(" # (3..4)
- (initialization꞉ ForStatementInitialization) ► (variant꞉ ExpressionStatement) ► (expression꞉ Expression) ► (variant꞉ ElementaryType) ► (variant꞉ IntKeyword): "int" # (4..7)
- (SKIPPED): "" # (7..7)
- (close_paren꞉ CloseParen): ")" # (7..8)
- (trailing_trivia꞉ EndOfLine): "\n" # (8..9)
- (SKIPPED): "" # (9..9)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ for(int) │ 0..8
Errors: # 2 total
- >
Error: Expected Ampersand or AmpersandAmpersand or AmpersandEqual or Asterisk or AsteriskAsterisk or AsteriskEqual or BangEqual or Bar or BarBar or BarEqual or Caret or CaretEqual or Equal or EqualEqual or GreaterThan or GreaterThanEqual or GreaterThanGreaterThan or GreaterThanGreaterThanEqual or GreaterThanGreaterThanGreaterThan or GreaterThanGreaterThanGreaterThanEqual or LessThan or LessThanEqual or LessThanLessThan or LessThanLessThanEqual or Minus or MinusEqual or Percent or PercentEqual or Plus or PlusEqual or Semicolon or Slash or SlashEqual.
╭─[crates/solidity/testing/snapshots/cst_output/Statements/recovery_ignore_multiple_empty_matches/input.sol:1:8]
1 │ for(int)
│ │
│ ╰─ Error occurred here.
───╯
- >
Error: Expected AddressKeyword or AssemblyKeyword or BoolKeyword or BreakKeyword or BytesKeyword or ContinueKeyword or DecimalLiteral or DoKeyword or DoubleQuotedHexStringLiteral or DoubleQuotedStringLiteral or DoubleQuotedUnicodeStringLiteral or EmitKeyword or FalseKeyword or FixedKeyword or ForKeyword or FunctionKeyword or HexLiteral or Identifier or IfKeyword or IntKeyword or MappingKeyword or NewKeyword or OpenBrace or OpenBracket or OpenParen or PayableKeyword or ReturnKeyword or SingleQuotedHexStringLiteral or SingleQuotedStringLiteral or SingleQuotedUnicodeStringLiteral or StringKeyword or TrueKeyword or TryKeyword or TypeKeyword or UfixedKeyword or UintKeyword or UncheckedKeyword or WhileKeyword.
╭─[crates/solidity/testing/snapshots/cst_output/Statements/recovery_ignore_multiple_empty_matches/input.sol:1:10]
1 │ for(int)
│ │
│ ╰─ Error occurred here.
───╯
Tree:
- (Statements): # "for(int)\n" (0..9)
- (item꞉ Statement) ► (variant꞉ ForStatement): # "for(int)\n" (0..9)
- (for_keyword꞉ ForKeyword): "for" # (0..3)
- (open_paren꞉ OpenParen): "(" # (3..4)
- (initialization꞉ ForStatementInitialization) ► (variant꞉ ExpressionStatement) ► (expression꞉ Expression) ► (variant꞉ ElementaryType) ► (variant꞉ IntKeyword): "int" # (4..7)
- (SKIPPED): "" # (7..7)
- (close_paren꞉ CloseParen): ")" # (7..8)
- (trailing_trivia꞉ EndOfLine): "\n" # (8..9)
- (SKIPPED): "" # (9..9)
Loading

0 comments on commit bcbf33d

Please sign in to comment.