Add support for C11 _Generic selection (#559)#591
Open
mariam851 wants to merge 1 commit intoeliben:mainfrom
Open
Add support for C11 _Generic selection (#559)#591mariam851 wants to merge 1 commit intoeliben:mainfrom
mariam851 wants to merge 1 commit intoeliben:mainfrom
Conversation
Owner
|
The code of pycparser has been significantly refactored for the latest release. If you're interested, please adjust the PR to the new parser structure. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi @eliben,
This PR implements support for the C11 _Generic keyword, addressing issue #559.
The implementation follows the C11 standard by adding _Generic as a primary expression.
Changes:
Lexer: Added _GENERIC to the keywords list in c_lexer.py.
AST:
Updated _c_ast.cfg with GenericSelection and GenericAssociation nodes.
Regenerated c_ast.py to include the new node classes.
Parser:
Added p_primary_expression_6 to support generic_selection.
Added rules for generic_selection, generic_assoc_list, and generic_association.
Updated p_primary_expression to include the new rule.
Validation:
Conflicts: After adding the rules, the parser now reports 173 shift/reduce and 180 reduce/reduce conflicts (a minimal increase of 3/3, which is expected for this feature).
Manual Testing: Verified with a test script parsing complex _Generic expressions.
update: I've run the tests locally using python -m unittest discover tests and everything passed (133 tests). Ready for your review whenever the workflows are approved.