-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(lex,parse): Add stub try/catch implementation #611
base: main
Are you sure you want to change the base?
Conversation
RBI 9.4 adds support for error handling via the `try`/`catch` model [1]. Interestingly, `try`, `catch`, and `endtry` are all valid identifiers! That makes parsing a little bit tougher, but it's not unprecedented in this language. Detect `try`/`catch`/throw`/`end try` during lexing and emit the proper lexemes. [1] https://developer.roku.com/docs/references/brightscript/language/error-handling.html see #554
22c9744
to
fe9077e
Compare
Throwing exceptions and catching them aren't yet supported in `brs`, so executing only the `try` block seems to be a reasonable "bare minimum" approach to try/catch support. Handle `try`, `catch`, and `end try` lexemes in the parser, emitting TryCatch statements for the interpreter to execute naïvely. see #554
fe9077e
to
a5487ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for keeping this PR simple. I just have a noob question below
@@ -94,6 +98,8 @@ export const KeyWords: { [key: string]: L } = { | |||
stop: L.Stop, | |||
sub: L.Sub, | |||
to: L.To, | |||
try: L.Try, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noob question: why are try
and endtry
keywords but not reserved words while throw
is both?
Try..Catch and Throw implementation was finished in the Roku Community fork: |
Implementing
try
/catch
/throw
takes a good bit of work in the interpreter, so I'm splitting that into two pull requests. This one includes parsingtry
/catch
/end try
(withoutthrow
), and always executes only thetry
block to maintain backwards compatibility. It's a weird partial state, but the alternative is a massive pull request that can't be reasonably reviewed or understood.see #554