Skip to content

Lezer#1889

Closed
jpolitz wants to merge 3 commits into
brownplt:drydockfrom
jpolitz:lezer
Closed

Lezer#1889
jpolitz wants to merge 3 commits into
brownplt:drydockfrom
jpolitz:lezer

Conversation

@jpolitz

@jpolitz jpolitz commented Jun 30, 2026

Copy link
Copy Markdown
Member

No description provided.

jpolitz and others added 3 commits June 30, 2026 20:05
…M6 demo

A Lezer grammar (generated from pyret-grammar.bnf, then hand-tuned for the few
spots Pyret leans on GLR) that matches the canonical RNGLR parser exactly on
accept/reject, tree structure, and final ast.arr across the repo corpus (553
files), bootstrapworld starter-files (182), and ~9.7k fuzz mutants -- at ~5x the
speed and ~5-9x smaller.

Architecture: an external tokenizer replays Pyret's own tokenizer into Lezer, so
token-level disambiguation is inherited and only the grammar (CFG) is in scope.
Includes the oracle/measure/compare-trees/ast-equiv/fuzz harness, a to-rnglr
adapter that reshapes the Lezer tree so the existing translate() is reused
unchanged, and a standalone CodeMirror 6 editor demo (cm6-demo/) with Pyret
highlighting, folding, and CPO-style Tab/reindent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
surface-parse-lezer lives inside parse-pyret.js and reuses its in-closure
translate() + tokenizer, fed by the lezer-pyret bundle through a to-rnglr adapter
(no separate builtin needed). Threaded through CompileOptions, the CLI flag def,
the compile-lib pyret-string seam, and the file/npm locators' get-module -- the
latter being the real per-file parse point for file-based runs.

Default parser unchanged. Verified byte-identical program output and parse-error
messages with and without the flag; tests/parse/parse.js 60 specs, 0 failures.
Note: the bundle path in require-node-compile-dependencies.js is currently an
absolute machine path -- make configurable before sharing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The locators' get-module routes parsing through the Lezer frontend when the URL
has ?parser=lezer, inside a try/catch that falls back to the built-in parser on
any error. cpo-config.json registers the browser bundle (relative path) as a
raw-js module; CPO compiles parse-pyret from lang via the pyret->../lang symlink,
so surface-parse-lezer flows in automatically.

Default (built-in) parser unchanged. Verified: make web-local builds clean and
the bundle's lezerParseToRnglr yields ast.arr byte-identical to the RNGLR oracle.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jpolitz jpolitz closed this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant