Skip to content

Instantly share code, notes, and snippets.

@devn
Created January 5, 2011 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devn/765778 to your computer and use it in GitHub Desktop.
Save devn/765778 to your computer and use it in GitHub Desktop.
(defn quoted-string [ch]
(let [quoteSeparator (is-char ch)
stringBody (stringify (many1 (either (not-char-of #{ch \# \newline}) (not-followed-by (string "#") (string "{")))))
expressionBody (let-bind [_ (string "#{")
expr (stringify (many1 (not-char \})))
_ (string "}")]
(result (read-string expr)))
expansionBody (many (either stringBody expressionBody))
optimize (fn [exp] (if (== 2 (count exp)) (second exp) exp))]
(>>== (between quoteSeparator quoteSeparator expansionBody) #(optimize (apply list 'str %)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment