The following facilities are experimental.
This module is deprecated; it reprovides expr/c for backward compatibility.
syntax
[syntax-class-idsyntax-class-contract]...)|(optional-arg...))arg = contract-expr| keywordcontract-exprcontract-expr : contract?
syntax
A syntax class can be reified into a run-time value, and a reified syntax class can be used in a pattern via the ~reflect and ~splicing-reflect pattern forms.
syntax
( reify-syntax-class syntax-class-id)
procedure
procedure
procedure
maybe-attrs =| #:attributes(attr-arity-decl...)Like ~var , except that the syntax class position is an expression evaluating to a reified syntax object, not a syntax class name, and the attributes bound by the reified syntax class (if any) must be specified explicitly.
Like ~reflect but for reified splicing syntax classes.
#:attributes(diff)#:attributes(quot)> (partition/r#'(12345)r-nat>3)#<syntax:eval:5:0 ((4 5) (1 2 3))>
> (partition/r#'(12345)r-nat/mult2)#<syntax:eval:5:0 ((2 4) (1 3 5))>
> (bad-attrsr-nat>)#<syntax 3>
> (bad-attrsr-nat/mult)reflect-syntax-class: reified syntax-class is missing
declared attribute `diff'
syntax
#:descriptiondescription-expr#:attributes(attr-arity-decl...)parser-expr)
The parser procedure is given two arguments, the syntax to parse and a failure procedure. To signal a successful parse, the parser procedure returns a list of N+1 elements, where N is the number of attributes declared by the splicing syntax class. The first element is the size of the prefix consumed. The rest of the list contains the values of the attributes.
To indicate failure, the parser calls the failure procedure with an optional message argument.
Unlike single-term patterns and head patterns, ellipsis-head patterns cannot be encapsulated by syntax classes, since they describe not only sets of terms but also repetition constraints.
This module provides ellipsis-head alternative sets, reusable encapsulations of ellipsis-head patterns.
syntax
( define-eh-alternative-set nameeh-alternative...)
Unlike syntax classes, ellipsis-head alternative sets must be defined before they are referenced, and they do not delimit cuts (use ~delimit-cut instead).
Includes the alternatives of eh-alternative-set-id, prefixing their attributes with name.
> (parse/options#'(m#:a1#:b2#:b3))#<syntax:eval:12:0 (1 (2 3))>
> (parse/options#'(m#:a1#:a2))m: too many occurrences of #:a option
at: ()
within: (m #:a 1 #:a 2)
in: (m #:a 1 #:a 2)
... )> (parse/more-options#'(m#:a1#:b2#:c34#:c56))#<syntax:eval:15:0 (1 (2) ((3 4) (5 6)))>
#<syntax:eval:18:0 (1 (2) ((3 4) (5 6)))>
syntax
( define-syntax-class/specialize headersyntax-class-use)
header = id| (id. kw-formals)syntax-class-use = target-stxclass-id| (target-stxclass-idarg...)
'ok
?: expected natural number greater than 10
at: 8
in: (8 9)
syntax
( template tmpl)
syntax
( template/loc loc-exprtmpl)
syntax
( quasitemplate tmpl)
syntax
( quasitemplate/loc loc-exprtmpl)
syntax
( define-template-metafunction metafunction-idexpr)
stx)]))#<syntax:eval:23:0 abc>
#<syntax:eval:24:0 ((a tmp-a) (b tmp-b) (c tmp-c))>
Metafunctions are useful for performing transformations in contexts where macro expansion does not occur, such as binding occurrences. For example:
(join#:lctxnamemake-name)__))))'(let-values (((posn? make-posn posn-x posn-y) (make-struct-type ___))) ___)
If join were defined as a macro, it would not be usable in the context above; instead, let-values would report an invalid binding list.