Skip to content
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

capture-api cannot handle "and" keyword correctly #94

Closed
dnns92 opened this issue Feb 25, 2021 · 1 comment · Fixed by #179
Closed

capture-api cannot handle "and" keyword correctly #94

dnns92 opened this issue Feb 25, 2021 · 1 comment · Fixed by #179

Comments

@dnns92
Copy link

dnns92 commented Feb 25, 2021

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.

@bronikkk
Copy link

I can't see support for
https://en.wikipedia.org/wiki/C_alternative_tokens
in the grammar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants