-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added the VerifiedErrors extension class in patterns object, added correct partial amending semantics * satisfied MiMA * Changed names of new combinators, no need to jump through so many hoops now! * verify -> verified * Added intrinsic, needs testing * Added correct partial amend behaviour onto deprecated deoptimised combinators
- Loading branch information
Showing
10 changed files
with
144 additions
and
115 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
26 changes: 26 additions & 0 deletions
26
parsley/shared/src/main/scala/parsley/errors/patterns.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package parsley.errors | ||
|
||
import parsley.Parsley | ||
|
||
import parsley.internal.deepembedding.frontend | ||
|
||
// TODO: document | ||
object patterns { | ||
implicit final class VerifiedErrors[P, A](p: P)(implicit con: P => Parsley[A]) { | ||
private def verified(msggen: Either[A => Seq[String], Option[A => String]]) = new Parsley(new frontend.VerifiedError(con(p).internal, msggen)) | ||
|
||
// TODO: it should have the partial amend semantics, because `amendAndDislodge` can restore the other semantics anyway | ||
// Document that `attempt` may be used when this is an informative but not terminal error. | ||
def verifiedFail(msggen: A => Seq[String]): Parsley[Nothing] = verified(Left(msggen)) | ||
def verifiedFail(msg: String, msgs: String*): Parsley[Nothing] = this.verifiedFail(_ => msg +: msgs) | ||
|
||
// TODO: Documentation and testing ahead of future release | ||
// like notFollowedBy, but does consume input on "success" and always fails | ||
// it should also have the partial amend semantics, because `amendAndDislodge` can restore the other semantics anyway | ||
// Document that `attempt` may be used when this is an informative but not terminal error. | ||
private def verifiedUnexpected(reason: Option[A => String]) = verified(Right(reason)) | ||
def verifiedUnexpected: Parsley[Nothing] = this.verifiedUnexpected(None) | ||
def verifiedUnexpected(reason: String): Parsley[Nothing] = this.verifiedUnexpected(_ => reason) | ||
def verifiedUnexpected(reason: A => String): Parsley[Nothing] = this.verifiedUnexpected(Some(reason)) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.