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 _Atomic and _Atomic ( type ) #9

Closed
visq opened this issue Jun 26, 2016 · 2 comments
Closed

Support _Atomic and _Atomic ( type ) #9

visq opened this issue Jun 26, 2016 · 2 comments

Comments

@visq
Copy link
Owner

visq commented Jun 26, 2016

C11 has introduced a rather unpleasant complication.
The keyword _Atomic is allowed to be used in two different contexts:
(1) as a type qualifier if it is not followed by a opening parenthesis
(2) as part of a type specifier if it is followed by ( type )
It is tricky to extend the happy spec to support both forms in a conflict-free way.

@visq
Copy link
Owner Author

visq commented Jun 29, 2016

One solution for LR parsers is implemented in https://github.com/jhjourdan/C11parser/blob/master/lexer.mll. They combine the tokens ATOMIC and LPAREN to ATOMIC_LPAREN, which allows to distinguish the type qualifier ATOMIC and the type specifier ATOMIC_LPAREN type RPAREN.
If the performance of the parser does not drop significantly, this seems like an acceptable solution.

@visq
Copy link
Owner Author

visq commented Jun 4, 2018

Implemented a simple solution that directly recognizes "_Atomic\s*(" as a special token, following the approach described in the previous post.

@visq visq closed this as completed Jun 4, 2018
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

No branches or pull requests

1 participant