Skip to content

Commit

Permalink
patch negative-int parser to return a negative number. fixes #27
Browse files Browse the repository at this point in the history
  • Loading branch information
nyoung-outpace committed May 25, 2014
1 parent f2e8d5a commit 68845ca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/parsatron/languages/bencode.clj
Expand Up @@ -8,9 +8,12 @@
(let->> [digits (many1 (digit))]
(always (read-string (apply str digits)))))

(defn neg [x]
(* -1 x))

(defparser negative-int []
(let->> [digits (>> (char \-) (many1 (digit)))]
(always (read-string (apply str digits)))))
(always (neg (read-string (apply str digits))))))

(defparser ben-integer []
(between (char \i) (char \e)
Expand Down

0 comments on commit 68845ca

Please sign in to comment.