Skip to content

parser: extend Pratt error spans to cover subexpressions - #50

Merged
sylvestre merged 2 commits into
uutils:mainfrom
Franklin-Qi:feature-task#42-Parser-extend-spans-during-Pratt-parsing-for-better-error-report
Jun 28, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
Franklin-Qi:feature-task#42-Parser-extend-spans-during-Pratt-parsing-for-better-error-report

Conversation

@Franklin-Qi

Copy link
Copy Markdown
Collaborator
  • Track an anchor at the start of each Pratt subexpression and report errors from that anchor through the offending token, instead of highlighting only the final token.

  • Apply this to assignment/index/place errors, prefix operators, unclosed parentheses and brackets, and related Pratt paths. Keep narrow spans for non-associative operators (e.g. chained = ).

  • Add unit tests that assert the highlighted source snippets for common parse failures.

Closes: #42

- Track an anchor at the start of each Pratt subexpression and report errors from that anchor through the offending token, instead of highlighting only the final token.

- Apply this to assignment/index/place errors, prefix operators, unclosed parentheses and brackets, and related Pratt paths. Keep narrow spans for non-associative operators (e.g. chained = ).

- Add unit tests that assert the highlighted source snippets for common parse failures.

Closes: uutils#42
@Alonely0

Copy link
Copy Markdown
Collaborator

At first glance, this looks great, ty! After merging the tests PR, there are some trivial merge conflicts, do you mind fixing them and rebasing? As with the other PR, I will review this on Friday or this weekend :)

@Alonely0
Alonely0 self-requested a review June 17, 2026 10:05
@Franklin-Qi

Copy link
Copy Markdown
Collaborator Author

At first glance, this looks great, ty! After merging the tests PR, there are some trivial merge conflicts, do you mind fixing them and rebasing? As with the other PR, I will review this on Friday or this weekend :)

Thank you for your review. I would be happy to resolve this conflict.

@Alonely0 Alonely0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Quite minimal and a great addition, thank you! I have some thoughts on the ergonomics of the implementation, but it's nothing we can't touch up later on. Especially considering the next language edition will change the range types.

We would be able to merge this the moment the conflicts on the tests are dealt with, so let me know if you're too busy to take care of it; I don't mind handling it. I have some pending changes to the Pratt parser, and I would rather merge this before pushing so there are no conflicts on your end.

@sylvestre
sylvestre merged commit 04610f1 into uutils:main Jun 28, 2026
13 checks passed
@Franklin-Qi

Copy link
Copy Markdown
Collaborator Author

Quite minimal and a great addition, thank you! I have some thoughts on the ergonomics of the implementation, but it's nothing we can't touch up later on. Especially considering the next language edition will change the range types.

We would be able to merge this the moment the conflicts on the tests are dealt with, so let me know if you're too busy to take care of it; I don't mind handling it. I have some pending changes to the Pratt parser, and I would rather merge this before pushing so there are no conflicts on your end.

@Alonely0 Thank you for your review. I've been quite busy recently, but I will continue to work on the AWK-related issues this week.🎉

@Alonely0

Copy link
Copy Markdown
Collaborator

Yeah no problem, take it easy :)

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.

Parser: extend spans during Pratt parsing for better error reports.

3 participants