Package at.jku.ssw.fp.sect06_3
Class Result<T>
- java.lang.Object
-
- at.jku.ssw.fp.sect06_3.Result<T>
-
- Type Parameters:
T
- the type of the parse result
public class Result<T> extends Object
Class representing a result of a parser. A result of a parser consists of the parse result and the rest of the input. The parse result is either an real result or an exception. One of the two is not-null.- Author:
- Herbert Praehofer
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
failed()
Returns if this object represents a failed result.static <T> Result<T>
failure(Exception excpt, FList<String> rest)
Creates a failed result consisting of an exception and the rest of the input.static <T> Result<T>
success(T result, FList<String> rest)
Creates a successful result consisting of a parse result and the rest of the input.boolean
successful()
Returns if this object represents a successful result.String
toString()
-
-
-
Method Detail
-
success
public static <T> Result<T> success(T result, FList<String> rest)
Creates a successful result consisting of a parse result and the rest of the input. The exception isnull
.- Type Parameters:
T
- the type of the parse result- Parameters:
result
- the parse resultrest
- the rest of the input- Returns:
- the result object
-
failure
public static <T> Result<T> failure(Exception excpt, FList<String> rest)
Creates a failed result consisting of an exception and the rest of the input. The parse result isnull
.- Type Parameters:
T
- the type of the parse result (used for type checking)- Parameters:
excpt
- the exception showing the parse failurerest
- the rest of the input- Returns:
- the failed result object
-
successful
public boolean successful()
Returns if this object represents a successful result.- Returns:
true
if this object represents a successful result
-
failed
public boolean failed()
Returns if this object represents a failed result.- Returns:
true
if this object represents a failed result
-
-