aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang.lux
diff options
context:
space:
mode:
authorEduardo Julian2018-06-17 00:27:21 -0400
committerEduardo Julian2018-06-17 00:27:21 -0400
commitb6ccfc87c52e1a98ead3b04b45bccc119418a4dc (patch)
treedb13d4605a0a3041de6ef2ef5ddc92b766f1a7f3 /new-luxc/source/luxc/lang.lux
parentbcd3d9ee8f6797f758a2abea98d5cb6a74cc7df0 (diff)
- Migrated Scheme back-end to stdlib.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/lang/name.lux (renamed from new-luxc/source/luxc/lang.lux)25
1 files changed, 14 insertions, 11 deletions
diff --git a/new-luxc/source/luxc/lang.lux b/stdlib/source/lux/lang/name.lux
index f02af30c5..1053eb76f 100644
--- a/new-luxc/source/luxc/lang.lux
+++ b/stdlib/source/lux/lang/name.lux
@@ -4,7 +4,7 @@
[text]
text/format)))
-(def: (normalize-char char)
+(def: (sanitize char)
(-> Nat Text)
(case char
(^ (char "*")) "_ASTER_"
@@ -30,15 +30,18 @@
(^ (char ">")) "_GT_"
(^ (char "~")) "_TILDE_"
(^ (char "|")) "_PIPE_"
- _
- (text.from-code char)))
+ _ (text.from-code char)))
-(def: underflow Nat (dec +0))
-
-(def: #export (normalize-name name)
+(def: #export (normalize name)
(-> Text Text)
- (loop [idx (dec (text.size name))
- output ""]
- (if (n/= underflow idx)
- output
- (recur (dec idx) (format (|> (text.nth idx name) maybe.assume normalize-char) output)))))
+ (let [name/size (text.size name)]
+ (loop [idx +0
+ output ""]
+ (if (n/< name/size idx)
+ (recur (inc idx)
+ (|> (text.nth idx name) maybe.assume sanitize (format output)))
+ output))))
+
+(def: #export (definition [module name])
+ (-> Ident Text)
+ (format (normalize module) "___" (normalize name)))