Skip to content

Commit

Permalink
Rename parseEntire* to parse*
Browse files Browse the repository at this point in the history
  • Loading branch information
alllex committed Jul 26, 2023
1 parent 00d0b67 commit bc43021
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/commonMain/kotlin/me/alllex/parsus/parser/Grammar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ abstract class Grammar<out V>(
/**
* Attempts to parse the entire input and returns the parsed value or the default value if parsing fails.
*/
inline fun <V> Grammar<V>.parseEntireOrElse(input: String, default: (ParseError) -> V): V {
inline fun <V> Grammar<V>.parseOrElse(input: String, default: (ParseError) -> V): V {
return when (val result = parse(input)) {
is ParsedValue -> result.value
is ParseError -> default(result)
Expand All @@ -203,4 +203,4 @@ inline fun <V> Grammar<V>.parseEntireOrElse(input: String, default: (ParseError)
/**
* Attempts to parse the entire input and returns the parsed value or `null` if parsing fails.
*/
fun <V> Grammar<V>.parseEntireOrNull(input: String): V? = parseEntireOrElse(input) { null }
fun <V> Grammar<V>.parseOrNull(input: String): V? = parseOrElse(input) { null }

0 comments on commit bc43021

Please sign in to comment.