cimplec/sim-c

[BUG REPORT] Fails to account for missing right braces"}" in nested blocks.

10Kaiser10 opened this issue · 6 comments

Describe the bug
Does not raise an error when there is an unequal number of right and left braces in nested blocks of code.

To Reproduce
SimC code:

MAIN
{
    var a = 1
    {
        var b = a+1
    }
    print(b)
END_MAIN

C Code:

#include <stdio.h>
int main() {
{
	int a = 1;
{
	int b = a + 1;
	}
	printf("%d", b);

	return 0;
}

Expected behavior
Should raise an error

Can we conduct a check (to see if the braces are balanced) at the beginning of compilation using a stack?

Can I try this out?

In the "LexicalAnalyser.py" balancing check is done only for '(' and ')'

In the "LexicalAnalyser.py" balancing check is done only for '(' and ')'

Okay @sourav-suku
So we just need to account for { } , right?

@Chasmiccoder
Ya.I guess so.
We should even account for [ ] as its case is similar to { }.

@Chasmiccoder Assigned to you.