-
Notifications
You must be signed in to change notification settings - Fork 38
Issue 473 using a span on Production. #537
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
Conversation
|
The error messages, and underlining is not great. It just just kind of the position we are at when we finally can figure out that we have no symbol. E.g. underlining the Seems like it should be possible to get rid of the whitespace though in the |
|
There, that is better: |
|
This looks like a good start! Can we simplify this so we always give |
|
Edit: Some of what I originally said here was based on an incorrect reading of I think the ideal value for the Production's span is something like: For the case where symbols is not empty, not even close but will keep trying. |
Agreed, that would be great if possible! Looking at while i < self.src.len() {
if let Some(j) = self.lookahead_is("|", i) {
self.ast.add_prod(rn.clone(), syms, prec, action);
syms = Vec::new();
prec = None;
action = None;
i = self.parse_ws(j, true)?;
continue;
} else if let Some(j) = self.lookahead_is(";", i) {
self.ast.add_prod(rn, syms, prec, action);
return Ok(j);
}
...That's mostly at the start of the loop to deal with |
One of the things that is making this specific thing difficult is that a |
|
So 94622a2 is as close as I've gotten. It is quite often +1 or -1 when the production starts or ends with a And just for clarity, here's permutations of the examples again which cause the assertion on the latest version of the patch: The single character underlines pointing at the last character in the sequences |
|
This feels like a significant improvement! Do we have tests for all the cases you've listed above? |
|
Kind of, except for the last two, which are just whitespace variations, Except that output is when run through nimbleparse, but we don't really have any systematic way to test nimbleparse output yet. So that test just tests that the spans which drive nimbleparse return the expected results. I suppose I should/need to add the last two variants. |
|
If we get those two tests in, I think we'll be ready to squash. |
|
Should be fixed in 09d9efb |
|
Please squash. |
09d9efb to
e854d81
Compare
|
Oops, typos. |
This provides a span for `Production`, even when the prod is empty. The production will span all it's `Symbols`. Previously when a production was empty, or `%empty` it had no Symbols and subsequently no span. Now an empty production will at least have a zero length span on the production.
e854d81 to
d1ff8d9
Compare
|
Squashed. |
So here is a similar thing to PR #476 except instead of adding an empty symbol, it adds an
Option<Span>toProduction.the assertion in
nimbleparseshould now be okay, but only because nimbleparse will always produce a grammar from a parser which ensures that either symbols has a symbol, containing a span orempty_spanisSome.That is, this isn't true in general from an
ASTbuilt using the public constructors.This entails adding a
spanargument toadd_prodand theProductionsstruct.