The problem of parsing structured text has resisted one-size-fits all solutions for over 60 years. Lezer isn't such a solution either, but it is a ver

The Lezer Parser System

submited by
Style Pass
2024-04-24 07:00:06

The problem of parsing structured text has resisted one-size-fits all solutions for over 60 years. Lezer isn't such a solution either, but it is a very decent parser generator, especially well suited for use in code editors.

Lezer (the Dutch word for reader, pronounced like “laser”) provides a parser generator that outputs JavaScript modules, which can be loaded to parse code into a non-abstract syntax tree. This tree can then be used to do highlighting and basic semantic analysis.

Lezer can quickly re-parse documents that were slightly changed compared to a previously parsed version by reusing nodes from the old parse.

Being designed for the code editor use case, the parser is equipped with strategies for recovering from syntax errors, and can produce a tree for any input.

By using the LR parsing algorithm, an efficient tokenizer, and data structures optimized for locality, the parser can process its input at a very respectable speed.

Leave a Comment