Permalink
Browse files

Don't expose parsers symbol

  • Loading branch information...
1 parent 78b5b30 commit f8b5dba9a11c6206cae748519895a3355afb8d02 @mattyoho committed Aug 6, 2012
Showing with 13 additions and 13 deletions.
  1. +13 −13 src/tnetstring/core.clj
View
@@ -16,7 +16,11 @@
(recur str (assoc dict key value))))
dict))
-(def parsers
+(defn- parse-length [str]
+ (let [[length-str remain] (split str #":" 2)]
+ [(Integer/parseInt length-str) remain]))
+
+(let [parsers
{ \# #(Long/parseLong %)
\^ #(Double/parseDouble %)
\! (fn [s] (if (or (= "true" s) (= "false" s))
@@ -26,18 +30,14 @@
(throw (IllegalArgumentException. "Nil does not have a body"))))
\, #(identity %)
\] #(parse-list % [])
- \} #(parse-dict % {})})
-
-(defn- parse-length [str]
- (let [[length-str remain] (split str #":" 2)]
- [(Integer/parseInt length-str) remain]))
-
-(defn- payload [str len]
- (let [payload-str (.substring str 0 len)
- remain (subs str (+ 1 len))
- payload-type (.charAt str len)
- parser (fn [] (get parsers payload-type))]
- [((parser) payload-str), remain]))
+ \} #(parse-dict % {})}]
+
+ (defn- payload [str len]
+ (let [payload-str (.substring str 0 len)
+ remain (subs str (+ 1 len))
+ payload-type (.charAt str len)
+ parser (fn [] (get parsers payload-type))]
+ [((parser) payload-str), remain])))
(defn parse
"Parses a tnetstring"

0 comments on commit f8b5dba

Please sign in to comment.