-
Notifications
You must be signed in to change notification settings - Fork 363
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
parser error if identifier is also a token (CxxKeyword) #586
Comments
For my understanding typeid is a keyword in C++ and C++\CLI: http://en.cppreference.com/w/cpp/language/typeid General question is why do we need keywords? For syntax highlighting only? |
@guwirth This is correct for typeid but C++/CLI uses new keywords which created problems with C++ only sources and therefore I removed them from CxxKeyword. The drawbacks are the missing highlighting and the tags in AST which can be used by checks etc.
The minimal but not optimal solution is to remove the CxxKeyword.TYPEID to avoid the parser error. Should I create a PR for this?
|
@Bertk My initial idea and question was to remove all keywords from the grammar and replace them with strings. Question is how to deal otherwise with a mixture of C, C++ and C++/CLI. I'm only not sure with other side effects this could have? E.g. How does Sonar calculate the complexity?
Keeping it in https://github.com/wenns/sonar-cxx/blob/master/cxx-squid/src/main/java/org/sonar/cxx/api/CxxKeyword.java should also keep the syntax highlighting?
Someone using this?
You can give it a try.
During my work on C++11 and C++14 extensions I also realized that there are still differences in the grammar. I think that is an extra point we should keep in mind and fix. |
AstScanner is using keywords for e.g. ComplexityVisitor. Still not sure how many places has to be adapted in case we remove CxxKeyword from lexer/grammar? |
Close this use #597 for further discussions. |
Parser fails if a keyword is used as identifier - the following code is correct and uses "typeid" which is defined as token CxxKeyword.TYPEID.
This problem was detected while C++/CLI support was introduced (#582 )
The text was updated successfully, but these errors were encountered: