Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello Pest team!
I'm working on a Ctiny language interpreter for a university course. You can find my repository here | GitHub.
While working on the AST, I have faced a problem.
Considering the following grammar:
and my AST node structs:
While parsing the pairs of an expression, I want to be able to combine Spans to create Nodes of Expression::BinaryExpression for easier debugging later (giving the span of the Node to a pest::CustomError). But so far, there is no merge function for Span, and since there is no getter for the its
input
field... it would require me to pass everywhere the &str of the original input string... which is really annoying, especially considering I'm only manipulating pairs and spans that all have the reference I'm looking for. So the best approach to this is really to add a getterget_input
and amerge
function to Span.You can have a look at this fork in action, specifically on span merging here. Especially at the following code:
I'm not the only one facing this issue. A friend of mine, also working on this course is facing a similar issue.
That's what I have done with this PR. I also added meaningful documentation in comments as well as tests.