aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2018-05-08 23:07:21 -0400
committerEduardo Julian2018-05-08 23:07:21 -0400
commit3b80f40384a8af8770a7c4f1be8b334ceb950a27 (patch)
tree7c0bf34f3f5b22ef57d1e31b18c6112a602582c4 /stdlib/source
parent8c90251c12a4d0d4cc191bfb273bb5eb51bb0356 (diff)
- Improved the way Bool values are parsed.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/lang/syntax.lux50
1 files changed, 22 insertions, 28 deletions
diff --git a/stdlib/source/lux/lang/syntax.lux b/stdlib/source/lux/lang/syntax.lux
index d30436533..6c7236f76 100644
--- a/stdlib/source/lux/lang/syntax.lux
+++ b/stdlib/source/lux/lang/syntax.lux
@@ -29,8 +29,7 @@
(lux (control monad
["p" parser "p/" Monad<Parser>]
["ex" exception #+ exception:])
- (data [bool]
- ["e" error]
+ (data ["e" error]
[number]
[product]
[maybe]
@@ -205,10 +204,6 @@
(l.seq l.decimal
(l.some rich-digit)))
-(def: (marker^ token)
- (-> Text (l.Lexer Text))
- (p.after (l.this token) (p/wrap token)))
-
(do-template [<name> <tag> <lexer> <codec>]
[(def: #export (<name> where)
(-> Cursor (l.Lexer [Cursor Code]))
@@ -222,10 +217,6 @@
(wrap [(update@ #.column (n/+ (text.size chunk)) where)
[where (<tag> value)]]))))]
- [bool #.Bool
- (p.either (marker^ "true") (marker^ "false"))
- bool.Codec<Text,Bool>]
-
[int #.Int
(l.seq (p.default "" (l.one-of "-"))
rich-digits^)
@@ -570,24 +561,28 @@
(wrap [["" first-part]
(text.size first-part)])))))
-## The only (syntactic) difference between a symbol and a tag (both
-## being identifiers), is that tags must be prefixed with a hash-sign
-## (i.e. #).
-## Semantically, though, they are very different, with symbols being
-## used to refer to module definitions and local variables, while tags
-## provide the compiler with information related to data-structure
-## construction and de-structuring (during pattern-matching).
-(do-template [<name> <tag> <lexer> <extra>]
- [(def: #export (<name> current-module aliases where)
- (-> Text Aliases Cursor (l.Lexer [Cursor Code]))
- (do p.Monad<Parser>
- [[value length] <lexer>]
- (wrap [(update@ #.column (|>> ($_ n/+ <extra> length)) where)
- [where (<tag> value)]])))]
+(def: #export (tag current-module aliases where)
+ (-> Text Aliases Cursor (l.Lexer [Cursor Code]))
+ (do p.Monad<Parser>
+ [[value length] (p.after (l.this "#")
+ (ident^ current-module aliases))]
+ (wrap [(update@ #.column (|>> ($_ n/+ +1 length)) where)
+ [where (#.Tag value)]])))
- [symbol #.Symbol (ident^ current-module aliases) +0]
- [tag #.Tag (p.after (l.this "#") (ident^ current-module aliases)) +1]
- )
+(def: #export (symbol current-module aliases where)
+ (-> Text Aliases Cursor (l.Lexer [Cursor Code]))
+ (do p.Monad<Parser>
+ [[value length] (ident^ current-module aliases)]
+ (wrap [(update@ #.column (|>> (n/+ length)) where)
+ [where (case value
+ (^template [<name> <value>]
+ ["" <name>]
+ (#.Bool <value>))
+ (["true" true]
+ ["false" false])
+
+ _
+ (#.Symbol value))]])))
(exception: #export (end-of-file {module Text})
module)
@@ -607,7 +602,6 @@
(form where ast')
(tuple where ast')
(record where ast')
- (bool where)
(nat where)
(frac where)
(int where)