tree-sitter / tree-sitter-c

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

bug: Discrepancy between parse and playground trees #211

Closed SunBK201 closed 3 weeks ago

SunBK201 commented 1 month ago

Did you check existing issues?

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

No response

Describe the bug

I found that the output of tree-sitter-c is inconsistent with that of playground c. Just like https://github.com/tree-sitter/tree-sitter/issues/3449.

I use pypi https://pypi.org/project/tree-sitter-c to parse the C code. There is an error node, but there is no such error node in the playground:

err = route4_set_parms(net, tp, base, f, handle, head, tb, tca[TCA_RATE], new, flags, extack);

In addition, I found that the parsing error of using pypi https://pypi.org/project/tree-sitter-c is consistent with the parsing error of using pypi https://pypi.org/project/tree-sitter-cpp. Does this mean that tree-sitter-c and tree-sitter-cpp in pypi use the cpp parser at the same time?

Steps To Reproduce/Bad Parse Tree

err = route4_set_parms(net, tp, base, f, handle, head, tb, tca[TCA_RATE], new, flags, extack);

ERROR NODE: , (behind new)

Expected Behavior/Parse Tree

err = route4_set_parms(net, tp, base, f, handle, head, tb, tca[TCA_RATE], new, flags, extack);

This code should have no error nodes in tree-sitter-c.

Repro

err = route4_set_parms(net, tp, base, f, handle, head, tb, tca[TCA_RATE], new, flags, extack);
Crispy-fried-chicken commented 1 month ago

I’ve also meet this problem, How can we make the parser in pypi consistent with the one in playground?

SunBK201 commented 1 month ago

@amaanq Does pypi tree-sitter-c use tree-sitter-cpp parser?

amaanq commented 3 weeks ago

no, and the latest version does not have this issue