@willbooster/tree-sitter-c 40.0.3 → 40.0.5

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.
@@ -1,4 +1,4 @@
1
- // code-gauge-allow-file fileNcss 575 -- Annotation and argument scanners share lexical helpers and keyword tables.
1
+ // code-gauge-allow-file fileNcss -- Annotation and argument scanners share lexical helpers and keyword tables.
2
2
  #ifndef TREE_SITTER_C_FUNCTION_MACRO_H_
3
3
  #define TREE_SITTER_C_FUNCTION_MACRO_H_
4
4
 
@@ -72,8 +72,8 @@ static bool function_macro_attribute_keyword(const char *word, bool trailing);
72
72
  static bool function_macro_keyword(const char *word);
73
73
  static bool function_macro_word_in(const char *word, const char *const *words, unsigned count);
74
74
 
75
- // code-gauge-allow functionCognitiveComplexity 18 -- Balanced delimiter recovery, trivia, and braced handoff share one consumed group.
76
- // code-gauge-allow functionNcss 33 -- Balanced delimiter recovery, trivia, and braced handoff share one consumed group.
75
+ // code-gauge-allow functionCognitiveComplexity -- Balanced delimiter recovery, trivia, and braced handoff share one consumed group.
76
+ // code-gauge-allow functionNcss -- Balanced delimiter recovery, trivia, and braced handoff share one consumed group.
77
77
  static inline bool scan_raw_macro_type_tail(TSLexer *lexer, const PragmaTrivia *trivia) {
78
78
  while (pragma_space(lexer->lookahead)) lexer->advance(lexer, true);
79
79
  if (lexer->lookahead == ')' || pragma_eof(lexer)) return false;
@@ -116,8 +116,8 @@ static bool function_macro_first_word(TSLexer *lexer, const MacroName *name, con
116
116
  return false;
117
117
  }
118
118
 
119
- // code-gauge-allow functionCognitiveComplexity 17 -- Attribute roles share first-word dispatch, token ranges, and group results.
120
- // code-gauge-allow functionNcss 32 -- Attribute roles share first-word dispatch, token ranges, and group results.
119
+ // code-gauge-allow functionCognitiveComplexity -- Attribute roles share first-word dispatch, token ranges, and group results.
120
+ // code-gauge-allow functionNcss -- Attribute roles share first-word dispatch, token ranges, and group results.
121
121
  static bool scan_function_attribute_guard(TSLexer *lexer, bool prototype, bool require_literal, bool trailing, const MacroAttributeSymbols *symbols) {
122
122
  const PragmaTrivia *trivia = &symbols->trivia;
123
123
  bool braced_only = symbols->allow_braced_start && lexer->result_symbol == symbols->braced_start;
@@ -259,7 +259,7 @@ static MacroTypeResult function_macro_type_transition(MacroTypeState *state, Mac
259
259
  return MACRO_TYPE_REJECT;
260
260
  }
261
261
 
262
- // code-gauge-allow functionCognitiveComplexity 20 -- Keyword, modifier, and group alternatives classify one consumed type-prefix word.
262
+ // code-gauge-allow functionCognitiveComplexity -- Keyword, modifier, and group alternatives classify one consumed type-prefix word.
263
263
  static MacroTypePrefix function_macro_type_prefix_item(TSLexer *lexer, const MacroName *name, const char *const *reserved_words, unsigned reserved_count, const MacroTypeState *state, const PragmaTrivia *trivia) {
264
264
  if (name->ascii && strcmp(name->word, pragma_word) == 0) {
265
265
  return scan_pragma_suffix_end_with(lexer, false, trivia) && scan_pragma_spacing_with(lexer, trivia)
@@ -297,7 +297,7 @@ static MacroTypePrefix function_macro_macro_type_item(TSLexer *lexer, const Macr
297
297
  return MACRO_TYPE_PREFIX_INVALID;
298
298
  }
299
299
 
300
- // code-gauge-allow functionCognitiveComplexity 16 -- Literal prefixes inspect one consumed first argument token without restarting the lexer.
300
+ // code-gauge-allow functionCognitiveComplexity -- Literal prefixes inspect one consumed first argument token without restarting the lexer.
301
301
  static bool function_macro_trailing_argument_prefix(TSLexer *lexer, const PragmaTrivia *trivia) {
302
302
  do {
303
303
  lexer->advance(lexer, false);
@@ -380,7 +380,7 @@ static bool function_macro_modifier_balanced(TSLexer *lexer, int32_t open, int32
380
380
  return function_macro_group_contents(lexer, open, close, NULL, NULL, false, true, trivia) == MACRO_GROUP_BALANCED;
381
381
  }
382
382
 
383
- // code-gauge-allow functionParameterCount 7 -- One group proof uses its delimiter pair, optional outputs, grammar mode, and trivia context.
383
+ // code-gauge-allow functionParameterCount -- One group proof uses its delimiter pair, optional outputs, grammar mode, and trivia context.
384
384
  static MacroGroup function_macro_group_prefix(TSLexer *lexer, int32_t open, int32_t close, bool *literal, bool *unterminated_raw, bool type_argument, const PragmaTrivia *trivia) {
385
385
  lexer->advance(lexer, false);
386
386
  if (type_argument && (!scan_pragma_spacing_with(lexer, trivia) || (!preproc_word(lexer->lookahead, false) && lexer->lookahead != '\\'))) {
@@ -389,8 +389,8 @@ static MacroGroup function_macro_group_prefix(TSLexer *lexer, int32_t open, int3
389
389
  return function_macro_group_contents(lexer, open, close, literal, unterminated_raw, type_argument, false, trivia);
390
390
  }
391
391
 
392
- // code-gauge-allow functionCognitiveComplexity 17 -- Trivia and delimiter alternatives update the same nesting and argument-word state.
393
- // code-gauge-allow functionParameterCount 8 -- The shared group lexer uses its delimiter pair, optional outputs, two grammar modes, and trivia context.
392
+ // code-gauge-allow functionCognitiveComplexity -- Trivia and delimiter alternatives update the same nesting and argument-word state.
393
+ // code-gauge-allow functionParameterCount -- The shared group lexer uses its delimiter pair, optional outputs, two grammar modes, and trivia context.
394
394
  static MacroGroup function_macro_group_contents(TSLexer *lexer, int32_t open, int32_t close, bool *literal, bool *unterminated_raw, bool type_argument, bool modifier, const PragmaTrivia *trivia) {
395
395
  unsigned depth = 1;
396
396
  unsigned nested = 0;
@@ -447,7 +447,7 @@ static void function_macro_note_literal(bool *literal, unsigned depth, unsigned
447
447
  if (c == '"' || (c == '\'' && !word->number) || (c >= '0' && c <= '9' && !word->identifier)) *literal = true;
448
448
  }
449
449
 
450
- // code-gauge-allow functionCognitiveComplexity 27 -- Words, groups, and punctuators advance the same declaration-tail state.
450
+ // code-gauge-allow functionCognitiveComplexity -- Words, groups, and punctuators advance the same declaration-tail state.
451
451
  static bool function_macro_declaration_continues(TSLexer *lexer, bool post_type, bool allow_braced, const PragmaTrivia *trivia) {
452
452
  MacroPrototypeTail tail = {.post_type = post_type, .explicit_type = post_type};
453
453
  for (;;) {
@@ -559,7 +559,7 @@ static MacroArgumentToken function_macro_argument_token(TSLexer *lexer, MacroArg
559
559
  return MACRO_ARGUMENT_CONSUMED;
560
560
  }
561
561
 
562
- // code-gauge-allow functionCognitiveComplexity 18 -- Raw and escaped quote scanning share delimiter, newline, and splice termination.
562
+ // code-gauge-allow functionCognitiveComplexity -- Raw and escaped quote scanning share delimiter, newline, and splice termination.
563
563
  static bool function_macro_argument_quote(TSLexer *lexer, int32_t quote, bool raw, bool *unterminated_raw) {
564
564
  lexer->advance(lexer, false);
565
565
  if (raw) {
@@ -589,7 +589,7 @@ static bool function_macro_argument_slash(TSLexer *lexer, bool allow_division) {
589
589
  return allow_division;
590
590
  }
591
591
 
592
- // code-gauge-allow functionCognitiveComplexity 16 -- Identifier, pp-number, and GNU raw-string prefix transitions share token-character state.
592
+ // code-gauge-allow functionCognitiveComplexity -- Identifier, pp-number, and GNU raw-string prefix transitions share token-character state.
593
593
  static void function_macro_argument_word(MacroArgumentWord *word, int32_t c) {
594
594
  bool member = preproc_word(c, word->identifier || word->number);
595
595
  bool digit = c >= '0' && c <= '9';
package/src/pragma.h CHANGED
@@ -1,4 +1,4 @@
1
- // code-gauge-allow-file fileNcss 493 -- Preprocessor tokens and pragma operators share names, spacing, and literal readers.
1
+ // code-gauge-allow-file fileNcss -- Preprocessor tokens and pragma operators share names, spacing, and literal readers.
2
2
  #ifndef TREE_SITTER_C_PRAGMA_H_
3
3
  #define TREE_SITTER_C_PRAGMA_H_
4
4
 
@@ -330,7 +330,7 @@ typedef struct {
330
330
 
331
331
  static bool scan_preproc_quote_step(TSLexer *lexer, PreprocQuoteState *state, int32_t c);
332
332
 
333
- // code-gauge-allow functionCognitiveComplexity 25 -- Unterminated quote recovery tracks line splices alongside comment fallback boundaries.
333
+ // code-gauge-allow functionCognitiveComplexity -- Unterminated quote recovery tracks line splices alongside comment fallback boundaries.
334
334
  static bool scan_preproc_quote(TSLexer *lexer, int32_t quote, bool escaped, bool directive_text) {
335
335
  lexer->mark_end(lexer);
336
336
  PreprocQuoteState state = {.literal = true, .directive_text = directive_text};
@@ -354,8 +354,8 @@ static bool scan_preproc_quote(TSLexer *lexer, int32_t quote, bool escaped, bool
354
354
  return false;
355
355
  }
356
356
 
357
- // code-gauge-allow functionCognitiveComplexity 30 -- Comment transitions in unterminated quotes share split-splice and mark-end state.
358
- // code-gauge-allow functionNcss 36 -- Comment transitions in unterminated quotes share split-splice and mark-end state.
357
+ // code-gauge-allow functionCognitiveComplexity -- Comment transitions in unterminated quotes share split-splice and mark-end state.
358
+ // code-gauge-allow functionNcss -- Comment transitions in unterminated quotes share split-splice and mark-end state.
359
359
  static bool scan_preproc_quote_step(TSLexer *lexer, PreprocQuoteState *state, int32_t c) {
360
360
  if (state->line) {
361
361
  if (!state->after_comment) lexer->mark_end(lexer);
@@ -386,8 +386,8 @@ static bool scan_preproc_quote_step(TSLexer *lexer, PreprocQuoteState *state, in
386
386
  return true;
387
387
  }
388
388
 
389
- // code-gauge-allow functionCognitiveComplexity 29 -- Standard, delimited, and named universal character names share hex/name validation.
390
- // code-gauge-allow functionNcss 32 -- Standard, delimited, and named universal character names share hex/name validation.
389
+ // code-gauge-allow functionCognitiveComplexity -- Standard, delimited, and named universal character names share hex/name validation.
390
+ // code-gauge-allow functionNcss -- Standard, delimited, and named universal character names share hex/name validation.
391
391
  static bool scan_preproc_ucn(TSLexer *lexer, bool *in_number) {
392
392
  while (!scan_preproc_splices(lexer)) *in_number = false;
393
393
  int32_t prefix = lexer->lookahead;
package/src/scanner.c CHANGED
@@ -28,11 +28,7 @@ void tree_sitter_c_external_scanner_destroy(void *payload) {
28
28
  CScanner *scanner = payload;
29
29
  EmptyDirectives *state = scanner_directives(scanner);
30
30
  if (!state) return;
31
- free(state->starts);
32
- free(state->ends);
33
- free(state->line_ends);
34
- free(state->directive_starts);
35
- free(state->directive_ends);
31
+ empty_directives_release(state);
36
32
  macro_proof_destroy(&scanner->proof_memo);
37
33
  free(scanner);
38
34
  }
@@ -49,7 +45,7 @@ void tree_sitter_c_external_scanner_deserialize(void *payload, const char *buffe
49
45
  if (state) state->ready = length && buffer[0];
50
46
  }
51
47
 
52
- // code-gauge-allow functionCognitiveComplexity 16 -- External-token validity dispatches each lexing mode to its scanner.
48
+ // code-gauge-allow functionCognitiveComplexity -- External-token validity dispatches each lexing mode to its scanner.
53
49
  bool tree_sitter_c_external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) {
54
50
  CScanner *scanner = payload;
55
51
  EmptyDirectives *state = scanner_directives(scanner);
@@ -189,8 +185,8 @@ static bool scan_declaration_tokens(CScanner *scanner, TSLexer *lexer, const boo
189
185
  return scan_preproc_tokens(state, lexer, valid_symbols);
190
186
  }
191
187
 
192
- // code-gauge-allow functionCognitiveComplexity 28 -- External-token validity selects one preprocessor lexing mode and preserves its token range.
193
- // code-gauge-allow functionNcss 34 -- External-token validity selects one preprocessor lexing mode and preserves its token range.
188
+ // code-gauge-allow functionCognitiveComplexity -- External-token validity selects one preprocessor lexing mode and preserves its token range.
189
+ // code-gauge-allow functionNcss -- External-token validity selects one preprocessor lexing mode and preserves its token range.
194
190
  static bool scan_preproc_tokens(EmptyDirectives *state, TSLexer *lexer, const bool *valid_symbols) {
195
191
  bool directive_text = !valid_symbols[PREPROC_ARG] && valid_symbols[PREPROC_DIRECTIVE_ARG];
196
192
  PreprocArgumentMode argument_mode = preproc_argument_mode(
Binary file
package/tree-sitter.json CHANGED
@@ -19,12 +19,13 @@
19
19
  "src/macroProof.h",
20
20
  "src/conditionalMacro.h",
21
21
  "src/emptyDirectives.h",
22
+ "src/directiveScan.h",
22
23
  "src/gnuRawString.h"
23
24
  ]
24
25
  }
25
26
  ],
26
27
  "metadata": {
27
- "version": "40.0.3",
28
+ "version": "40.0.5",
28
29
  "license": "MIT",
29
30
  "description": "C grammar for tree-sitter",
30
31
  "authors": [