www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

stx-untyped-only.scrbl (1588B)


      1 #lang scribble/manual
      2 @require[racket/require
      3          "utils.rkt"
      4          @for-label[phc-toolkit/stx]]
      5 
      6 @title{Transformers utilities}
      7 
      8 @(declare-exporting phc-toolkit/stx
      9                     #:use-sources
     10                     [(lib "phc-toolkit/untyped-only/stx.rkt")])
     11 
     12 @defproc[(make-rest-transformer [tranformer-function (-> syntax? syntax?)])
     13          (-> syntax? syntax?)]{
     14  Returns a transformer function which applies @racket[tranformer-function] on
     15  the @racket[stx-cdr] of its argument. It is a shorthand for:
     16 
     17  @racketblock[(λ (stx)
     18                 (syntax-case stx ()
     19                   [(_ . rest) (f #'rest)]))]
     20 }
     21 
     22 @defproc[(make-id+call-transformer [result syntax?])
     23          (-> syntax? syntax?)]{
     24  Returns a transformer function which returns:
     25  @itemlist[
     26  @item{the given @racket[result], when it is called as an identifier macro}
     27  @item{@racket[(result arg ...)] where the @racket[arg ...] are the macro's
     28    arguments (except the macro identifier itself), when it is called as a
     29    regular macro.}]
     30 
     31  It is a shorthand for:
     32 
     33  @RACKETBLOCK[(λ (stx)
     34                 (syntax-case stx ()
     35                   [(_ . args) (quasisyntax/top-loc stx (#,result . args))]
     36                   [id (identifier? #'id) result]))]
     37 }
     38 
     39 @defproc[(make-id+call-transformer-delayed [result (-> syntax?)])
     40          (-> syntax? syntax?)]{
     41                                
     42  Like @racket[make-id+call-transformer], but the result is wrapped in a
     43  function which is evaluated only when the returned transformer function is
     44  run. This is useful when the expression depends on some mutable context.}