syntax/parse: use lazy-require-syntax

This commit is contained in:
Ryan Culpepper 2017-12-14 12:04:38 +01:00 committed by Georges Dupéron
parent e4d1bbc473
commit c913d14d7c
2 changed files with 15 additions and 65 deletions

View File

@ -1,21 +0,0 @@
#lang racket/base
(require (for-template "parse.rkt"))
(provide id:define-syntax-class
id:define-splicing-syntax-class
id:define-integrable-syntax-class
id:syntax-parse
id:syntax-parser
id:define/syntax-parse
id:syntax-parser/template
id:parser/rhs
id:define-eh-alternative-set)
(define (id:define-syntax-class) #'define-syntax-class)
(define (id:define-splicing-syntax-class) #'define-splicing-syntax-class)
(define (id:define-integrable-syntax-class) #'define-integrable-syntax-class)
(define (id:syntax-parse) #'syntax-parse)
(define (id:syntax-parser) #'syntax-parser)
(define (id:define/syntax-parse) #'define/syntax-parse)
(define (id:syntax-parser/template) #'syntax-parser/template)
(define (id:parser/rhs) #'parser/rhs)
(define (id:define-eh-alternative-set) #'define-eh-alternative-set)

View File

@ -1,6 +1,5 @@
#lang racket/base
(require (for-syntax racket/base
racket/lazy-require)
(require racket/lazy-require
syntax/parse/private/keywords)
;; keep and keep as abs. path -- lazy-loaded macros produce references to this
@ -8,25 +7,20 @@
;; (so for consistency etc, require absolutely from all modules)
(require stxparse-info/parse/private/residual)
(begin-for-syntax
(lazy-require
;; load macro transformers lazily via identifier
;; This module path must also be absolute (not sure why,
;; but it definitely breaks on relative module path).
[stxparse-info/parse/private/parse-aux
(id:define-syntax-class
id:define-splicing-syntax-class
id:define-integrable-syntax-class
id:syntax-parse
id:syntax-parser
id:define/syntax-parse
id:syntax-parser/template
id:parser/rhs
id:define-eh-alternative-set)]))
;; FIXME: workaround for phase>0 bug in racket/runtime-path (and thus lazy-require)
;; Without this, dependencies don't get collected.
(require racket/runtime-path (for-meta 2 '#%kernel))
(define-runtime-module-path-index _unused_ 'stxparse-info/parse/private/parse-aux)
(lazy-require-syntax
;; load macro transformers lazily via identifier
;; This module path must also be absolute (not sure why,
;; but it definitely breaks on relative module path).
[syntax/parse/private/parse
(define-syntax-class
define-splicing-syntax-class
define-integrable-syntax-class
syntax-parse
syntax-parser
define/syntax-parse
syntax-parser/template
parser/rhs
define-eh-alternative-set)])
(provide define-syntax-class
define-splicing-syntax-class
@ -45,26 +39,3 @@
syntax-parser/template
parser/rhs
define-eh-alternative-set)
(define-syntaxes (define-syntax-class
define-splicing-syntax-class
define-integrable-syntax-class
syntax-parse
syntax-parser
define/syntax-parse
syntax-parser/template
parser/rhs
define-eh-alternative-set)
(let ([tx (lambda (get-id)
(lambda (stx)
((syntax-local-value (get-id)) stx)))])
(values
(tx id:define-syntax-class)
(tx id:define-splicing-syntax-class)
(tx id:define-integrable-syntax-class)
(tx id:syntax-parse)
(tx id:syntax-parser)
(tx id:define/syntax-parse)
(tx id:syntax-parser/template)
(tx id:parser/rhs)
(tx id:define-eh-alternative-set))))