www

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

sc.rkt (2578B)


      1 #lang racket/base
      2 (require (for-syntax racket/base
      3                      racket/lazy-require)
      4          syntax/parse/private/keywords)
      5 
      6 ;; keep and keep as abs. path -- lazy-loaded macros produce references to this
      7 ;; must be required via *absolute module path* from any disappearing module
      8 ;; (so for consistency etc, require absolutely from all modules)
      9 (require stxparse-info/parse/private/residual
     10          racket/syntax
     11          racket/stxparam
     12          syntax/stx)
     13 
     14 (begin-for-syntax
     15  (lazy-require
     16   ;; load macro transformers lazily via identifier
     17   ;; This module path must also be absolute (not sure why,
     18   ;; but it definitely breaks on relative module path).
     19   [stxparse-info/parse/private/parse-aux
     20    (id:define-syntax-class
     21     id:define-splicing-syntax-class
     22     id:define-integrable-syntax-class
     23     id:syntax-parse
     24     id:syntax-parser
     25     id:define/syntax-parse
     26     id:syntax-parser/template
     27     id:parser/rhs
     28     id:define-eh-alternative-set)]))
     29 ;; FIXME: workaround for phase>0 bug in racket/runtime-path (and thus lazy-require)
     30 ;; Without this, dependencies don't get collected.
     31 (require racket/runtime-path (for-meta 2 '#%kernel))
     32 (define-runtime-module-path-index _unused_ 'stxparse-info/parse/private/parse-aux)
     33 
     34 (provide define-syntax-class
     35          define-splicing-syntax-class
     36          define-integrable-syntax-class
     37          syntax-parse
     38          syntax-parser
     39          define/syntax-parse
     40 
     41          (except-out (all-from-out syntax/parse/private/keywords)
     42                      ~reflect
     43                      ~splicing-reflect
     44                      ~eh-var)
     45          attribute
     46          this-syntax
     47 
     48          syntax-parser/template
     49          parser/rhs
     50          define-eh-alternative-set)
     51 
     52 (define-syntaxes (define-syntax-class
     53                   define-splicing-syntax-class
     54                   define-integrable-syntax-class
     55                   syntax-parse
     56                   syntax-parser
     57                   define/syntax-parse
     58                   syntax-parser/template
     59                   parser/rhs
     60                   define-eh-alternative-set)
     61   (let ([tx (lambda (get-id)
     62               (lambda (stx)
     63                 (syntax-case stx ()
     64                   [(_ . args)
     65                    (datum->syntax stx (cons (get-id) #'args) stx)])))])
     66     (values 
     67      (tx id:define-syntax-class)
     68      (tx id:define-splicing-syntax-class)
     69      (tx id:define-integrable-syntax-class)
     70      (tx id:syntax-parse)
     71      (tx id:syntax-parser)
     72      (tx id:define/syntax-parse)
     73      (tx id:syntax-parser/template)
     74      (tx id:parser/rhs)
     75      (tx id:define-eh-alternative-set))))