diff options
author | Eduardo Julian | 2017-09-19 21:52:42 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-09-19 21:52:42 -0400 |
commit | 70534ffd9c346ac23f9d5574b9c7820dccebc350 (patch) | |
tree | e2370a43a8bb2bdcb349d5bbbe477312859365f3 /stdlib/source/lux/data/text | |
parent | e717f33e192a5969760c033c47f9c4709485dd76 (diff) |
- Some refactoring.
- Moved "assume" and "default" to lux/data/maybe.
Diffstat (limited to 'stdlib/source/lux/data/text')
-rw-r--r-- | stdlib/source/lux/data/text/lexer.lux | 8 | ||||
-rw-r--r-- | stdlib/source/lux/data/text/regex.lux | 7 |
2 files changed, 7 insertions, 8 deletions
diff --git a/stdlib/source/lux/data/text/lexer.lux b/stdlib/source/lux/data/text/lexer.lux index ae3c4859f..cb68fe93d 100644 --- a/stdlib/source/lux/data/text/lexer.lux +++ b/stdlib/source/lux/data/text/lexer.lux @@ -1,8 +1,6 @@ (;module: [lux #- not] - (lux (control functor - applicative - [monad #+ do Monad] + (lux (control [monad #+ do Monad] ["p" parser]) (data [text "text/" Monoid<Text>] [product] @@ -19,7 +17,7 @@ (def: (remaining offset tape) (-> Offset Text Text) - (|> tape (text;split offset) assume product;right)) + (|> tape (text;split offset) maybe;assume product;right)) (def: cannot-lex-error Text "Cannot lex from empty text.") @@ -121,7 +119,7 @@ (-> Nat Nat (Lexer Text)) (do p;Monad<Parser> [char any - #let [char' (assume (text;nth +0 char))] + #let [char' (maybe;assume (text;nth +0 char))] _ (p;assert ($_ text/append "Character is not within range: " (text;from-code bottom) "-" (text;from-code top)) (and (n.>= bottom char') (n.<= top char')))] diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux index c42aa9ba3..6d430b756 100644 --- a/stdlib/source/lux/data/text/regex.lux +++ b/stdlib/source/lux/data/text/regex.lux @@ -8,6 +8,7 @@ [number "Int/" Codec<Text,Int>] [product] ["R" result] + [maybe] (coll [list "L/" Fold<List> Monad<List>])) [macro #- run] (macro [code] @@ -77,9 +78,9 @@ (def: re-range^ (l;Lexer Code) (do p;Monad<Parser> - [from (|> regex-char^ (:: @ map (|>. (text;nth +0) assume))) + [from (|> regex-char^ (:: @ map (|>. (text;nth +0) maybe;assume))) _ (l;this "-") - to (|> regex-char^ (:: @ map (|>. (text;nth +0) assume)))] + to (|> regex-char^ (:: @ map (|>. (text;nth +0) maybe;assume)))] (wrap (` (l;range (~ (code;nat from)) (~ (code;nat to))))))) (def: re-char^ @@ -487,7 +488,7 @@ [g!temp (macro;gensym "temp")] (wrap (list& (` (^multi (~ g!temp) [(l;run (~ g!temp) (regex (~ (code;text pattern)))) - (#R;Success (~ (default g!temp + (#R;Success (~ (maybe;default g!temp bindings)))])) body branches)))) |