bnf-parser is a deterministic compiler/parser library for Backus-Naur Form (BNF) grammars, currently at version 4.1.3. It differentiates itself by compiling BNF definitions directly into WebAssembly modules, enabling high-performance parsing. This compilation process also generates TypeScript type definitions for the resulting Abstract Syntax Tree (AST), making it easier to work with parsed outputs in type-safe environments. The compiled WebAssembly artifacts are platform-agnostic, capable of running wherever `WebAssembly.Instance()` is supported, and are bundled into a single JavaScript file for easy integration with bundlers. The library primarily functions as a `devDependency`, with its `bnf-compile` CLI tool generating standalone parser artifacts that do not require `bnf-parser` as a runtime dependency. Releases appear to be frequent, with several patch versions addressing memory management, compatibility, and bug fixes since the major v4.0.0 release.
npm install bnf-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to compile a BNF grammar into a WebAssembly parser using the `bnf-compile` CLI tool and then import and utilize the generated TypeScript parser to process an input string and inspect its Abstract Syntax Tree (AST).
Update imports to use `import { Symbol } from 'bnf-parser/legacy';` for older APIs. For new compilation-based workflows, use `npx bnf-compile` and import the generated ES module. Ensure your project is configured for ESM or use a bundler.Upgrade to `bnf-parser@4.1.1` or newer. If issues persist with extremely large inputs, consider optimizing your BNF grammar to reduce complexity or segmenting inputs if feasible.
Install `bnf-parser` with `--save-dev`. Ensure your build process properly includes the `bnf-compile` step and that your runtime code only imports the generated parser files, not the `bnf-parser` library directly.
Upgrade to `bnf-parser@4.0.5` or newer to ensure correct handling of hexadecimal literals and robust CLI behavior.
Update your import statements to use ES module syntax (e.g., `import * as syntax from './path/to/parser.js';`) and ensure your project's `package.json` is configured for ES modules (`"type": "module"`) or your bundler is correctly configured for ESM.
Upgrade `bnf-parser` to `4.1.1` or newer to benefit from memory usage fixes. Review your BNF grammar for potential infinite recursion or excessively complex rules. For very large inputs, consider processing them in smaller chunks if your grammar allows.
Upgrade to `bnf-parser@4.0.1` or newer, as this bug was addressed shortly after the v4.0.0 release.
No dependency data recorded yet.