make RegexParser.err handle whitespace like literal and regex.#30
Merged
gourlaysama merged 1 commit intoscala:masterfrom Aug 18, 2014
Merged
make RegexParser.err handle whitespace like literal and regex.#30gourlaysama merged 1 commit intoscala:masterfrom
gourlaysama merged 1 commit intoscala:masterfrom
Conversation
This overrides `err` in RegexParser to make it consume whitespace just
like regex and literal. The original motivation was:
object parser extends RegexParsers {
def num = "\\d+".r
def twoNums = num ~ (num | err("error!"))
}
// succeeds
parser.parseAll(twoNums, "42 721")
// fails with a parsing Failure instead of an Error
// because err doesn't consume the whitespace but the regex does.
parser.parseAll(twoNums, "42 foo")
This may change the output of some parsers that failed to parse input
(from a Failure to an Error).
Fixes scala#29
Contributor
Author
|
I am still not 100% convinced that this change cannot break somebody's parser, by turning a successful parse into an error (because of no backtracking with errors compared to failures)... |
Contributor
Author
|
... but even if that's a semantic change, it is worth it. |
gourlaysama
added a commit
that referenced
this pull request
Aug 18, 2014
make RegexParser.err handle whitespace like literal and regex.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This overrides
errin RegexParser to make it consume whitespace justlike regex and literal. The original motivation was:
This may change the output of some parsers that failed to parse input
(from a Failure to an Error).
Fixes #29