Skip to content

Commit c2fdefa

Browse files
authored
refactor: clean up implementation and tests (#37)
1 parent 929a6f7 commit c2fdefa

File tree

2 files changed

+2
-56
lines changed

2 files changed

+2
-56
lines changed

src/scanner.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,42 +34,6 @@ static void skip_wspace(TSLexer *lexer) {
3434
}
3535
}
3636

37-
static bool is_bracket_argument(TSLexer *lexer) {
38-
if (lexer->lookahead != '[') {
39-
return false;
40-
}
41-
advance(lexer);
42-
43-
int open_level = 0;
44-
while (lexer->lookahead == '=') {
45-
++open_level;
46-
advance(lexer);
47-
}
48-
49-
if (lexer->lookahead != '[') {
50-
return false;
51-
}
52-
53-
while (lexer->lookahead != '\0') {
54-
advance(lexer);
55-
if (lexer->lookahead == ']') {
56-
advance(lexer);
57-
58-
int close_level = 0;
59-
while (lexer->lookahead == '=') {
60-
++close_level;
61-
advance(lexer);
62-
}
63-
64-
if (lexer->lookahead == ']' && close_level == open_level) {
65-
advance(lexer);
66-
return true;
67-
}
68-
}
69-
}
70-
return false;
71-
}
72-
7337
static bool is_open_brackets(struct TreeSitterCMakeState *state,
7438
TSLexer *lexer) {
7539
if (lexer->lookahead != '[') {

test/corpus/parentheses.txt

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,17 @@ message(STATUS (TEST))
1515

1616
===========================================================
1717
Missing parentheses inside command invocation [parentheses]
18+
:error
1819
===========================================================
1920
message(STATUS (TEST)
2021
---
21-
(source_file
22-
(normal_command
23-
(identifier)
24-
(argument_list
25-
(argument (unquoted_argument))
26-
(argument (unquoted_argument))
27-
)
28-
(MISSING ")")
29-
)
30-
)
3122

3223
==================================================================
3324
Nested missing parentheses inside command invocation [parentheses]
25+
:error
3426
==================================================================
3527
message(STATUS ((TEST))
3628
---
37-
(source_file
38-
(normal_command
39-
(identifier)
40-
(argument_list
41-
(argument (unquoted_argument))
42-
(argument (unquoted_argument))
43-
)
44-
(MISSING ")")
45-
)
46-
)
4729

4830
===============================================
4931
Many arguments inside parentheses [parentheses]

0 commit comments

Comments
 (0)