Skip to content

Commit

Permalink
Fixed issue in grammar parser and the grammar function now calls pars…
Browse files Browse the repository at this point in the history
…e-ex. Updated docs.
  • Loading branch information
aaronc committed Feb 20, 2012
1 parent 3f7207d commit 7b45c50
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
9 changes: 5 additions & 4 deletions README.md
Expand Up @@ -9,9 +9,9 @@ even parsing test.
The primarly design goal is to make it easy to generate correct
parsers, but performance is not a primary consideration.
Scenarios that do not depend on speed, such as generating macros,
are good use cases. The entire framework is expressed in about
200 lines of code so that it can be easily embedded in projects
that do not want an extra dependency.
are good use cases. The entire framework is expressed in a little
more than 300 lines of code (excluding comments and docstrings)
so that it can be easily embedded in projects that do not want an extra dependency.

This library should be considered **alpha** quality as it has
not been used in production.
Expand Down Expand Up @@ -68,7 +68,8 @@ user> (parser3 [:a 1 2 3 :b "H" "e" "ll" "o" :c 10 20 30])
Please see the [generated documentation](http://aaronc.github.com/clj-parse/) for details on usage.
You can see some interesting examples in the [tests](https://github.com/aaronc/clj-parse/blob/master/test/clj_parse/test/pseudoebnf.clj). A macro `dbg-parser` is available for debugging
parsers and all matcher functions take an optional string as their first parameter which shows up in
debugging output.
debugging output. There is a function `parse-ex` which will throw an exception explaining the reason that
a parser failed and a function `parse-detailed` that provides detailed information on parsing errors.

## License

Expand Down
1 change: 0 additions & 1 deletion src/clj_parse/core.clj
Expand Up @@ -114,7 +114,6 @@

(defn- track-match-fail! [ctxt]
(when error-index
(when **debug** (**debug** "track-match-fail! " ctxt @parser-stack))
(let [last-idx @error-index
cur-idx (count (first ctxt))]
(cond (< cur-idx last-idx)
Expand Down
4 changes: 2 additions & 2 deletions src/clj_parse/pseudoebnf.clj
Expand Up @@ -11,7 +11,7 @@
(let [m* (op name matcher)] (if transform (mapply transform m*) m*)))
(mseq "match espression"
(mor (msubseq "nested sequence expression" #(apply grammar %))
(mexcept :? :+ :*))
#(and (not (sequential? %)) (not (#{:* :+ :?} %))))
(mdefault [nil] (m? "matcher name" string?))
(mdefault m1
(m? (mor "match operator"
Expand All @@ -22,7 +22,7 @@
"match transform expression" (mignore :=>)
(m1 "transform function" ifn?)))))))))

(defn grammar [& forms] (first (GrammarExpr forms)))
(defn grammar [& forms] (first (parse-ex GrammarExpr forms)))

(def GrammarOrExpr
(mapply
Expand Down

0 comments on commit 7b45c50

Please sign in to comment.