A Clojure/ClojureScript parser generator that turns EBNF or ABNF grammars into executable parsers for any context-free grammar.
Instaparse is a parser generator library for Clojure and ClojureScript that converts EBNF or ABNF grammar specifications into executable parsers. It solves the problem of building parsers for complex languages by providing a simple, notation-driven approach that works with any context-free grammar, including those with left recursion or ambiguity.
Clojure and ClojureScript developers who need to parse custom languages, data formats, or domain-specific languages without dealing with low-level parser implementation details.
Developers choose Instaparse because it eliminates the typical restrictions of parser generators, supports any context-free grammar, and integrates seamlessly with Clojure's data structures and transformation tools, making parsing as easy as writing a grammar.
Instaparse is a parser generator for Clojure and ClojureScript that transforms standard EBNF or ABNF notation into executable parsers. It aims to make context-free grammars as easy to use as regular expressions, providing a simple yet powerful way to build parsers for a wide range of languages and data formats.
Instaparse believes that writing parsers should be straightforward and accessible, leveraging familiar notation while removing traditional limitations like grammar restrictions or left-recursion issues.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Accepts left-recursive, right-recursive, and ambiguous context-free grammars without LL/LALR restrictions, allowing natural grammar design as shown in the tutorial with examples like S = S 'a' | Epsilon.
Outputs parse trees in hiccup or enlive formats, enabling easy manipulation with Clojure's transform functions or libraries like enlive, as demonstrated in the arithmetic evaluator example.
Provides detailed error messages, total parse mode to embed failures in trees, and optional visualization with character spans, aiding in diagnosing complex parse issues.
Adds lookahead, negative lookahead, and ordered choice operators for disambiguation and enhanced expressiveness, such as parsing equal runs of a's, b's, and c's which pure CFGs cannot handle.
Tied exclusively to Clojure and ClojureScript, making it unsuitable for polyglot projects or teams not using these languages, as highlighted in the dependency requirements.
Grammar strings embedded in Clojure code require escaping quotes and backslashes, reducing readability—a noted issue in the README that suggests using external files as a workaround.
The visualize function depends on rhizome and graphviz, which aren't bundled, adding setup complexity and potential version conflicts for users wanting graphical tree output.
Highly recursive grammars can produce deeply nested trees that cause Clojure stack overflows, as warned in the README with examples like left-recursive parsers on long strings.