Hi, I tried out a double quoted string parser in parsatron. I'd appreciate it very much if someone could review it and let me know if it looks okay.
(ns mycode.core (:require [the.parsatron :as p])) (p/defparser optional [p default-value] (p/either (p/attempt p) (p/always default-value))) (def escape-map { \n \newline \t \tab \\ \\ \" \" \r \return}) (p/defparser -char-parser [] (p/let->> [ _e (optional (p/char \\) nil) _c (if _e (p/token #(#{\" \\ \n \r \t} %)) (p/token #(not= % \"))) ] (p/always (if _e (escape-map _c) _c)))) (p/defparser string-parser [] (p/let->> [ _ (p/char \") _str (p/many (-char-parser)) _ (p/char \") ] (p/always _str))) (defn doit [s] (p/run (pdf-string-parser) s)) Regards, Kashyap -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.