diff options
author | Eduardo Julian | 2018-10-29 21:54:10 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-10-29 21:54:10 -0400 |
commit | 3da30aff80bc8c80e090574887a58c6015ceb694 (patch) | |
tree | cc157fb121fd6cfb2559f6dedd0de046566a453a /stdlib/source/lux/platform/compiler/name.lux | |
parent | 70ffb24d3a0d817080d54e4d3eb4bd49ba18feea (diff) |
Extracted "phase" from under "lux/platform/compiler/default".
Diffstat (limited to 'stdlib/source/lux/platform/compiler/name.lux')
-rw-r--r-- | stdlib/source/lux/platform/compiler/name.lux | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/stdlib/source/lux/platform/compiler/name.lux b/stdlib/source/lux/platform/compiler/name.lux new file mode 100644 index 000000000..184b2cab5 --- /dev/null +++ b/stdlib/source/lux/platform/compiler/name.lux @@ -0,0 +1,47 @@ +(.module: + [lux #* + [data + ["." maybe] + ["." text + format]]]) + +(`` (template: (!sanitize char) + ("lux syntax char case!" char + [["*"] "_ASTER_" + ["+"] "_PLUS_" + ["-"] "_DASH_" + ["/"] "_SLASH_" + ["\"] "_BSLASH_" + ["_"] "_UNDERS_" + ["%"] "_PERCENT_" + ["$"] "_DOLLAR_" + ["'"] "_QUOTE_" + ["`"] "_BQUOTE_" + ["@"] "_AT_" + ["^"] "_CARET_" + ["&"] "_AMPERS_" + ["="] "_EQ_" + ["!"] "_BANG_" + ["?"] "_QM_" + [":"] "_COLON_" + ["."] "_PERIOD_" + [","] "_COMMA_" + ["<"] "_LT_" + [">"] "_GT_" + ["~"] "_TILDE_" + ["|"] "_PIPE_"] + (text.from-code char)))) + +(def: #export (normalize name) + (-> Text Text) + (let [name/size (text.size name)] + (loop [idx 0 + output ""] + (if (n/< name/size idx) + (recur (inc idx) + (|> ("lux text char" name idx) !sanitize (format output))) + output)))) + +(def: #export (definition [module short]) + (-> Name Text) + (format (normalize module) "___" (normalize short))) |