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

[FEATURE] Add if cascade without braces #408

Open
Math-O5 opened this issue Dec 14, 2020 · 6 comments
Open

[FEATURE] Add if cascade without braces #408

Math-O5 opened this issue Dec 14, 2020 · 6 comments
Labels
enhancement New feature or request moderate Moderate problem

Comments

@Math-O5
Copy link
Collaborator

Math-O5 commented Dec 14, 2020

Is your feature request related to a problem? Please describe.
Extension of #27, the goal is implement if cascade statement when the command use no braces, as follows:

Should be allowed

Sim-C:

if (expression)
    if(expression)
        cmd
     else
         cmd
else
    cmd 

Plus, you should ensure that when if (expresion) is called without braces and followed of else, only and necessary one instruction is between both.

Should NOT be allowed

if (expression)
    if(expression)
        cmd
        cmd 
     else
         cmd
else
    cmd 
if (expression)
    if(expression)
        cmd
     else
         // missing command here
else
    cmd 
@Math-O5 Math-O5 added enhancement New feature or request KWoC'20 These issues are being listed as part of KWoC'20 moderate Moderate problem labels Dec 14, 2020
@Math-O5 Math-O5 changed the title [FEATURE] Add if cascade [FEATURE] Add if cascade without braces Dec 14, 2020
@Chasmiccoder
Copy link
Contributor

Hi there! @Math-O5
Can I work on this?
I have understood the issue, but I am still uncertain how to go about doing this, so I might need some help.

@frankhart2018
Copy link
Member

Sure assigning this to you @Chasmiccoder.

@Chasmiccoder
Copy link
Contributor

Chasmiccoder commented Dec 20, 2020

Hi guys. @Math-O5 @frankhart2018
I went through the tokens that correspond to this part of the simc code:
image

The tokens look like this:
image

So, to implement the if cascade feature, can I do this:
if tokens[i] corresponds to 'if' statement,
----count the number of newlines.
----if the number of newlines exceeds 2, then the programmer has implemented more than 1 statement in the if block,
--------print error message
----else
--------return the corresponding opcode

Please tell me if this is the right approach. I am having difficulty in finding out how many statements follow the if condition.
Thanks!

@Chasmiccoder
Copy link
Contributor

Hi @Math-O5. I got on a call with @frankhart2018
I think we need to solve #24
before we solve this issue.
If not, please tell me how to go about doing it.
Thanks

@Math-O5
Copy link
Collaborator Author

Math-O5 commented Dec 28, 2020

@Chasmiccoder You are right, I will work on #24 first, then

@Chasmiccoder
Copy link
Contributor

@Chasmiccoder You are right, I will work on #24 first, then

Thank you! @Math-O5

@Chasmiccoder Chasmiccoder removed their assignment Jan 5, 2021
@frankhart2018 frankhart2018 removed the KWoC'20 These issues are being listed as part of KWoC'20 label Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request moderate Moderate problem
Projects
None yet
Development

No branches or pull requests

3 participants