diff options
Diffstat (limited to 'stdlib/source/parser/lux/data/text.lux')
-rw-r--r-- | stdlib/source/parser/lux/data/text.lux | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/stdlib/source/parser/lux/data/text.lux b/stdlib/source/parser/lux/data/text.lux index e02733f77..b6d86b35a 100644 --- a/stdlib/source/parser/lux/data/text.lux +++ b/stdlib/source/parser/lux/data/text.lux @@ -24,7 +24,7 @@ (type: .public Offset Nat) -(def: beginning +(def beginning Offset 0) @@ -39,7 +39,7 @@ [#basis Offset #distance Offset])) -(def: .public (slice parser) +(def .public (slice parser) (-> (Parser Slice) (Parser Text)) (do //.monad [[basis distance] parser] @@ -51,7 +51,7 @@ {.#None} (exception.except ..cannot_slice []))))) -(def: (left_over offset tape) +(def (left_over offset tape) (-> Offset Text Text) (|> tape (/.clip_since offset) maybe.trusted)) @@ -68,7 +68,7 @@ "Offset" (n#encoded offset) "Input" (..left_over offset tape))) -(def: .public (result parser input) +(def .public (result parser input) (All (_ a) (-> (Parser a) Text (Try a))) (case (parser [..beginning input]) {try.#Failure msg} @@ -79,12 +79,12 @@ {try.#Success output} (exception.except ..unconsumed_input [end_offset input])))) -(def: .public offset +(def .public offset (Parser Offset) (function (_ (^.let input [offset tape])) {try.#Success [input offset]})) -(def: (with_slices parser) +(def (with_slices parser) (-> (Parser (List Slice)) (Parser Slice)) (do //.monad [offset ..offset @@ -96,7 +96,7 @@ #distance 0] slices)))) -(def: .public any +(def .public any (Parser Text) (function (_ [offset tape]) (case (/.char offset tape) @@ -106,7 +106,7 @@ _ (exception.except ..cannot_parse [])))) -(def: .public any! +(def .public any! (Parser Slice) (function (_ [offset tape]) (case (/.char offset tape) @@ -119,7 +119,7 @@ (exception.except ..cannot_slice [])))) (with_template [<name> <type> <any>] - [(`` (def: .public (<name> parser) + [(`` (def .public (<name> parser) (All (_ a) (-> (Parser a) (Parser <type>))) (function (_ input) (case (parser input) @@ -137,7 +137,7 @@ (exception.report "Reference" (/.format reference))) -(def: .public (this reference) +(def .public (this reference) (-> Text (Parser Any)) (function (_ [offset tape]) (case (/.index_since offset reference tape) @@ -150,14 +150,14 @@ _ (exception.except ..cannot_match [reference])))) -(def: .public end +(def .public end (Parser Any) (function (_ (^.let input [offset tape])) (if (n.= offset (/.size tape)) {try.#Success [input []]} (exception.except ..unconsumed_input input)))) -(def: .public next +(def .public next (Parser Text) (function (_ (^.let input [offset tape])) (case (/.char offset tape) @@ -167,12 +167,12 @@ _ (exception.except ..cannot_parse [])))) -(def: .public remaining +(def .public remaining (Parser Text) (function (_ (^.let input [offset tape])) {try.#Success [input (..left_over offset tape)]})) -(def: .public (range bottom top) +(def .public (range bottom top) (-> Nat Nat (Parser Text)) (do //.monad [char any @@ -182,7 +182,7 @@ (n.<= top char')))] (in char))) -(def: .public (range! bottom top) +(def .public (range! bottom top) (-> Nat Nat (Parser Slice)) (do //.monad [it ..any! @@ -194,11 +194,11 @@ (in it))) (with_template [<bottom> <top> <text> <slice>] - [(def: .public <text> + [(def .public <text> (Parser Text) (..range (char <bottom>) (char <top>))) - (def: .public <slice> + (def .public <slice> (Parser Slice) (..range! (char <bottom>) (char <top>)))] @@ -208,20 +208,20 @@ ["0" "7" octal octal!] ) -(def: .public alpha (Parser Text) (//.either ..lower ..upper)) -(def: .public alpha! (Parser Slice) (//.either ..lower! ..upper!)) +(def .public alpha (Parser Text) (//.either ..lower ..upper)) +(def .public alpha! (Parser Slice) (//.either ..lower! ..upper!)) -(def: .public alpha_num (Parser Text) (//.either ..alpha ..decimal)) -(def: .public alpha_num! (Parser Slice) (//.either ..alpha! ..decimal!)) +(def .public alpha_num (Parser Text) (//.either ..alpha ..decimal)) +(def .public alpha_num! (Parser Slice) (//.either ..alpha! ..decimal!)) -(def: .public hexadecimal +(def .public hexadecimal (Parser Text) (all //.either ..decimal (..range (char "a") (char "f")) (..range (char "A") (char "F")))) -(def: .public hexadecimal! +(def .public hexadecimal! (Parser Slice) (all //.either ..decimal! @@ -240,7 +240,7 @@ ) (with_template [<name> <modifier> <exception>] - [(def: .public (<name> options) + [(def .public (<name> options) (-> Text (Parser Text)) (function (_ [offset tape]) (case (/.char offset tape) @@ -258,7 +258,7 @@ ) (with_template [<name> <modifier> <exception>] - [(def: .public (<name> options) + [(def .public (<name> options) (-> Text (Parser Slice)) (function (_ [offset tape]) (case (/.char offset tape) @@ -281,7 +281,7 @@ (exception.report "Character" (/.format (/.of_char character)))) -(def: .public (satisfies parser) +(def .public (satisfies parser) (-> (-> Char Bit) (Parser Text)) (function (_ [offset tape]) (case (/.char offset tape) @@ -293,7 +293,7 @@ _ (exception.except ..cannot_parse [])))) -(def: .public (satisfies! parser) +(def .public (satisfies! parser) (-> (-> Char Bit) (Parser Slice)) (function (_ [offset tape]) (case (/.char offset tape) @@ -306,22 +306,22 @@ _ (exception.except ..cannot_parse [])))) -(def: .public space +(def .public space (Parser Text) (..satisfies /.space?)) -(def: .public space! +(def .public space! (Parser Slice) (..satisfies! /.space?)) -(def: .public (and left right) +(def .public (and left right) (-> (Parser Text) (Parser Text) (Parser Text)) (do //.monad [=left left =right right] (in (all /#composite =left =right)))) -(def: .public (and! left right) +(def .public (and! left right) (-> (Parser Slice) (Parser Slice) (Parser Slice)) (do //.monad [(open "left[0]") left @@ -329,7 +329,7 @@ (in [left#basis ("lux i64 +" left#distance right#distance)]))) (with_template [<name> <base> <doc_modifier>] - [(def: .public (<name> parser) + [(def .public (<name> parser) (-> (Parser Text) (Parser Text)) (|> parser <base> (at //.monad each /.together)))] @@ -338,7 +338,7 @@ ) (with_template [<name> <base> <doc_modifier>] - [(def: .public (<name> parser) + [(def .public (<name> parser) (-> (Parser Slice) (Parser Slice)) (with_slices (<base> parser)))] @@ -347,7 +347,7 @@ ) (with_template [<name> <base> <doc_modifier>] - [(def: .public (<name> amount parser) + [(def .public (<name> amount parser) (-> Nat (Parser Text) (Parser Text)) (|> parser (<base> amount) @@ -359,7 +359,7 @@ ) (with_template [<name> <base> <doc_modifier>] - [(def: .public (<name> amount parser) + [(def .public (<name> amount parser) (-> Nat (Parser Slice) (Parser Slice)) (with_slices (<base> amount parser)))] @@ -369,24 +369,24 @@ [at_least! //.at_least "at least"] ) -(def: .public (between minimum additional parser) +(def .public (between minimum additional parser) (-> Nat Nat (Parser Text) (Parser Text)) (|> parser (//.between minimum additional) (at //.monad each /.together))) -(def: .public (between! minimum additional parser) +(def .public (between! minimum additional parser) (-> Nat Nat (Parser Slice) (Parser Slice)) (with_slices (//.between minimum additional parser))) -(def: .public (enclosed [start end] parser) +(def .public (enclosed [start end] parser) (All (_ a) (-> [Text Text] (Parser a) (Parser a))) (|> parser (//.before (this end)) (//.after (this start)))) -(def: .public (local local_input parser) +(def .public (local local_input parser) (All (_ a) (-> Text (Parser a) (Parser a))) (function (_ real_input) (case (..result parser local_input) @@ -396,7 +396,7 @@ {try.#Success value} {try.#Success [real_input value]}))) -(def: .public (then structured text) +(def .public (then structured text) (All (_ s a) (-> (Parser a) (//.Parser s Text) |