7 Syntax Objects
This module provides tools for macro transformers.
7.1 Contracts
Recognizes syntax objects
stx such that
(syntax->datum stx)
satisfies
datum/c.
7.2 Syntax Lists
7.3 Syntax Conversions
The "master" keyword #:stx sets all attributes from a single syntax
object, defaulting to #f for unadorned syntax objects.
The individual keywords #:src, #:ctxt, #:prop, and
#:cert override #:stx for individual syntax object
attributes. They control source location information, lexical context
information, syntax object properties, and syntax certificates, respectively.
Examples: |
> (to-datum #'(a b c)) |
(a b c) |
> (to-datum (list #'a #'b #'c)) |
(#<syntax:2:0 a> #<syntax:2:0 b> #<syntax:2:0 c>) |
7.4 Source Locations
These produce the directory and file name, respectively, of the path with which
stx is associated, or #f if stx is not associated
with a path.
These functions extract the planet package with which
stx is
associated, if any, based on its source location information and the currently
installed set of planet packages. They produce, respectively, the planet
package s-expression, its owner, name, major version number, minor version
number, or a symbol corresponding to a
planet module path. They each
produce
#f if
stx is not associated with a planet package.
7.5 Syntax Errors
A parameter that may be used to store the current syntax object being
transformed. It is not used by the expander; you have to assign to it yourself.
This parameter is used by
syntax-error, below. It defaults to
#f.
Raises a syntax error based on the locations of
(current-syntax) and
stx, with
(format fmt arg ...) as its message.
Examples: |
|
|
a: general location |
|
a: specific location |
7.6 Pattern Bindings