1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-16 05:34:48 +00:00
janet/tools/tmcorelib.janet
Calvin Rose eae4e0dede Add functionality that allows the set macro to
take a tuple as an l-value. Remove the old
multi-sym report in anticipation of a different
mechanism.
2019-01-06 19:33:27 -05:00

32 lines
651 B
Plaintext

# Helper to generate core library mappings for janet
# Used to help build the tmLanguage grammar.
(def allsyms (all-symbols))
(def- escapes
{(get "|" 0) `\|`
(get "-" 0) `\-`
(get "+" 0) `\+`
(get "*" 0) `\*`
(get "^" 0) `\^`
(get "$" 0) `\$`
(get "?" 0) `\?`
38 "&"
60 "<"
62 ">"
34 """
39 "'"
47 "/"})
(defn- escape
"Escape special characters for HTML and regex encoding."
[str]
(def buf @"")
(loop [byte :in str]
(if-let [rep (get escapes byte)]
(buffer/push-string buf rep)
(buffer/push-byte buf byte)))
buf)
(print (string/join (map escape allsyms) "|"))