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

Better handling of infinite loops in repetitions #958

Closed
bd82 opened this issue May 20, 2019 · 1 comment
Closed

Better handling of infinite loops in repetitions #958

bd82 opened this issue May 20, 2019 · 1 comment

Comments

@bd82
Copy link
Member

bd82 commented May 20, 2019

Chevrotain currently detects infinite loops in repetitions (MANY/AT_LEAST_ONE).
If this is detected an error will be thrown at runtime.

There are some problems with this approach:

Instead of throwing an error when we encounter an infinite loop we could simply gracefully
exit the repetition's loop and "carry on", this would resolve both issues described above:

  • No error would be thrown to break the error recovery flow.
  • If a syntax error would occur due to gracefully exiting the repetition, it would be a "regular"
    syntax error with full position information so it would be much more useful for a grammar's end user.

The one disadvantage to this approach is that we would be losing the clear indication
of infinite loops for grammar developers. While this is unfortunate as long as we actually avoid the infinite loops than such grammar issues would still be far easier for grammar developers to debug versus the original situation which caused the infinite loop detection to be implemented.

@bd82
Copy link
Member Author

bd82 commented May 24, 2019

Resolved in #959
and released in 4.4.0

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

1 participant