[BUG REPORT] Fails to account for missing right braces"}" in nested blocks.
10Kaiser10 opened this issue · 6 comments
10Kaiser10 commented
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
Chasmiccoder commented
Can we conduct a check (to see if the braces are balanced) at the beginning of compilation using a stack?
Chasmiccoder commented
Can I try this out?
sourav-suku commented
In the "LexicalAnalyser.py" balancing check is done only for '(' and ')'
Chasmiccoder commented
In the "LexicalAnalyser.py" balancing check is done only for '(' and ')'
Okay @sourav-suku
So we just need to account for { } , right?
sourav-suku commented
@Chasmiccoder
Ya.I guess so.
We should even account for [ ] as its case is similar to { }.
Math-O5 commented
@Chasmiccoder Assigned to you.