parent
076621558e
commit
22a9b0cf35
|
@ -79,6 +79,18 @@
|
|||
(s= ((x.c1 x.c2) ...) '((2 3) (4 5)))))
|
||||
(terx (#:c 1 2) ((~eh-var x extopts) ...)
|
||||
#rx"missing required occurrence of A option")
|
||||
|
||||
;; from Alexis King (#2551) (3/2019)
|
||||
(let ()
|
||||
(define-eh-alternative-set opts
|
||||
[pattern {~optional {~seq #:foo foo:expr}}])
|
||||
(test-exn "eh-alts no spurious description"
|
||||
(lambda (e)
|
||||
(and (regexp-match? #rx"expected more terms" (exn-message e))
|
||||
(not (regexp-match? #rx"eh-alt-parser" (exn-message e)))))
|
||||
(lambda ()
|
||||
(syntax-parse #'(use-opts #:foo)
|
||||
[(_ {~eh-var o opts} ...) 'ok]))))
|
||||
)
|
||||
(require 'eh-alts)
|
||||
|
||||
|
|
|
@ -54,11 +54,11 @@
|
|||
(let-values ([(name formals arity)
|
||||
(let ([p (check-stxclass-header #'header stx)])
|
||||
(values (car p) (cadr p) (caddr p)))])
|
||||
(let ([the-rhs (parse-rhs #'rhss splicing? #:context stx)])
|
||||
(let ([the-rhs (parse-rhs #'rhss splicing? #:context stx
|
||||
#:default-description (symbol->string (syntax-e name)))])
|
||||
(with-syntax ([name name]
|
||||
[formals formals]
|
||||
[desc (cond [(rhs-description the-rhs) => constant-desc]
|
||||
[else (symbol->string (syntax-e name))])]
|
||||
[desc (cond [(rhs-description the-rhs) => constant-desc] [else #f])]
|
||||
[parser (generate-temporary (format-symbol "parse-~a" name))]
|
||||
[arity arity]
|
||||
[attrs (rhs-attrs the-rhs)]
|
||||
|
@ -155,7 +155,7 @@
|
|||
(with-syntax ([formals* formals*]
|
||||
[(def ...) defs]
|
||||
[((vdef ...) ...) vdefss]
|
||||
[description (or description (symbol->string (syntax-e name)))]
|
||||
[description description]
|
||||
[transparent? transparent?]
|
||||
[delimit-cut? delimit-cut?]
|
||||
[body body])
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
(-> syntax?
|
||||
boolean?)]
|
||||
[parse-rhs
|
||||
(-> syntax? boolean?
|
||||
#:context (or/c false/c syntax?)
|
||||
rhs?)]
|
||||
(->* [syntax? boolean? #:context (or/c false/c syntax?)]
|
||||
[#:default-description (or/c #f string?)]
|
||||
rhs?)]
|
||||
[parse-pattern+sides
|
||||
(-> syntax? syntax?
|
||||
#:splicing? boolean?
|
||||
|
@ -178,8 +178,8 @@
|
|||
|
||||
;; ---
|
||||
|
||||
;; parse-rhs : Syntax Boolean #:context Syntax -> RHS
|
||||
(define (parse-rhs stx splicing? #:context ctx)
|
||||
;; parse-rhs : Syntax Boolean #:context Syntax #:default-description (U String #f) -> RHS
|
||||
(define (parse-rhs stx splicing? #:context ctx #:default-description [default-description #f])
|
||||
(call/txlifts
|
||||
(lambda ()
|
||||
(parameterize ((current-syntax-context ctx))
|
||||
|
@ -194,7 +194,7 @@
|
|||
(or attributes
|
||||
(filter (lambda (a) (symbol-interned? (attr-name a)))
|
||||
(intersect-sattrss (map variant-attrs variants)))))
|
||||
(make rhs sattrs transp? description variants
|
||||
(make rhs sattrs transp? (or description #`(quote #,default-description)) variants
|
||||
(append (get-txlifts-as-definitions) defs)
|
||||
commit? delimit-cut?)))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user