Skip to content
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

Try catch support #248

Merged
merged 13 commits into from
Nov 20, 2020
Merged

Try catch support #248

merged 13 commits into from
Nov 20, 2020

Conversation

TwitchBronBron
Copy link
Member

@TwitchBronBron TwitchBronBron commented Nov 20, 2020

Add support for try/catch statements and throw statements.

Resolves #218

throw = true
end sub
`);

expect(parser.diagnostics[0]?.message).to.eql(DiagnosticMessages.cannotUseReservedWordAsIdentifier('throw').message);
expect(parser.diagnostics[0]?.message).to.eql(DiagnosticMessages.foundUnexpectedToken('=').message);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking for throw token earlier in the process causes a more generic error to be thrown. It's not really worth refactoring the parser just to get a slightly better error message, and we will definitely still get an error message so it's fine to just change this test.

: print a.b.c : catch e : print "error" : end try
`);

// expectNoParseErrors(`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three outlier syntaxes aren't currently supported. I want to support them eventually, but just don't have the time right now. I left them here so we don't forget to support them sometime in the future.

@TwitchBronBron TwitchBronBron merged commit ac24b01 into master Nov 20, 2020
@TwitchBronBron TwitchBronBron deleted the try-catch-support branch November 20, 2020 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Try catch keyword support
1 participant