mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-09-11 17:56:48 +03:00
21 lines
851 B
Plaintext
21 lines
851 B
Plaintext
Parser.until.go
|
|
: ∀(A: *)
|
|
∀(until: (Parser Bool))
|
|
∀(parse: (Parser A))
|
|
∀(terms: (List.Concatenator A))
|
|
(Parser (List.Concatenator A))
|
|
= λA λuntil λparse λterms λcode
|
|
let P = λx(Parser.Result (List.Concatenator A))
|
|
let done = λcode λstop
|
|
let P = λx ∀(code: String) (Parser.Result (List.Concatenator A))
|
|
let true = λcode
|
|
(Parser.Result.done (List.Concatenator A) code terms)
|
|
let false = λcode
|
|
let P = λx (Parser.Result (List.Concatenator A))
|
|
let done = λcode λvalue (Parser.until.go A until parse λx(terms (List.cons A value x)) code)
|
|
let fail = λerror (Parser.Result.fail (List.Concatenator A) error)
|
|
(~(parse code) P done fail)
|
|
((~stop P true false) code)
|
|
let fail = λerror (Parser.Result.fail (List.Concatenator A) error)
|
|
(~(until code) P done fail)
|