Result
halotukozak.alpaca.Result
The outcome of tokenizing or parsing: the value, or the errors met on the way.
Both cases carry the context (lexer or parser) as it was when the run ended. A Result.Failure may still hold a value in recovered, when an error-handling strategy skipped past the errors and the run went on to the end; otherwise recovered is None.
MyParser.parse(lexemes) match
case Result.Success(ctx, value) => println(value)
case Result.Failure(ctx, recovered, errors) => errors.foreach(e => println(e.message))
For Alpaca's own error types, getOrThrow returns the value or throws the errors as an exception (LexerException for LexerErrors, ParserException for ParserErrors).
Type parameters
- Ctx
-
the lexer or parser context type
- Err
-
the error type: LexerError for
tokenize, ParserError forparse - Value
-
the value: the lexemes for
tokenize, the root rule's result forparse
Attributes
- Source
- Result.scala
- Graph
-
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass Any
Members list
In this article
