# @lezer/generator

> Parser generator for the incremental lezer parser

Latest version **1.8.0** (published 2025-06-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @lezer/generator
pnpm add @lezer/generator
yarn add @lezer/generator
bun add @lezer/generator
```

Provides the command `lezer-generator`.

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.8.0 |
| Published | 2025-06-23 |
| First published | 2021-08-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 364.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 187 |
| Author | Marijn Haverbeke |
| Maintainers | marijn |

## Links

- npm: https://www.npmjs.com/package/@lezer/generator
- Repository: https://github.com/lezer-parser/generator
- Homepage: https://github.com/lezer-parser/generator#readme
- Issues: https://github.com/lezer-parser/generator/issues
- npm.io page: https://npm.io/package/@lezer/generator

## Dependencies (2)

- [@lezer/lr](https://npm.io/package/@lezer/lr.md) ^1.3.0
- [@lezer/common](https://npm.io/package/@lezer/common.md) ^1.1.0

## Recent versions

- 1.8.0 (latest) — 2025-06-23
- 1.7.3 — 2025-03-31
- 1.7.2 — 2024-12-06
- 1.7.1 — 2024-06-19
- 1.7.0 — 2024-03-12
- 1.6.0 — 2024-01-08
- 1.5.1 — 2023-09-15
- 1.5.0 — 2023-08-20
- 1.4.2 — 2023-08-17
- 1.4.1 — 2023-08-17
- 1.4.0 — 2023-08-11
- 1.3.0 — 2023-06-15
- 1.2.4 — 2023-06-12
- 1.2.3 — 2023-04-28
- 1.2.2 — 2023-01-18
- … 13 more at https://npm.io/package/@lezer/generator/versions

## README

# @lezer/generator

[ [**WEBSITE**](http://lezer.codemirror.net) | [**ISSUES**](https://github.com/lezer-parser/lezer/issues) | [**FORUM**](https://discuss.codemirror.net/c/lezer) | [**CHANGELOG**](https://github.com/lezer-parser/generator/blob/master/CHANGELOG.md) ]

This is an [LR(1)](https://en.wikipedia.org/wiki/LR_parser) (more precisely pseudo-[LALR](https://en.wikipedia.org/wiki/LALR_parser),with opt-in [GLR](https://en.wikipedia.org/wiki/GLR_parser)) parser generator which outputs grammars that can be used by the [Lezer](https://github.com/lezer-parser/lezer/) parser.

This package exports both a command-line parser generator tool called [`lezer-generator`](https://lezer.codemirror.net/docs/guide/#building-a-grammar) and a [programming interface](https://lezer.codemirror.net/docs/ref/#generator).

The grammar format that the tool accepts is documented in the [system guide](https://lezer.codemirror.net/docs/guide/#writing-a-grammar).

See `test/cases/` for some simple example grammars, or [lezer-javascript](https://github.com/lezer-parser/javascript) for a real grammar.

You can import `"@lezer/generator/rollup"` to get a [Rollup](https://rollupjs.org/guide/en/) plugin that will transform files ending in `.grammar` or `.grammar.terms` (a pseudo-source referring to the terms produced by the `.grammar` file) as part of the rollup build process.

```javascript
import {lezer} from "@lezer/generator/rollup"

export default {
  input: "./in.js",
  output: {file: "out.js", format: "cjs"},
  plugins: [lezer()]
}
```

The plugin can be passed `lezer({exportName})` option to configure the name of the parser export.

The code is licensed under an MIT license.

---
_Source: https://npm.io/package/@lezer/generator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
