About closed my issue #3240
yuriv opened this issue · comments
Problem
This is not Duplicate of #3239
because the problem here with nested choice operator[[ ]]
.
Try to run tree-sitter with first fragment:
(translation_unit (declaration (primitive_type) @tt [(attributed_declarator) @attributed_declarator (identifier) @ii]) @dd) (translation_unit (declaration (primitive_type) @tt (init_declarator) @id) @dd)
and another fragment:
(translation_unit (declaration (primitive_type) @tt [[(attributed_declarator) @attributed_declarator (identifier) @ii] (init_declarator) @id]) @dd)
with C code:
int k; int l=0;
In the first case you have got valid output, in the second - one pattern for the last declaration only:
pattern: 0
capture: 4 - dd, start: (1, 0), end: (1, 8), text: int l=0;
capture: 0 - tt, start: (1, 0), end: (1, 3), text: int
capture: 3 - id, start: (1, 4), end: (1, 7), text: l=0
Although both cases are semantically identical. I think the problem there with nested choice operator processing. And one thing more, the query pattern from issue #3240 generated by script from grammar.json
file and should be conformed the CST and should produce
Steps to reproduce
like in issue #3240
Expected behavior
Both cases:
pattern: 0
capture: 3 - dd, start: (0, 0), end: (0, 6), text: int k;
capture: 0 - tt, start: (0, 0), end: (0, 3), text: int
capture: 2 - ii, start: (0, 4), end: (0, 5), text: k
pattern: 1
capture: 6 - dd, start: (1, 0), end: (1, 8), text: int l=0;
capture: 4 - tt, start: (1, 0), end: (1, 3), text: int
capture: 5 - id, start: (1, 4), end: (1, 7), text: l=0
Tree-sitter version (tree-sitter --version)
tree-sitter 0.22.2
Operating system/version
Rocky Linux 8.9