tree-sitter / tree-sitter-c

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

Feat(query): include group + individual token #208

Closed ilan-schemoul closed 3 months ago

ilan-schemoul commented 3 months ago

Problem

I want to select "struct abc { int a; };" struct_specifier in c does not include semicolon I do not know if it's a bug or I don't know how to use the app or a feature lacks but : ((structspecifier ()) ";") @c @c is not the struct with ";" but is the struct without semicolon (structspecifier () ";") @c gives error impossible pattern

Expected behavior

((structspecifier ()) ";") @c to select struct with semicolo or something similar

amaanq commented 3 months ago

belongs in tree-sitter-c, but you can just do this

(translation_unit
  (struct_specifier (_))
  .
  ";") @c