-
Notifications
You must be signed in to change notification settings - Fork 38
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
Get line containing the point of an span. #53
Labels
Comments
kaj
added a commit
to kaj/nom_locate
that referenced
this issue
Oct 16, 2020
Add a function to get the full input line containing the (start point of the) LocatedSpan. As suggested in fflorent#53.
kaj
added a commit
to kaj/nom_locate
that referenced
this issue
Oct 16, 2020
Add a function to get the full input line containing the (start point of the) LocatedSpan. As suggested in fflorent#53.
progval
pushed a commit
that referenced
this issue
Oct 18, 2020
* Implement LocatedSpan::get_line(). Add a function to get the full input line containing the (start point of the) LocatedSpan. As suggested in #53. * Add some tests. * Remove bogus comment. * No need for get_line() to return Option. * The test that uses `format!` requires std. * Some rustfmt. * Refactor two similar unsafe blocks to one. * Add some disclaimer comments / docs. * Rename get_line to get_line_beginning. * Add line_begining_may_ot_be_entire_len test. This test documents how `get_line_beginning()` differs from a hypotetical `get_line()` method.
This is implemented and should be closed, unless we also want to provide some way to get the full line given the original input span. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A method to get the textual line containing the (start of) a
LocatedSpan
would be nice.I want to present parse errors in a user-friendly way, like this:
As
LocatedSpan
has methodsget_column
,get_utf8_column
andlocation_line
to get line-relative information, andfragment
to get the source text from the span, I think it would be reasonable to also provide a methodline_fragment
(or some better name) to get the line text.I currently do this with the following unsafe and abstraction-level-breaking code, adapted from the private
get_columns_and_bytes_before
method.https://github.com/kaj/rsass/blob/580121abdf1367384109afaa0c18b88b99e4c959/src/error.rs#L125-L143
The text was updated successfully, but these errors were encountered: