@willbooster/tree-sitter-c 9.0.0 → 9.0.1
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/grammar.js +5 -4
- package/package.json +1 -1
- package/src/scanner.c +13 -14
- package/tree-sitter-c.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -68,6 +68,7 @@ module.exports = Object.assign(
|
|
|
68
68
|
name: 'c',
|
|
69
69
|
|
|
70
70
|
conflicts: ($) => [
|
|
71
|
+
[$.preproc_include_argument],
|
|
71
72
|
[$._preproc_include_token, $.preproc_argument_list],
|
|
72
73
|
[$._preproc_include_path, $.preproc_include_argument],
|
|
73
74
|
[$.compound_statement, $.initializer_list],
|
|
@@ -256,8 +257,10 @@ module.exports = Object.assign(
|
|
|
256
257
|
alias($.preproc_call_expression, $.call_expression)
|
|
257
258
|
),
|
|
258
259
|
|
|
259
|
-
preproc_include_argument: ($) =>
|
|
260
|
-
|
|
260
|
+
preproc_include_argument: ($) => prec.dynamic(-1, seq($.identifier, repeat1($._preproc_include_segment))),
|
|
261
|
+
|
|
262
|
+
_preproc_include_segment: ($) =>
|
|
263
|
+
prec.dynamic(-1, seq(repeat(choice($.comment, $.pragma_operator)), $._preproc_include_token)),
|
|
261
264
|
|
|
262
265
|
_preproc_include_token: ($) =>
|
|
263
266
|
choice(
|
|
@@ -266,8 +269,6 @@ module.exports = Object.assign(
|
|
|
266
269
|
$.char_literal,
|
|
267
270
|
$.string_literal,
|
|
268
271
|
$.system_lib_string,
|
|
269
|
-
$.comment,
|
|
270
|
-
$.pragma_operator,
|
|
271
272
|
...BINARY_OPERATORS.map(([operator]) => operator),
|
|
272
273
|
'!',
|
|
273
274
|
'~',
|
package/package.json
CHANGED
package/src/scanner.c
CHANGED
|
@@ -30,17 +30,16 @@ bool tree_sitter_c_external_scanner_scan(void *payload, TSLexer *lexer, const bo
|
|
|
30
30
|
}
|
|
31
31
|
bool directive_text = !valid_symbols[PREPROC_ARG] && valid_symbols[PREPROC_DIRECTIVE_ARG];
|
|
32
32
|
TSSymbol argument_symbol = directive_text ? PREPROC_DIRECTIVE_ARG : PREPROC_ARG;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
33
|
+
bool argument_valid = valid_symbols[PREPROC_ARG] || directive_text;
|
|
34
|
+
while (valid_symbols[PREPROC_LPAREN] && lexer->lookahead == '\\') {
|
|
35
|
+
lexer->advance(lexer, true);
|
|
36
|
+
if (!scan_preproc_newline(lexer, true)) return false;
|
|
37
|
+
}
|
|
38
|
+
if (valid_symbols[PREPROC_LPAREN] && lexer->lookahead == '(') {
|
|
39
|
+
lexer->advance(lexer, false);
|
|
40
|
+
lexer->mark_end(lexer);
|
|
41
|
+
lexer->result_symbol = PREPROC_LPAREN;
|
|
42
|
+
return true;
|
|
44
43
|
}
|
|
45
44
|
if (valid_symbols[PREPROC_NEWLINE]) {
|
|
46
45
|
for (;;) {
|
|
@@ -52,16 +51,16 @@ bool tree_sitter_c_external_scanner_scan(void *payload, TSLexer *lexer, const bo
|
|
|
52
51
|
lexer->mark_end(lexer);
|
|
53
52
|
if (!scan_preproc_newline(lexer, true)) {
|
|
54
53
|
lexer->result_symbol = argument_symbol;
|
|
55
|
-
return
|
|
54
|
+
return argument_valid && scan_preproc_arg(lexer, true, directive_text);
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
|
-
if (scan_preproc_newline(lexer, false)) {
|
|
57
|
+
if (lexer->eof(lexer) || scan_preproc_newline(lexer, false)) {
|
|
59
58
|
lexer->mark_end(lexer);
|
|
60
59
|
lexer->result_symbol = PREPROC_NEWLINE;
|
|
61
60
|
return true;
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
|
-
if (
|
|
63
|
+
if (argument_valid) {
|
|
65
64
|
lexer->result_symbol = argument_symbol;
|
|
66
65
|
return scan_preproc_arg(lexer, false, directive_text);
|
|
67
66
|
}
|
package/tree-sitter-c.wasm
CHANGED
|
Binary file
|