tree-sitter / tree-sitter-c

C grammar for tree-sitter
MIT License
225 stars 100 forks source link

fix: properly suffix elifdef #186

Closed brandonspark closed 7 months ago

brandonspark commented 7 months ago

This PR makes it so that preproc_elifdef is not unconditionally used in all preproc_if_<suffix> variants. For instance, preproc_if and preproc_if_in_field_declaration_list are in different contexts, and the former permits any block_item to appear within its preprocessor statements, whereas the latter only allows _field_declaration_list_item. Since the preproc_elifdef was not suffixed, however, this means preproc_if_in_field_declaration_list actually also permits block_items to appear in it.

amaanq commented 7 months ago

Nice catch, thanks! Just a side note, can you regenerate with tree-sitter built from 0.20.9 or HEAD? you can do so like so: cargo install --git https://github.com/tree-sitter/tree-sitter

If you notice, your generated output rolls back some changes made in parser.h

brandonspark commented 7 months ago

@amaanq done!

amaanq commented 7 months ago

thanks!