Lezer#1889
Closed
jpolitz wants to merge 3 commits into
Closed
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.