Merge `ExitWhileStatement` and `ExitForStatement`
Closed this issue · 4 comments
TwitchBronBron commented
I'm not sure why there are two separate statements here, for exit while
and exit for
. I think exit
on its own is also technically valid syntax.
We should merge them into a single ExitStatement
that optionally takes a tokenKind for the thing that comes after it.
markwpearce commented
exit
on its own is a syntax error:
for i = 1 to 10
if i mod 4 = 0
exit
end if
print i
end for
produces:
Syntax Error. (compile error &h02 (ERR_SYNTAX): syntax error ) in main.main(12)
=================================================================
An error occurred while attempting to compile the application's components:
-------> Compilation Failed.
pkg:/source/main.brs(NaN)
Syntax Error. (compile error &h02 (ERR_SYNTAX): syntax error ) in main.main(12)
markwpearce commented
I think we should just leave it as-is.
TwitchBronBron commented
Regardless of the standalone exit
not being valid, is there any reason to have separate exit for
and exit while
statements? We have a single ContinueStatement
, I think exit <something>
makes sense to be a single statement type as well.
brighterscript/src/parser/Statement.ts
Line 3601 in 353f463
markwpearce commented
Good point... i'll merge them