Skip to content
Prev Previous commit
Next Next commit
fixed compilation error around eol
  • Loading branch information
Jason Jackson committed Jun 4, 2011
commit 21a506647e6349baca57ff84dca3f677d8da870a
12 changes: 6 additions & 6 deletions doc/xml.clj
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@
(result {(keyword tag-name) contents})))

(def xml
(let [list$ #(flatten (apply list %&))]
(let [list$ #(flatten (list %&))]
(element
(<|> (<$> #(apply merge-with list$ %) (many1 (lazy xml)))
(stringify (many (<|> letter space)))))))

(defn -main []
(println (:value (parse xml input))))
(prn (:value (parse xml input))))

;; (-main)

;; Output:
;; {:library
;; {:book ({:author Fogus,
;; :title Joy of Clojure}
;; {:author MIT,
;; :title Structured and Interpretation of Computer Programs})}}
;; {:book ({:author "Fogus",
;; :title "Joy of Clojure"}
;; {:author "MIT",
;; :title "Structured and Interpretation of Computer Programs"})}}
23 changes: 12 additions & 11 deletions src/eu/dnetlib/clojure/clarsec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,6 @@
(consumed (first strn)
(. strn (substring 1)))))))

(def eof
(make-monad 'Parser
(fn p-eof [strn]
(if (= "" strn)
(consumed "" "")
(failed)))))

(def eol
(>> (optional (satisfy #(= % \return)))
(satisfy #(= % \newline))))

(def fail (make-monad 'Parser (fn p-fail [strn] (failed))))

(defn satisfy [pred]
Expand Down Expand Up @@ -203,6 +192,18 @@
(def stringLiteral
(stringify (lexeme (between (is-char \") (is-char \") (many (not-char \"))))))

(def eof
(make-monad 'Parser
(fn p-eof [strn]
(if (= "" strn)
(consumed "" "")
(failed)))))

(def eol
(>> (optional (satisfy #(= % \return)))
(satisfy #(= % \newline))))


(defn force-during-parse [d]
(make-monad 'Parser
(fn [strn]
Expand Down