1///|
2pub impl[A] trait BitOr {
lor(Self, Self) -> Self
}
types implementing this trait can use the | operator
BitOr for type Parser[A] (Input) -> (A, Input) raise ParseError
Parser[type parameter A
A] with (x : Parser[A], y : Parser[A]) -> Parser[A]
lor(Parser[A]
x, Parser[A]
y) {
3 fn(Input
input) {
4 Parser[A]
x(Input
input) catch {
5 ParseError
e =>
6 Parser[A]
y(Input
input) catch {
7 ParseError
e_ => raise if ParseError
e.(self : ParseError) -> SourcePos
source_pos() (self_ : SourcePos, other : SourcePos) -> Bool
> ParseError
e_.(self : ParseError) -> SourcePos
source_pos() { ParseError
e } else { ParseError
e_ }
8 }
9 }
10 }
11}
12
13///|
14pub fn[A] type Parser[A] (Input) -> (A, Input) raise ParseError
Parser::(x : Parser[A], msg : String) -> Parser[A]
label(Parser[A]
x : type Parser[A] (Input) -> (A, Input) raise ParseError
Parser[type parameter A
A], String
msg : String
String) -> type Parser[A] (Input) -> (A, Input) raise ParseError
Parser[type parameter A
A] {
15 fn(Input
input) { Parser[A]
x(Input
input) catch { ParseError
ParseErrorParseError
(_) as e => raise ParseError
e.(self : ParseError, x : String) -> ParseError
cons(String
msg) } }
16}
17