-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Macros can break Tree-Sitter parsing #30
Comments
I guess the only real solution here is to run the preprocessor in some capacity. e.g. AFX_EXT_CLASS would probably just be declared as an empty string, so wouldn't show up in tree-sitter. What would probably be easier for the beginning is to simply run a text-replace in the scripts first that removes these kinds of macros before doing any tree-sitter transformations/queries. |
That was my idea too: remove everything that is between Something along those lines:
It's not really fixing the issue, but workarounding it :) |
Ah, hm, I was thinking that we can just remove the macro when we're porting to e.g. Qt. |
You can't remove the export macro as you still need it on Windows, even with Qt. That would be an acceptable fix for v1. |
New idea: We can actually include/exclude certain ranges from the parsing. |
TODO: Put the macros to filter out in a setting. We may need to create a |
Example:
This is parsed entirely incorrectly:
It's a known bug in tree-sitter-cpp, that doesn't seem to have an easy solution.
tree-sitter/tree-sitter-cpp#85
It would be good to be able to fix this from within Knut somehow.
The text was updated successfully, but these errors were encountered: