-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added more meaningful error messages for oneOf and noneOf * Fixed scalaJS unicode regex
- Loading branch information
Showing
7 changed files
with
104 additions
and
30 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package parsley.errors | ||
|
||
import scala.util.matching.Regex | ||
|
||
private [parsley] object helpers { | ||
def renderRawString(s: String): String = s match { | ||
case "\n" => "newline" | ||
case "\t" => "tab" | ||
case " " => "space" | ||
case Unprintable(up) => f"unprintable character (\\u${up.head.toInt}%04X)" | ||
// Do we want this only in unexpecteds? | ||
case cs => "\"" + cs.takeWhile(c => c != '\n' && c != ' ') + "\"" | ||
} | ||
|
||
def combineAsList(elems: List[String]): Option[String] = elems.sorted.reverse match { | ||
case Nil => None | ||
case List(alt) => Some(alt) | ||
case List(alt1, alt2) => Some(s"$alt2 or $alt1") | ||
// If the result would contains "," then it's probably nicer to preserve any potential grouping using ";" | ||
case any@(alt::alts) if any.exists(_.contains(",")) => Some(s"${alts.reverse.mkString("; ")}; or $alt") | ||
case alt::alts => Some(s"${alts.reverse.mkString(", ")}, or $alt") | ||
} | ||
|
||
private val Unprintable: Regex = "(\\p{C})".r | ||
} |
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