sim-c icon indicating copy to clipboard operation
sim-c copied to clipboard

[FEATURE] Add if cascade without braces

Open Math-O5 opened this issue 3 years ago • 6 comments

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 avatar Dec 14 '20 20:12 Math-O5

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.

Chasmiccoder avatar Dec 18 '20 12:12 Chasmiccoder

Sure assigning this to you @Chasmiccoder.

frankhart2018 avatar Dec 18 '20 12:12 frankhart2018

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 avatar Dec 20 '20 04:12 Chasmiccoder

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

Chasmiccoder avatar Dec 28 '20 04:12 Chasmiccoder

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

Math-O5 avatar Dec 28 '20 20:12 Math-O5

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

Thank you! @Math-O5

Chasmiccoder avatar Jan 01 '21 10:01 Chasmiccoder