Permalink
Browse files

handle the '#' without matching "#{"

  • Loading branch information...
mmikulicic committed Jul 9, 2010
1 parent 67886c1 commit b6550880b1e17285a8edf92b5e5526505c248090
Showing with 17 additions and 1 deletion.
  1. +17 −1 src/haml_macro/core.clj
View
@@ -69,9 +69,25 @@
(defn not-char-of [s]
(satisfy #(not (contains? s %))))
+;; hack, probably incorrect but allow me to handle the '#{}' thing
+(defn notFollowedBy [p trailing]
+ (make-monad 'Parser
+ (fn p-try-parse [strn]
+ (let [res (parse p strn)]
+ (if (consumed? res)
+ (let [trail (parse trailing (:rest res))]
+ (if (consumed? trail)
+ (failed)
+ res
+ )
+ )
+ (failed))
+ ))))
+
+
(defn quotedString [ch]
(let [quoteSeparator (is-char ch)
- stringBody (stringify (many1 (not-char-of #{ch \#})))
+ stringBody (stringify (many1 (either (not-char-of #{\' \#}) (notFollowedBy (string "#") (string "{")))))
expressionBody (let-bind [_ (string "#{")
expr (stringify (many1 (not-char \})))
_ (string "}")]

0 comments on commit b655088

Please sign in to comment.