4 ms·
I'm curious if tree-sitter can handle c++/c. I think it's supper difficult with meta programming. Without the preprocessor, I think it is not possible to parse
by billconan 6y ago
I'm curious if tree-sitter can handle c++/c. I think it's supper difficult with meta programming. Without the preprocessor, I think it is not possible to parse c++ correctly.
- dcreager 6y agoWe do have C and C++ grammars [1,2] but they need some love. You're right that these two languages are among the hardest to support. You could get a tree-sitter external scanner to mimic the preprocessor without too much difficulty, but you'd still run into the problem that your macro definitions might appear in another file. Parsing in general is much easier to implement and reason about if the parse result depends only on the content of the single file that you're looking at. [1] https://github.com/tree-sitter/tree-sitter-c https://github.com/tree-sitter/tree-sitter-c [2] https://github.com/tree-sitter/tree-sitter-cpp https://github.com/tree-sitter/tree-sitter-cpp