aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/lang
diff options
context:
space:
mode:
authorEduardo Julian2017-11-21 16:09:07 -0400
committerEduardo Julian2017-11-21 16:09:07 -0400
commite37e3713e080606930a5f8442f03dabc4c26a7f9 (patch)
treead772c1801af0d01dc105bccf85703f13b127e50 /stdlib/source/lux/lang
parent3eabc421e559e7e2f903e06eb6b47a2ee0cd25b9 (diff)
- Fixed some bugs.
- Some small refactoring.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/lang/syntax.lux36
1 files changed, 20 insertions, 16 deletions
diff --git a/stdlib/source/lux/lang/syntax.lux b/stdlib/source/lux/lang/syntax.lux
index 7bc8e8cca..ae20fd9b6 100644
--- a/stdlib/source/lux/lang/syntax.lux
+++ b/stdlib/source/lux/lang/syntax.lux
@@ -30,14 +30,17 @@
["p" parser "p/" Monad<Parser>]
["ex" exception #+ exception:])
(data [bool]
- [text]
["e" error]
[number]
[product]
[maybe]
+ [text]
(text ["l" lexer]
format)
- (coll [sequence #+ Sequence]))))
+ (coll [sequence #+ Sequence]
+ [dict #+ Dict]))))
+
+(type: #export Aliases (Dict Text Text))
(def: white-space Text "\t\v \r\f")
(def: new-line Text "\n")
@@ -521,8 +524,8 @@
(def: current-module-mark Text (format identifier-separator identifier-separator))
-(def: (ident^ current-module)
- (-> Text (l;Lexer [Ident Nat]))
+(def: (ident^ current-module aliases)
+ (-> Text Aliases (l;Lexer [Ident Nat]))
($_ p;either
## When an identifier starts with 2 marks, its module is
## taken to be the current-module being compiled at the moment.
@@ -558,7 +561,8 @@
(p;either (do @
[_ (l;this identifier-separator)
second-part ident-part^]
- (wrap [[first-part second-part]
+ (wrap [[(|> aliases (dict;get first-part) (maybe;default first-part))
+ second-part]
($_ n.+
(text;size first-part)
+1
@@ -574,22 +578,22 @@
## 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 where)
- (-> Text Cursor (l;Lexer [Cursor Code]))
+ [(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)]])))]
- [symbol #;Symbol (ident^ current-module) +0]
- [tag #;Tag (p;after (l;this "#") (ident^ current-module)) +1]
+ [symbol #;Symbol (ident^ current-module aliases) +0]
+ [tag #;Tag (p;after (l;this "#") (ident^ current-module aliases)) +1]
)
(exception: #export End-Of-File)
(exception: #export Unrecognized-Input)
-(def: (ast current-module)
- (-> Text Cursor (l;Lexer [Cursor Code]))
+(def: (ast current-module aliases)
+ (-> Text Aliases Cursor (l;Lexer [Cursor Code]))
(: (-> Cursor (l;Lexer [Cursor Code]))
(function ast' [where]
(do p;Monad<Parser>
@@ -603,8 +607,8 @@
(frac where)
(int where)
(deg where)
- (symbol current-module where)
- (tag current-module where)
+ (symbol current-module aliases where)
+ (tag current-module aliases where)
(text where)
(do @
[end? l;end?]
@@ -613,9 +617,9 @@
(p;fail (Unrecognized-Input current-module))))
)))))
-(def: #export (read current-module [where offset source])
- (-> Text Source (e;Error [Source Code]))
- (case (p;run [offset source] (ast current-module where))
+(def: #export (read current-module aliases [where offset source])
+ (-> Text Aliases Source (e;Error [Source Code]))
+ (case (p;run [offset source] (ast current-module aliases where))
(#e;Error error)
(#e;Error error)