Instaparse is a simple yet powerful parser generator for Clojure and ClojureScript that turns grammars written in EBNF or ABNF into executable parsers, with support for left recursion, ambiguous grammars, PEG-like lookahead, and various output formats. Instaparse supports most of the common notations for context-free grammars. For example, a popular alternative to * is to surround the term with curly braces {}, and a popular alternative to ? is to surround the term with square brackets []. Rules can be specified with =, :, :=, or ::=. Rules can optionally end with ;. Instaparse is very flexible in terms of how you use whitespace (as in Clojure, , is treated as whitespace) and you can liberally use parentheses for grouping.
Features
- Grammar definitions in familiar EBNF or ABNF syntax
- Handles left- and right-recursive and ambiguous grammars
- Support for lookahead and negative lookahead (PEG-like extensions)
- Multiple output formats including hiccup and enlive parse trees
- Detailed error reporting and optional lazy parse results
- "Total parsing" mode and combinator-based grammar building