diff options
Diffstat (limited to 'stdlib/source/library/lux/control/parser')
-rw-r--r-- | stdlib/source/library/lux/control/parser/analysis.lux | 34 | ||||
-rw-r--r-- | stdlib/source/library/lux/control/parser/binary.lux | 71 | ||||
-rw-r--r-- | stdlib/source/library/lux/control/parser/cli.lux | 38 | ||||
-rw-r--r-- | stdlib/source/library/lux/control/parser/code.lux | 106 | ||||
-rw-r--r-- | stdlib/source/library/lux/control/parser/environment.lux | 6 | ||||
-rw-r--r-- | stdlib/source/library/lux/control/parser/json.lux | 64 | ||||
-rw-r--r-- | stdlib/source/library/lux/control/parser/synthesis.lux | 36 | ||||
-rw-r--r-- | stdlib/source/library/lux/control/parser/text.lux | 58 | ||||
-rw-r--r-- | stdlib/source/library/lux/control/parser/tree.lux | 8 | ||||
-rw-r--r-- | stdlib/source/library/lux/control/parser/type.lux | 86 | ||||
-rw-r--r-- | stdlib/source/library/lux/control/parser/xml.lux | 60 |
11 files changed, 282 insertions, 285 deletions
diff --git a/stdlib/source/library/lux/control/parser/analysis.lux b/stdlib/source/library/lux/control/parser/analysis.lux index 0c5f47cb3..03b29e3f3 100644 --- a/stdlib/source/library/lux/control/parser/analysis.lux +++ b/stdlib/source/library/lux/control/parser/analysis.lux @@ -53,39 +53,39 @@ (def: .public (result parser input) (All (_ a) (-> (Parser a) (List Analysis) (Try a))) (case (parser input) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [#.End value]} - {#try.Success value} + {try.#Success [{.#End} value]} + {try.#Success value} - {#try.Success [unconsumed _]} + {try.#Success [unconsumed _]} (exception.except ..unconsumed_input unconsumed))) (def: .public any (Parser Analysis) (function (_ input) (case input - #.End + {.#End} (exception.except ..cannot_parse input) - {#.Item [head tail]} - {#try.Success [tail head]}))) + {.#Item [head tail]} + {try.#Success [tail head]}))) (def: .public end! (Parser Any) (function (_ tokens) (case tokens - #.End {#try.Success [tokens []]} - _ {#try.Failure (format "Expected list of tokens to be empty!" - (remaining_inputs tokens))}))) + {.#End} {try.#Success [tokens []]} + _ {try.#Failure (format "Expected list of tokens to be empty!" + (remaining_inputs tokens))}))) (def: .public end? (Parser Bit) (function (_ tokens) - {#try.Success [tokens (case tokens - #.End true - _ false)]})) + {try.#Success [tokens (case tokens + {.#End} true + _ false)]})) (template [<query> <assertion> <tag> <type> <eq>] [(`` (as_is (def: .public <query> @@ -93,7 +93,7 @@ (function (_ input) (case input (^ (list& (<tag> x) input')) - {#try.Success [input' x]} + {try.#Success [input' x]} _ (exception.except ..cannot_parse input)))) @@ -104,7 +104,7 @@ (case input (^ (list& (<tag> actual) input')) (if (\ <eq> = expected actual) - {#try.Success [input' []]} + {try.#Success [input' []]} (exception.except ..cannot_parse input)) _ @@ -128,7 +128,7 @@ (^ (list& (/.tuple head) tail)) (do try.monad [output (..result parser head)] - {#try.Success [tail output]}) + {try.#Success [tail output]}) _ (exception.except ..cannot_parse input)))) diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux index 0f5e925e1..c37298d24 100644 --- a/stdlib/source/library/lux/control/parser/binary.lux +++ b/stdlib/source/library/lux/control/parser/binary.lux @@ -41,29 +41,29 @@ (def: .public (result parser input) (All (_ a) (-> (Parser a) Binary (Try a))) (case (parser [0 input]) - {#try.Failure msg} - {#try.Failure msg} + {try.#Failure msg} + {try.#Failure msg} - {#try.Success [[end _] output]} + {try.#Success [[end _] output]} (let [length (/.size input)] (if (n.= end length) - {#try.Success output} + {try.#Success output} (exception.except ..binary_was_not_fully_read [length end]))))) (def: .public end? (Parser Bit) (function (_ (^@ input [offset data])) - {#try.Success [input (n.= offset (/.size data))]})) + {try.#Success [input (n.= offset (/.size data))]})) (def: .public offset (Parser Offset) (function (_ (^@ input [offset data])) - {#try.Success [input offset]})) + {try.#Success [input offset]})) (def: .public remaining (Parser Nat) (function (_ (^@ input [offset data])) - {#try.Success [input (n.- offset (/.size data))]})) + {try.#Success [input (n.- offset (/.size data))]})) (type: .public Size Nat) @@ -78,11 +78,11 @@ (Parser I64) (function (_ [offset binary]) (case (<read> offset binary) - {#try.Success data} - {#try.Success [(n.+ <size> offset) binary] data} + {try.#Success data} + {try.#Success [(n.+ <size> offset) binary] data} - {#try.Failure error} - {#try.Failure error})))] + {try.#Failure error} + {try.#Failure error})))] [bits/8 ..size/8 /.read/8!] [bits/16 ..size/16 /.read/16!] @@ -122,8 +122,8 @@ (def: .public (or left right) (All (_ l r) (-> (Parser l) (Parser r) (Parser (Or l r)))) - (!variant [[0 [#.Left] left] - [1 [#.Right] right]])) + (!variant [[0 [.#Left] left] + [1 [.#Right] right]])) (def: .public (rec body) (All (_ a) (-> (-> (Parser a) (Parser a)) (Parser a))) @@ -154,7 +154,7 @@ (-> Nat (Parser Binary)) (function (_ [offset binary]) (case size - 0 {#try.Success [[offset binary] (/.empty 0)]} + 0 {try.#Success [[offset binary] (/.empty 0)]} _ (|> binary (/.slice offset size) (\ try.monad each (|>> [[(n.+ size offset) binary]])))))) @@ -246,17 +246,17 @@ (let [pair (//.and type type) indexed ..nat quantified (//.and (..list type) type)] - (!variant [[0 [#.Primitive] (//.and ..text (..list type))] - [1 [#.Sum] pair] - [2 [#.Product] pair] - [3 [#.Function] pair] - [4 [#.Parameter] indexed] - [5 [#.Var] indexed] - [6 [#.Ex] indexed] - [7 [#.UnivQ] quantified] - [8 [#.ExQ] quantified] - [9 [#.Apply] pair] - [10 [#.Named] (//.and ..name type)]]))))) + (!variant [[0 [.#Primitive] (//.and ..text (..list type))] + [1 [.#Sum] pair] + [2 [.#Product] pair] + [3 [.#Function] pair] + [4 [.#Parameter] indexed] + [5 [.#Var] indexed] + [6 [.#Ex] indexed] + [7 [.#UnivQ] quantified] + [8 [.#ExQ] quantified] + [9 [.#Apply] pair] + [10 [.#Named] (//.and ..name type)]]))))) (def: .public location (Parser Location) @@ -268,14 +268,13 @@ (function (_ recur) (let [sequence (..list recur)] (//.and ..location - (!variant [[00 [#.Bit] ..bit] - [01 [#.Nat] ..nat] - [02 [#.Int] ..int] - [03 [#.Rev] ..rev] - [04 [#.Frac] ..frac] - [05 [#.Text] ..text] - [06 [#.Identifier] ..name] - [07 [#.Tag] ..name] - [08 [#.Form] sequence] - [09 [#.Variant] sequence] - [10 [#.Tuple] sequence]])))))) + (!variant [[0 [.#Bit] ..bit] + [1 [.#Nat] ..nat] + [2 [.#Int] ..int] + [3 [.#Rev] ..rev] + [4 [.#Frac] ..frac] + [5 [.#Text] ..text] + [6 [.#Identifier] ..name] + [7 [.#Form] sequence] + [8 [.#Variant] sequence] + [9 [.#Tuple] sequence]])))))) diff --git a/stdlib/source/library/lux/control/parser/cli.lux b/stdlib/source/library/lux/control/parser/cli.lux index aca4512fb..f68605f14 100644 --- a/stdlib/source/library/lux/control/parser/cli.lux +++ b/stdlib/source/library/lux/control/parser/cli.lux @@ -16,26 +16,26 @@ (def: .public (result parser inputs) (All (_ a) (-> (Parser a) (List Text) (Try a))) (case (//.result parser inputs) - {#try.Success [remaining output]} + {try.#Success [remaining output]} (case remaining - #.End - {#try.Success output} + {.#End} + {try.#Success output} _ - {#try.Failure (format "Remaining CLI inputs: " (text.interposed " " remaining))}) + {try.#Failure (format "Remaining CLI inputs: " (text.interposed " " remaining))}) - {#try.Failure try} - {#try.Failure try})) + {try.#Failure try} + {try.#Failure try})) (def: .public any (Parser Text) (function (_ inputs) (case inputs - {#.Item arg inputs'} - {#try.Success [inputs' arg]} + {.#Item arg inputs'} + {try.#Success [inputs' arg]} _ - {#try.Failure "Cannot parse empty arguments."}))) + {try.#Failure "Cannot parse empty arguments."}))) (def: .public (parse parser) (All (_ a) (-> (-> Text (Try a)) (Parser a))) @@ -52,33 +52,33 @@ [[remaining raw] (any inputs)] (if (text\= reference raw) (in [remaining []]) - {#try.Failure (format "Missing token: '" reference "'")})))) + {try.#Failure (format "Missing token: '" reference "'")})))) (def: .public (somewhere cli) (All (_ a) (-> (Parser a) (Parser a))) (function (_ inputs) (loop [immediate inputs] (case (//.result cli immediate) - {#try.Success [remaining output]} - {#try.Success [remaining output]} + {try.#Success [remaining output]} + {try.#Success [remaining output]} - {#try.Failure try} + {try.#Failure try} (case immediate - #.End - {#try.Failure try} + {.#End} + {try.#Failure try} - {#.Item to_omit immediate'} + {.#Item to_omit immediate'} (do try.monad [[remaining output] (recur immediate')] - (in [{#.Item to_omit remaining} + (in [{.#Item to_omit remaining} output]))))))) (def: .public end (Parser Any) (function (_ inputs) (case inputs - #.End {#try.Success [inputs []]} - _ {#try.Failure (format "Unknown parameters: " (text.interposed " " inputs))}))) + {.#End} {try.#Success [inputs []]} + _ {try.#Failure (format "Unknown parameters: " (text.interposed " " inputs))}))) (def: .public (named name value) (All (_ a) (-> Text (Parser a) (Parser a))) diff --git a/stdlib/source/library/lux/control/parser/code.lux b/stdlib/source/library/lux/control/parser/code.lux index d58874cf4..4e31cb1b4 100644 --- a/stdlib/source/library/lux/control/parser/code.lux +++ b/stdlib/source/library/lux/control/parser/code.lux @@ -24,8 +24,8 @@ (def: (un_paired pairs) (All (_ a) (-> (List [a a]) (List a))) (case pairs - #.End #.End - {#.Item [[x y] pairs']} (list& x y (un_paired pairs')))) + {.#End} {.#End} + {.#Item [[x y] pairs']} (list& x y (un_paired pairs')))) (type: .public Parser (//.Parser (List Code))) @@ -40,30 +40,30 @@ (Parser Code) (function (_ tokens) (case tokens - #.End - {#try.Failure "There are no tokens to parse!"} + {.#End} + {try.#Failure "There are no tokens to parse!"} - {#.Item [t tokens']} - {#try.Success [tokens' t]}))) + {.#Item [t tokens']} + {try.#Success [tokens' t]}))) (def: .public next (Parser Code) (function (_ tokens) (case tokens - #.End - {#try.Failure "There are no tokens to parse!"} + {.#End} + {try.#Failure "There are no tokens to parse!"} - {#.Item next _} - {#try.Success [tokens next]}))) + {.#Item next _} + {try.#Success [tokens next]}))) (template [<query> <check> <type> <tag> <eq> <desc>] - [(with_expansions [<failure> (as_is {#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})] + [(with_expansions [<failure> (as_is {try.#Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})] (def: .public <query> (Parser <type>) (function (_ tokens) (case tokens - {#.Item [[_ {<tag> x}] tokens']} - {#try.Success [tokens' x]} + {.#Item [[_ {<tag> x}] tokens']} + {try.#Success [tokens' x]} _ <failure>))) @@ -72,45 +72,44 @@ (-> <type> (Parser Any)) (function (_ tokens) (case tokens - {#.Item [[_ {<tag> actual}] tokens']} + {.#Item [[_ {<tag> actual}] tokens']} (if (\ <eq> = expected actual) - {#try.Success [tokens' []]} + {try.#Success [tokens' []]} <failure>) _ <failure>))))] - [bit bit! Bit #.Bit bit.equivalence "bit"] - [nat nat! Nat #.Nat nat.equivalence "nat"] - [int int! Int #.Int int.equivalence "int"] - [rev rev! Rev #.Rev rev.equivalence "rev"] - [frac frac! Frac #.Frac frac.equivalence "frac"] - [text text! Text #.Text text.equivalence "text"] - [identifier identifier! Name #.Identifier name.equivalence "identifier"] - [tag tag! Name #.Tag name.equivalence "tag"] + [bit bit! Bit .#Bit bit.equivalence "bit"] + [nat nat! Nat .#Nat nat.equivalence "nat"] + [int int! Int .#Int int.equivalence "int"] + [rev rev! Rev .#Rev rev.equivalence "rev"] + [frac frac! Frac .#Frac frac.equivalence "frac"] + [text text! Text .#Text text.equivalence "text"] + [identifier identifier! Name .#Identifier name.equivalence "identifier"] ) (def: .public (this! code) (-> Code (Parser Any)) (function (_ tokens) (case tokens - {#.Item [token tokens']} + {.#Item [token tokens']} (if (code\= code token) - {#try.Success [tokens' []]} - {#try.Failure ($_ text\composite "Expected a " (code.format code) " but instead got " (code.format token) + {try.#Success [tokens' []]} + {try.#Failure ($_ text\composite "Expected a " (code.format code) " but instead got " (code.format token) (remaining_inputs tokens))}) _ - {#try.Failure "There are no tokens to parse!"}))) + {try.#Failure "There are no tokens to parse!"}))) (template [<query> <check> <tag> <eq> <desc>] - [(with_expansions [<failure> (as_is {#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})] + [(with_expansions [<failure> (as_is {try.#Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})] (def: .public <query> (Parser Text) (function (_ tokens) (case tokens - {#.Item [[_ {<tag> ["" x]}] tokens']} - {#try.Success [tokens' x]} + {.#Item [[_ {<tag> ["" x]}] tokens']} + {try.#Success [tokens' x]} _ <failure>))) @@ -119,16 +118,15 @@ (-> Text (Parser Any)) (function (_ tokens) (case tokens - {#.Item [[_ {<tag> ["" actual]}] tokens']} + {.#Item [[_ {<tag> ["" actual]}] tokens']} (if (\ <eq> = expected actual) - {#try.Success [tokens' []]} + {try.#Success [tokens' []]} <failure>) _ <failure>))))] - [local_identifier local_identifier! #.Identifier text.equivalence "local identifier"] - [ local_tag local_tag! #.Tag text.equivalence "local tag"] + [local_identifier local_identifier! .#Identifier text.equivalence "local identifier"] ) (template [<name> <tag> <desc>] @@ -137,46 +135,46 @@ (-> (Parser a) (Parser a))) (function (_ tokens) (case tokens - {#.Item [[_ {<tag> members}] tokens']} + {.#Item [[_ {<tag> members}] tokens']} (case (p members) - {#try.Success [#.End x]} {#try.Success [tokens' x]} - _ {#try.Failure ($_ text\composite "Parser was expected to fully consume " <desc> (remaining_inputs tokens))}) + {try.#Success [{.#End} x]} {try.#Success [tokens' x]} + _ {try.#Failure ($_ text\composite "Parser was expected to fully consume " <desc> (remaining_inputs tokens))}) _ - {#try.Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})))] + {try.#Failure ($_ text\composite "Cannot parse " <desc> (remaining_inputs tokens))})))] - [form #.Form "form"] - [variant #.Variant "variant"] - [tuple #.Tuple "tuple"] + [form .#Form "form"] + [variant .#Variant "variant"] + [tuple .#Tuple "tuple"] ) (def: .public end! (Parser Any) (function (_ tokens) (case tokens - #.End {#try.Success [tokens []]} - _ {#try.Failure ($_ text\composite "Expected list of tokens to be empty!" (remaining_inputs tokens))}))) + {.#End} {try.#Success [tokens []]} + _ {try.#Failure ($_ text\composite "Expected list of tokens to be empty!" (remaining_inputs tokens))}))) (def: .public end? (Parser Bit) (function (_ tokens) - {#try.Success [tokens (case tokens - #.End true - _ false)]})) + {try.#Success [tokens (case tokens + {.#End} true + _ false)]})) (def: .public (result parser inputs) (All (_ a) (-> (Parser a) (List Code) (Try a))) (case (parser inputs) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [unconsumed value]} + {try.#Success [unconsumed value]} (case unconsumed - #.End - {#try.Success value} + {.#End} + {try.#Success value} _ - {#try.Failure (|> unconsumed + {try.#Failure (|> unconsumed (list\each code.format) (text.interposed ", ") (text\composite "Unconsumed inputs: "))}))) @@ -195,5 +193,5 @@ result (//.or parser ..any)] (case result - {#.Left _} (//.failure (text\composite "Did NOT expect to parse code: " (code.format sample))) - {#.Right output} (in output)))) + {.#Left _} (//.failure (text\composite "Did NOT expect to parse code: " (code.format sample))) + {.#Right output} (in output)))) diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux index ce254222e..b6a788e24 100644 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ b/stdlib/source/library/lux/control/parser/environment.lux @@ -33,10 +33,10 @@ (-> Property (Parser Text)) (function (_ environment) (case (dictionary.value name environment) - {#.Some value} - {#try.Success [environment value]} + {.#Some value} + {try.#Success [environment value]} - #.None + {.#None} (exception.except ..unknown_property [name])))) (def: .public (result parser environment) diff --git a/stdlib/source/library/lux/control/parser/json.lux b/stdlib/source/library/lux/control/parser/json.lux index 3a0d76c1f..979d7c8a8 100644 --- a/stdlib/source/library/lux/control/parser/json.lux +++ b/stdlib/source/library/lux/control/parser/json.lux @@ -34,26 +34,26 @@ (def: .public (result parser json) (All (_ a) (-> (Parser a) JSON (Try a))) (case (//.result parser (list json)) - {#try.Success [remainder output]} + {try.#Success [remainder output]} (case remainder - #.End - {#try.Success output} + {.#End} + {try.#Success output} _ (exception.except ..unconsumed_input remainder)) - {#try.Failure error} - {#try.Failure error})) + {try.#Failure error} + {try.#Failure error})) (def: .public any (Parser JSON) (<| (function (_ inputs)) (case inputs - #.End + {.#End} (exception.except ..empty_input []) - {#.Item head tail} - {#try.Success [tail head]}))) + {.#Item head tail} + {try.#Success [tail head]}))) (exception: .public (unexpected_value [value JSON]) (exception.report @@ -71,10 +71,10 @@ _ (//.failure (exception.error ..unexpected_value [head])))))] - [null /.Null #/.Null] - [boolean /.Boolean #/.Boolean] - [number /.Number #/.Number] - [string /.String #/.String] + [null /.Null /.#Null] + [boolean /.Boolean /.#Boolean] + [number /.Number /.#Number] + [string /.String /.#String] ) (exception: .public [a] (value_mismatch [reference JSON @@ -108,9 +108,9 @@ _ (//.failure (exception.error ..unexpected_value [head])))))] - [boolean? boolean! /.Boolean bit.equivalence #/.Boolean] - [number? number! /.Number frac.equivalence #/.Number] - [string? string! /.String text.equivalence #/.String] + [boolean? boolean! /.Boolean bit.equivalence /.#Boolean] + [number? number! /.Number frac.equivalence /.#Number] + [string? string! /.String text.equivalence /.#String] ) (def: .public (nullable parser) @@ -123,14 +123,14 @@ (do //.monad [head ..any] (case head - {#/.Array values} + {/.#Array values} (case (//.result parser (row.list values)) - {#try.Failure error} + {try.#Failure error} (//.failure error) - {#try.Success [remainder output]} + {try.#Success [remainder output]} (case remainder - #.End + {.#End} (in output) _ @@ -144,19 +144,19 @@ (do //.monad [head ..any] (case head - {#/.Object kvs} + {/.#Object kvs} (case (|> kvs dictionary.entries (list\each (function (_ [key value]) - (list {#/.String key} value))) + (list {/.#String key} value))) list.together (//.result parser)) - {#try.Failure error} + {try.#Failure error} (//.failure error) - {#try.Success [remainder output]} + {try.#Success [remainder output]} (case remainder - #.End + {.#End} (in output) _ @@ -169,23 +169,23 @@ (All (_ a) (-> Text (Parser a) (Parser a))) (function (recur inputs) (case inputs - (^ (list& {#/.String key} value inputs')) + (^ (list& {/.#String key} value inputs')) (if (text\= key field_name) (case (//.result parser (list value)) - {#try.Success [#.End output]} - {#try.Success [inputs' output]} + {try.#Success [{.#End} output]} + {try.#Success [inputs' output]} - {#try.Success [inputs'' _]} + {try.#Success [inputs'' _]} (exception.except ..unconsumed_input inputs'') - {#try.Failure error} - {#try.Failure error}) + {try.#Failure error} + {try.#Failure error}) (do try.monad [[inputs'' output] (recur inputs')] - (in [(list& {#/.String key} value inputs'') + (in [(list& {/.#String key} value inputs'') output]))) - #.End + {.#End} (exception.except ..empty_input []) _ diff --git a/stdlib/source/library/lux/control/parser/synthesis.lux b/stdlib/source/library/lux/control/parser/synthesis.lux index 1578f9115..0a8db3267 100644 --- a/stdlib/source/library/lux/control/parser/synthesis.lux +++ b/stdlib/source/library/lux/control/parser/synthesis.lux @@ -53,38 +53,38 @@ (def: .public (result parser input) (All (_ a) (-> (Parser a) (List Synthesis) (Try a))) (case (parser input) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [#.End value]} - {#try.Success value} + {try.#Success [{.#End} value]} + {try.#Success value} - {#try.Success [unconsumed _]} + {try.#Success [unconsumed _]} (exception.except ..unconsumed_input unconsumed))) (def: .public any (Parser Synthesis) (.function (_ input) (case input - #.End + {.#End} (exception.except ..empty_input []) - {#.Item [head tail]} - {#try.Success [tail head]}))) + {.#Item [head tail]} + {try.#Success [tail head]}))) (def: .public end! (Parser Any) (.function (_ tokens) (case tokens - #.End {#try.Success [tokens []]} - _ (exception.except ..expected_empty_input [tokens])))) + {.#End} {try.#Success [tokens []]} + _ (exception.except ..expected_empty_input [tokens])))) (def: .public end? (Parser Bit) (.function (_ tokens) - {#try.Success [tokens (case tokens - #.End true - _ false)]})) + {try.#Success [tokens (case tokens + {.#End} true + _ false)]})) (template [<query> <assertion> <tag> <type> <eq>] [(`` (def: .public <query> @@ -92,7 +92,7 @@ (.function (_ input) (case input (^ (list& (<tag> x) input')) - {#try.Success [input' x]} + {try.#Success [input' x]} _ (exception.except ..cannot_parse input))))) @@ -103,7 +103,7 @@ (case input (^ (list& (<tag> actual) input')) (if (\ <eq> = expected actual) - {#try.Success [input' []]} + {try.#Success [input' []]} (exception.except ..cannot_parse input)) _ @@ -125,7 +125,7 @@ (^ (list& (/.tuple head) tail)) (do try.monad [output (..result parser head)] - {#try.Success [tail output]}) + {try.#Success [tail output]}) _ (exception.except ..cannot_parse input)))) @@ -138,7 +138,7 @@ (if (n.= expected actual) (do try.monad [output (..result parser (list body))] - {#try.Success [tail [environment output]]}) + {try.#Success [tail [environment output]]}) (exception.except ..wrong_arity [expected actual])) _ @@ -152,7 +152,7 @@ (do try.monad [inits (..result init_parsers inits) iteration (..result iteration_parser (list iteration))] - {#try.Success [tail [start inits iteration]]}) + {try.#Success [tail [start inits iteration]]}) _ (exception.except ..cannot_parse input)))) diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/library/lux/control/parser/text.lux index 8594dc353..b887806ba 100644 --- a/stdlib/source/library/lux/control/parser/text.lux +++ b/stdlib/source/library/lux/control/parser/text.lux @@ -58,18 +58,18 @@ (def: .public (result parser input) (All (_ a) (-> (Parser a) Text (Try a))) (case (parser [start_offset input]) - {#try.Failure msg} - {#try.Failure msg} + {try.#Failure msg} + {try.#Failure msg} - {#try.Success [[end_offset _] output]} + {try.#Success [[end_offset _] output]} (if (n.= end_offset (/.size input)) - {#try.Success output} + {try.#Success output} (exception.except ..unconsumed_input [end_offset input])))) (def: .public offset (Parser Offset) (function (_ (^@ input [offset tape])) - {#try.Success [input offset]})) + {try.#Success [input offset]})) (def: (with_slices parser) (-> (Parser (List Slice)) (Parser Slice)) @@ -87,8 +87,8 @@ (Parser Text) (function (_ [offset tape]) (case (/.char offset tape) - {#.Some output} - {#try.Success [[("lux i64 +" 1 offset) tape] (/.of_char output)]} + {.#Some output} + {try.#Success [[("lux i64 +" 1 offset) tape] (/.of_char output)]} _ (exception.except ..cannot_parse [])))) @@ -97,8 +97,8 @@ (Parser Slice) (function (_ [offset tape]) (case (/.char offset tape) - {#.Some _} - {#try.Success [[("lux i64 +" 1 offset) tape] + {.#Some _} + {try.#Success [[("lux i64 +" 1 offset) tape] [#basis offset #distance 1]]} @@ -110,7 +110,7 @@ (All (_ a) (-> (Parser a) (Parser <type>))) (function (_ input) (case (parser input) - {#try.Failure msg} + {try.#Failure msg} (<any> input) _ @@ -128,9 +128,9 @@ (-> Text (Parser Any)) (function (_ [offset tape]) (case (/.index_since offset reference tape) - {#.Some where} + {.#Some where} (if (n.= offset where) - {#try.Success [[("lux i64 +" (/.size reference) offset) tape] + {try.#Success [[("lux i64 +" (/.size reference) offset) tape] []]} (exception.except ..cannot_match [reference])) @@ -141,15 +141,15 @@ (Parser Any) (function (_ (^@ input [offset tape])) (if (n.= offset (/.size tape)) - {#try.Success [input []]} + {try.#Success [input []]} (exception.except ..unconsumed_input input)))) (def: .public next (Parser Text) (function (_ (^@ input [offset tape])) (case (/.char offset tape) - {#.Some output} - {#try.Success [input (/.of_char output)]} + {.#Some output} + {try.#Success [input (/.of_char output)]} _ (exception.except ..cannot_parse [])))) @@ -157,7 +157,7 @@ (def: .public remaining (Parser Text) (function (_ (^@ input [offset tape])) - {#try.Success [input (..left_over offset tape)]})) + {try.#Success [input (..left_over offset tape)]})) (def: .public (range bottom top) (-> Nat Nat (Parser Text)) @@ -211,10 +211,10 @@ (-> Text (Parser Text)) (function (_ [offset tape]) (case (/.char offset tape) - {#.Some output} + {.#Some output} (let [output' (/.of_char output)] (if (<modifier> (/.contains? output' options)) - {#try.Success [[("lux i64 +" 1 offset) tape] output']} + {try.#Success [[("lux i64 +" 1 offset) tape] output']} (exception.except <exception> [options output]))) _ @@ -229,10 +229,10 @@ (-> Text (Parser Slice)) (function (_ [offset tape]) (case (/.char offset tape) - {#.Some output} + {.#Some output} (let [output' (/.of_char output)] (if (<modifier> (/.contains? output' options)) - {#try.Success [[("lux i64 +" 1 offset) tape] + {try.#Success [[("lux i64 +" 1 offset) tape] [#basis offset #distance 1]]} (exception.except <exception> [options output]))) @@ -252,9 +252,9 @@ (-> (-> Char Bit) (Parser Text)) (function (_ [offset tape]) (case (/.char offset tape) - {#.Some output} + {.#Some output} (if (parser output) - {#try.Success [[("lux i64 +" 1 offset) tape] (/.of_char output)]} + {try.#Success [[("lux i64 +" 1 offset) tape] (/.of_char output)]} (exception.except ..character_does_not_satisfy_predicate [output])) _ @@ -340,11 +340,11 @@ (All (_ a) (-> Text (Parser a) (Parser a))) (function (_ real_input) (case (..result parser local_input) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success value} - {#try.Success [real_input value]}))) + {try.#Success value} + {try.#Success [real_input value]}))) (def: .public (slice parser) (-> (Parser Slice) (Parser Text)) @@ -352,10 +352,10 @@ [[basis distance] parser] (function (_ (^@ input [offset tape])) (case (/.clip basis distance tape) - {#.Some output} - {#try.Success [input output]} + {.#Some output} + {try.#Success [input output]} - #.None + {.#None} (exception.except ..cannot_slice []))))) (def: .public (then structured text) diff --git a/stdlib/source/library/lux/control/parser/tree.lux b/stdlib/source/library/lux/control/parser/tree.lux index 68b4336a5..4d331c84f 100644 --- a/stdlib/source/library/lux/control/parser/tree.lux +++ b/stdlib/source/library/lux/control/parser/tree.lux @@ -28,7 +28,7 @@ (def: .public value (All (_ t) (Parser t t)) (function (_ zipper) - {#try.Success [zipper (zipper.value zipper)]})) + {try.#Success [zipper (zipper.value zipper)]})) (exception: .public cannot_move_further) @@ -37,11 +37,11 @@ (All (_ t) (Parser t [])) (function (_ zipper) (case (<direction> zipper) - #.None + {.#None} (exception.except ..cannot_move_further []) - {#.Some next} - {#try.Success [next []]})))] + {.#Some next} + {try.#Success [next []]})))] [down zipper.down] [up zipper.up] diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index 4e2414934..29fab0aa4 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -23,7 +23,7 @@ ["[0]" //]) (template: (|recursion_dummy|) - [{#.Primitive "" #.End}]) + [{.#Primitive "" {.#End}}]) (template [<name>] [(exception: .public (<name> [type Type]) @@ -74,13 +74,13 @@ (def: (result' env poly types) (All (_ a) (-> Env (Parser a) (List Type) (Try a))) (case (//.result poly [env types]) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [[env' remaining] output]} + {try.#Success [[env' remaining] output]} (case remaining - #.End - {#try.Success output} + {.#End} + {try.#Success output} _ (exception.except ..unconsumed_input remaining)))) @@ -92,47 +92,47 @@ (def: .public env (Parser Env) (.function (_ [env inputs]) - {#try.Success [[env inputs] env]})) + {try.#Success [[env inputs] env]})) (def: (with_env temp poly) (All (_ a) (-> Env (Parser a) (Parser a))) (.function (_ [env inputs]) (case (//.result poly [temp inputs]) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [[_ remaining] output]} - {#try.Success [[env remaining] output]}))) + {try.#Success [[_ remaining] output]} + {try.#Success [[env remaining] output]}))) (def: .public next (Parser Type) (.function (_ [env inputs]) (case inputs - #.End + {.#End} (exception.except ..empty_input []) - {#.Item headT tail} - {#try.Success [[env inputs] headT]}))) + {.#Item headT tail} + {try.#Success [[env inputs] headT]}))) (def: .public any (Parser Type) (.function (_ [env inputs]) (case inputs - #.End + {.#End} (exception.except ..empty_input []) - {#.Item headT tail} - {#try.Success [[env tail] headT]}))) + {.#Item headT tail} + {try.#Success [[env tail] headT]}))) (def: .public (local types poly) (All (_ a) (-> (List Type) (Parser a) (Parser a))) (.function (_ [env pass_through]) (case (result' env poly types) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success output} - {#try.Success [[env pass_through] output]}))) + {try.#Success output} + {try.#Success [[env pass_through] output]}))) (def: (label idx) (-> Nat Code) @@ -146,13 +146,13 @@ (case (//.result poly [(dictionary.has current_id [type g!var] env) inputs]) - {#try.Failure error} - {#try.Failure error} + {try.#Failure error} + {try.#Failure error} - {#try.Success [[_ inputs'] output]} - {#try.Success [[env inputs'] [g!var output]]})))) + {try.#Success [[_ inputs'] output]} + {try.#Success [[env inputs'] [g!var output]]})))) -(template [<name> <flattener> <tag> <exception>] +(template [<name> <flattener> <exception>] [(`` (def: .public (<name> poly) (All (_ a) (-> (Parser a) (Parser a))) (do //.monad @@ -162,8 +162,8 @@ (local members poly) (//.failure (exception.error <exception> headT)))))))] - [variant type.flat_variant #.Sum ..not_variant] - [tuple type.flat_tuple #.Product ..not_tuple] + [variant type.flat_variant ..not_variant] + [tuple type.flat_tuple ..not_tuple] ) (def: polymorphic' @@ -192,8 +192,8 @@ (recur (++ current_arg) (|> env' (dictionary.has funcI [headT funcL]) - (dictionary.has (++ funcI) [{#.Parameter (++ funcI)} varL])) - {#.Item varL all_varsL})) + (dictionary.has (++ funcI) [{.#Parameter (++ funcI)} varL])) + {.#Item varL all_varsL})) (let [partialI (|> current_arg (n.* 2) (n.+ funcI)) partial_varI (++ partialI) partial_varL (label partial_varI) @@ -203,8 +203,8 @@ (recur (++ current_arg) (|> env' (dictionary.has partialI [(|recursion_dummy|) partialC]) - (dictionary.has partial_varI [{#.Parameter partial_varI} partial_varL])) - {#.Item partial_varL all_varsL}))) + (dictionary.has partial_varI [{.#Parameter partial_varI} partial_varL])) + {.#Item partial_varL all_varsL}))) [all_varsL env']))]] (<| (with_env env') (local (list non_poly)) @@ -229,7 +229,7 @@ .let [[funcT paramsT] (type.flat_application (type.anonymous headT))]] (if (n.= 0 (list.size paramsT)) (//.failure (exception.error ..not_application headT)) - (..local {#.Item funcT paramsT} poly)))) + (..local {.#Item funcT paramsT} poly)))) (template [<name> <test>] [(def: .public (<name> expected) @@ -258,12 +258,12 @@ [env ..env headT any] (case headT - {#.Parameter idx} + {.#Parameter idx} (case (dictionary.value (adjusted_idx env idx) env) - {#.Some [poly_type poly_code]} + {.#Some [poly_type poly_code]} (in poly_code) - #.None + {.#None} (//.failure (exception.error ..unknown_parameter headT))) _ @@ -275,10 +275,10 @@ [env ..env headT any] (case headT - {#.Parameter idx} + {.#Parameter idx} (if (n.= id (adjusted_idx env idx)) (in []) - (//.failure (exception.error ..wrong_parameter [{#.Parameter id} headT]))) + (//.failure (exception.error ..wrong_parameter [{.#Parameter id} headT]))) _ (//.failure (exception.error ..not_parameter headT))))) @@ -288,7 +288,7 @@ (do //.monad [headT any] (case headT - {#.Ex ex_id} + {.#Ex ex_id} (in ex_id) _ @@ -299,7 +299,7 @@ (do //.monad [inputT any] (case inputT - {#.Named name anonymousT} + {.#Named name anonymousT} (in [name anonymousT]) _ @@ -310,7 +310,7 @@ (do [! //.monad] [headT any] (case (type.anonymous headT) - (^ {#.Apply (|recursion_dummy|) {#.UnivQ _ headT'}}) + (^ {.#Apply (|recursion_dummy|) {.#UnivQ _ headT'}}) (do ! [[recT _ output] (|> poly (with_extension (|recursion_dummy|)) @@ -327,9 +327,9 @@ [env ..env headT any] (case (type.anonymous headT) - (^multi (^ {#.Apply (|recursion_dummy|) {#.Parameter funcT_idx}}) + (^multi (^ {.#Apply (|recursion_dummy|) {.#Parameter funcT_idx}}) (n.= 0 (adjusted_idx env funcT_idx)) - [(dictionary.value 0 env) {#.Some [self_type self_call]}]) + [(dictionary.value 0 env) {.#Some [self_type self_call]}]) (in self_call) _ diff --git a/stdlib/source/library/lux/control/parser/xml.lux b/stdlib/source/library/lux/control/parser/xml.lux index 6a1eb1206..71fb6fab9 100644 --- a/stdlib/source/library/lux/control/parser/xml.lux +++ b/stdlib/source/library/lux/control/parser/xml.lux @@ -42,13 +42,13 @@ (def: (result' parser attrs documents) (All (_ a) (-> (Parser a) Attrs (List XML) (Try a))) (case (//.result parser [attrs documents]) - {#try.Success [[attrs' remaining] output]} + {try.#Success [[attrs' remaining] output]} (if (list.empty? remaining) - {#try.Success output} + {try.#Success output} (exception.except ..unconsumed_inputs remaining)) - {#try.Failure error} - {#try.Failure error})) + {try.#Failure error} + {try.#Failure error})) (def: .public (result parser documents) (All (_ a) (-> (Parser a) (List XML) (Try a))) @@ -58,55 +58,55 @@ (Parser Text) (function (_ [attrs documents]) (case documents - #.End + {.#End} (exception.except ..empty_input []) - {#.Item head tail} + {.#Item head tail} (case head - {#/.Text value} - {#try.Success [[attrs tail] value]} + {/.#Text value} + {try.#Success [[attrs tail] value]} - {#/.Node _} + {/.#Node _} (exception.except ..unexpected_input []))))) (def: .public tag (Parser Tag) (function (_ [attrs documents]) (case documents - #.End + {.#End} (exception.except ..empty_input []) - {#.Item head _} + {.#Item head _} (case head - {#/.Text _} + {/.#Text _} (exception.except ..unexpected_input []) - {#/.Node tag _ _} - {#try.Success [[attrs documents] tag]})))) + {/.#Node tag _ _} + {try.#Success [[attrs documents] tag]})))) (def: .public (attribute name) (-> Attribute (Parser Text)) (function (_ [attrs documents]) (case (dictionary.value name attrs) - #.None + {.#None} (exception.except ..unknown_attribute [name (dictionary.keys attrs)]) - {#.Some value} - {#try.Success [[attrs documents] value]}))) + {.#Some value} + {try.#Success [[attrs documents] value]}))) (def: .public (node expected parser) (All (_ a) (-> Tag (Parser a) (Parser a))) (function (_ [attrs documents]) (case documents - #.End + {.#End} (exception.except ..empty_input []) - {#.Item head tail} + {.#Item head tail} (case head - {#/.Text _} + {/.#Text _} (exception.except ..unexpected_input []) - {#/.Node actual attrs' children} + {/.#Node actual attrs' children} (if (name\= expected actual) (|> children (..result' parser attrs') @@ -117,11 +117,11 @@ (Parser XML) (function (_ [attrs documents]) (case documents - #.End + {.#End} (exception.except ..empty_input []) - {#.Item head tail} - {#try.Success [[attrs tail] head]}))) + {.#Item head tail} + {try.#Success [[attrs tail] head]}))) (exception: .public nowhere) @@ -129,16 +129,16 @@ (All (_ a) (-> (Parser a) (Parser a))) (function (recur [attrs input]) (case (//.result parser [attrs input]) - {#try.Success [[attrs remaining] output]} - {#try.Success [[attrs remaining] output]} + {try.#Success [[attrs remaining] output]} + {try.#Success [[attrs remaining] output]} - {#try.Failure error} + {try.#Failure error} (case input - #.End + {.#End} (exception.except ..nowhere []) - {#.Item head tail} + {.#Item head tail} (do try.monad [[[attrs tail'] output] (recur [attrs tail])] - (in [[attrs {#.Item head tail'}] + (in [[attrs {.#Item head tail'}] output])))))) |