File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -14,12 +14,35 @@ pub(crate) fn scan_shebang(ptr: &mut Ptr) -> bool {
14
14
}
15
15
}
16
16
17
+ fn scan_block_comment ( ptr : & mut Ptr ) -> Option < SyntaxKind > {
18
+ if ptr. next_is ( '*' ) {
19
+ ptr. bump ( ) ;
20
+ let mut depth: u32 = 1 ;
21
+ while depth > 0 {
22
+ if ptr. next_is ( '*' ) && ptr. nnext_is ( '/' ) {
23
+ depth -= 1 ;
24
+ ptr. bump ( ) ;
25
+ ptr. bump ( ) ;
26
+ } else if ptr. next_is ( '/' ) && ptr. nnext_is ( '*' ) {
27
+ depth += 1 ;
28
+ ptr. bump ( ) ;
29
+ ptr. bump ( ) ;
30
+ } else if ptr. bump ( ) . is_none ( ) {
31
+ break ;
32
+ }
33
+ }
34
+ Some ( COMMENT )
35
+ } else {
36
+ None
37
+ }
38
+ }
39
+
17
40
pub ( crate ) fn scan_comment ( ptr : & mut Ptr ) -> Option < SyntaxKind > {
18
41
if ptr. next_is ( '/' ) {
19
42
bump_until_eol ( ptr) ;
20
43
Some ( COMMENT )
21
44
} else {
22
- None
45
+ scan_block_comment ( ptr )
23
46
}
24
47
}
25
48
Original file line number Diff line number Diff line change
1
+ /* */
2
+ /**/
3
+ /* /* */ */
4
+ /*
Original file line number Diff line number Diff line change
1
+ COMMENT 5 "/* */"
2
+ WHITESPACE 1 "\n"
3
+ COMMENT 4 "/**/"
4
+ WHITESPACE 1 "\n"
5
+ COMMENT 11 "/* /* */ */"
6
+ WHITESPACE 1 "\n"
7
+ COMMENT 3 "/*\n"
You can’t perform that action at this time.
0 commit comments