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

Fix GNU statement expression syntax and code generation #71

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MartinSpiessl
Copy link

The statement expression itself is not allowed at places where an ordinary statement would stand. As with other expressions, this is only facilitated via the expression_statement rule that adds a semicolon after the expression. The reason why this bug was not discovered is probably because the code generator also drops the parentheses around the statement expression, turning it into a compound statement.

This commit fixes that by removing the faulty rule extension, introducing a CoumpoundExpression class, and making sure the parentheses are added when an object of this type is discovered during code generation.

The statement expression itself is not allowed just at places
where an ordinary statement would stand. As with other expressions,
this is only facilitated via the expression_statement rule that adds
a semicolon after the expression. The reason why this bug was not
discovered is probably because the code generator also drops the
parentheses around the statement expression,
turning it into a compound statement.

This commit fixes that by removing the faulty rule extension,
introducing a CoumpoundExpression class, and making sure the
parentheses are added when an object of this type is discovered
during code generation.
@inducer
Copy link
Owner

inducer commented Jan 2, 2023

Thanks! Could you add a test?

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.

2 participants