Repository navigation
parser: extend Pratt error spans to cover subexpressions - #50
Conversation
- 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
|
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
left a comment
There was a problem hiding this comment.
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.
…ratt-parsing-for-better-error-report
@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.🎉 |
|
Yeah no problem, take it easy :) |
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