Skip to content

Commit

Permalink
fix parsing empty /**/ comments (#844)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarTawfik authored Feb 22, 2024
1 parent b7a5791 commit f62de9e
Show file tree
Hide file tree
Showing 14 changed files with 187 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-papayas-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/slang": patch
---

fix parsing empty `/**/` comments
5 changes: 4 additions & 1 deletion crates/solidity/inputs/language/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,10 @@ codegen_language_macros::compile!(Language(
Trivia(
name = MultiLineComment,
scanner = Sequence([
TrailingContext(scanner = Atom("/*"), not_followed_by = Atom("*")),
TrailingContext(
scanner = Atom("/*"),
not_followed_by = Sequence([Atom("*"), Not(['/'])])
),
ZeroOrMore(Choice([
Not(['*']),
TrailingContext(
Expand Down

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

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,11 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ /*/ needs another one to terminate: /*/ │ 0..39
Errors: []

Tree:
- (SourceUnit) ► (LeadingTrivia): # "/*/ needs another one to terminate: /*/\n" (0..40)
- (MultiLineComment): "/*/ needs another one to terminate: /*/" # (0..39)
- (EndOfLine): "\n" # (39..40)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*/ needs another one to terminate: /*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ /**/ │ 0..4
Errors: []

Tree:
- (SourceUnit) ► (LeadingTrivia): # "/**/\n" (0..5)
- (MultiLineComment): "/**/" # (0..4)
- (EndOfLine): "\n" # (4..5)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/**/
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ /***/ │ 0..5
Errors: []

Tree:
- (SourceUnit) ► (LeadingTrivia): # "/***/\n" (0..6)
- (MultiLineNatSpecComment): "/***/" # (0..5)
- (EndOfLine): "\n" # (5..6)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/***/
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ /****/ │ 0..6
Errors: []

Tree:
- (SourceUnit) ► (LeadingTrivia): # "/****/\n" (0..7)
- (MultiLineNatSpecComment): "/****/" # (0..6)
- (EndOfLine): "\n" # (6..7)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/****/
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ (a, b) = (123, 135) │ 0..19
2 │ /**/ │ 20..24
3 │ { throw; │ 25..34
Errors: # 1 total
- >
Error: Expected CloseBrace or Identifier.
╭─[crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/input.sol:3:3]
3 │ { throw;
│ ──┬──
│ ╰──── Error occurred here.
───╯
Tree:
- (TupleDeconstructionStatement): # "(a, b) = (123, 135)\n/**/\n{ throw; \n" (0..35)
- (open_paren꞉ OpenParen): "(" # (0..1)
- (elements꞉ TupleDeconstructionElements): # "a, b" (1..5)
- (item꞉ TupleDeconstructionElement) ► (member꞉ TupleMember) ► (variant꞉ UntypedTupleMember) ► (name꞉ Identifier): "a" # (1..2)
- (separator꞉ Comma): "," # (2..3)
- (item꞉ TupleDeconstructionElement) ► (member꞉ TupleMember) ► (variant꞉ UntypedTupleMember): # " b" (3..5)
- (LeadingTrivia) ► (Whitespace): " " # (3..4)
- (name꞉ Identifier): "b" # (4..5)
- (close_paren꞉ CloseParen): ")" # (5..6)
- (LeadingTrivia) ► (Whitespace): " " # (6..7)
- (equal꞉ Equal): "=" # (7..8)
- (expression꞉ Expression): # " (123, 135)\n/**/\n{" (8..26)
- (variant꞉ TupleExpression): # " (123, 135)\n" (8..20)
- (LeadingTrivia) ► (Whitespace): " " # (8..9)
- (open_paren꞉ OpenParen): "(" # (9..10)
- (items꞉ TupleValues): # "123, 135" (10..18)
- (item꞉ TupleValue) ► (expression꞉ Expression) ► (variant꞉ DecimalNumberExpression) ► (literal꞉ DecimalLiteral): "123" # (10..13)
- (separator꞉ Comma): "," # (13..14)
- (item꞉ TupleValue) ► (expression꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 135" (14..18)
- (LeadingTrivia) ► (Whitespace): " " # (14..15)
- (literal꞉ DecimalLiteral): "135" # (15..18)
- (close_paren꞉ CloseParen): ")" # (18..19)
- (TrailingTrivia) ► (EndOfLine): "\n" # (19..20)
- (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroups): # "/**/\n{" (20..26)
- (item꞉ NamedArgumentGroup): # "/**/\n{" (20..26)
- (LeadingTrivia): # "/**/\n" (20..25)
- (MultiLineComment): "/**/" # (20..24)
- (EndOfLine): "\n" # (24..25)
- (open_brace꞉ OpenBrace): "{" # (25..26)
- (LeadingTrivia) ► (Whitespace): " " # (26..27)
- (SKIPPED): "throw" # (27..32)
- (semicolon꞉ Semicolon): ";" # (32..33)
- (TrailingTrivia): # " \n" (33..35)
- (Whitespace): " " # (33..34)
- (EndOfLine): "\n" # (34..35)
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ (a, b) = (123, 135) │ 0..19
2 │ /**/ │ 20..24
3 │ { throw; │ 25..34
Errors: # 1 total
- >
Error: Expected CloseBrace or Identifier.
╭─[crates/solidity/testing/snapshots/cst_output/TupleDeconstructionStatement/invalid_termination/input.sol:3:3]
3 │ { throw;
│ ──┬──
│ ╰──── Error occurred here.
───╯
Tree:
- (TupleDeconstructionStatement): # "(a, b) = (123, 135)\n/**/\n{ throw; \n" (0..35)
- (open_paren꞉ OpenParen): "(" # (0..1)
- (elements꞉ TupleDeconstructionElements): # "a, b" (1..5)
- (item꞉ TupleDeconstructionElement) ► (member꞉ TupleMember) ► (variant꞉ UntypedTupleMember) ► (name꞉ Identifier): "a" # (1..2)
- (separator꞉ Comma): "," # (2..3)
- (item꞉ TupleDeconstructionElement) ► (member꞉ TupleMember) ► (variant꞉ UntypedTupleMember): # " b" (3..5)
- (LeadingTrivia) ► (Whitespace): " " # (3..4)
- (name꞉ Identifier): "b" # (4..5)
- (close_paren꞉ CloseParen): ")" # (5..6)
- (LeadingTrivia) ► (Whitespace): " " # (6..7)
- (equal꞉ Equal): "=" # (7..8)
- (expression꞉ Expression): # " (123, 135)\n/**/\n{" (8..26)
- (variant꞉ TupleExpression): # " (123, 135)\n" (8..20)
- (LeadingTrivia) ► (Whitespace): " " # (8..9)
- (open_paren꞉ OpenParen): "(" # (9..10)
- (items꞉ TupleValues): # "123, 135" (10..18)
- (item꞉ TupleValue) ► (expression꞉ Expression) ► (variant꞉ DecimalNumberExpression) ► (literal꞉ DecimalLiteral): "123" # (10..13)
- (separator꞉ Comma): "," # (13..14)
- (item꞉ TupleValue) ► (expression꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 135" (14..18)
- (LeadingTrivia) ► (Whitespace): " " # (14..15)
- (literal꞉ DecimalLiteral): "135" # (15..18)
- (close_paren꞉ CloseParen): ")" # (18..19)
- (TrailingTrivia) ► (EndOfLine): "\n" # (19..20)
- (options꞉ FunctionCallOptions) ► (variant꞉ NamedArgumentGroup): # "/**/\n{" (20..26)
- (LeadingTrivia): # "/**/\n" (20..25)
- (MultiLineComment): "/**/" # (20..24)
- (EndOfLine): "\n" # (24..25)
- (open_brace꞉ OpenBrace): "{" # (25..26)
- (LeadingTrivia) ► (Whitespace): " " # (26..27)
- (SKIPPED): "throw" # (27..32)
- (semicolon꞉ Semicolon): ";" # (32..33)
- (TrailingTrivia): # " \n" (33..35)
- (Whitespace): " " # (33..34)
- (EndOfLine): "\n" # (34..35)

0 comments on commit f62de9e

Please sign in to comment.