Permalink
Browse files

Symbol name cleanup; don't shadow str function

  • Loading branch information...
1 parent f8b5dba commit 2d5560cdce1116df881ecb7bae33568d129ffbb9 @mattyoho committed Aug 6, 2012
Showing with 17 additions and 17 deletions.
  1. +17 −17 src/tnetstring/core.clj
View
34 src/tnetstring/core.clj
@@ -3,21 +3,21 @@
(declare parse)
-(defn- parse-list [str the-list]
- (if (not (blank? str))
- (let [[element str] (parse str)]
- (recur str (conj the-list element)))
+(defn- parse-list [s the-list]
+ (if (not (blank? s))
+ (let [[element s] (parse s)]
+ (recur s (conj the-list element)))
the-list))
-(defn- parse-dict [str dict]
- (if (not (blank? str))
- (let [[key value-and-rest] (parse str)]
- (let [[value str] (parse value-and-rest)]
- (recur str (assoc dict key value))))
+(defn- parse-dict [s dict]
+ (if (not (blank? s))
+ (let [[key value-and-rest] (parse s)]
+ (let [[value s] (parse value-and-rest)]
+ (recur s (assoc dict key value))))
dict))
-(defn- parse-length [str]
- (let [[length-str remain] (split str #":" 2)]
+(defn- parse-length [s]
+ (let [[length-str remain] (split s #":" 2)]
[(Integer/parseInt length-str) remain]))
(let [parsers
@@ -32,16 +32,16 @@
\] #(parse-list % [])
\} #(parse-dict % {})}]
- (defn- payload [str len]
- (let [payload-str (.substring str 0 len)
- remain (subs str (+ 1 len))
- payload-type (.charAt str len)
+ (defn- payload [s len]
+ (let [payload-str (.substring s 0 len)
+ remain (subs s (+ 1 len))
+ payload-type (.charAt s len)
parser (fn [] (get parsers payload-type))]
[((parser) payload-str), remain])))
(defn parse
"Parses a tnetstring"
- [str]
- (let [[payload-len payload-str] (parse-length str)]
+ [s]
+ (let [[payload-len payload-str] (parse-length s)]
(payload payload-str payload-len)))

0 comments on commit 2d5560c

Please sign in to comment.