-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lex,parse): Add stub try/catch implementation (#195)
* feat(parse): Consume try, catch, and end try lexemes 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 naively. see sjbarag/brs#554#554 * feat(lex): Emit try/catch/throw lexemes for parsing 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 sjbarag/brs#554 * Removing `super()` from TryCatch statement implementation --------- Co-authored-by: Sean Barag <[email protected]>
- Loading branch information
Showing
11 changed files
with
1,292 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
sub main() | ||
a = 5 | ||
|
||
print "[pre_try] a = " a | ||
try | ||
a = a * 2 | ||
print "[in_try] a = " a | ||
catch e | ||
' currently unimplemented | ||
end try | ||
|
||
print "[post_try] a = " a | ||
end sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.