Skip to content

Commit 582c16d

Browse files
committed
prioritize parsing MultiLineComment over MultiLineNatSpecComment
1 parent 8a93ce8 commit 582c16d

6 files changed

Lines changed: 57 additions & 2 deletions

File tree

.changeset/great-sheep-camp.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+
prioritize parsing `MultiLineComment` over `MultiLineNatSpecComment`

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ codegen_language_macros::compile!(Language(
425425
Trivia(
426426
name = MultiLineNatSpecComment,
427427
scanner = Sequence([
428-
Atom("/**"),
428+
TrailingContext(scanner = Atom("/**"), not_followed_by = Atom("/")),
429429
ZeroOrMore(Choice([
430430
Not(['*']),
431431
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: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.
2+
3+
Source: >
4+
1 │ // The below comments should be parsed into two separate tokens, instead of one NatSpec comment: │ 0..96
5+
2 │ │ 97..97
6+
3 │ contract Foo { │ 98..112
7+
4 │ /**/ │ 113..119
8+
5 │ } │ 120..121
9+
6 │ /**/ │ 122..126
10+
11+
Errors: []
12+
13+
Tree:
14+
- (SourceUnit): # "// The below comments should be parsed into two se..." (0..127)
15+
- (members꞉ SourceUnitMembers): # "// The below comments should be parsed into two se..." (0..122)
16+
- (item꞉ SourceUnitMember) ► (variant꞉ ContractDefinition): # "// The below comments should be parsed into two se..." (0..122)
17+
- (LeadingTrivia): # "// The below comments should be parsed into two se..." (0..98)
18+
- (SingleLineComment): "// The below comments should be parsed into two se..." # (0..96)
19+
- (EndOfLine): "\n" # (96..97)
20+
- (EndOfLine): "\n" # (97..98)
21+
- (contract_keyword꞉ ContractKeyword): "contract" # (98..106)
22+
- (LeadingTrivia) ► (Whitespace): " " # (106..107)
23+
- (name꞉ Identifier): "Foo" # (107..110)
24+
- (LeadingTrivia) ► (Whitespace): " " # (110..111)
25+
- (open_brace꞉ OpenBrace): "{" # (111..112)
26+
- (TrailingTrivia) ► (EndOfLine): "\n" # (112..113)
27+
- (LeadingTrivia): # " /**/\n" (113..120)
28+
- (Whitespace): " " # (113..115)
29+
- (MultiLineComment): "/**/" # (115..119)
30+
- (EndOfLine): "\n" # (119..120)
31+
- (close_brace꞉ CloseBrace): "}" # (120..121)
32+
- (TrailingTrivia) ► (EndOfLine): "\n" # (121..122)
33+
- (LeadingTrivia): # "/**/\n" (122..127)
34+
- (MultiLineComment): "/**/" # (122..126)
35+
- (EndOfLine): "\n" # (126..127)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// The below comments should be parsed into two separate tokens, instead of one NatSpec comment:
2+
3+
contract Foo {
4+
/**/
5+
}
6+
/**/

0 commit comments

Comments
 (0)