nearley is a simple, fast and powerful parsing toolkit. It consists of:
- A powerful, modular DSL for describing languages
- An efficient, lightweight Earley parser
- Loads of tools, editor plug-ins, and other goodies!
nearley is a streaming parser with support for catching errors gracefully and providing all parsings for ambiguous grammars. It is compatible with a variety of lexers (we recommend moo). It comes with tools for creating tests, railroad diagrams and fuzzers from your grammars, and has support for a variety of editors and platforms. It works in both node and the browser.
Unlike most other parser generators, nearley can handle any grammar you can define in BNF (and more!). In particular, while most existing JS parsers such as PEGjs and Jison choke on certain grammars (e.g. left recursive ones), nearley handles them easily and efficiently by using the Earley parsing algorithm.
nearley is used by a wide variety of projects:
- artificial intelligence and
- computational linguistics classes at universities;
- file format parsers;
- data-driven markup languages;
- compilers for real-world programming languages;
- and nearley itself! The nearley compiler is bootstrapped.
nearley is an npm staff pick.
Please visit our website https://nearley.js.org to get started! You will find a tutorial, detailed reference documents, and links to several real-world examples to get inspired.
Please read this document before working on nearley. If you are interested in contributing but unsure where to start, take a look at the issues labeled "up for grabs" on the issue tracker, or message a maintainer (@kach or @tjvr on Github).
nearley is MIT licensed.
If you are citing nearley in academic work, please use the following BibTeX entry.