dj-peg 0.1.0
A Ring inspired (aka functional and composable) parsing expression grammar
(PEG) library.
A while back I wrote a PEG generator. Since it was buggy, I've completely
rewritten it and also tried to write it psuedo literate programming (LP)
style, in that I try to make it more of a story. I don't rely on any LP
tools, its just heavily commented and should flow linearly. So if you never
knew about PEGs before and want to dive into it, this would be a good
opportunity to learn about it. Also I make good use of continuations,
trampolines, and closures. Please check it out.
A quick example:
(require [dj.peg :as peg])
(let [num (peg/alter-result (peg/token #"\d+") #(Integer/parseInt %))
whitespace (peg/token #"\s+")
triplet (peg/seq num whitespace num whitespace num)]
(peg/parse triplet "3 44 2theremaininginput"))
;;user=> [[3 " " 44 " " 2] "theremaininginput"]
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en