tree-sitter-kdl 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +1 -1
- package/.github/workflows/lint.yml +19 -0
- package/.github/workflows/publish.yml +2 -2
- package/Cargo.toml +1 -1
- package/bindings/rust/lib.rs +7 -3
- package/grammar.js +19 -32
- package/package.json +1 -1
- package/queries/highlights.scm +6 -3
- package/src/grammar.json +5 -63
- package/src/node-types.json +4 -38
- package/src/parser.c +4162 -6112
- package/src/scanner.c +50 -4
package/src/scanner.c
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#include "wctype.h"
|
|
3
3
|
#include <ctype.h>
|
|
4
4
|
|
|
5
|
-
enum { EOF };
|
|
5
|
+
enum { EOF, MULTI_LINE_COMMENT };
|
|
6
6
|
|
|
7
7
|
void *tree_sitter_kdl_external_scanner_create() { return NULL; }
|
|
8
8
|
|
|
@@ -17,14 +17,60 @@ void tree_sitter_kdl_external_scanner_deserialize(void *payload,
|
|
|
17
17
|
const char *buffer,
|
|
18
18
|
unsigned length) {}
|
|
19
19
|
|
|
20
|
+
static void advance(TSLexer *lexer) { lexer->advance(lexer, false); }
|
|
21
|
+
|
|
20
22
|
bool tree_sitter_kdl_external_scanner_scan(void *payload, TSLexer *lexer,
|
|
21
23
|
const bool *valid_symbols) {
|
|
22
|
-
// check for
|
|
23
|
-
if (lexer->lookahead == 0) {
|
|
24
|
+
// check for End-of-file
|
|
25
|
+
if (valid_symbols[EOF] && lexer->lookahead == 0) {
|
|
24
26
|
lexer->result_symbol = EOF;
|
|
25
|
-
|
|
27
|
+
advance(lexer);
|
|
26
28
|
return true;
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
// multi-line-comment := '/*' commented-block
|
|
32
|
+
if (lexer->lookahead == '/') {
|
|
33
|
+
advance(lexer);
|
|
34
|
+
if (lexer->lookahead != '*')
|
|
35
|
+
return false;
|
|
36
|
+
advance(lexer);
|
|
37
|
+
|
|
38
|
+
bool after_star = false;
|
|
39
|
+
unsigned nesting_depth = 1;
|
|
40
|
+
// commented-block := '*/' | (multi-line-comment | '*' | '/' | [^*/]+) commented-block
|
|
41
|
+
for (;;) {
|
|
42
|
+
switch (lexer->lookahead) {
|
|
43
|
+
case '\0':
|
|
44
|
+
return false;
|
|
45
|
+
case '*':
|
|
46
|
+
advance(lexer);
|
|
47
|
+
after_star = true;
|
|
48
|
+
break;
|
|
49
|
+
case '/':
|
|
50
|
+
if (after_star) {
|
|
51
|
+
advance(lexer);
|
|
52
|
+
after_star = false;
|
|
53
|
+
nesting_depth--;
|
|
54
|
+
if (nesting_depth == 0) {
|
|
55
|
+
lexer->result_symbol = MULTI_LINE_COMMENT;
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
advance(lexer);
|
|
60
|
+
after_star = false;
|
|
61
|
+
if (lexer->lookahead == '*') {
|
|
62
|
+
nesting_depth++;
|
|
63
|
+
advance(lexer);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
advance(lexer);
|
|
69
|
+
after_star = false;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
29
75
|
return false;
|
|
30
76
|
}
|