@lezer/lr

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

Library
npm
v1.4.10
685 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
35 /100 Needs Attention
Development Activity 8
Maintenance 0
Community 44
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
75 /100 Good
Architecture 85
Code Quality 78
Innovation 82
Learning Curve 55

@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
61%
GPL 2.0

Discourse

Community

47,915

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
Ruby 61%
JavaScript 32%
Updated 4 days ago
Java
34%
Apache 2.0

Enso

Analytics · Data Engineering · Low Code Platforms

7,441

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
59
Repo Health
90
Technical
61
Dependency
Built with
Java 34%
TypeScript 27%
Scala 26%
Updated 1 months ago
TypeScript
48%
AGPL 3.0

Grafana

Analytics · Monitoring

76,962

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
63
Dependency
Built with
TypeScript 48%
Go 46%
Updated 4 days ago
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,529

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
65
Dependency
Built with
TypeScript 67%
Vue 25%
Updated 6 days ago
Python
62%
Apache 2.0

marimo

Data Engineering · Developer Tools

22,918

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
89
Repo Health
91
Technical
65
Dependency
Built with
Python 62%
TypeScript 37%
Updated 5 days ago
Clojure
56%
Other

Metabase

Analytics

49,438

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
64
Dependency
Built with
Clojure 56%
TypeScript 38%
Updated 4 days ago
TypeScript
92%
Other

n8n

Automation · No Code Platforms

206,147

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
65
Dependency
Built with
TypeScript 92%
Updated 4 days ago
JavaScript
64%
AGPL 3.0

overleaf

Collaboration · Productivity

18,188

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

View details
87
Repo Health
80
Technical
62
Dependency
Built with
JavaScript 64%
TypeScript 30%
Updated 2 weeks ago
Python
49%
Other

Arize Phoenix

Analytics · Devops · Monitoring

11,641

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
67
Dependency
Built with
Python 49%
TypeScript 42%
Updated 4 days ago

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