Uh oh!
There was an error while loading. Please reload this page.
Introduce location tracking in the tokenizer and parser - #710
Conversation
ankrgyl
commented
Nov 15, 2022
@alamb@AugustoFKL this PR addresses #524. This change is reasonably contained, but one thing that could make it even smaller would be maintaining the interface (i.e. |
alamb
commented
Nov 16, 2022
Thanks @ankrgyl -- I'll try to look at this PR more carefully later this week |
Pull Request Test Coverage Report for Build 3623431070
💛 - Coveralls |
AugustoFKL
commented
Nov 16, 2022
alamb
left a comment
There was a problem hiding this comment.
This PR looks great @ankrgyl -- thank you for proposing it; I apologize for the delay in finding time to review it
I think we can avoid many of the changes with an impl PartialEq as I mentioned
Otherwise, all this PR needs is some tests and I think it would be ready to merge.
Thanks again!
| pub column: u64, | ||
| } | ||
| /// A [Token] with [Location] attached to it |
There was a problem hiding this comment.
We can probably avoid many of the changes in this PR by implementing PartialEq between Token and TokenWithLocation:
implPartialEq<Token>` forTokenWithLocationWhich would allow things like
ifself.peek_nth_token(1).token == Token::RArrow{to keep working
| #[cfg(feature = "std")] | ||
| impl std::error::Error for TokenizerError {} | ||
| struct State<'a> { |
ankrgyl
commented
Dec 1, 2022
@alamb updated with the |
alamb
commented
Dec 1, 2022
I think the goal should be that if we accidentally break the location parsing code some tests will fail. I think ensuring the locations are set on parse errors would be particularly helpful. So perhaps you could add a few tests that assert locations of parsed tokens, and then a test that has a parsing error that retrieves the location of the error (if this last test needs more code changes, we could do it as a follow on PR) Thank you so much for pushing this along @ankrgyl -- this is going to be a great addition (and is a long asked for feature) |
ankrgyl
commented
Dec 1, 2022
Added a few tests. We'll need to thread parser locations through as a follow up PR, but I added a test that fails in the parser due to a tokenizer error (and asserts the location) + a test that we can fill in with locations once the parser carries along that info. |
alamb
left a comment
There was a problem hiding this comment.
I think this looks great -- thank you @ankrgyl
Would you like a chance to review @AugustoFKL ?
| assert_eq!( | ||
| ast, | ||
| Err(ParserError::TokenizerError( | ||
| "Unterminated string literal at Line: 1, Column 5".to_string() |
| impl<'a> Parser<'a> { | ||
| /// Parse the specified tokens | ||
| /// To avoid breaking backwards compatibility, this function accepts |
alamb
commented
Dec 2, 2022
This appears to have a logical conflict with master. I am planning on cutting a release soon -- maybe given the nature of this change I will make release right before this change, and then merge this one. That way people who use the tip of this repository can effectively beta test the changes before we make a release for everyone 🤔 |
ankrgyl
commented
Dec 2, 2022
That seems wise to me. We may even want to flesh out the (potentially breaking) parser changes so that users who upgrade only need to adjust to breakages once. Happy to contribute those and collaborate with you on that. |
ankrgyl
commented
Dec 2, 2022
Additionally, I just rebased and updated the merge conflicts. |
alamb
commented
Dec 2, 2022
That would be awesome. I plan to make a release soon (TM) -- either later today or over the weekend sometime. Then let's merge this one in and iterate. |
alamb
commented
Dec 5, 2022
@ankrgyl I took the liberty of fixing the clippy CI error and merging up from main to this branch. |
alamb
commented
Dec 5, 2022
This is merged and should be included in the 0.29.0 release (eta in approximately 1 months time) I would love to start collaborating to fixup the parser. The first step might be to list / sketch out the changes that are needed. Thanks again -- this is super exciting! |
This revives PR #288 and #514, rebased against the latest and done with fewer variable renames (limiting merge conflicts).
Closes#524