4 ms·
We 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
by dcreager 6y ago
We 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