Skip to content

Commit

Permalink
Document exception throwing
Browse files Browse the repository at this point in the history
  • Loading branch information
alllex committed Jun 26, 2023
1 parent a3a828c commit 53bba91
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/commonMain/kotlin/me/alllex/parsus/parser/Grammar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ abstract class Grammar<out V>(
* If parsing is successful, returns a value.
* Otherwise, throws a [ParseException] containing an error.
*/
@Throws(ParseException::class)
fun parseEntireOrThrow(input: String): V {
return parseEntire(input).getOrThrow()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ inline fun <T> ParseResult<T>.getOrElse(f: (ParseError) -> T): T {
}
}

@Throws(ParseException::class)
fun <T> ParseResult<T>.getOrThrow(): T {
return when (this) {
is ParsedValue -> value
Expand Down

0 comments on commit 53bba91

Please sign in to comment.