Both the struct_specifier and union_specifier allow preprocessor directives inside of their definitions. This is fairly common in C code to allow flags to selectively enable and disable portions of the struct and union. This is also fairly common in C code to allow flags to selectively add and remove variants to an enum (or, to include a set of enum variants from a header file).
The existing grammar supports correctly parsing the struct_specifier and union_specifier in the presence of preprocessor directives, but does not allow the enum_specifier to be correctly parsed.
Did you check existing issues?
Tree-Sitter CLI Version, if relevant (output of
tree-sitter --version
)tree-sitter 0.20.8 (660481dbf71413eba5a928b0b0ab8da50c1109e0)
Describe the bug
Both the
struct_specifier
andunion_specifier
allow preprocessor directives inside of their definitions. This is fairly common in C code to allow flags to selectively enable and disable portions of thestruct
andunion
. This is also fairly common in C code to allow flags to selectively add and remove variants to anenum
(or, to include a set ofenum
variants from a header file).The existing grammar supports correctly parsing the
struct_specifier
andunion_specifier
in the presence of preprocessor directives, but does not allow theenum_specifier
to be correctly parsed.Steps To Reproduce/Bad Parse Tree
Expected Behavior/Parse Tree
Repro