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

Parsers.Parser doesn't provide an easy way to override no success messages #5192

Closed
scabug opened this issue Nov 16, 2011 · 3 comments
Closed
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Nov 16, 2011

Parsers.Parser don't provide an easy way to override error messages. The common idiom for that is unsuspectingly very fragile. I suggest adding two new method, withFailureMessage and withErrorMessage, to provide that functionality. As for the problem, I'll let the comment in my proposed API describe it:

The semantics are slightly different than those obtained by doing | failure(msg), in that the message produced by this method will always replace the message produced, which is not guaranteed by that idiom.

For example, parser p below will always produce the designated failure message, while q will not produce it if sign is parsed but number is not.

def p = sign.? ~ number withFailureMessage  "Number expected!"
def q = sign.? ~ number | failure("Number expected!")
@scabug
Copy link
Author

scabug commented Nov 16, 2011

Imported From: https://issues.scala-lang.org/browse/SI-5192?orig=1
Reporter: @dcsobral

@scabug
Copy link
Author

scabug commented Nov 16, 2011

@dcsobral said:
This is implemented by pull request scala/scala#114.

@scabug
Copy link
Author

scabug commented Jan 15, 2012

@dcsobral said:
The proposed patch was accepted, this issue can be closed.

@scabug scabug closed this as completed Jan 15, 2012
@scabug scabug added this to the 2.10.0 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants