Add error messages for incomplete parsing #3
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.
Hi,
I have tried to improve the error messages produced
by parsers in the case of error-less incomplete parsings.
(The example is in the git commit message as well as
comments on changes done.)
The patch makes the definition of the function "parse1"
more explicit (it doesn't use the functions "bestError"
and "maximumBy" now) , but in this way one avoids
to go through the list of possible parsings several times.
There is a type change in the function "parse" exported by
the module Prim.hs, since we need to know the position
where the parsing stopped when emitting a message in
the function "parse1". This can be avoided by introducing
a new function "parse' " or putting the corresponding code
inside of the definition of "parse1" . I am not sure what is
better as of now the function "parse" is not used in other
parts of the Boomerang library, and it is unclear to me if
anybody imports it. (In most cases only the specific parsers
like parseString, parseStrings, parseTexts would be used.)
Best,
Ivan
PS. I have run the travis build on my master branch and it
was successful.