aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool
diff options
context:
space:
mode:
authorEduardo Julian2019-03-17 22:19:33 -0400
committerEduardo Julian2019-03-17 22:19:33 -0400
commit0fcb373ed1cdc2750f02e5535d29569dd8ae5a5b (patch)
tree0e4c1b0bcb9b18a95a6bebc648ba8570e6dd3816 /stdlib/source/lux/tool
parent54b69afa96cd00b174b07c3f23b496b5e5b63858 (diff)
Minor improvements.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/tool/compiler/default/syntax.lux44
-rw-r--r--stdlib/source/lux/tool/compiler/phase/analysis/module.lux16
2 files changed, 32 insertions, 28 deletions
diff --git a/stdlib/source/lux/tool/compiler/default/syntax.lux b/stdlib/source/lux/tool/compiler/default/syntax.lux
index 4743d26ce..8eaf3a558 100644
--- a/stdlib/source/lux/tool/compiler/default/syntax.lux
+++ b/stdlib/source/lux/tool/compiler/default/syntax.lux
@@ -180,8 +180,8 @@
## else
<cannot-close>))))))))
-(`` (do-template [<name> <close> <tag> <context>]
- [(def: (<name> parse source)
+(do-template [<name> <close> <tag> <context>]
+ [(`` (def: (<name> parse source)
(-> Parser Parser)
(let [[_ _ source-code] source
source-code//size ("lux text size" source-code)]
@@ -193,20 +193,20 @@
(#error.Failure error)
(let [[where offset _] source]
- (case (read-close (char <close>) source-code//size source-code offset)
+ (case (read-close (char (~~ (static <close>))) source-code//size source-code offset)
(#error.Success offset')
(#error.Success [[(update@ #.column inc where) offset' source-code]
[where (<tag> (list.reverse stack))]])
(#error.Failure error)
- (#error.Failure error)))))))]
+ (#error.Failure error))))))))]
- ## Form and tuple syntax is mostly the same, differing only in the
- ## delimiters involved.
- ## They may have an arbitrary number of arbitrary Code nodes as elements.
- [parse-form (~~ (static ..close-form)) #.Form "Form"]
- [parse-tuple (~~ (static ..close-tuple)) #.Tuple "Tuple"]
- ))
+ ## Form and tuple syntax is mostly the same, differing only in the
+ ## delimiters involved.
+ ## They may have an arbitrary number of arbitrary Code nodes as elements.
+ [parse-form ..close-form #.Form "Form"]
+ [parse-tuple ..close-tuple #.Tuple "Tuple"]
+ )
(def: (parse-record parse source)
(-> Parser Parser)
@@ -500,27 +500,27 @@
(let [offset/1 (!inc offset/0)]
(<| (!with-char+ source-code//size source-code offset/1 char/1 <end-of-file>)
("lux syntax char case!" char/1
- [(~~ (do-template [<char> <bit>]
- [[<char>]
- (#error.Success [[(update@ #.column (|>> !inc/2) where)
- (!inc offset/1)
- source-code]
- [where (#.Bit <bit>)]])]
-
- ["0" #0]
- ["1" #1]))
+ [[(~~ (static ..name-separator))]
+ (!parse-short-name current-module <consume-2> where #.Tag)
## Single-line comment
[(~~ (static ..sigil))]
- (case ("lux text index" source-code (static text.new-line) offset/1)
+ (case ("lux text index" source-code (static text.new-line) (!inc offset/1))
(#.Some end)
(recur [(!new-line where) (!inc end) source-code])
_
<end-of-file>)
- [(~~ (static ..name-separator))]
- (!parse-short-name current-module <consume-2> where #.Tag)]
+ (~~ (do-template [<char> <bit>]
+ [[<char>]
+ (#error.Success [[(update@ #.column (|>> !inc/2) where)
+ (!inc offset/1)
+ source-code]
+ [where (#.Bit <bit>)]])]
+
+ ["0" #0]
+ ["1" #1]))]
## else
(cond (!name-char?|head char/1) ## Tag
diff --git a/stdlib/source/lux/tool/compiler/phase/analysis/module.lux b/stdlib/source/lux/tool/compiler/phase/analysis/module.lux
index cc7c857a0..0d69f524c 100644
--- a/stdlib/source/lux/tool/compiler/phase/analysis/module.lux
+++ b/stdlib/source/lux/tool/compiler/phase/analysis/module.lux
@@ -5,11 +5,11 @@
["ex" exception (#+ exception:)]
pipe]
[data
- ["." text ("#;." equivalence)
+ ["." text ("#@." equivalence)
format]
["." error]
[collection
- ["." list ("#;." fold functor)]
+ ["." list ("#@." fold functor)]
[dictionary
["." plist]]]]
["." macro]]
@@ -86,7 +86,11 @@
[self-name macro.current-module-name]
(function (_ state)
(#error.Success [(update@ #.modules
- (plist.update self-name (update@ #.imports (|>> (#.Cons module))))
+ (plist.update self-name (update@ #.imports (function (_ current)
+ (if (list.any? (text@= module)
+ current)
+ current
+ (#.Cons module current)))))
state)
[]])))))
@@ -236,16 +240,16 @@
(///.throw cannot-declare-tags-for-unnamed-type [tags type]))
_ (ensure-undeclared-tags self-name tags)
_ (///.assert cannot-declare-tags-for-foreign-type [tags type]
- (text;= self-name type-module))]
+ (text@= self-name type-module))]
(///extension.lift
(function (_ state)
(case (|> state (get@ #.modules) (plist.get self-name))
(#.Some module)
- (let [namespaced-tags (list;map (|>> [self-name]) tags)]
+ (let [namespaced-tags (list@map (|>> [self-name]) tags)]
(#error.Success [(update@ #.modules
(plist.update self-name
(|>> (update@ #.tags (function (_ tag-bindings)
- (list;fold (function (_ [idx tag] table)
+ (list@fold (function (_ [idx tag] table)
(plist.put tag [idx namespaced-tags exported? type] table))
tag-bindings
(list.enumerate tags))))