syntax/parse: fix dependencies, add deps test
Removes residual dep on racket/contract (again!) Removes use of racket/struct (which depends on contract) List other residual dependencies in sc.rkt
This commit is contained in:
parent
cb1a1e233e
commit
0a7d97df86
36
pkgs/racket-test/tests/stxparse/deps.rkt
Normal file
36
pkgs/racket-test/tests/stxparse/deps.rkt
Normal file
|
@ -0,0 +1,36 @@
|
|||
#lang racket/base
|
||||
(require rackunit)
|
||||
|
||||
;; Check that syntax/parse/pre has minimal *residual* dependencies.
|
||||
|
||||
(define (make-tracing-module-name-resolver omnr table)
|
||||
(case-lambda
|
||||
[(mod rel stx load?)
|
||||
(when load?
|
||||
(define res (omnr mod rel stx #f))
|
||||
(hash-set! table (resolved-module-path-name res) #t))
|
||||
(omnr mod rel stx load?)]
|
||||
[args
|
||||
(apply omnr args)]))
|
||||
|
||||
(define ns (make-base-namespace))
|
||||
(define loaded (make-hash))
|
||||
|
||||
(define-check (check-no-dep mod)
|
||||
(define res ((current-module-name-resolver) mod #f #f #f))
|
||||
(define name (resolved-module-path-name res))
|
||||
(check-false (hash-ref loaded name #f)))
|
||||
|
||||
(parameterize ((current-module-name-resolver
|
||||
(make-tracing-module-name-resolver
|
||||
(current-module-name-resolver)
|
||||
loaded))
|
||||
(current-namespace ns))
|
||||
(namespace-require 'syntax/parse/pre)
|
||||
|
||||
(test-case "no dep on racket/contract/base"
|
||||
(check-no-dep 'racket/contract/base))
|
||||
(test-case "no deps on impl modules"
|
||||
(check-no-dep 'syntax/parse/private/rep)
|
||||
(check-no-dep 'syntax/parse/private/parse))
|
||||
)
|
|
@ -1,6 +1,5 @@
|
|||
#lang racket/base
|
||||
(require racket/struct
|
||||
(for-syntax racket/base racket/struct-info racket/struct))
|
||||
(require (for-syntax racket/base racket/struct-info))
|
||||
(provide match ?)
|
||||
|
||||
(define-syntax (match stx)
|
||||
|
@ -82,10 +81,10 @@
|
|||
[(match-p x s success failure)
|
||||
(prefab-struct-key (syntax-e #'s))
|
||||
(with-syntax ([key (prefab-struct-key (syntax-e #'s))]
|
||||
[(p ...) (struct->list (syntax-e #'s))])
|
||||
[(p ...) (cdr (vector->list (struct->vector (syntax-e #'s))))])
|
||||
#'(let ([xkey (prefab-struct-key x)])
|
||||
(if (equal? xkey 'key)
|
||||
(let ([xps (struct->list x)])
|
||||
(let ([xps (cdr (vector->list (struct->vector x)))])
|
||||
(match-p xps (list p ...) success failure))
|
||||
failure)))]
|
||||
))
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
racket/syntax
|
||||
racket/stxparam
|
||||
syntax/stx
|
||||
racket/struct
|
||||
syntax/parse/private/residual ;; keep abs. path
|
||||
syntax/parse/private/runtime ;; keep abs.path
|
||||
syntax/parse/private/runtime-reflect) ;; keep abs. path
|
||||
|
@ -625,7 +624,7 @@ Conventions:
|
|||
#`(let ([datum (if (syntax? x) (syntax-e x) x)])
|
||||
(if (let ([xkey (prefab-struct-key datum)])
|
||||
(and xkey (equal? xkey 'key)))
|
||||
(let ([datum (struct->list datum)]
|
||||
(let ([datum (cdr (vector->list (struct->vector datum)))]
|
||||
[scx (if (syntax? x) x cx)] ;; FIXME: (struct? datum) => (syntax? x) ???
|
||||
[pr* (ps-add-unpstruct pr)])
|
||||
(parse:S datum scx subpattern pr* es k))
|
||||
|
|
|
@ -6,7 +6,10 @@
|
|||
;; keep and keep as abs. path -- lazy-loaded macros produce references to this
|
||||
;; must be required via *absolute module path* from any disappearing module
|
||||
;; (so for consistency etc, require absolutely from all modules)
|
||||
(require syntax/parse/private/residual)
|
||||
(require syntax/parse/private/residual
|
||||
racket/syntax
|
||||
racket/stxparam
|
||||
syntax/stx)
|
||||
|
||||
(begin-for-syntax
|
||||
(lazy-require
|
||||
|
|
Loading…
Reference in New Issue
Block a user