Amotoen
Description
This project adds support in Clojure for Parsing Expression Grammars.
If you were using clj-peg you should move to Amotoen.
Claim to fame
Maybe there isn't fame... but, the grammar for Amotoen grammars is shown below:
:Whitespace '(| \space \newline \tab \,)
:_* '(* :Whitespace)
:_ [:Whitespace '(* :Whitespace)]
:Grammar [\{ :_* :Rule '(* [:_ :Rule]) :_* \}]
:Rule [:Keyword :_ :Body]
:Keyword [\: :ValidKeywordChar '(* :ValidKeywordChar)]
:Body '(| :Keyword :Char :Grouping)
:Grouping '(| :Sequence :Either :ZeroOrMore :AnyNot)
:Sequence [\[ :_* :Body '(* [:_* :Body]) :_* \]]
:Either [\( \| :_ :Body '(* [:_* :Body]) :_* \)]
:ZeroOrMore [\( \* :_ :Body :_* \)]
:AnyNot [\( \% :_ :Body :_* \)]
:Char [\\ (list '| (pegs "tab") (pegs "space") (pegs "newline") '(% \space))]
:ValidKeywordChar (lpegs '| "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:/*+!_?-")
Use
This project builds with Leiningen, so once you've lein installed it, you can use the
following code (the README on github goes in to more detail).
(ns tld.company.project
(:use (com.lithinos.amotoen core)))
(def some-grammar { :Content [\a \b] })
(let [ast (pegasus :Content some-grammar (gen-ps "ab"))]
(println "AST:" ast))
License
This project has been released under the EPL 1.0 license.
Downloads
Please see the related github project page.