-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
[BUG REPORT] Does not allow single line block statements without { } #27
Comments
@frankhart2018 May I be assigned? |
Sure @Math-O5. Thanks for showing interest to contribute. |
So, in this issue, after every code block statement (like if), we have to check for spaces and enter braces accordingly right? |
No I guess you misunderstood @lolzone13. What this issue means is C allows code without a { } for block statements like if or else or loops when there is only a single statement in that block. For eg:- if(1 == 2) This is something which C allows but simC doesn't at this moment. Hint: The change has to be made only in simc_parser.py :) |
So I can check if the code block has a single statement and then I can make the changes right? |
Yeah. Do you want to take this? |
Yeah, I'll give it a shot. |
Since no one was an assignee here, I was trying this. With some modifications, I got this output -
for
I just remove those errors so that this works out.
for which output is -
If this much is fine for now, then I can send a PR. |
Hey @shobhit10058 this issue is for all types of block statements and not only for if statements. This is what I added in #341 when @Math-O5 created the PR. So if you are presenting a solution it should be for all block statements that simC currently supports and not just if else. |
oh, ok got it!! |
@shobhit10058 After you finish I can try check the case where there is more than one instruction before else without braces. I'm planning in fact check the entire structure in cascade:
So, let me know when you finish I'll submt PR in your fork. |
So, I think the following are the block statements you are looking to adding this support to -
|
@Math-O5 can you review? |
ok, the function's code I mentioned earlier was not compiled because its parameter types and return type could not be judged as it was not used. This is working -
to
The function is not supported without braces in c also so I did not add for it now. But it can be extended feature. |
Merged. |
Describe the bug
Error when braces not included after if or any other block statement, when it should take only the immediate line into account.
To Reproduce
simC code:-
C Code:-
Not generated, throws error.
Expected behavior
C Code:-
The text was updated successfully, but these errors were encountered: