Language creationπ i
This module provides forms for creating new #lang languages.
It abstracts over several language-creation components such as
syntax/module-reader, reader submodules, and #%module-begin.
This library makes it easy to create simple one-off languages driven by
a single macro.
( define-lang-syntaxlang-collection-namemodule-body-syntaxmaybe-module-begin)
maybe-module-begin =
| #:module-begin
| base-module-begin
Defines a reader submodule that implements a
#lang that is equivalent
to
racket/base, except that
module-body-syntax wraps
all forms in the module. This must be used in the
main.rkt file of the
collection directory
lang-collection-name. For example, assuming this
is in the main file of a collection directory named
display-syntax:
(define-syntaxdisplay-each-body-stx
(syntax-parser
[(_body...)
#'(begin(displayln#'body)...)]))
Then the following creates a
#lang display-syntax that prints each
syntax object of the language when run:
(define-lang-syntaxdisplay-syntaxdisplay-each-body-stx)
If
base-module-begin is provided, it is used as the
#%module-begin of the new language instead of the
#%module-begin from
racket/base.