Skip to content

Commit def2023

Browse files
committed
fix nested block comments with a slash in between
1 parent 3691201 commit def2023

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/scanner.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ typedef struct {
214214
static inline void process_left_forward_slash(BlockCommentProcessing *processing, char current) {
215215
if (current == '*') {
216216
processing->nestingDepth += 1;
217+
} else if (current == '/') {
218+
processing->state = LeftForwardSlash;
219+
return;
217220
}
218221
processing->state = Continuing;
219222
};

test/corpus/source_files.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ Nested block comments
4848

4949
// ---
5050

51+
/*
52+
nested with extra slash between two nested block comments
53+
/**///**/
54+
*/
55+
56+
// ---
57+
5158
----
5259

5360
(source_file
@@ -56,6 +63,8 @@ Nested block comments
5663
(block_comment)
5764
(line_comment)
5865
(block_comment)
66+
(line_comment)
67+
(block_comment)
5968
(line_comment))
6069

6170
============================================

0 commit comments

Comments
 (0)