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

Fix non-termination in parser #239

Merged
merged 2 commits into from
Jun 9, 2023
Merged

Conversation

aibaars
Copy link
Contributor

@aibaars aibaars commented Jun 9, 2023

My earlier changes #238 somehow caused the parser to hang on some inputs. I'm not sure how it ended up in an infinite loop, but the changes I made to the scanner were not entirely right. I changed the scanner to return false if it sees a newline before a . character that has no following . character otherwise we'd end up calling mark_end, advancing a bit, and subsequently trying to scan a next token which makes no sense.

@hendrikvanantwerpen

Checklist:

  • All tests pass in CI.
  • There are sufficient tests for the new fix/feature.
  • Grammar rules have not been renamed unless absolutely necessary.
  • The conflicts section hasn't grown too much.
  • The parser size hasn't grown too much (check the value of STATE_COUNT in src/parser.c).

Copy link
Contributor

@dcreager dcreager left a comment

Choose a reason for hiding this comment

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

Thanks for the quick debug on that @aibaars!

Copy link
Contributor

@hendrikvanantwerpen hendrikvanantwerpen left a comment

Choose a reason for hiding this comment

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

It's a bit tricky to follow the control flow here. I certainly didn't see that possibility last time either.

Afaict these changes do prevent the problematic case you describe, so approved!

@aibaars aibaars merged commit 2edbd43 into tree-sitter:master Jun 9, 2023
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.

3 participants