struct Pars::ParseResult(T)

Overview

ParseResult(T) is a result of a parsed Parser with return type T.

Defined in:

pars/parse_result.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(value : T, context : Pars::ParseContext) #

Creates a new successful ParseResult.


[View source]

Class Method Detail

def self.error(message : String, context : ParseContext) #

Creates an errored ParseResult.


[View source]
def self.error(e : ParseError) #

Creates an errored ParseResult that wraps e.


[View source]

Instance Method Detail

def context #

[View source]
def error! : ParseError #

Directly access the ParseError.

Note: this unsafe and should only be used if #errored == true.


[View source]
def error? : ParseError | Nil #

Returns a ParseError, or nil if parsing was successful.


[View source]
def errored #

[View source]
def value : T | ParseError #

Returns the parsed value, or a ParseError.


[View source]
def value! : T #

Directly access to parsed value.

Note: this is unsafe and should only be used if #errored == false.


[View source]