Skip to content
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

Make RegexParser.err handle whitespace like literal and regex #203

Merged
merged 1 commit into from
Mar 1, 2020

Conversation

Philippus
Copy link
Member

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 #29, reintroduction of #30

@Philippus Philippus requested a review from gourlaysama April 11, 2019 07:26
@Philippus Philippus closed this Jun 8, 2019
@Philippus Philippus deleted the issue/29 branch June 8, 2019 07:01
@Philippus Philippus restored the issue/29 branch June 8, 2019 07:25
@Philippus Philippus reopened this Jun 8, 2019
@Philippus Philippus closed this Jun 30, 2019
@Philippus Philippus deleted the issue/29 branch June 30, 2019 08:18
@Philippus Philippus restored the issue/29 branch June 30, 2019 08:18
@Philippus Philippus reopened this Jun 30, 2019
Soya-Onishi pushed a commit to Soya-Onishi/scala-parser-combinators that referenced this pull request Aug 5, 2019
This change means revival of lastNoSuccessVar(deleted by scala#108).
However, in this time, a new variable(`lastFailure` in `Success` class) is
immutable(i.e. this variable does not means revival of side effects).
That is why, probably, this change does not break referentially transparent.
@SethTisue
Copy link
Member

@Philippus this certainly looks plausible to me. maybe we should just merge it?

@Philippus Philippus merged commit 5147f67 into scala:1.2.x Mar 1, 2020
@Philippus Philippus deleted the issue/29 branch March 1, 2020 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

err Not Working as (I) Expected
2 participants