Repository navigation
Description
Pre-flight checks
- I have checked the Troubleshooting section in the README
What happened?
While indexing a C firmware project, Graphify reported syntax errors and produced partial extraction for affected headers/source files. I reduced the patterns below to synthetic ISO C examples and reproduced them directly in the installed tree-sitter-c parser, without any XC8 or GNU extensions.
Expected: valid unnamed bit-fields parse without a missing identifier, and valid conditional-source patterns do not prevent C files from being indexed. The #ifdef examples yield valid C with FEATURE both defined and undefined. Could Graphify track these upstream limitations or document a preprocessing option that preserves source locations?
Steps to reproduce
Save the examples below to individual C files. To isolate the parser in Graphify's Python environment, run:
from pathlib import Path
from tree_sitter import Language, Parser
import tree_sitter_c
parser = Parser(Language(tree_sitter_c.language()))
root = parser.parse(Path('repro.c').read_bytes()).root_node
print(root.has_error, root)
**Unnamed bit-fields**
struct Bits {
unsigned value : 1;
unsigned : 1;
unsigned : 0;
};
**Macros between enum members**
enum Mode {
A = 0,
#define FLAG 1
B = 128
};
**Optional enum member with a leading comma**
enum OptionalMode {
OFF = 0
#ifdef FEATURE
, ON = 1
#endif
};
**Optional initializer items (both comma placements)**
int a[] = {1
#ifdef FEATURE
, 2
#endif
};
int b[] = {1,
#ifdef FEATURE
2,
#endif
3};
**Conditional parameter list**
void f(
#ifdef FEATURE
int x
#else
void
#endif
) {}
**Conditional else-if and a conditional if header**
void g(int x) {
if (x == 0) {}
#ifdef FEATURE
else if (x == 1) {}
#endif
else {}
}
void h(int x) {
#ifdef FEATURE
if (x)
#endif
{ x++; }
}Error output or graph output
All the examples reproduce `root.has_error == True` with tree-sitter-c 0.24.2. The unnamed bit-fields produce `(MISSING field_identifier)`; #define between enum members produces `(MISSING ",")` even though the preceding enumerator already ends with a comma. Moving that macro outside the enum removes the diagnostic. The other cases produce error or missing nodes in the corresponding conditional construct.
Graphify version
0.9.123
Operating System
Windows
Python Version
3.13
Installation Method
uv tool install (recommended)
Additional Environment Details
Python 3.13.18; tree-sitter 0.25.2; tree-sitter-c 0.24.2. The minimal test uses the parser directly and needs no API key or firmware files.
Additional context
Related upstream threads: tree-sitter/tree-sitter-c#108 (general conditional preprocessing) and tree-sitter/tree-sitter-c#324 (a related initializer-list case involving #line). C11 draft sections 5.1.1.2 and 6.7.2.1 cover preprocessing order and unnamed bit-fields: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf.
Activity
github-actions commentedon Nov 30, 2026
Thanks for opening this issue, @miroslavdraxal-lgtm. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
Deepjyoti-Sarmah commentedon Nov 30, 2026
Thanks for the careful reduction, @miroslavdraxal-lgtm. Testing each pattern directly against the parser made this easy to reproduce.
I opened #5657 for it. Here's what I found on v8 (0.9.124), from Graphify's side rather than the parser's:
f()and its call edges disappear from the graph completely.The fix doesn't wait on tree-sitter-c#108. When a C file has parse errors, Graphify reads it a second time from a "first branch" view: directive lines, later conditional branches and unnamed bit-fields are replaced with spaces, and newlines are kept, so every line and column stays the same. No macro is evaluated. The view's result is used only if it keeps every node and edge the normal parse found. So a function that exists only under
#elsecan't go missing.All six of your examples parse cleanly with it. Limitations: only the first branch of each conditional is checked, and unnamed bit-fields are recognised only with built-in integer types (not
uint8_t : 3;).