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

Support #if and #ifdef in if statements #202

Closed

Conversation

MarcelRobitaille
Copy link

Fixes #76

I was not able to add more than $.preproc_if_in_if_statement and $.preproc_ifdef_in_if_statement to _else_clause_preproc. I got some conflicts. I am not very experienced in writing tree-sitter grammars.

@amaanq
Copy link
Member

amaanq commented Mar 26, 2024

This is a sizable state count increase, and I don't think I really want to support this use case - this just opens the door for many other edge cases with preproc defines as well. Tree-sitter is just not going to handle every possible usage of macros and/or preproc defines well

@amaanq amaanq closed this Mar 26, 2024
@MarcelRobitaille
Copy link
Author

Thank you for your feedback.

Is there any state count where you would accept this? I got the state count down to 2594 and all of the tests (including the ones I added) pass.

@amaanq
Copy link
Member

amaanq commented Mar 27, 2024

What's the large state count? But again, this still sets a precedence I don't like anyways, and might be even more harmful for C++ since that would need to be updated with these changes afterwards.

@MarcelRobitaille
Copy link
Author

#define LANGUAGE_VERSION 14
#define STATE_COUNT 2594
#define LARGE_STATE_COUNT 693
#define SYMBOL_COUNT 352
#define ALIAS_COUNT 3
#define TOKEN_COUNT 155
#define EXTERNAL_TOKEN_COUNT 0
#define FIELD_COUNT 39
#define MAX_ALIAS_SEQUENCE_LENGTH 9
#define PRODUCTION_ID_COUNT 132

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 this pull request may close these issues.

Seems 'function_definition' not parsed correctly when putting 'else-if' in '#ifndef'
2 participants