tree-sitter-cpp
tree-sitter-cpp copied to clipboard
capture-api cannot handle "and" keyword correctly
I use py-tree-sitter with the grammar of this repository to parse c++/c files. However I found that the "and" keyword leads to a weird behaviour. I'm not sure if I should post it here or at py-tree-sitter. Feel free to tell me.
See this code example:
void something() {
if (some_var and some_other_var == nullptr) {
doSomething();
}
}
void something2() {
if (some_var && some_other_var == nullptr) {
doSomething();
}
}
This should lead to something similar, as the "and" keyword basically is the "&&" operator. (IIRC)
However, when capturing the if-statements' content I get these returns:
file_captures[0][0].sexp()
'(condition_clause initializer: (declaration type: (type_identifier) declarator: (identifier) (MISSING ";")) value: (binary_expression left: (identifier) right: (nullptr)))'
file_captures[1][0].sexp()
'(condition_clause value: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (nullptr))))'
So I think the "and" keyword is not handled properly, leading the tree-sitter to assume there is a missing ";" somewhere. Its not a type_identifier at all.
I can't see support for https://en.wikipedia.org/wiki/C_alternative_tokens in the grammar.