-
Notifications
You must be signed in to change notification settings - Fork 33
Lrpar diagnostics #567
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
base: master
Are you sure you want to change the base?
Lrpar diagnostics #567
Conversation
I was thinking about it and, while I anticipate not having any issues with |
I did the easy part of This doesn't appear to be something that we can even achieve via I'm uncertain, but wondering if it will be enough to add the yacc sources to My hope is that perhaps that can be moved to it's own field outside of conflicts, and returned unconditionally. |
@@ -1547,6 +1528,10 @@ where | |||
} | |||
} | |||
|
|||
fn indent(s: &str, indent: &str) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's document this one. I suspect we should also reorder the parameters (I misread the calls above!).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it okay if I reorder the parameters in a separate PR?
Since this function is copy/paste from nimbleparse I'd want to update that as well, and I fear updating all the callers over seems like it might make these patches a bit more messy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it okay if I reorder the parameters in a separate PR?
Works for me!
} | ||
|
||
impl PushLine for String { | ||
fn push_line<S: AsRef<str>>(&mut self, s: S) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we call this pushln
to mirror println
? Also, a quick docstring on the trait to make that clear would be great.
A couple of small comments but I think we can easily get this in: I appreciate that there are more rough edges we could smooth off, but this already feels like an improvement. |
This patch moves the
diagnostics.rs
from nimbleparse, tolrpar
, so it can be used inCTParserBuilder
.It modifies the
YaccGrammarError
andCTConflictsError
and some portions of theHeaderError
error printing to inline the source snippets in the error messages.There is a couple of things to note:
CTConflictsError
changes here, I'll explain the hurdles I ran into below.CTConflictsError{stable}
is used viadowncast_ref
in the testsuite, and theSpannedDiagnosticsFormatter
only borrows the string, owned bybuild()
which causes lifetime problems with trying to put theSDF
into theCTConflictsError
with the source string and the formatter, thus it gets pre-formatted into aString
and embed that in theCTConflictsError
.Further, since the source string contains temp filenames when run during the testsuite, it is difficult to do some form of string comparison with what we expect the error to output.
Thus the somewhat weird implementation where we also include the otherwise unused
stable
, and jump through clippy hoops to keep the existing tests working, without a string comparison replacement. Otherwise I probably would likely have just usedErrorString
, and removedCTConflictsError
.