-
Notifications
You must be signed in to change notification settings - Fork 4
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
Move block statement to statement #53
Conversation
leewei05
commented
Nov 30, 2023
- Move block statement to statement
- Support single statement for if statement
- Fix dangling else problem
d6c5df4
to
04209db
Compare
04209db
to
68645cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's essential to distinguish between blocks and normal statements since blocks cannot always be replaced by a statement. Consider the main_func
as an example, which must have its body enclosed within a pair of curly braces.
Allowing any statement to represent its body could result in syntactically valid, yet unintended code like the following Python-ish syntax:
int main()
return 0;
For reference, in the C standard ISO/IEC 9899:1999, section 6.9.1 defines the syntax of a function-definition:
- function-definition:
declaration-specifiers declarator declaration-listopt compound-statement
Here, the compound-statement corresponds to our block-statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create a test for the if_else_single_stmt
, possibly a nested one as well!
68645cb
to
939323a
Compare
35f7d06
to
6cfe5f7
Compare
6cfe5f7
to
bc10ad1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, for the proper support of the if statement! 🎉
We're now closer to the moon. 🚀