@willbooster/tree-sitter-c 34.0.3 → 36.0.0

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/README.md CHANGED
@@ -24,7 +24,7 @@ the trees that error recovery produces may change; such changes are released as
24
24
  ## Usage
25
25
 
26
26
  The npm package ships `tree-sitter-c.wasm` for
27
- [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 17.0.1 or later within 17.x, which runs in Node.js, Bun, browsers, and Cloudflare Workers. The parser carries the ABI number of the WillBooster/tree-sitter generator (`0x5742000c`), so it loads only with that runtime; upstream tree-sitter runtimes reject it. In Node.js and Bun, load the grammar from its path:
27
+ [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 20.0.0 or later within 20.x, which runs in Node.js, Bun, browsers, and Cloudflare Workers. The parser carries the ABI number of the WillBooster/tree-sitter generator (`0x5742000c`), so it loads only with that runtime; upstream tree-sitter runtimes reject it. In Node.js and Bun, load the grammar from its path:
28
28
 
29
29
  ```js
30
30
  import { fileURLToPath } from 'node:url';
@@ -123,7 +123,7 @@ and initialized declarators. Derived custom declaration builders also need `_gua
123
123
  also anchor the guarded type route. Retain that route in custom block and for-declaration builders. Keep the marked-type rule's
124
124
  ordinary type and annotation alternatives after the prefix guard, so typedef-return prototypes remain prototypes.
125
125
  Guard-owned initialized declarators also need their `_declarator` supertype alias; accepting the syntax alone does not
126
- preserve subtype queries. Keep ordinary initializers on their existing declarator family. Custom declaration builders
126
+ preserve supertype metadata. Keep ordinary initializers on their existing declarator family. Custom declaration builders
127
127
  must admit `_bare_marker_initializer_declaration` where they need the published bare-name initializer preference.
128
128
  If their ordinary function declarators reject C's opaque trailing identifiers, adapt that private initializer route
129
129
  separately and retain its `_declarator` alias.
@@ -149,7 +149,7 @@ Annotation lookahead hands the first unquoted brace in an argument group to the
149
149
  whole braced body. The argument grammar handles compound literals, inline types, aggregate initializers, and GNU
150
150
  statement expressions. Proved braced arguments also accept named declarations such as `register int a[sizeof(struct { int m; })]`,
151
151
  including declaration specifiers and trailing GNU attributes. Their `parameter_declaration` nodes require a name and retain
152
- public type and declarator subtype queries. Quoted punctuation and comments remain literal content. Semicolons and preprocessing directives
152
+ public type and declarator supertypes. Quoted punctuation and comments remain literal content. Semicolons and preprocessing directives
153
153
  encountered before an unknown annotation's braced handoff reject that lookahead; directive-bearing arguments need
154
154
  separate support. The marker proof balances recognized declaration-modifier groups, including inline types inside
155
155
  attribute arguments, in one pass. Those recognized groups do not turn an attribute's internal brace into the following
@@ -165,7 +165,7 @@ can declare an integer when `Word` is a typedef and `ATTR` is empty, or a struct
165
165
  selects its argument. For a genuinely bare prefix with an initialized first declarator, the grammar preserves the
166
166
  published first type-name preference, even though the remaining declarator can be approximate. Uninitialized marked
167
167
  types and prefixes with recognized declaration attributes or known specifiers keep the concrete macro-type route.
168
- This preference preserves query fields; it does not resolve both macro expansions semantically.
168
+ This preference preserves the `type` field; it does not resolve both macro expansions semantically.
169
169
 
170
170
  A proved braced macro call can also supply a declarator. Its `function_declarator` keeps the macro name in `declarator`
171
171
  and the structural argument group in `parameters`, so a physical semicolon, comma, initializer or function body
@@ -214,7 +214,7 @@ In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-
214
214
  fuzzed with, at the version recorded in `Cargo.lock`:
215
215
 
216
216
  ```sh
217
- cargo add willbooster-tree-sitter@17.0.1 --rename tree-sitter
217
+ cargo add willbooster-tree-sitter@20.0.0 --rename tree-sitter
218
218
  cargo add willbooster-tree-sitter-c --rename tree-sitter-c
219
219
  ```
220
220
 
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-c",
3
- "version": "34.0.3",
3
+ "version": "36.0.0",
4
4
  "description": "C grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "c",
7
- "incremental",
8
7
  "parsing",
9
8
  "tree-sitter"
10
9
  ],
@@ -60,7 +59,7 @@
60
59
  "@vitest/browser-playwright": "5.0.5",
61
60
  "@willbooster/oxlint-config": "1.4.9",
62
61
  "@willbooster/wb": "23.3.0",
63
- "@willbooster/web-tree-sitter": "17.0.1",
62
+ "@willbooster/web-tree-sitter": "20.0.0",
64
63
  "conventional-changelog-conventionalcommits": "10.4.1",
65
64
  "lefthook": "2.2.2",
66
65
  "oxlint": "1.90.0",
@@ -71,7 +70,7 @@
71
70
  "wrangler": "4.156.0"
72
71
  },
73
72
  "peerDependencies": {
74
- "@willbooster/web-tree-sitter": "^17.0.1"
73
+ "@willbooster/web-tree-sitter": "^20.0.0"
75
74
  },
76
75
  "peerDependenciesMeta": {
77
76
  "@willbooster/web-tree-sitter": {
@@ -1,4 +1,4 @@
1
- // code-gauge-allow-file fileNcss 706 -- One source-fact pass shares compact character storage, directive lexing and physical-position conversion.
1
+ // code-gauge-allow-file fileNcss 733 -- One source-fact pass shares compact character storage, directive lexing and physical-position conversion.
2
2
  #ifndef TREE_SITTER_C_EMPTY_DIRECTIVES_H_
3
3
  #define TREE_SITTER_C_EMPTY_DIRECTIVES_H_
4
4
 
@@ -16,7 +16,7 @@ typedef struct {
16
16
  uint8_t *prefix_barriers;
17
17
  uint32_t length, index, byte, end, page_count;
18
18
  uint32_t conditional_depth;
19
- bool utf16, encoding_known;
19
+ bool utf16, encoding_known, has_hash, has_directives, has_directive_ends, has_empty, has_barriers;
20
20
  } DirectiveInput;
21
21
 
22
22
  typedef struct {
@@ -46,7 +46,7 @@ static void directive_release(DirectiveInput *input);
46
46
  static unsigned directive_utf8_width(uint32_t c);
47
47
  static void directive_barrier(DirectiveInput *input);
48
48
  static void directive_line_end(EmptyDirectives *state, DirectiveInput *input, DirectiveLine *line);
49
- static void directive_complete_required(EmptyDirectives *state, DirectiveLine *line);
49
+ static void directive_complete_required(EmptyDirectives *state, DirectiveInput *input, DirectiveLine *line);
50
50
  static bool directive_requires_operand(DirectiveKind kind);
51
51
  static void directive_line_character(EmptyDirectives *state, DirectiveInput *input, DirectiveLine *line, int32_t c);
52
52
  static void directive_code(EmptyDirectives *state, DirectiveInput *input, DirectiveLine *line, int32_t c);
@@ -59,6 +59,7 @@ static void directive_line_comment(EmptyDirectives *state, DirectiveInput *input
59
59
  static uint32_t directive_splice_end(const DirectiveInput *input);
60
60
 
61
61
  static bool empty_directives_build(EmptyDirectives *state, TSLexer *lexer);
62
+ static void empty_directives_prune(EmptyDirectives *state, DirectiveInput *input);
62
63
  static bool empty_directives_line_end_at(const EmptyDirectives *state, uint32_t byte);
63
64
  static bool empty_directives_start_at(const EmptyDirectives *state, uint32_t byte);
64
65
  static void empty_directives_consume_started(TSLexer *lexer, EmptyDirectives *state, bool skip_prefix);
@@ -94,7 +95,7 @@ static void directive_word_role(DirectiveLine *line, DirectiveKind kind, bool na
94
95
  static bool directive_horizontal(int32_t c);
95
96
  static bool directive_newline(int32_t c);
96
97
  static uint32_t directive_byte(const DirectiveInput *input);
97
- static void directive_record(EmptyDirectives *state, uint32_t start, uint32_t end);
98
+ static void directive_record(EmptyDirectives *state, DirectiveInput *input, uint32_t start, uint32_t end);
98
99
 
99
100
  static bool empty_directives_initialize(EmptyDirectives *state, TSLexer *lexer) {
100
101
  TSLexerCheckpoint start;
@@ -139,11 +140,10 @@ static bool empty_directives_skip(TSLexer *lexer, void *payload) {
139
140
  return empty_directives_consume(lexer, payload, false);
140
141
  }
141
142
 
142
- // A null directive, including its prefix, starts only at `#`, `\\` or a space, so other characters need no position query,
143
- // which would make the runtime allocate the token on the heap.
143
+ // A null directive, including its prefix, starts only at `#`, `\\` or a space, so other characters cannot match `starts`.
144
144
  static bool empty_directives_consume(TSLexer *lexer, EmptyDirectives *state, bool skip_prefix) {
145
145
  int32_t c = lexer->lookahead;
146
- if (!state || !(c == '#' || c == '\\' || pragma_space(c))) return false;
146
+ if (!state || !state->starts || !(c == '#' || c == '\\' || pragma_space(c))) return false;
147
147
  TSLexerPosition position;
148
148
  lexer->get_position(lexer, &position);
149
149
  if (!empty_directives_start_at(state, position.bytes)) return false;
@@ -167,7 +167,7 @@ static void empty_directives_consume_started(TSLexer *lexer, EmptyDirectives *st
167
167
  !(state->ends[position.bytes / 8] & (1u << (position.bytes % 8))));
168
168
  }
169
169
 
170
- // code-gauge-allow functionNcss 33 -- The source-fact buffers are allocated and released together so initialization fails atomically.
170
+ // code-gauge-allow functionNcss 35 -- The source-fact buffers are allocated and released together so initialization fails atomically.
171
171
  static bool empty_directives_build(EmptyDirectives *state, TSLexer *lexer) {
172
172
  TSLexerPosition start;
173
173
  lexer->get_position(lexer, &start);
@@ -178,6 +178,10 @@ static bool empty_directives_build(EmptyDirectives *state, TSLexer *lexer) {
178
178
  }
179
179
  input.end = byte;
180
180
  state->bytes = byte;
181
+ if (!input.has_hash) {
182
+ directive_release(&input);
183
+ return true;
184
+ }
181
185
  state->starts = calloc((size_t)state->bytes / 8 + 1, 1);
182
186
  state->ends = calloc((size_t)state->bytes / 8 + 1, 1);
183
187
  state->directive_starts = calloc((size_t)state->bytes / 8 + 1, 1);
@@ -185,8 +189,8 @@ static bool empty_directives_build(EmptyDirectives *state, TSLexer *lexer) {
185
189
  input.prefix_barriers = calloc((size_t)state->bytes / 8 + 1, 1);
186
190
  if (!state->starts || !state->ends || !state->directive_starts || !state->directive_ends || !input.prefix_barriers) goto failed;
187
191
  empty_directives_find(state, &input);
188
- directive_prefixes(state, &input);
189
- state->line_ends = input.prefix_barriers;
192
+ if (input.has_empty || input.has_barriers) directive_prefixes(state, &input);
193
+ empty_directives_prune(state, &input);
190
194
  directive_release(&input);
191
195
  return true;
192
196
  failed:
@@ -200,6 +204,24 @@ failed:
200
204
  return false;
201
205
  }
202
206
 
207
+ static void empty_directives_prune(EmptyDirectives *state, DirectiveInput *input) {
208
+ if (!input->has_empty) {
209
+ free(state->starts);
210
+ free(state->ends);
211
+ state->starts = state->ends = NULL;
212
+ }
213
+ if (!input->has_directives) {
214
+ free(state->directive_starts);
215
+ state->directive_starts = NULL;
216
+ }
217
+ if (!input->has_directive_ends) {
218
+ free(state->directive_ends);
219
+ state->directive_ends = NULL;
220
+ }
221
+ if (input->has_barriers) state->line_ends = input->prefix_barriers;
222
+ else free(input->prefix_barriers);
223
+ }
224
+
203
225
  // code-gauge-allow functionCognitiveComplexity 29 -- The reverse lexical pass applies sparse physical-position corrections while carrying null-prefix and line-end facts.
204
226
  static void directive_prefixes(EmptyDirectives *state, DirectiveInput *input) {
205
227
  bool prefix = false, line_end = false;
@@ -246,6 +268,7 @@ static uint32_t directive_skip_inert(const DirectiveInput *input, uint32_t end,
246
268
  // `*byte` is the lexer's position before the character and is advanced past it.
247
269
  static bool directive_append(DirectiveInput *input, uint32_t *capacity, uint32_t *byte, TSLexer *lexer) {
248
270
  uint32_t c = lexer->lookahead, index = input->length, start = *byte;
271
+ if (c == '#') input->has_hash = true;
249
272
  unsigned width = directive_utf8_width(c), utf16_width = c > 0xffff && c <= 0x10ffff ? 4 : 2;
250
273
  if (!directive_reserve(input, capacity, c > 0xffff && c <= 0x10ffff ? 2 : 1)) return false;
251
274
  directive_encode(input, c);
@@ -334,8 +357,8 @@ static void empty_directives_find(EmptyDirectives *state, DirectiveInput *input)
334
357
  if (c < 0) break;
335
358
  directive_line_character(state, input, &line, c);
336
359
  }
337
- directive_complete_required(state, &line);
338
- if (line.pending) directive_record(state, line.start, input->end);
360
+ directive_complete_required(state, input, &line);
361
+ if (line.pending) directive_record(state, input, line.start, input->end);
339
362
  }
340
363
 
341
364
  static void directive_line_character(EmptyDirectives *state, DirectiveInput *input, DirectiveLine *line, int32_t c) {
@@ -355,6 +378,7 @@ static void directive_line_character(EmptyDirectives *state, DirectiveInput *inp
355
378
  line->operand = false;
356
379
  line->start = input->previous_byte;
357
380
  state->directive_starts[line->start / 8] |= 1u << (line->start % 8);
381
+ input->has_directives = true;
358
382
  line->beginning = false;
359
383
  line->pending = true;
360
384
  return;
@@ -475,8 +499,8 @@ static void directive_line_comment(EmptyDirectives *state, DirectiveInput *input
475
499
  }
476
500
 
477
501
  static void directive_line_end(EmptyDirectives *state, DirectiveInput *input, DirectiveLine *line) {
478
- directive_complete_required(state, line);
479
- if (line->pending) directive_record(state, line->start, directive_byte(input));
502
+ directive_complete_required(state, input, line);
503
+ if (line->pending) directive_record(state, input, line->start, directive_byte(input));
480
504
  line->beginning = true;
481
505
  line->pending = false;
482
506
  bool required = line->kind == DIRECTIVE_CONDITION ||
@@ -490,13 +514,14 @@ static void directive_line_end(EmptyDirectives *state, DirectiveInput *input, Di
490
514
  }
491
515
  }
492
516
 
493
- static void directive_complete_required(EmptyDirectives *state, DirectiveLine *line) {
517
+ static void directive_complete_required(EmptyDirectives *state, DirectiveInput *input, DirectiveLine *line) {
494
518
  bool pragma_name = line->pragma_name;
495
519
  line->pragma_name = false;
496
520
  if (!line->required_end) return;
497
521
  if (line->operand || line->pragma_pending || pragma_name) {
498
522
  uint32_t end = line->required_end;
499
523
  state->directive_ends[end / 8] |= 1u << (end % 8);
524
+ input->has_directive_ends = true;
500
525
  }
501
526
  line->required_end = 0;
502
527
  }
@@ -509,6 +534,7 @@ static void directive_barrier(DirectiveInput *input) {
509
534
  if (!input->index || !directive_newline(directive_character(input, input->index - 1))) return;
510
535
  uint32_t byte = input->previous_byte;
511
536
  input->prefix_barriers[byte / 8] |= 1u << (byte % 8);
537
+ input->has_barriers = true;
512
538
  if (input->index < 2) return;
513
539
  int32_t previous = directive_character(input, input->index - 2);
514
540
  if (directive_newline(previous) && previous != directive_character(input, input->index - 1)) {
@@ -715,7 +741,10 @@ static DirectiveKind directive_keyword(EmptyDirectives *state, DirectiveInput *i
715
741
  DirectiveKind kind = directive_word_kind(word);
716
742
  // Directives in a group that may be skipped need no operand, and the parser cannot tell which groups are skipped.
717
743
  if (directive_requires_operand(kind) && !input->conditional_depth) line->required_end = end;
718
- else state->directive_ends[end / 8] |= 1u << (end % 8);
744
+ else {
745
+ state->directive_ends[end / 8] |= 1u << (end % 8);
746
+ input->has_directive_ends = true;
747
+ }
719
748
  if (word->length < sizeof word->directive) {
720
749
  if (strcmp(word->directive, "if") == 0 || strcmp(word->directive, "ifdef") == 0 || strcmp(word->directive, "ifndef") == 0) input->conditional_depth++;
721
750
  else if (strcmp(word->directive, "endif") == 0 && input->conditional_depth) input->conditional_depth--;
@@ -813,9 +842,10 @@ static uint32_t directive_byte(const DirectiveInput *input) {
813
842
  return input->byte;
814
843
  }
815
844
 
816
- static void directive_record(EmptyDirectives *state, uint32_t start, uint32_t end) {
845
+ static void directive_record(EmptyDirectives *state, DirectiveInput *input, uint32_t start, uint32_t end) {
817
846
  state->starts[start / 8] |= 1u << (start % 8);
818
847
  state->ends[end / 8] |= 1u << (end % 8);
848
+ input->has_empty = true;
819
849
  }
820
850
 
821
851
  #endif
package/src/pragma.h CHANGED
@@ -51,7 +51,7 @@ static bool scan_pragma_empty(TSLexer *lexer, const PragmaTrivia *trivia);
51
51
  static bool scan_pragma_suffix_end_with(TSLexer *lexer, bool mark_end, const PragmaTrivia *trivia);
52
52
  static bool scan_pragma_suffix(TSLexer *lexer);
53
53
  static bool scan_pragma_suffix_end(TSLexer *lexer, bool mark_end);
54
- static bool pragma_space(int32_t c);
54
+ static inline bool pragma_space(int32_t c);
55
55
  static bool scan_pragma_word(TSLexer *lexer);
56
56
  static bool scan_preproc_newline(TSLexer *lexer, bool skip);
57
57
  static bool scan_preproc_splices(TSLexer *lexer);
@@ -443,10 +443,11 @@ static bool scan_preproc_splices(TSLexer *lexer) {
443
443
  return true;
444
444
  }
445
445
 
446
- static bool pragma_space(int32_t c) {
447
- return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f' || c == '\v' ||
448
- c == 0x85 || c == 0xA0 || c == 0x1680 || (c >= 0x2000 && c <= 0x200A) ||
449
- c == 0x2028 || c == 0x2029 || c == 0x202F || c == 0x205F || c == 0x3000;
446
+ static inline bool pragma_space(int32_t c) {
447
+ return c < 0x85
448
+ ? c == ' ' || (uint32_t)(c - '\t') <= '\r' - '\t'
449
+ : c == 0x85 || c == 0xA0 || c == 0x1680 || (uint32_t)(c - 0x2000) <= 0x200A - 0x2000 ||
450
+ c == 0x2028 || c == 0x2029 || c == 0x202F || c == 0x205F || c == 0x3000;
450
451
  }
451
452
 
452
453
  static bool scan_function_macro_name(TSLexer *lexer, bool allow_pragma, TSSymbol pragma_symbol) {
package/src/scanner.c CHANGED
@@ -13,6 +13,8 @@ static EmptyDirectives *scanner_directives(CScanner *scanner);
13
13
 
14
14
  static bool only_extras_valid(const EmptyDirectives *state, const bool *valid_symbols);
15
15
  static bool scan_extras(EmptyDirectives *state, TSLexer *lexer, const bool *valid_symbols);
16
+ static bool scan_extras_pragma(EmptyDirectives *state, TSLexer *lexer, const TSLexerCheckpoint *start, bool skipped);
17
+ static uint32_t extras_start_byte(TSLexer *lexer, const TSLexerCheckpoint *start, bool skipped);
16
18
  static bool scan_preproc_tokens(EmptyDirectives *state, TSLexer *lexer, const bool *valid_symbols);
17
19
  static bool scan_declaration_tokens(CScanner *scanner, TSLexer *lexer, const bool *valid_symbols);
18
20
  static bool scan_directive_context(EmptyDirectives *state, TSLexer *lexer, const bool *valid_symbols);
@@ -79,35 +81,49 @@ bool tree_sitter_c_external_scanner_scan(void *payload, TSLexer *lexer, const bo
79
81
  }
80
82
 
81
83
  static bool only_extras_valid(const EmptyDirectives *state, const bool *valid_symbols) {
82
- if (!state || !state->ready) return false;
83
- for (unsigned i = PREPROC_ARG; i < DIRECTIVE_CONTEXT; i++) {
84
- if (valid_symbols[i]) return false;
85
- }
86
- return !valid_symbols[PREPROC_DIRECTIVE_START];
84
+ return state && state->ready && !valid_symbols[PREPROC_DIRECTIVE_START] &&
85
+ !memchr(valid_symbols + PREPROC_ARG, true, (DIRECTIVE_CONTEXT - PREPROC_ARG) * sizeof(*valid_symbols));
87
86
  }
88
87
 
89
- // Decides as the general path does in states where only extras are valid, but queries the position only once the first
90
- // non-space character shows that a null directive or `_Pragma` may follow, since any position query makes the runtime
91
- // allocate the token on the heap. A null directive's prefix holds only spaces and splices, and line ends are recorded
92
- // only at spaces and newlines. The skipped spaces moved the lexer, so the start position is read back through the mark.
88
+ // `starts` marks only `#`, `\`, and spaces/splices before a null directive's `#`, and `line_ends` marks only spaces and
89
+ // newlines, so `extras_start_byte` restores the pre-space checkpoint via `mark_end_at` only after `#`/`\` (when `starts`
90
+ // exists) or `_Pragma` (when skipped spaces may start at `line_ends`), avoiding checkpoint/column work on other tokens.
93
91
  static bool scan_extras(EmptyDirectives *state, TSLexer *lexer, const bool *valid_symbols) {
94
- TSLexerCheckpoint start;
95
- lexer->get_checkpoint(lexer, &start);
92
+ bool allow_empty = valid_symbols[PREPROC_EMPTY] && state->starts;
93
+ bool allow_pragma = valid_symbols[PRAGMA_OPERATOR];
94
+ if (!allow_empty && !allow_pragma) return false;
95
+ bool skipped = pragma_space(lexer->lookahead);
96
+ TSLexerCheckpoint start = {0};
97
+ if (skipped && (allow_empty || state->line_ends)) lexer->get_checkpoint(lexer, &start);
96
98
  while (pragma_space(lexer->lookahead)) lexer->advance(lexer, true);
97
99
  int32_t c = lexer->lookahead;
98
- if (c != '#' && c != '\\' && c != '_') return false;
99
- TSLexerPosition position;
100
- lexer->mark_end_at(lexer, &start);
101
- lexer->get_mark_end(lexer, &position);
102
- if (valid_symbols[PREPROC_EMPTY] && empty_directives_start_at(state, position.bytes)) {
103
- empty_directives_consume_started(lexer, state, true);
104
- lexer->mark_end(lexer);
105
- lexer->result_symbol = PREPROC_EMPTY;
106
- return true;
100
+ if (c == '_') return allow_pragma && scan_extras_pragma(state, lexer, &start, skipped);
101
+ if (!allow_empty || (c != '#' && c != '\\')) return false;
102
+ if (!empty_directives_start_at(state, extras_start_byte(lexer, &start, skipped))) return false;
103
+ empty_directives_consume_started(lexer, state, true);
104
+ lexer->mark_end(lexer);
105
+ lexer->result_symbol = PREPROC_EMPTY;
106
+ return true;
107
+ }
108
+
109
+ static bool scan_extras_pragma(EmptyDirectives *state, TSLexer *lexer, const TSLexerCheckpoint *start, bool skipped) {
110
+ if (!scan_pragma_word(lexer)) return false;
111
+ if (skipped && state->line_ends && empty_directives_line_end_at(state, extras_start_byte(lexer, start, true))) {
112
+ return false;
107
113
  }
108
- if (!valid_symbols[PRAGMA_OPERATOR] || empty_directives_line_end_at(state, position.bytes)) return false;
109
114
  lexer->result_symbol = PRAGMA_OPERATOR;
110
- return scan_pragma_with(lexer, &(PragmaTrivia){empty_directives_skip, state});
115
+ return scan_pragma_suffix_end_with(lexer, true, &(PragmaTrivia){empty_directives_skip, state});
116
+ }
117
+
118
+ static uint32_t extras_start_byte(TSLexer *lexer, const TSLexerCheckpoint *start, bool skipped) {
119
+ TSLexerPosition position;
120
+ if (skipped) {
121
+ lexer->mark_end_at(lexer, start);
122
+ lexer->get_mark_end(lexer, &position);
123
+ } else {
124
+ lexer->get_position(lexer, &position);
125
+ }
126
+ return position.bytes;
111
127
  }
112
128
 
113
129
  static bool scan_conditional_directive(EmptyDirectives *state, TSLexer *lexer, const bool *valid_symbols) {
Binary file
package/tree-sitter.json CHANGED
@@ -24,7 +24,7 @@
24
24
  }
25
25
  ],
26
26
  "metadata": {
27
- "version": "34.0.3",
27
+ "version": "36.0.0",
28
28
  "license": "MIT",
29
29
  "description": "C grammar for tree-sitter",
30
30
  "authors": [