No description
  • Scheme 97.6%
  • Racket 2.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-04 22:32:48 -07:00
at-exp fix(reader): Preserve native dot recovery and dotted commands 2026-09-04 17:37:28 -07:00
tests fix(reader): Preserve native dot recovery and dotted commands 2026-09-04 17:37:28 -07:00
.gitignore Port at-expression grammar and reusable readers 2026-09-04 17:08:32 -07:00
at-exp.ss Port at-expression grammar and reusable readers 2026-09-04 17:08:32 -07:00
build.ss Port at-expression grammar and reusable readers 2026-09-04 17:08:32 -07:00
gerbil.pkg Add fixed Gerbil language reader integration 2026-09-04 16:13:13 -07:00
LICENSE Import pristine Racket at-exp package 2026-09-04 16:08:20 -07:00
LICENSE-MIT.txt Port at-expression grammar and reusable readers 2026-09-04 17:08:32 -07:00
README.md cleanup readme a bit 2026-09-04 22:32:48 -07:00

Gerbil @-expressions

#lang :at-exp adds Racket-style @ expressions to Gerbil.

Example

#lang :at-exp

(export main)

(def (greet name)
  @string-append{Hello, @|name|!})

(def (main)
  (displayln (greet "Gerbil")))

Reader API

Use the reader independently of #lang:

(import (prefix-in :at-exp/reader at-))
(at-read (open-input-string "@list[1]{hello}")) ; => (list 1 "hello")
(at-read-inside (open-input-string "Hello @|name|!")) ; => ("Hello " name "!")
Export Behavior
read Optional input port; returns one datum or end-of-file.
read-syntax Optional source name, then input port; returns Gerbil runtime syntax (AST) or end-of-file. A false source name uses the port's source.
read-inside Optional input port; reads the entire port as text and returns a list of strings and expressions.
read-syntax-inside Optional source name, then input port; returns a syntax-wrapped text list. Also accepts command-char:.
make-at-readtable Returns a native readtable without changing the current table or any port.
make-at-reader Returns a reader procedure. Accepts the options below plus syntax?: (default #t) and inside?: (default #f); uses the read-syntax calling convention when syntax?: is true, otherwise read.
use-at-readtable Accepts the readtable options below and installs the result as both the current readtable and the current input port's table. Other existing ports retain their tables.

Omitted ports default to current-input-port; omitted source names default to #f. Inside readers consume through end-of-file, returning an empty list (syntax-wrapped when requested) for empty input.

Customization

Both factories accept these keywords:

  • readtable: — base table, defaulting to current-readtable; #f selects Gambit's standard table.
  • command-char: — character introducing at-expressions; defaults to #\@.
  • command-readtable: — defaults to the base table. Accepts a table, #f for Gambit's standard table, or 'dynamic for the current table when reading a command. Applies to the initial command read; nested host expressions use the ambient table. Expression escapes use the command table throughout.
  • datum-readtable: — table for bracketed arguments. Accepts a table, #t for the constructed at-table (default), #f for Gambit's standard table, a function transforming the constructed table, or 'dynamic. The closing ] remains a delimiter regardless of its supplied handler.
  • syntax-post-processor: — procedure receiving and returning Gerbil runtime syntax after each at-form is assembled, before punctuation prefixes are applied. Runs even for datum readers, but not for ordinary host datums or text chunks. Defaults to values.

The convenience read, read-syntax, and read-inside use dynamic command and datum tables. read-syntax-inside uses the factory defaults.

Development

gerbil build
gerbil test -v 0 ./tests/reader-test.ss ./tests/api-test.ss

Tested with Gerbil v0.19-dev-38-g98e339be and Gambit v4.9.7-6-g64f4d369.

Attribution and license

The grammar is adapted from Racket's scribble/reader.rkt, by eli and mflatt. Reader test cases come from the Scribble reader tests.

This port uses the upstream MIT license option; the Gerbil implementation and tests are also MIT-licensed. See LICENSE and LICENSE-MIT.txt.