Calamity210 / BirbLang

Minimal Bird programming language curated to help new contributers delve into OSS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] statements with single statement body expect their outer compound statement to end

AkramIzz opened this issue · comments

Describe the bug
if, for, while to name a few take a body statement. In general, this is either a single statement or a compound statement.
Statements that take a single statement body expect their outer compound statement to end If they are nested inside a compound statement, ie, they expect a RBRACE ('}') token after the single statement

if (true) {
  if (true)
    screm('true is true');
//v--- The parser throws unexpected token error
  screm('just testing');
}

If they aren't nested they run, but the program ends after the single statement.

if (true)
  screm('true is true');
// program ends here
screm('just testing');

To Reproduce
Steps to reproduce the behavior:

  1. Run the above provided birb programs

Actual Results
The first program throws the following error:
UnexpectedTokenException: [Line 4] Unexpected token `screm`, was expecting `TokenType.TOKEN_RBRACE`
The second program outputs the following:
true is true

Expected Behaviour
Expected the first program to run without errors and the second program to not end after the single statement body. Also both programs should output:

true is true
just testing
commented

Fixed in c9f3e78