From repair sequence to repaired input strings
Closed this issue · 4 comments
This may not be the right venue to ask, but I thought it was worth while asking (since couldn't find in README/docs).
Is there an API provided to apply the repair sequence(s) produced to the original input (i.e. producing a new input string that would not raise a parse error)? Or is the expectation that consumers do that themselves? Since users can plug in custom lexers, I'm inclined to believe that the latter is the expectation, but I wanted to confirm before reimplementing something already available in grmtools
.
There isn't (currently) a mechanism to mutate the input string -- I'm not sure how useful that is in general. You should be able to put your own together fairly easily by using the ParseError
struct to see exactly where an error occurred (i.e. get its Lexeme
and ask it for its span
) and then the ParseRepair
struct to see which repairs were found. grmtools always uses the first repair returned, so that should allow you to "recreate" the input grmtools implicitly parsed.
Hope that helps!
If you have further questions, please shout, otherwise I think this can probably be closed.
This was really helpful, thank you so much!
I have the same question. It would be great if you can share your solution here.