defstxclass uses #:kind "syntax class" for better labeling

This commit is contained in:
Ryan Culpepper 2017-05-18 11:26:22 -04:00
parent 544b7a2721
commit ce9b309dbc

View File

@ -1,20 +1,24 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual @(require (for-syntax racket/base)
scribble/manual
scribble/struct scribble/struct
scribble/decode scribble/decode
scribble/eval scribble/eval
"parse-common.rkt" "parse-common.rkt"
(for-label syntax/kerncase)) (for-label racket/base racket/contract syntax/kerncase))
@title{Library Syntax Classes and Literal Sets} @title{Library Syntax Classes and Literal Sets}
@section{Syntax Classes} @section{Syntax Classes}
@(begin @(begin
(define-syntax-rule (defstxclass name . pre-flows) (define-syntax (defstxclass stx)
(defidform name . pre-flows)) (syntax-case stx ()
(define-syntax-rule (defstxclass* (name arg ...) . pre-flows) [(defstxclass name . pre-flows)
(defform (name arg ...) . pre-flows))) (identifier? #'name)
#'(defidform #:kind "syntax class" name . pre-flows)]
[(defstxclass datum . pre-flows)
#'(defproc #:kind "syntax class" datum @#,tech{syntax class} . pre-flows)])))
@defstxclass[expr]{ @defstxclass[expr]{
@ -42,9 +46,8 @@ Match syntax satisfying the corresponding predicates.
@defstxclass[id]{ Alias for @racket[identifier]. } @defstxclass[id]{ Alias for @racket[identifier]. }
@defstxclass[nat]{ Alias for @racket[exact-nonnegative-integer]. } @defstxclass[nat]{ Alias for @racket[exact-nonnegative-integer]. }
@defproc[(static [predicate (-> any/c any/c)] @defstxclass[(static [predicate (-> any/c any/c)]
[description (or/c string? #f)]) [description (or/c string? #f)])]{
(attributes value)]{
The @racket[static] syntax class matches an The @racket[static] syntax class matches an
identifier that is bound in the syntactic environment to static identifier that is bound in the syntactic environment to static
@ -58,17 +61,16 @@ When used outside of the dynamic extent of a macro transformer (see
The attribute @var[value] contains the value the name is bound to. The attribute @var[value] contains the value the name is bound to.
} }
@defproc[(expr/c [contract-expr syntax?] @defstxclass[(expr/c [contract-expr syntax?]
[#:positive pos-blame [#:positive pos-blame
(or/c syntax? string? module-path-index? 'from-macro 'use-site 'unknown) (or/c syntax? string? module-path-index? 'from-macro 'use-site 'unknown)
'use-site] 'use-site]
[#:negative neg-blame [#:negative neg-blame
(or/c syntax? string? module-path-index? 'from-macro 'use-site 'unknown) (or/c syntax? string? module-path-index? 'from-macro 'use-site 'unknown)
'from-macro] 'from-macro]
[#:name expr-name (or/c identifier? string? symbol?) #f] [#:name expr-name (or/c identifier? string? symbol?) #f]
[#:macro macro-name (or/c identifier? string? symbol?) #f] [#:macro macro-name (or/c identifier? string? symbol?) #f]
[#:context ctx (or/c syntax? #f) #, @elem{determined automatically}]) [#:context ctx (or/c syntax? #f) #, @elem{determined automatically}])]{
(attributes c)]{
Accepts an expression (@racket[expr]) and computes an attribute Accepts an expression (@racket[expr]) and computes an attribute
@racket[c] that represents the expression wrapped with the contract @racket[c] that represents the expression wrapped with the contract