cm6-lezer-scheme-common-lang
v0.1.2
Published
A broad Lezer grammar for Scheme/Guile-ish S-expressions (no external tokenizers).
Maintainers
Readme
cm6-lezer-scheme-common-lang
A broad Lezer grammar for Scheme/Guile-ish S-expressions, intended to work “generally well” across many S-expression languages while still capturing a few common Scheme heads like define, define-syntax, define-macro, and syntax-rules.
Design goals
- Prefer parsing most Guile code reasonably well.
- Stay broad enough for many other S-expression dialects.
- No external tokenizers (single grammar file).
Tradeoffs
#| ... |#comments are supported but not nested (nested block comments require an external tokenizer in Lezer).
Install
npm install cm6-lezer-scheme-common-langUsage
import { parser } from "cm6-lezer-scheme-common-lang";
const tree = parser.parse("(define (f x) (list x x))");
console.log(tree.toString());import { scheme } from "cm6-lezer-scheme-common-lang";
const schemeLangSupport = scheme();Build from source
If you cloned the repo (or you’re using the zip), install deps and build:
npm install
npm run buildThis uses lezer-generator to produce:
dist/parser.jsdist/parser.terms.js
Lezer CLI behavior is documented in the Lezer guide. (It writes both output and terms files when -o is provided.)
Notable tokens / nodes
SigilParenStart,SigilBracketStart,SigilBraceStart- Catch an edge-case where n characters are glued to an opening delimiter, like
foo(or#hash[.
- Catch an edge-case where n characters are glued to an opening delimiter, like
DefineForm,DefineSyntaxForm,DefineMacroForm,SyntaxRulesForm- Recognize lists whose head is
define,define-syntax,define-macro,syntax-rules.
- Recognize lists whose head is
License
MIT
