Skip to content

Commit

Permalink
Allow continue as local var (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron authored Oct 27, 2022
1 parent 361458d commit 3c06628
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/parser/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,8 @@ export class Parser {
return this.gotoStatement();
}

if (this.check(TokenKind.Continue)) {
//the continue keyword (followed by `for`, `while`, or a statement separator)
if (this.check(TokenKind.Continue) && this.checkAnyNext(TokenKind.While, TokenKind.For, TokenKind.Newline, TokenKind.Colon, TokenKind.Comment)) {
return this.continueStatement();
}

Expand Down
14 changes: 14 additions & 0 deletions src/parser/tests/statement/Continue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ describe('parser continue statements', () => {
]);
});

it('allows `continue` to be used as a local variable', () => {
program.setFile<BrsFile>('source/main.bs', `
sub main()
continue = true
print continue
if not continue then
print continue
end if
end sub
`);
program.validate();
expectZeroDiagnostics(program);
});

it('transpiles properly', () => {
testTranspile(`
sub main()
Expand Down

0 comments on commit 3c06628

Please sign in to comment.