Skip to content
Browse files

some doc

  • Loading branch information...
1 parent 5a5daf6 commit 7c1964bdfdcdde372965d5519aa167dad4725d87 @mmikulicic committed Jan 4, 2010
Showing with 35 additions and 6 deletions.
  1. +33 −4 README
  2. +2 −2 project.clj
View
37 README
@@ -1,15 +1,44 @@
# clarsec
-FIXME: write description
+clarsec is an attempt to port haskell parsec to clojure
+
+This library is inspired on http://kotka.de/projects/clojure/parser.html and uses the Meikel Brandmeyer's "monad" library (slightly adapted), as I didn't understand how the clojure contrib monad
+library works.
## Usage
-FIXME: write
+there is an example parser which I ported straight from a Haskell Parsec code.
+
+Basically, you should be able to write the examples on http://kotka.de/projects/clojure/parser.html.
+
+The library comes with a small number of basic combinators. I hope it will be useful.
+
+## Caveats
+
+forward references are a mess. I tried to maintain the DSL as simple as possible. Imagine that "structureDef" and "comma" are two already existing
+parsers, and "brackets" and "sepBy" are two combinators. I want to be able to write it like this:
+
+ (def structure
+ (brackets (sepBy structureDef comma)))
+
+however, clojures 'def' binding is strict and all the referenced vars have to be already defined, otherwise you get:
+
+ Var example/structureDef is unbound.
+
+I'm a clojure newbie, so I don't know exactly how to avoid this. I know only of two workarounds:
+
+ 1. use functions: (defn structure [] (brackets (sepBy (structureDef) (comma))))
+ 2. use delay: (def structure (delay (brackets (sepBy structureDef comma))))
+
+I opted for the "delay", as it allowed me to avoid all those spurious parens, and retain the illusion of a parser DSL, and put the "delay" only where needed. (or everywhere
+with a "defblabla" macro).
+
+Unfortunately this required a small patch to Brandmeyer's monad library.
## Installation
-FIXME: write
+leim jar
## License
-FIXME: write
+http://www.apache.org/licenses/LICENSE-2.0.html
View
4 project.clj
@@ -1,4 +1,4 @@
-(defproject clarsec "1.0.0-SNAPSHOT" :description "FIXME: write" :dependencies [
- [org.clojure/clojure "1.1.0-master-SNAPSHOT"]
+(defproject clarsec "0.0.1-SNAPSHOT" :description "Parsec ported to clojure" :dependencies [
+ [org.clojure/clojure "1.1.0"]
[org.clojure/clojure-contrib "1.0-SNAPSHOT"]
] :main eu.dnetlib.dlms.parser)

0 comments on commit 7c1964b

Please sign in to comment.
Something went wrong with that request. Please try again.