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
Parenthesized compound statement support #422
Comments
Thanks for the detailed report. I have no objections to adding support for this in pycparser; PRs welcome. |
is sufficient to parse
as:
I'm not sure if this sufficiently captures the "evaluates to last statement" nature though. |
Fixed by #423 |
I've found that these parenthesized compound statements are legal in more places than the parser currently allows. Some examples:
Adjusting the rule for the parenthesized statement to come from a |
Compound statements enclosed in parentheses are a relatively common pattern, particularly when implementing single evaluation macros such as:
I cannot find whether the
({...})
pattern is an extension or standard C, the following page simply states that GNU C allows it. https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html.Regardless of its extension status, I haven't found a compiler on https://godbolt.org/ that fails to compile the following snippet:
Attempting to parse the above using pycparser (release_2.20) results in:
The text was updated successfully, but these errors were encountered: