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

Error handling #55

Closed
DaOnlyOwner opened this issue Jun 15, 2020 · 1 comment
Closed

Error handling #55

DaOnlyOwner opened this issue Jun 15, 2020 · 1 comment

Comments

@DaOnlyOwner
Copy link

Hello again ;)

I have a question regarding error handling: Is it possible to provide custom error messages when a syntax error is found in the given input?

Right now the error messages are not really useful by its own (i.e. "syntax error at character 27...")

@TheLartians
Copy link
Owner

Hey, yeah first of all let me apologise for not adding better documentation yet, I haven't found the time yet to properly maintain this project.

There are currently two ways to handle errors:

  • You let your program run and catch the exception that is thrown when a syntax error is encountered. The captured SyntaxError class itself contains the virtual parse tree of the rule that was attempted to be parsed, which might provide useful error information. You can see the examples to see how to output information.
  • You split your program into a parsing and interpretation step and do manual error handling. I would recommend looking at the run method's implementation to see how those steps are performed.

Eventually I hope to update this project and give it proper documentation. Until then feel free to ask here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants