tree-sitter / tree-sitter-python

Python grammar for tree-sitter
MIT License
360 stars 132 forks source link

[Feature] hope to be able to replace or modify a specific Node. #267

Closed songhtdo closed 3 months ago

songhtdo commented 3 months ago

Did you check the tree-sitter docs?

Is your feature request related to a problem? Please describe.

Hello, thank you very much for providing a great library. However, during my specific use, I found that there were occasional parsing errors, especially when parsing C++ due to the complexity of the syntax, which can easily lead to some inconsistencies with expectations. This kind of problem usually occurs in a complex grammatical structure, and if the problematic node content is parsed separately, it is correct.

I hope you can provide a function that allows manual replacement of specific Node nodes. This method is equivalent to patching specific error results, which is easier to implement than directly modifying the language's grammar.js requirements. Through the analysis of this patch method, it will be cleaner than the later conversion process.

Describe the solution you'd like

The content is as above。

Describe alternatives you've considered

The content is as above。

Additional context

No response

songhtdo commented 3 months ago

It is hoped that the nodes from Tree A can be merged into Tree B.