[FEATURE] Add if cascade without braces
Math-O5 opened this issue · 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
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.
Sure assigning this to you @Chasmiccoder.
Hi guys. @Math-O5 @frankhart2018
I went through the tokens that correspond to this part of the simc code:
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!
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 You are right, I will work on #24 first, then
@Chasmiccoder You are right, I will work on #24 first, then
Thank you! @Math-O5