Jison is a JavaScript parser generator that creates bottom-up parsers from user-defined grammars. It supports grammars defined in either a JSON format or a Bison-style syntax, outputting a standalone JavaScript file capable of parsing the specified language. The API is intentionally designed to be similar to Bison's, making it approachable for developers familiar with traditional parser generators like Yacc or Bison. As of its latest release, 0.4.18, published in 2014, the project appears to be largely unmaintained. It generates parsers that can be used as command-line tools or programmatically within a CommonJS environment. Its primary differentiator is providing a Bison-like grammar definition and parser generation workflow targeting JavaScript.
npm install jisonVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to programmatically define a grammar, instantiate a Jison parser, and use it to parse an arithmetic expression, including error handling.
Consider alternative, actively maintained parser generator libraries for JavaScript (e.g., Nearley, PEG.js) for new development. For existing projects, thoroughly test compatibility and consider vendoring a patched version.
Always use `const Parser = require('jison').Parser;` syntax. If your project is pure ESM, you may need to use a wrapper or a dynamic `import()` call if `jison` is the only CJS dependency.Familiarize yourself with the concepts of parser generators and context-free grammars. Refer to the official Jison documentation or the Bison manual for fundamental understanding before writing complex grammars.
Ensure your file is treated as CommonJS (e.g., `.js` file without `"type": "module"` in `package.json`, or specifically use a CJS environment). If you must use Jison in an ESM context, consider a dynamic import: `const { Parser } = await import('jison');`.Install jison globally: `npm install -g jison`. If already installed, ensure your `PATH` environment variable includes the npm global bin directory.
Review your input string against the grammar rules. If the input is valid according to your intent, debug your grammar definition for ambiguities, missing rules, or incorrect token definitions. Use Jison's debug mode (`jison -t`) for more detailed parser output.
No dependency data recorded yet.