@lezer/lr

Runtime incremental GLR parser engine that powers Lezer grammars and CodeMirror's syntax trees

Library
npm
v1.4.10
685stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
36/100Needs Attention
Development Activity12
Maintenance0
Community44
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
75/100Good
Architecture85
Code Quality78
Innovation82
Learning Curve55

@lezer/lr is the run-time parsing engine of the Lezer system: it consumes the compact parser tables produced by @lezer/generator and executes them to build syntax trees incrementally, prioritizing speed and small tree size over a highly labeled parse tree. Nodes are minimal blobs of start offset, end offset, tag, and children, which keeps both the generated parser tables and the resulting trees compact enough to re-parse on every keystroke in an editor.

As a GLR (Generalized LR) parser, it can explore multiple parse paths simultaneously to handle ambiguous grammars and recover gracefully from syntax errors mid-edit, making it well suited to live code editors rather than one-shot batch compilers. It is the parsing core underneath CodeMirror 6’s language support packages (@codemirror/lang-*) and any other project that needs fast, incremental, error-tolerant parsing in JavaScript.

What You Get

  • An LRParser runtime that executes generated parser tables to produce syntax trees
  • GLR (Generalized LR) parsing that explores multiple parse paths to handle ambiguous grammars and recover from syntax errors
  • Incremental re-parsing designed to run efficiently on every keystroke in an editor
  • ContextTracker and ExternalTokenizer/LocalTokenGroup hooks for context-sensitive or hand-written tokenization alongside the generated grammar
  • Compact, minimally-labeled syntax trees (start, end, tag, children) that keep memory and re-parse cost low

Common Use Cases

  • Powering a CodeMirror 6 language extension (e.g. @codemirror/lang-javascript) that needs live syntax highlighting and folding
  • Building a custom code editor or IDE-like tool that requires fast incremental reparsing as the user types
  • Implementing error-tolerant parsing for a domain-specific language embedded in an interactive tool
  • Consuming grammar tables generated by @lezer/generator at build time to parse a custom file format at runtime

Under The Hood

Architecture - The engine is organized around four focused modules: parse.ts (966 lines) implements LRParser, the core GLR driving loop that walks generated action/goto tables and manages competing parse stacks; stack.ts (536 lines) implements the Stack data structure representing one in-progress parse path, supporting the fork/merge operations GLR parsing needs for ambiguity; token.ts (402 lines) implements the tokenizer runtime, including InputStream, ExternalTokenizer, and LocalTokenGroup for grammars that need custom or context-sensitive tokenization beyond what the generated tables encode; and constants.ts centralizes the encoding scheme shared with @lezer/generator’s table format. index.ts is a minimal three-line public surface re-exporting LRParser, Stack, and the tokenizer primitives. Tech Stack - Pure TypeScript with a single runtime dependency, @lezer/common (the shared tree/node type definitions used across the Lezer ecosystem), built via a custom build.js script and the author’s own @marijn/buildtool, emitting both ESM (dist/index.js) and CJS (dist/index.cjs) bundles with type declarations. Code Quality - The package’s own test script explicitly defers to @lezer/generator’s test suite (‘Tests are in @lezer/generator’), reflecting that this runtime is validated end-to-end against real generated grammars rather than in isolation; the small, single-purpose module boundaries (parse/stack/token/constants) keep each piece independently reasoned about despite the algorithmic complexity of GLR parsing. API Design - The public API is deliberately narrow — LRParser, Stack, ContextTracker, and tokenizer helpers — because almost all day-to-day usage goes through a generated parser object rather than this package’s exports directly; documentation for the actual parsing interface lives on the Lezer website rather than in inline JSDoc, reflecting its role as an internal engine for generated parsers rather than a general-purpose end-user API.

Used by 10 apps in this directory

Ruby
62%
GPL 2.0

Discourse

Community

47,672

Open-source community platform with dynamic trust levels, real-time chat, and a powerful plugin architecture for self-hosted forums.

View details
89
Repo Health
89
Technical
67
Dependency
Built with
Ruby62%
JavaScript31%
Updated today
Java
34%
Apache 2.0

Enso

Analytics · Data Engineering · Low Code Platforms

7,437

A visual and textual programming platform for data prep and analysis where the node graph and the underlying Enso code are always perfectly in sync, built by an Alteryx co-founder on a GraalVM engine.

View details
70
Repo Health
90
Technical
62
Dependency
Built with
Java34%
TypeScript27%
Scala26%
Updated 1 weeks ago
TypeScript
48%
AGPL 3.0

Grafana

Monitoring · Analytics

76,300

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
65
Dependency
Built with
TypeScript48%
Go46%
Updated today
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,055

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
66
Dependency
Built with
TypeScript67%
Vue23%
Updated 3 days ago
Python
61%
Apache 2.0

marimo

Developer Tools · Data Engineering

22,393

A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.

View details
90
Repo Health
91
Technical
66
Dependency
Built with
Python61%
TypeScript37%
Updated today
Clojure
54%
Other

Metabase

Analytics

48,828

The open-source BI platform that lets anyone ask questions and build dashboards without writing SQL — with an embedded analytics SDK and AI-powered query assistant included.

View details
95
Repo Health
84
Technical
65
Dependency
Built with
Clojure54%
TypeScript40%
Updated today
TypeScript
92%
Other

n8n

Automation · No Code Platforms

201,152

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
66
Dependency
Built with
TypeScript92%
Updated today
JavaScript
63%
AGPL 3.0

overleaf

Collaboration · Productivity

18,035

Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.

View details
84
Repo Health
80
Technical
67
Dependency
Built with
JavaScript63%
TypeScript29%
Updated 1 months ago
Python
47%
Other

Arize Phoenix

Devops · Analytics · Monitoring

11,105

Open-source AI observability platform for tracing, evaluating, and debugging LLM applications with built-in intelligence and MCP support.

View details
90
Repo Health
88
Technical
68
Dependency
Built with
Python47%
TypeScript41%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search