diff options
author | Eduardo Julian | 2017-05-07 20:10:14 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-05-07 20:10:14 -0400 |
commit | b3d7e4aa4b646c082769b8305f179988a946493b (patch) | |
tree | dc718d5f639e6f4de24c369dce557f2bdac3d9b7 /new-luxc | |
parent | 29c0e991917ac744b856919331ff039d04d5832b (diff) |
- Added underscore separators ( _ ) for digits in the parser for the new compiler.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/parser.lux | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/new-luxc/source/luxc/parser.lux b/new-luxc/source/luxc/parser.lux index c9ba89b75..d76050860 100644 --- a/new-luxc/source/luxc/parser.lux +++ b/new-luxc/source/luxc/parser.lux @@ -206,6 +206,22 @@ ## These are very simple parsers that just cut chunks of text in ## specific shapes and then use decoders already present in the ## standard library to actually produce the values from the literals. +(def: rich-digit + (Lexer Char) + (l;either l;digit + (l;char #"_"))) + +(def: rich-digits + (Lexer Text) + (l;seq' (l/map char;as-text l;digit) + (l;some' rich-digit))) + +(def: (without-separators raw) + (-> (Lexer Text) (Lexer Text)) + (do Monad<Lexer> + [input raw] + (wrap (text;replace-all "_" "" input)))) + (do-template [<name> <tag> <lexer> <codec>] [(def: #export (<name> where) (-> Cursor (Lexer [Cursor Code])) @@ -224,25 +240,30 @@ bool;Codec<Text,Bool>] [parse-nat #;Nat - (l;seq' (l;text "+") (l;many' l;digit)) + (without-separators + (l;seq' (l;text "+") + rich-digits)) number;Codec<Text,Nat>] [parse-int #;Int - (l;seq' (l;default "" (l;text "-")) - (l;many' l;digit)) + (without-separators + (l;seq' (l;default "" (l;text "-")) + rich-digits)) number;Codec<Text,Int>] [parse-real #;Real - ($_ l;seq' - (l;default "" (l;text "-")) - (l;many' l;digit) - (l;text ".") - (l;many' l;digit)) + (without-separators + ($_ l;seq' + (l;default "" (l;text "-")) + rich-digits + (l;text ".") + rich-digits)) number;Codec<Text,Real>] [parse-deg #;Deg - (l;seq' (l;text ".") - (l;many' l;digit)) + (without-separators + (l;seq' (l;text ".") + rich-digits)) number;Codec<Text,Deg>] ) |