Skip to content

Commit f62de9e

Browse files
authored
fix parsing empty /**/ comments (#844)
1 parent b7a5791 commit f62de9e

14 files changed

Lines changed: 187 additions & 2 deletions

File tree

.changeset/flat-papayas-destroy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@nomicfoundation/slang": patch
3+
---
4+
5+
fix parsing empty `/**/` comments

crates/solidity/inputs/language/src/definition.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,10 @@ codegen_language_macros::compile!(Language(
395395
Trivia(
396396
name = MultiLineComment,
397397
scanner = Sequence([
398-
TrailingContext(scanner = Atom("/*"), not_followed_by = Atom("*")),
398+
TrailingContext(
399+
scanner = Atom("/*"),
400+
not_followed_by = Sequence([Atom("*"), Not(['/'])])
401+
),
399402
ZeroOrMore(Choice([
400403
Not(['*']),
401404
TrailingContext(

crates/solidity/outputs/cargo/slang_solidity/src/generated/language.rs

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/cargo/tests/src/cst_output/generated/SourceUnit.rs

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.
2+
3+
Source: >
4+
1 │ /*/ needs another one to terminate: /*/ │ 0..39
5+
6+
Errors: []
7+
8+
Tree:
9+
- (SourceUnit) ► (LeadingTrivia): # "/*/ needs another one to terminate: /*/\n" (0..40)
10+
- (MultiLineComment): "/*/ needs another one to terminate: /*/" # (0..39)
11+
- (EndOfLine): "\n" # (39..40)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*/ needs another one to terminate: /*/
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.
2+
3+
Source: >
4+
1 │ /**/ │ 0..4
5+
6+
Errors: []
7+
8+
Tree:
9+
- (SourceUnit) ► (LeadingTrivia): # "/**/\n" (0..5)
10+
- (MultiLineComment): "/**/" # (0..4)
11+
- (EndOfLine): "\n" # (4..5)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/**/
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.
2+
3+
Source: >
4+
1 │ /***/ │ 0..5
5+
6+
Errors: []
7+
8+
Tree:
9+
- (SourceUnit) ► (LeadingTrivia): # "/***/\n" (0..6)
10+
- (MultiLineNatSpecComment): "/***/" # (0..5)
11+
- (EndOfLine): "\n" # (5..6)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/***/

0 commit comments

Comments
 (0)