aboutsummaryrefslogtreecommitdiff
path: root/luxc/src
diff options
context:
space:
mode:
authorEduardo Julian2019-01-09 23:44:54 -0400
committerEduardo Julian2019-01-09 23:44:54 -0400
commit8b6f4e486ffc9b6b8fec314f2a94998feb919c39 (patch)
tree0dacadaa2acf95960249deb435cd8c9e780896f2 /luxc/src
parent9a6d43895330f7c71bde85aa46230a40ada5dbd5 (diff)
Shortened normalization codes.
Diffstat (limited to 'luxc/src')
-rw-r--r--luxc/src/lux/base.clj68
1 files changed, 41 insertions, 27 deletions
diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj
index e6fecf367..0b14e667d 100644
--- a/luxc/src/lux/base.clj
+++ b/luxc/src/lux/base.clj
@@ -258,8 +258,7 @@
(assert false (str "Unknown var: " (first pattern))))
'_
(transform-pattern (vec (rest pattern)))]
- :else pattern
- ))
+ :else pattern))
(defmacro |case [value & branches]
(assert (= 0 (mod (count branches) 2)))
@@ -670,29 +669,29 @@
(defn ^:private normalize-char [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_"
+ \* "_AS"
+ \+ "_PL"
+ \- "_DS"
+ \/ "_SL"
+ \\ "_BS"
+ \_ "_US"
+ \% "_PC"
+ \$ "_DL"
+ \' "_QU"
+ \` "_BQ"
+ \@ "_AT"
+ \^ "_CR"
+ \& "_AA"
+ \= "_EQ"
+ \! "_BG"
+ \? "_QM"
+ \: "_CO"
+ \. "_PD"
+ \, "_CM"
+ \< "_LT"
+ \> "_GT"
+ \~ "_TI"
+ \| "_PI"
;; default
char))
@@ -1208,10 +1207,12 @@
(pr-str ?value)
[_ ($Nat ?value)]
- (str "+" (Long/toUnsignedString ?value))
+ (Long/toUnsignedString ?value)
[_ ($Int ?value)]
- (pr-str ?value)
+ (if (< ?value 0)
+ (pr-str ?value)
+ (str "+" (pr-str ?value)))
[_ ($Rev ?value)]
(encode-rev ?value)
@@ -1470,3 +1471,16 @@
_output
_output)))
+
+(defn timed% [what when operation]
+ (fn [state]
+ (let [pre (System/currentTimeMillis)]
+ (|case (operation state)
+ ($Right state* output)
+ (let [post (System/currentTimeMillis)
+ duration (- post pre)
+ _ (|log! (str what " [" when "]: +" duration "ms" "\n"))]
+ ($Right (T [state* output])))
+
+ ($Left ^String msg)
+ (fail* msg)))))