Skip to content

About

Scheme parser for tree-sitter

Topics

Resources

Contributing

Stars

52 stars

Watchers

6 watching

Forks

Latest commit

 

History

148 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tree-sitter-scheme

Test Build Crates.io Version NPM Version

Scheme parser for tree-sitter.

Recent News

  • 2026-10-12: Released 0.25.0. Maintained parsers for R5RS, R6RS, R7RS-small, Chez Scheme, Guile, and CHICKEN Scheme live under dialects/. The default scheme parser accepts all three standards plus some extensions. Reusable reader fragments live under grammar/. See docs/design.md to add, change, or make yourself a dialect.

  • 2026-10-12: 0.25.0 is a breaking change. The default parser is not compatible with 0.24.7-1. See nodes.md.

    • syntax is now syntax_quote
    • #; is sexp_comment, not comment
    • New nodes: dot, datum_label, datum_label_id, datum_reference
    • list is () or [] only; . is a child dot
    • byte_vector also matches #u8(...)
    • Dropped extensions: {} lists, symbols that start with a digit, \ + any character in strings, extra character names (#\bel, #\ls, #\nel, #\rubout, #\vt)

Status

The default scheme parser accepts the union of R5RS, R6RS, and R7RS-small reader syntax. When the standards disagree on a token boundary, it uses the R6RS reading.

Extensions:

  • Steel Scheme #\u hexadecimal characters
  • #: keywords

More syntax is welcome if it is widely used. Please open an issue. If you want dialect specific syntax very much, prefer a dialect parser.

Separate parsers live under dialects/. Each is its own Tree-sitter language named scheme, not a drop-in for the default parser:

  • dialects/r5rs/ — R5RS
  • dialects/r6rs/ — R6RS
  • dialects/r7rs/ — R7RS-small
  • dialects/chez/ — Chez Scheme 10.4
  • dialects/guile/ — GNU Guile 3.0.11
  • dialects/chicken/ — CHICKEN Scheme 6.0.0

See each dialect grammar.js for coverage. Chez, Guile, and CHICKEN also have notes in docs/. Generate a dialect from its own directory; see CONTRIBUTING.md.

Implementation

  • Support for implementation
    • Chez Scheme (#1)
    • Chicken Scheme (#3)
    • Guile Scheme (#7)
    • Steel Scheme (#17)

Usage

See nodes.md for the default parser's visible nodes.

This parser doesn't parse language constructs. Instead, it parses code as lists.

If you want language constructs support, use custom queries (see #5), also see thchha/tree-sitter-scheme.

To use a dialect parser, clone this repository, generate and build that dialect with the tree-sitter CLI, then copy the compiled library to the location your editor requires:

npm install
cd dialects/r5rs
npx tree-sitter generate
npx tree-sitter build

Replace r5rs with r6rs, r7rs, chez, guile, or chicken. Generate from the dialect directory; generating from the repository root overwrites default src/. See CONTRIBUTING.md.

If you want to make your own parser, look at the reusable fragments in grammar/ and the notes in docs/design.md and docs/dialect-workflow.md.

Query

The queries here are too simple and not intended to be useful in an editor. You need to write by yourself, according to the grammar files.

Reference

Scheme

Tree-sitter

About

Scheme parser for tree-sitter

Topics

Resources

Contributing

Stars

52 stars

Watchers

6 watching

Forks

Releases

Used by

Contributors

Languages