/*---------------------------------------------------------------------------
  Copyright 2020-2021, Microsoft Research, Daan Leijen.

  This is free software; you can redistribute it and/or modify it under the
  terms of the Apache License, Version 2.0. A copy of the License can be
  found in the LICENSE file at the root of this distribution.
---------------------------------------------------------------------------*/

/* Parser combinators
*/
module std/text/parsestd/text/parse

import std/core/undivstd/core/undiv

pub alias parserstd/text/parse/parser: (E, V) -> V<ee: E,aa: V> = () -> <parsestd/text/parse/parse: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> aa: V

pubstd/text/parse/parse: (E, V) -> V effect parsestd/text/parse/parse: (E, V) -> V
  fun satisfy( predpred: (sslice) -> maybe<($727, sslice)> : sslicestd/core/sslice/sslice: V -> totalstd/core/types/total: E maybestd/core/types/maybe: V -> V<(std/core/types/tuple2: (V, V) -> Vaa: V,sslicestd/core/sslice/sslice: V)> ) : maybestd/core/types/maybe: V -> V<aa: V>
  ctl fail(msgmsg: string : stringstd/core/types/string: V) : aa: V
  ctl pick() : boolstd/core/types/bool: V
  fun current-input() : sslicestd/core/sslice/sslice: V

pub fun starts-withstd/text/parse/starts-with: forall<a> (s : string, p : () -> parse a) -> maybe<(a, sslice)>( ss: string : stringstd/core/types/string: V, pp: () -> parse $2621 : () -> parsestd/text/parse/parse: (E, V) -> V aa: V )result: -> total maybe<(2665, sslice)>  : maybestd/core/types/maybe: V -> V<(std/core/types/tuple2: (V, V) -> Vaa: V,sslicestd/core/sslice/sslice: V)>
  match ss: string.slicestd/core/sslice/slice: (s : string) -> sslice.parsestd/text/parse/parse: (input0 : sslice, p : () -> parse $2621) -> parse-error<$2621>(pp: () -> parse $2621)
    ParseOkstd/text/parse/ParseOk: forall<a> (result : a, rest : sslice) -> parse-error<a>(xx: $2621,restrest: sslice) -> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>((std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)xx: $2621,restrest: sslice)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b))
    _               -> Nothingstd/core/types/Nothing: forall<a> maybe<a>


pub type parse-errorstd/text/parse/parse-error: V -> V<aa: V>
  ParseOkstd/text/parse/ParseOk: forall<a> (result : a, rest : sslice) -> parse-error<a>( result: aa: V, reststd/text/parse/parse-error/rest: forall<a> (parse-error<a>) -> sslice : sslicestd/core/sslice/sslice: V )
  ParseErrorstd/text/parse/ParseError: forall<a> (msg : string, rest : sslice) -> parse-error<a>( msg : stringstd/core/types/string: V, rest : sslicestd/core/sslice/sslice: V )

pub fun maybestd/text/parse/maybe: forall<a> (perr : parse-error<a>) -> maybe<a>( perrperr: parse-error<$1562> : parse-errorstd/text/parse/parse-error: V -> V<aa: V> )result: -> total maybe<1598> : maybestd/core/types/maybe: V -> V<aa: V>
  perrperr: parse-error<$1562>.eitherstd/text/parse/either: (perr : parse-error<$1562>) -> either<string,$1562>.maybestd/core/either/maybe: (e : either<string,$1562>) -> maybe<$1562>

pub fun eitherstd/text/parse/either: forall<a> (perr : parse-error<a>) -> either<string,a>( perrperr: parse-error<$636> : parse-errorstd/text/parse/parse-error: V -> V<aa: V> )result: -> total either<string,669> : eitherstd/core/types/either: (V, V) -> V<stringstd/core/types/string: V,aa: V>
  match perrperr: parse-error<$636>
    ParseOkstd/text/parse/ParseOk: forall<a> (result : a, rest : sslice) -> parse-error<a>(xx: $636,_) -> Rightstd/core/types/Right: forall<a,b> (right : b) -> either<a,b>(xx: $636)
    ParseErrorstd/text/parse/ParseError: forall<a> (msg : string, rest : sslice) -> parse-error<a>(msgmsg: string,_) -> Leftstd/core/types/Left: forall<a,b> (left : a) -> either<a,b>(msgmsg: string)

pub fun parse-eofstd/text/parse/parse-eof: forall<a,e> (input : sslice, p : () -> <parse|e> a) -> e parse-error<a>( inputinput: sslice : sslicestd/core/sslice/sslice: V, pp: () -> <parse|$2455> $2454 : () -> <parsestd/text/parse/parse: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> aa: V)result: -> 2476 parse-error<2475> : ee: E parse-errorstd/text/parse/parse-error: V -> V<aa: V>
  parsestd/text/parse/parse: (input0 : sslice, p : () -> <parse|$2455> $2454) -> $2455 parse-error<$2454>(inputinput: sslice)
    val xx: $2454 = pp: () -> <parse|$2455> $2454()
    eofstd/text/parse/eof: () -> <parse|$2455> ()()
    xx: $2454

pub fun parsestd/text/parse/parse: forall<a,e> (input0 : sslice, p : () -> <parse|e> a) -> e parse-error<a>( input0input0: sslice : sslicestd/core/sslice/sslice: V, pp: () -> <parse|$1802> $1801 : () -> <parsestd/text/parse/parse: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> aa: V )result: -> 2447 parse-error<2446> : ee: E parse-errorstd/text/parse/parse-error: V -> V<aa: V>
  var inputinput: local-var<$1811,sslice> := input0input0: sslice
  handlehandler: (() -> <parse,local<$1811>|$1802> $1801) -> <local<$1811>|$1802> parse-error<$1801> pp: () -> <parse|$1802> $1801
    returnreturn: (x : $1801) -> <local<$1811>|_1848> parse-error<$1801>(xx: $1801)
      ParseOkstd/text/parse/ParseOk: forall<a> (result : a, rest : sslice) -> parse-error<a>(xx: $1801,inputinput: sslice)

    fun current-inputcurrent-input: () -> <local<$1811>|$1802> sslice()
      inputinput: sslice

    brk failfail: (msg : string) -> <local<$1811>|$1802> parse-error<$1801>(msgmsg: string)
      ParseErrorstd/text/parse/ParseError: forall<a> (msg : string, rest : sslice) -> parse-error<a>(msgmsg: string,inputinput: sslice)

    fun satisfysatisfy: (pred : (sslice) -> maybe<(_1863, sslice)>) -> <local<$1811>|$1802> maybe<_1863>(predpred: (sslice) -> maybe<(_1863, sslice)>)
      val inpinp: sslice = inputinput: sslice
      val mm: () -> maybe<(_1863, sslice)>   = fnfn: () -> maybe<(_1863, sslice)>() : totalstd/core/types/total: E __w-l61-c30: V { predpred: (sslice) -> maybe<(_1863, sslice)>(inpinp: sslice) }
      match mm: () -> <local<$1811>|$1802> maybe<(_1863, sslice)>()
        Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>((std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)xx: _1863,capcap: sslice)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)) -> { inputinput: local-var<$1811,sslice> :=std/core/types/local-set: (v : local-var<$1811,sslice>, assigned : sslice) -> <local<$1811>|$1802> () capcap: sslice; Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(xx: _1863) }
        Nothingstd/core/types/Nothing: forall<a> maybe<a>       -> Nothingstd/core/types/Nothing: forall<a> maybe<a>

    ctl pickpick: (resume : (bool) -> <local<$1811>|$1802> parse-error<$1801>) -> <local<$1811>|$1802> parse-error<$1801>
() val savesave: sslice = inputinput: sslice; match resumeresume: (bool) -> <local<$1811>|$1802> parse-error<$1801>(Truestd/core/types/True: bool) ParseOkstd/text/parse/ParseOk: forall<a> (result : a, rest : sslice) -> parse-error<a>(x1x1: $1801,rest1rest1: sslice) -> ParseOkstd/text/parse/ParseOk: forall<a> (result : a, rest : sslice) -> parse-error<a>(x1x1: $1801,rest1rest1: sslice) err1err1: parse-error<$1801> -> inputinput: local-var<$1811,sslice> :=std/core/types/local-set: (v : local-var<$1811,sslice>, assigned : sslice) -> <local<$1811>|$1802> () savesave: sslice match resumeresume: (bool) -> <local<$1811>|$1802> parse-error<$1801>(Falsestd/core/types/False: bool) // todo: limit lookahead? ParseOkstd/text/parse/ParseOk: forall<a> (result : a, rest : sslice) -> parse-error<a>(x2x2: $1801,rest2rest2: sslice) -> ParseOkstd/text/parse/ParseOk: forall<a> (result : a, rest : sslice) -> parse-error<a>(x2x2: $1801,rest2rest2: sslice) _err2 -> err1err1: parse-error<$1801>
// todo: merge or pick closest? pub fun (||)std/text/parse/(||): forall<a,e> (p1 : parser<e,a>, p2 : parser<e,a>) -> <parse|e> a( p1p1: parser<$1322,$1321> : parserstd/text/parse/parser: (E, V) -> V<ee: E,aa: V>, p2p2: parser<$1322,$1321> : parserstd/text/parse/parser: (E, V) -> V<ee: E,aa: V> )result: -> <parse|1337> 1336 : <parsestd/text/parse/parse: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> aa: V if pickstd/text/parse/pick: () -> <parse|$1322> bool() then p1p1: parser<$1322,$1321>() else p2p2: parser<$1322,$1321>() pub fun optionalstd/text/parse/optional: forall<a,e> (default : a, p : parser<e,a>) -> <parse|e> a( defaultdefault: $1344 : aa: V, pp: parser<$1345,$1344> : parserstd/text/parse/parser: (E, V) -> V<ee: E,aa: V> )result: -> <parse|1363> 1362 : <parsestd/text/parse/parse: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> aa: V pp: parser<$1345,$1344> ||std/text/parse/(||): (p1 : parser<$1345,$1344>, p2 : parser<$1345,$1344>) -> <parse|$1345> $1344 (fnfn: () -> <parse|$1345> $1344() defaultdefault: $1344) pub fun choosestd/text/parse/choose: forall<a,e> (ps : list<parser<e,a>>) -> <parse|e> a( psps: list<parser<$1104,$1103>> : liststd/core/types/list: V -> V<parserstd/text/parse/parser: (E, V) -> V<ee: E,aa: V>> )result: -> <parse|1145> 1144 : <parsestd/text/parse/parse: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> aa: V match psps: list<parser<$1104,$1103>> Nilstd/core/types/Nil: forall<a> list<a> -> failstd/text/parse/fail: (msg : string) -> <parse|$1104> $1103("no further alternatives"literal: string
count= 23
) Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(pp: parser<$1104,$1103>,Nilstd/core/types/Nil: forall<a> list<a>) -> pp: parser<$1104,$1103>() Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(pp: parser<$1104,$1103>,pppp: list<parser<$1104,$1103>>) -> if pickstd/text/parse/pick: () -> <parse|$1104> bool() then pp: parser<$1104,$1103>() else choosestd/text/parse/choose: (ps : list<parser<$1104,$1103>>) -> <parse|$1104> $1103(pppp: list<parser<$1104,$1103>>
) pub fun satisfy-failstd/text/parse/satisfy-fail: forall<a> (msg : string, pred : (sslice) -> maybe<(a, sslice)>) -> parse a( msgmsg: string : stringstd/core/types/string: V, predpred: (sslice) -> maybe<($782, sslice)> : sslicestd/core/sslice/sslice: V -> maybestd/core/types/maybe: V -> V<(std/core/types/tuple2: (V, V) -> Vaa: V,sslicestd/core/sslice/sslice: V)> )result: -> parse 810 : parsestd/text/parse/parse: (E, V) -> V aa: V match satisfystd/text/parse/satisfy: (pred : (sslice) -> maybe<($782, sslice)>) -> parse maybe<$782>(predpred: (sslice) -> maybe<($782, sslice)>) Nothingstd/core/types/Nothing: forall<a> maybe<a> -> failstd/text/parse/fail: (msg : string) -> parse $782(msgmsg: string) Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(xx: $782) -> xx: $782 pub fun eofstd/text/parse/eof: () -> parse ()()result: -> parse () : parsestd/text/parse/parse: (E, V) -> V (std/core/types/unit: V)std/core/types/unit: V match satisfystd/text/parse/satisfy: (pred : (sslice) -> maybe<((), sslice)>) -> parse maybe<()>( fnfn: (s : sslice) -> maybe<((), sslice)>(ss: sslice) if ss: sslice.is-emptystd/core/sslice/is-empty: (slice : sslice) -> bool then Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>((std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)(std/core/types/Unit: ())std/core/types/Unit: (),ss: sslice)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)) else Nothingstd/core/types/Nothing: forall<a> maybe<a> ) Nothingstd/core/types/Nothing: forall<a> maybe<a> -> failstd/text/parse/fail: (msg : string) -> parse ()("expecting end-of-input"literal: string
count= 22
) Juststd/core/types/Just: forall<a> (value : a) -> maybe<a> -> (std/core/types/Unit: ()
)std/core/types/Unit: () pub fun char-isstd/text/parse/char-is: (msg : string, pred : (char) -> bool) -> parse char( msgmsg: string :stringstd/core/types/string: V, predpred: (char) -> bool : charstd/core/types/char: V -> boolstd/core/types/bool: V )result: -> parse char : parsestd/text/parse/parse: (E, V) -> V charstd/core/types/char: V satisfy-failstd/text/parse/satisfy-fail: (msg : string, pred : (sslice) -> maybe<(char, sslice)>) -> parse char(msgmsg: string) fnfn: (slice : sslice) -> maybe<(char, sslice)>(sliceslice: sslice) match sliceslice: sslice.nextstd/core/sslice/next: (slice : sslice) -> maybe<(char, sslice)> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>((std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)cc: char,restrest: sslice)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)) | predpred: (char) -> bool(cc: char) -> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>((std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)cc: char,restrest: sslice)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)) _ -> Nothingstd/core/types/Nothing: forall<a> maybe<a> fun next-while0std/text/parse/next-while0: (slice : sslice, pred : (char) -> bool, acc : list<char>) -> (list<char>, sslice)( sliceslice: sslice : sslicestd/core/sslice/sslice: V, predpred: (char) -> bool : charstd/core/types/char: V -> boolstd/core/types/bool: V, accacc: list<char> : liststd/core/types/list: V -> V<charstd/core/types/char: V> )result: -> total (list<char>, sslice) : (std/core/types/tuple2: (V, V) -> Vliststd/core/types/list: V -> V<charstd/core/types/char: V>,sslicestd/core/sslice/sslice: V) match sliceslice: sslice.nextstd/core/sslice/next: (slice : sslice) -> maybe<(char, sslice)> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>((std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)cc: char,restrest: sslice)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)) | predpred: (char) -> bool(cc: char) -> next-while0std/text/parse/next-while0: (slice : sslice, pred : (char) -> bool, acc : list<char>) -> (list<char>, sslice)(pretend-decreasingstd/core/undiv/pretend-decreasing: (x : sslice) -> sslice(restrest: sslice), predpred: (char) -> bool, Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(cc: char,accacc: list<char>) ) _ -> (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)accacc: list<char>.reversestd/core/list/reverse: (xs : list<char>) -> list<char>,sliceslice: sslice)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) pub fun chars-arestd/text/parse/chars-are: (msg : string, pred : (char) -> bool) -> parse list<char>( msgmsg: string :stringstd/core/types/string: V, predpred: (char) -> bool : charstd/core/types/char: V -> boolstd/core/types/bool: V )result: -> parse list<char> : parsestd/text/parse/parse: (E, V) -> V liststd/core/types/list: V -> V<charstd/core/types/char: V> satisfy-failstd/text/parse/satisfy-fail: (msg : string, pred : (sslice) -> maybe<(list<char>, sslice)>) -> parse list<char>(msgmsg: string) fnfn: (slice : sslice) -> maybe<(list<char>, sslice)>(sliceslice: sslice) match sliceslice: sslice.next-while0std/text/parse/next-while0: (slice : sslice, pred : (char) -> bool, acc : list<char>) -> (list<char>, sslice)(predpred: (char) -> bool,[std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>) (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)[std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>,_)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) -> Nothingstd/core/types/Nothing: forall<a> maybe<a> (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)xsxs: list<char>,restrest: sslice)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) -> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>((std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)xsxs: list<char>,restrest: sslice)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)) fun next-matchstd/text/parse/next-match: (slice : sslice, cs : list<char>) -> maybe<sslice>( sliceslice: sslice : sslicestd/core/sslice/sslice: V, cscs: list<char> : liststd/core/types/list: V -> V<charstd/core/types/char: V> )result: -> total maybe<sslice> : maybestd/core/types/maybe: V -> V<sslicestd/core/sslice/sslice: V> match cscs: list<char> Nilstd/core/types/Nil: forall<a> list<a> -> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(sliceslice: sslice) Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(cc: char,cccc: list<char>) -> match sliceslice: sslice.nextstd/core/sslice/next: (slice : sslice) -> maybe<(char, sslice)> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>((std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)dd: char,restrest: sslice)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)) | cc: char==std/core/char/(==): (char, char) -> booldd: char -> restrest: sslice.next-matchstd/text/parse/next-match: (slice : sslice, cs : list<char>) -> maybe<sslice>( cccc: list<char> ) _ -> Nothingstd/core/types/Nothing: forall<a> maybe<a> pub fun pstringstd/text/parse/pstring: (s : string) -> parse string( ss: string : stringstd/core/types/string: V )result: -> parse string : parsestd/text/parse/parse: (E, V) -> V stringstd/core/types/string: V satisfy-failstd/text/parse/satisfy-fail: (msg : string, pred : (sslice) -> maybe<(string, sslice)>) -> parse string(ss: string) fnfn: (slice : sslice) -> maybe<(string, sslice)>(sliceslice: sslice) match sliceslice: sslice.next-matchstd/text/parse/next-match: (slice : sslice, cs : list<char>) -> maybe<sslice>(ss: string.liststd/core/string/list: (s : string) -> list<char>) Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(restrest: sslice) -> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>((std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)ss: string,restrest: sslice)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)) Nothingstd/core/types/Nothing: forall<a> maybe<a> -> Nothingstd/core/types/Nothing: forall<a> maybe<a> pub fun charstd/text/parse/char: (c : char) -> parse char( cc: char : charstd/core/types/char: V )result: -> parse char : parsestd/text/parse/parse: (E, V) -> V charstd/core/types/char: V char-isstd/text/parse/char-is: (msg : string, pred : (char) -> bool) -> parse char( showstd/core/show/char/show: (c : char) -> parse string(cc: char), fnfn: (c0 : char) -> bool(c0c0: char) cc: char ==std/core/char/(==): (char, char) -> bool c0c0: char ) pub fun no-digitstd/text/parse/no-digit: () -> parse char()result: -> parse char : parsestd/text/parse/parse: (E, V) -> V charstd/core/types/char: V char-isstd/text/parse/char-is: (msg : string, pred : (char) -> bool) -> parse char("not a digit"literal: string
count= 11
, fnfn: (c : char) -> bool(cc: char) !std/core/types/bool/(!): (b : bool) -> boolcc: char.is-digitstd/core/char/is-digit: (c : char) -> bool
) pub fun digitstd/text/parse/digit: () -> parse int()result: -> parse int : parsestd/text/parse/parse: (E, V) -> V intstd/core/types/int: V val cc: char = char-isstd/text/parse/char-is: (msg : string, pred : (char) -> bool) -> parse char("digit"literal: string
count= 5
, is-digitstd/core/char/is-digit: (c : char) -> bool) (cc: char -std/core/char/(-): (c : char, d : char) -> parse char '0'literal: char
unicode= u0030
).intstd/core/char/int: (char) -> parse int
pub fun alphastd/text/parse/alpha: () -> parse char()result: -> parse char : parsestd/text/parse/parse: (E, V) -> V charstd/core/types/char: V char-isstd/text/parse/char-is: (msg : string, pred : (char) -> bool) -> parse char("alpha"literal: string
count= 5
, is-alphastd/core/char/is-alpha: (c : char) -> bool
) pub fun alpha-numstd/text/parse/alpha-num: () -> parse char()result: -> parse char : parsestd/text/parse/parse: (E, V) -> V charstd/core/types/char: V char-isstd/text/parse/char-is: (msg : string, pred : (char) -> bool) -> parse char("alpha-num"literal: string
count= 9
, is-alpha-numstd/core/char/is-alpha-num: (c : char) -> bool
) pub fun whitestd/text/parse/white: () -> parse char()result: -> parse char : parsestd/text/parse/parse: (E, V) -> V charstd/core/types/char: V char-isstd/text/parse/char-is: (msg : string, pred : (char) -> bool) -> parse char(""literal: string
count= 0
, is-whitestd/core/char/is-white: (c : char) -> bool
) pub fun whitespacestd/text/parse/whitespace: () -> parse string()result: -> parse string : parsestd/text/parse/parse: (E, V) -> V stringstd/core/types/string: V chars-arestd/text/parse/chars-are: (msg : string, pred : (char) -> bool) -> parse list<char>(""literal: string
count= 0
, is-whitestd/core/char/is-white: (c : char) -> bool).stringstd/core/string/listchar/string: (cs : list<char>) -> parse string
pub fun whitespace0std/text/parse/whitespace0: () -> parse string()result: -> parse string : parsestd/text/parse/parse: (E, V) -> V stringstd/core/types/string: V optionalstd/text/parse/optional: (default : string, p : parser<total,string>) -> parse string(""literal: string
count= 0
, whitespacestd/text/parse/whitespace: () -> parse string
) pub fun digitsstd/text/parse/digits: () -> parse string()result: -> parse string : parsestd/text/parse/parse: (E, V) -> V stringstd/core/types/string: V chars-arestd/text/parse/chars-are: (msg : string, pred : (char) -> bool) -> parse list<char>("digit"literal: string
count= 5
, is-digitstd/core/char/is-digit: (c : char) -> bool ).stringstd/core/string/listchar/string: (cs : list<char>) -> parse string
pub fun digits0std/text/parse/digits0: () -> parse string()result: -> parse string : parsestd/text/parse/parse: (E, V) -> V stringstd/core/types/string: V optionalstd/text/parse/optional: (default : string, p : parser<total,string>) -> parse string("0"literal: string
count= 1
, digitsstd/text/parse/digits: () -> parse string
) pub fun signstd/text/parse/sign: () -> parse bool()result: -> parse bool : parsestd/text/parse/parse: (E, V) -> V boolstd/core/types/bool: V val cc: char = one-of-orstd/text/parse/one-of-or: (chars : string, default : char) -> parse char("+-"literal: string
count= 2
, '+'literal: char
unicode= u002B
) (cc: char==std/core/char/(==): (char, char) -> parse bool'-'literal: char
unicode= u002D
) pub fun pnatstd/text/parse/pnat: () -> parse int()result: -> parse int : parsestd/text/parse/parse: (E, V) -> V intstd/core/types/int: V digitsstd/text/parse/digits: () -> parse string().parse-intstd/core/int/parse-int: (s : string, hex : ? bool) -> parse maybe<int>.defaultstd/core/maybe/default: (m : maybe<int>, nothing : int) -> parse int(0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
) pub fun pintstd/text/parse/pint: () -> parse int()result: -> parse int : parsestd/text/parse/parse: (E, V) -> V intstd/core/types/int: V val negneg: bool = signstd/text/parse/sign: () -> parse bool() val ii: int = pnatstd/text/parse/pnat: () -> parse int() if negneg: bool then ~std/core/int/(~): (i : int) -> parse intii: int else ii: int pub fun none-ofstd/text/parse/none-of: (chars : string) -> parse char( charschars: string : stringstd/core/types/string: V )result: -> parse char : parsestd/text/parse/parse: (E, V) -> V charstd/core/types/char: V char-isstd/text/parse/char-is: (msg : string, pred : (char) -> bool) -> parse char(""literal: string
count= 0
, fnfn: (c : char) -> bool(cc: char) !std/core/types/bool/(!): (b : bool) -> boolcharschars: string.containsstd/core/string/contains: (s : string, sub : string) -> bool(cc: char.stringstd/core/string/char/string: (c : char) -> string)
) pub fun none-of-many1std/text/parse/none-of-many1: (chars : string) -> parse string( charschars: string : stringstd/core/types/string: V )result: -> parse string : parsestd/text/parse/parse: (E, V) -> V stringstd/core/types/string: V chars-arestd/text/parse/chars-are: (msg : string, pred : (char) -> bool) -> parse list<char>(""literal: string
count= 0
, fnfn: (c : char) -> bool(cc: char) !std/core/types/bool/(!): (b : bool) -> boolcharschars: string.containsstd/core/string/contains: (s : string, sub : string) -> bool(cc: char.stringstd/core/string/char/string: (c : char) -> string)).stringstd/core/string/listchar/string: (cs : list<char>) -> parse string
pub fun one-ofstd/text/parse/one-of: (chars : string) -> parse char( charschars: string : stringstd/core/types/string: V )result: -> parse char : parsestd/text/parse/parse: (E, V) -> V charstd/core/types/char: V char-isstd/text/parse/char-is: (msg : string, pred : (char) -> bool) -> parse char(charschars: string, fnfn: (c : char) -> bool(cc: char) charschars: string.containsstd/core/string/contains: (s : string, sub : string) -> bool(cc: char.stringstd/core/string/char/string: (c : char) -> string)) // chars.list.map(fn(c){ (fn(){ char(c) } ) }).choose fun many-accstd/text/parse/many-acc: forall<a,e> (p : parser<e,a>, acc : list<a>) -> <parse|e> list<a>( pp: parser<$1452,$1451> : parserstd/text/parse/parser: (E, V) -> V<ee: E,aa: V>, accacc: list<$1451> : liststd/core/types/list: V -> V<aa: V> )result: -> <parse|1499> list<1498> : <parsestd/text/parse/parse: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> liststd/core/types/list: V -> V<aa: V> (fnfn: () -> <parse|$1452> list<$1451>() val xx: $1451 = pp: parser<$1452,$1451>() in many-accstd/text/parse/many-acc: (p : parser<$1452,$1451>, acc : list<$1451>) -> <parse|$1452> list<$1451>(pretend-decreasingstd/core/undiv/pretend-decreasing: (x : parser<$1452,$1451>) -> <parse|$1452> parser<$1452,$1451>(pp: parser<$1452,$1451>),Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1451,accacc: list<$1451>))) ||std/text/parse/(||): (p1 : parser<$1452,list<$1451>>, p2 : parser<$1452,list<$1451>>) -> <parse|$1452> list<$1451> (fnfn: () -> <parse|$1452> list<$1451>() accacc: list<$1451>.reversestd/core/list/reverse: (xs : list<$1451>) -> <parse|$1452> list<$1451>) pub fun manystd/text/parse/many: forall<a,e> (p : parser<e,a>) -> <parse|e> list<a>( pp: parser<$1507,$1506> : parserstd/text/parse/parser: (E, V) -> V<ee: E,aa: V> )result: -> <parse|1525> list<1524> : <parsestd/text/parse/parse: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> liststd/core/types/list: V -> V<aa: V> many-accstd/text/parse/many-acc: (p : parser<$1507,$1506>, acc : list<$1506>) -> <parse|$1507> list<$1506>(pp: parser<$1507,$1506>,[std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>) pub fun many1std/text/parse/many1: forall<a,e> (p : parser<e,a>) -> <parse|e> list<a>( pp: parser<$1533,$1532> : parserstd/text/parse/parser: (E, V) -> V<ee: E,aa: V> )result: -> <parse|1555> list<1554> : <parsestd/text/parse/parse: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> liststd/core/types/list: V -> V<aa: V> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(pp: parser<$1533,$1532>(), manystd/text/parse/many: (p : parser<$1533,$1532>) -> <parse|$1533> list<$1532>(pp: parser<$1533,$1532>)) fun count-accstd/text/parse/count-acc: forall<a,e> (n : int, acc : list<a>, p : parser<e,a>) -> <parse|e> list<a>( nn: int : intstd/core/types/int: V, accacc: list<$1152> : liststd/core/types/list: V -> V<aa: V>, pp: parser<$1153,$1152> : parserstd/text/parse/parser: (E, V) -> V<ee: E,aa: V> )result: -> <parse|1213> list<1212> : <parsestd/text/parse/parse: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> liststd/core/types/list: V -> V<aa: V> if nn: int <=std/core/int/(<=): (x : int, y : int) -> <parse|$1153> bool 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
then accacc: list<$1152>.reversestd/core/list/reverse: (xs : list<$1152>) -> <parse|$1153> list<$1152> else val xx: $1152 = pp: parser<$1153,$1152>() count-accstd/text/parse/count-acc: (n : int, acc : list<$1152>, p : parser<$1153,$1152>) -> <parse|$1153> list<$1152>(pretend-decreasingstd/core/undiv/pretend-decreasing: (x : int) -> <parse|$1153> int(nn: int -std/core/int/(-): (x : int, y : int) -> <parse|$1153> int 1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
), Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1152,accacc: list<$1152>), pp: parser<$1153,$1152>
) pub fun countstd/text/parse/count: forall<a,e> (n : int, p : parser<e,a>) -> <parse|e> list<a>( nn: int : intstd/core/types/int: V, pp: parser<$1221,$1220> : parserstd/text/parse/parser: (E, V) -> V<ee: E,aa: V> )result: -> <parse|1240> list<1239> : <parsestd/text/parse/parse: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> liststd/core/types/list: V -> V<aa: V> count-accstd/text/parse/count-acc: (n : int, acc : list<$1220>, p : parser<$1221,$1220>) -> <parse|$1221> list<$1220>(nn: int, [std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>, pp: parser<$1221,$1220>) pub fun one-of-orstd/text/parse/one-of-or: (chars : string, default : char) -> parse char( charschars: string : stringstd/core/types/string: V, defaultdefault: char : charstd/core/types/char: V )result: -> parse char : parsestd/text/parse/parse: (E, V) -> V charstd/core/types/char: V optionalstd/text/parse/optional: (default : char, p : parser<total,char>) -> parse char(defaultdefault: char){ one-ofstd/text/parse/one-of: (chars : string) -> parse char(charschars: string) } //val rx-float = regex(r"^([\-\+])?(\d+(?:\.\d+)?(?:[eE][\-\+]\d+)?)$") //val rx-hexfloat = regex(r"^([\-\+]?0[xX][0-9a-fA-F]+)(?:\.([0-9a-fA-F]+))?(?:[pP]([\-\+]?\d+))?$") pub fun hex-digitsstd/text/parse/hex-digits: () -> parse string()result: -> parse string : parsestd/text/parse/parse: (E, V) -> V stringstd/core/types/string: V chars-arestd/text/parse/chars-are: (msg : string, pred : (char) -> bool) -> parse list<char>("digit"literal: string
count= 5
, is-hex-digitstd/core/char/is-hex-digit: (c : char) -> bool ).stringstd/core/string/listchar/string: (cs : list<char>) -> parse string
/* pub fun test(s : string, x : a, p : () -> parse a ) : a parse-eof(s.slice,p).maybe.default(x) */