A simple, fast, and powerful Earley parser toolkit for JavaScript that handles any BNF grammar.
nearley is a parsing toolkit for JavaScript that allows developers to create parsers for custom languages, file formats, or data structures. It solves the problem of parsing complex or ambiguous grammars by implementing the Earley algorithm, which can handle any BNF-defined grammar, including those with left recursion.
JavaScript developers building compilers, interpreters, data format parsers, or language processing tools, as well as educators and students in computational linguistics or AI courses.
Developers choose nearley for its ability to parse any grammar without the limitations of other parser generators, its comprehensive tooling for grammar development, and its compatibility with both Node.js and browser environments.
๐๐๐ฒ Simple, fast, powerful parser toolkit for JavaScript.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Handles any BNF grammar, including ambiguous and left-recursive ones, which other JavaScript parsers like PEGjs and Jison cannot, as stated in the README.
Includes tools for generating tests, railroad diagrams, and fuzzers from grammars, aiding in development and documentation, as highlighted in the features.
Supports streaming input and gracefully catches errors during parsing, making it suitable for real-time applications, as mentioned in the documentation.
Works in both Node.js and browser environments and has editor plug-ins, ensuring versatility across development setups, per the README.
The Earley algorithm, while general, can be less efficient than specialized parsers for deterministic grammars, potentially impacting parsing speed in performance-critical applications.
Requires separate integration with a lexer like moo, adding setup complexity compared to all-in-one parser solutions, as the README notes it's compatible with various lexers but not bundled.
The modular DSL and advanced features may require more upfront learning, especially for developers new to parsing concepts, despite the comprehensive documentation.
nearley is an open-source alternative to the following products: