use defform #:grammar
This commit is contained in:
parent
293b208af7
commit
2eae24b0b1
|
@ -20,9 +20,10 @@ compatibility.
|
||||||
|
|
||||||
@defmodule[syntax/parse/experimental/provide]
|
@defmodule[syntax/parse/experimental/provide]
|
||||||
|
|
||||||
@defform/subs[#:literals (syntax-class/c)
|
@defform[#:literals (syntax-class/c)
|
||||||
(provide-syntax-class/contract
|
(provide-syntax-class/contract
|
||||||
[syntax-class-id syntax-class-contract] ...)
|
[syntax-class-id syntax-class-contract] ...)
|
||||||
|
#:grammar
|
||||||
([syntax-class-contract
|
([syntax-class-contract
|
||||||
(syntax-class/c (mandatory-arg ...))
|
(syntax-class/c (mandatory-arg ...))
|
||||||
(syntax-class/c (mandatory-arg ...)
|
(syntax-class/c (mandatory-arg ...)
|
||||||
|
@ -101,7 +102,8 @@ error is raised.
|
||||||
(~splicing-reflect var-id (reified-expr arg-expr ...)
|
(~splicing-reflect var-id (reified-expr arg-expr ...)
|
||||||
maybe-attrs)]]
|
maybe-attrs)]]
|
||||||
|
|
||||||
@specsubform/subs[(@#,(defhere ~reflect) var-id (reified-expr arg-expr ...) maybe-attrs)
|
@specsubform[(@#,(defhere ~reflect) var-id (reified-expr arg-expr ...) maybe-attrs)
|
||||||
|
#:grammar
|
||||||
([maybe-attrs (code:line)
|
([maybe-attrs (code:line)
|
||||||
(code:line #:attributes (attr-arity-decl ...))])]{
|
(code:line #:attributes (attr-arity-decl ...))])]{
|
||||||
|
|
||||||
|
@ -189,8 +191,9 @@ sets of terms but also repetition constraints.
|
||||||
This module provides @deftech{ellipsis-head alternative sets},
|
This module provides @deftech{ellipsis-head alternative sets},
|
||||||
reusable encapsulations of @|EHpatterns|.
|
reusable encapsulations of @|EHpatterns|.
|
||||||
|
|
||||||
@defform/subs[#:literals (pattern)
|
@defform[#:literals (pattern)
|
||||||
(define-eh-alternative-set name eh-alternative ...)
|
(define-eh-alternative-set name eh-alternative ...)
|
||||||
|
#:grammar
|
||||||
([alternative (pattern EH-pattern)])]{
|
([alternative (pattern EH-pattern)])]{
|
||||||
|
|
||||||
Defines @racket[name] as an ellipsis-head alternative set. Using
|
Defines @racket[name] as an ellipsis-head alternative set. Using
|
||||||
|
@ -246,7 +249,8 @@ their attributes with @racket[name].
|
||||||
|
|
||||||
@defmodule[syntax/parse/experimental/specialize]
|
@defmodule[syntax/parse/experimental/specialize]
|
||||||
|
|
||||||
@defform/subs[(define-syntax-class/specialize header syntax-class-use)
|
@defform[(define-syntax-class/specialize header syntax-class-use)
|
||||||
|
#:grammar
|
||||||
([header id
|
([header id
|
||||||
(id . kw-formals)]
|
(id . kw-formals)]
|
||||||
[syntax-class-use target-stxclass-id
|
[syntax-class-use target-stxclass-id
|
||||||
|
@ -272,8 +276,9 @@ patterns as @racket[target-stxclass-id] but with the given
|
||||||
|
|
||||||
@(define literal-ellipsis (racket ...))
|
@(define literal-ellipsis (racket ...))
|
||||||
|
|
||||||
@defform/subs[#:literals (?? ?@)
|
@defform[#:literals (?? ?@)
|
||||||
(template tmpl)
|
(template tmpl)
|
||||||
|
#:grammar
|
||||||
([tmpl pattern-variable-id
|
([tmpl pattern-variable-id
|
||||||
(head-tmpl . tmpl)
|
(head-tmpl . tmpl)
|
||||||
(head-tmpl ellipsis ...+ . tmpl)
|
(head-tmpl ellipsis ...+ . tmpl)
|
||||||
|
|
|
@ -15,8 +15,9 @@ As a remedy, @racketmodname[syntax/parse] offers @deftech{literal
|
||||||
sets}. A literal set is defined via @racket[define-literal-set] and
|
sets}. A literal set is defined via @racket[define-literal-set] and
|
||||||
used via the @racket[#:literal-set] option of @racket[syntax-parse].
|
used via the @racket[#:literal-set] option of @racket[syntax-parse].
|
||||||
|
|
||||||
@defform/subs[(define-literal-set id maybe-phase maybe-imports maybe-datum-literals
|
@defform[(define-literal-set id maybe-phase maybe-imports maybe-datum-literals
|
||||||
(literal ...))
|
(literal ...))
|
||||||
|
#:grammar
|
||||||
([literal literal-id
|
([literal literal-id
|
||||||
(pattern-id literal-id)]
|
(pattern-id literal-id)]
|
||||||
[maybe-phase (code:line)
|
[maybe-phase (code:line)
|
||||||
|
@ -114,7 +115,8 @@ the @racket[_phase] argument defaults to
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@defform/subs[(define-conventions name-id convention-rule ...)
|
@defform[(define-conventions name-id convention-rule ...)
|
||||||
|
#:grammar
|
||||||
([convention-rule (name-pattern syntax-class)]
|
([convention-rule (name-pattern syntax-class)]
|
||||||
[name-pattern exact-id
|
[name-pattern exact-id
|
||||||
name-rx]
|
name-rx]
|
||||||
|
|
|
@ -20,7 +20,8 @@ of @tech{syntax patterns}, which is described in detail in
|
||||||
Two parsing forms are provided: @racket[syntax-parse] and
|
Two parsing forms are provided: @racket[syntax-parse] and
|
||||||
@racket[syntax-parser].
|
@racket[syntax-parser].
|
||||||
|
|
||||||
@defform/subs[(syntax-parse stx-expr parse-option ... clause ...+)
|
@defform[(syntax-parse stx-expr parse-option ... clause ...+)
|
||||||
|
#:grammar
|
||||||
([parse-option (code:line #:context context-expr)
|
([parse-option (code:line #:context context-expr)
|
||||||
(code:line #:literals (literal ...))
|
(code:line #:literals (literal ...))
|
||||||
(code:line #:datum-literals (datum-literal ...))
|
(code:line #:datum-literals (datum-literal ...))
|
||||||
|
@ -74,7 +75,8 @@ failures; otherwise @racket[stx-expr] is used. The
|
||||||
[(x:id ...) 'ok]))
|
[(x:id ...) 'ok]))
|
||||||
}
|
}
|
||||||
|
|
||||||
@specsubform/subs[(code:line #:literals (literal ...))
|
@specsubform[(code:line #:literals (literal ...))
|
||||||
|
#:grammar
|
||||||
([literal literal-id
|
([literal literal-id
|
||||||
(pattern-id literal-id)
|
(pattern-id literal-id)
|
||||||
(pattern-id literal-id #:phase phase-expr)])
|
(pattern-id literal-id #:phase phase-expr)])
|
||||||
|
@ -105,7 +107,8 @@ occurrence of @racket[pattern-id] were replaced with the following pattern:
|
||||||
@racketblock[(~literal literal-id #:phase phase-expr)]
|
@racketblock[(~literal literal-id #:phase phase-expr)]
|
||||||
}
|
}
|
||||||
|
|
||||||
@specsubform/subs[(code:line #:datum-literals (datum-literal ...))
|
@specsubform[(code:line #:datum-literals (datum-literal ...))
|
||||||
|
#:grammar
|
||||||
([datum-literal literal-id
|
([datum-literal literal-id
|
||||||
(pattern-id literal-id)])]{
|
(pattern-id literal-id)])]{
|
||||||
|
|
||||||
|
@ -118,7 +121,8 @@ pattern:
|
||||||
@racketblock[(~datum literal-id)]
|
@racketblock[(~datum literal-id)]
|
||||||
}
|
}
|
||||||
|
|
||||||
@specsubform/subs[(code:line #:literal-sets (literal-set ...))
|
@specsubform[(code:line #:literal-sets (literal-set ...))
|
||||||
|
#:grammar
|
||||||
([literal-set literal-set-id
|
([literal-set literal-set-id
|
||||||
(literal-set-id literal-set-option ...)]
|
(literal-set-id literal-set-option ...)]
|
||||||
[literal-set-option (code:line #:at lctx)
|
[literal-set-option (code:line #:at lctx)
|
||||||
|
|
|
@ -260,7 +260,8 @@ like an @tech{annotated pattern variable} with the implicit syntax
|
||||||
class inserted.
|
class inserted.
|
||||||
}
|
}
|
||||||
|
|
||||||
@specsubform/subs[(@#,def[~var s+] pvar-id syntax-class-use maybe-role)
|
@specsubform[(@#,def[~var s+] pvar-id syntax-class-use maybe-role)
|
||||||
|
#:grammar
|
||||||
([syntax-class-use syntax-class-id
|
([syntax-class-use syntax-class-id
|
||||||
(syntax-class-id arg ...)]
|
(syntax-class-id arg ...)]
|
||||||
[maybe-role (code:line)
|
[maybe-role (code:line)
|
||||||
|
@ -305,7 +306,8 @@ combined with the syntax class's description in error messages.
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@specsubform/subs[(@#,defhere[~literal] literal-id maybe-phase)
|
@specsubform[(@#,defhere[~literal] literal-id maybe-phase)
|
||||||
|
#:grammar
|
||||||
([maybe-phase (code:line)
|
([maybe-phase (code:line)
|
||||||
(code:line #:phase phase-expr)])]{
|
(code:line #:phase phase-expr)])]{
|
||||||
|
|
||||||
|
@ -557,7 +559,8 @@ above).
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@specsubform/subs[(@#,def[~describe s] maybe-opaque expr S-pattern)
|
@specsubform[(@#,def[~describe s] maybe-opaque expr S-pattern)
|
||||||
|
#:grammar
|
||||||
([maybe-opaque (code:line)
|
([maybe-opaque (code:line)
|
||||||
(code:line #:opaque)]
|
(code:line #:opaque)]
|
||||||
[maybe-role (code:line)
|
[maybe-role (code:line)
|
||||||
|
@ -647,7 +650,8 @@ Equivalent to @racket[(~var pvar-id splicing-syntax-class-id)].
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@specsubform/subs[(@#,def[~var h] pvar-id splicing-syntax-class-use maybe-role)
|
@specsubform[(@#,def[~var h] pvar-id splicing-syntax-class-use maybe-role)
|
||||||
|
#:grammar
|
||||||
([splicing-syntax-class-use splicing-syntax-class-id
|
([splicing-syntax-class-use splicing-syntax-class-id
|
||||||
(splicing-syntax-class-id arg ...)]
|
(splicing-syntax-class-id arg ...)]
|
||||||
[maybe-role (code:line)
|
[maybe-role (code:line)
|
||||||
|
@ -721,7 +725,8 @@ terms instead.
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@specsubform/subs[(@#,def[~optional h] H-pattern maybe-optional-option)
|
@specsubform[(@#,def[~optional h] H-pattern maybe-optional-option)
|
||||||
|
#:grammar
|
||||||
([maybe-optional-option
|
([maybe-optional-option
|
||||||
(code:line)
|
(code:line)
|
||||||
(code:line #:defaults ([attr-arity-decl expr] ...))]
|
(code:line #:defaults ([attr-arity-decl expr] ...))]
|
||||||
|
@ -847,7 +852,8 @@ Here are the variants of @elem{@EHpattern}:
|
||||||
Matches if any of the inner @racket[EH-pattern] alternatives match.
|
Matches if any of the inner @racket[EH-pattern] alternatives match.
|
||||||
}
|
}
|
||||||
|
|
||||||
@specsubform/subs[(@#,defhere[~once] H-pattern once-option ...)
|
@specsubform[(@#,defhere[~once] H-pattern once-option ...)
|
||||||
|
#:grammar
|
||||||
([once-option (code:line #:name name-expr)
|
([once-option (code:line #:name name-expr)
|
||||||
(code:line #:too-few too-few-message-expr)
|
(code:line #:too-few too-few-message-expr)
|
||||||
(code:line #:too-many too-many-message-expr)])
|
(code:line #:too-many too-many-message-expr)])
|
||||||
|
@ -869,7 +875,8 @@ then the ellipsis pattern fails with the message either
|
||||||
of @racket[name-expr]"}.
|
of @racket[name-expr]"}.
|
||||||
}
|
}
|
||||||
|
|
||||||
@specsubform/subs[(@#,def[~optional eh] H-pattern optional-option ...)
|
@specsubform[(@#,def[~optional eh] H-pattern optional-option ...)
|
||||||
|
#:grammar
|
||||||
([optional-option (code:line #:name name-expr)
|
([optional-option (code:line #:name name-expr)
|
||||||
(code:line #:too-many too-many-message-expr)
|
(code:line #:too-many too-many-message-expr)
|
||||||
(code:line #:defaults ([attr-id expr] ...))])
|
(code:line #:defaults ([attr-id expr] ...))])
|
||||||
|
@ -890,7 +897,8 @@ sequence. The default attributes must be a subset of the subpattern's
|
||||||
attributes.
|
attributes.
|
||||||
}
|
}
|
||||||
|
|
||||||
@specsubform/subs[(@#,defhere[~between] H-pattern min-number max-number between-option ...)
|
@specsubform[(@#,defhere[~between] H-pattern min-number max-number between-option ...)
|
||||||
|
#:grammar
|
||||||
([reps-option (code:line #:name name-expr)
|
([reps-option (code:line #:name name-expr)
|
||||||
(code:line #:too-few too-few-message-expr)
|
(code:line #:too-few too-few-message-expr)
|
||||||
(code:line #:too-many too-many-message-expr)])
|
(code:line #:too-many too-many-message-expr)])
|
||||||
|
@ -966,16 +974,17 @@ within a @racket[~not] pattern unless there is an intervening
|
||||||
@racket[~delimit-cut] or @racket[~commit] pattern.
|
@racket[~delimit-cut] or @racket[~commit] pattern.
|
||||||
}
|
}
|
||||||
|
|
||||||
@specsubform/subs[(@#,defhere[~bind] [attr-arity-decl expr] ...)
|
@specsubform[(@#,defhere[~bind] [attr-arity-decl expr] ...)
|
||||||
([attr-arity-decl
|
#:grammar
|
||||||
attr-name-id
|
([attr-arity-decl attr-name-id
|
||||||
(attr-name-id depth)])]{
|
(attr-name-id depth)])]{
|
||||||
|
|
||||||
Evaluates the @racket[expr]s and binds them to the given
|
Evaluates the @racket[expr]s and binds them to the given
|
||||||
@racket[attr-id]s as attributes.
|
@racket[attr-id]s as attributes.
|
||||||
}
|
}
|
||||||
|
|
||||||
@specsubform/subs[(@#,defhere[~fail] maybe-fail-condition maybe-message-expr)
|
@specsubform[(@#,defhere[~fail] maybe-fail-condition maybe-message-expr)
|
||||||
|
#:grammar
|
||||||
([maybe-fail-condition (code:line)
|
([maybe-fail-condition (code:line)
|
||||||
(code:line #:when condition-expr)
|
(code:line #:when condition-expr)
|
||||||
(code:line #:unless condition-expr)]
|
(code:line #:unless condition-expr)]
|
||||||
|
|
|
@ -17,11 +17,12 @@ complex syntax, such as lists of distinct identifiers and formal
|
||||||
arguments with keywords. Macros that manipulate the same syntactic
|
arguments with keywords. Macros that manipulate the same syntactic
|
||||||
structures can share syntax class definitions.
|
structures can share syntax class definitions.
|
||||||
|
|
||||||
@defform*/subs[#:literals (pattern)
|
@defform*[#:literals (pattern)
|
||||||
[(define-syntax-class name-id stxclass-option ...
|
[(define-syntax-class name-id stxclass-option ...
|
||||||
stxclass-variant ...+)
|
stxclass-variant ...+)
|
||||||
(define-syntax-class (name-id . kw-formals) stxclass-option ...
|
(define-syntax-class (name-id . kw-formals) stxclass-option ...
|
||||||
stxclass-variant ...+)]
|
stxclass-variant ...+)]
|
||||||
|
#:grammar
|
||||||
([stxclass-option
|
([stxclass-option
|
||||||
(code:line #:attributes (attr-arity-decl ...))
|
(code:line #:attributes (attr-arity-decl ...))
|
||||||
(code:line #:description description-expr)
|
(code:line #:description description-expr)
|
||||||
|
@ -52,7 +53,8 @@ non-empty sequence of @racket[pattern] variants.
|
||||||
|
|
||||||
The following options are supported:
|
The following options are supported:
|
||||||
|
|
||||||
@specsubform/subs[(code:line #:attributes (attr-arity-decl ...))
|
@specsubform[(code:line #:attributes (attr-arity-decl ...))
|
||||||
|
#:grammar
|
||||||
([attr-arity-decl attr-id
|
([attr-arity-decl attr-id
|
||||||
(attr-id depth)])]{
|
(attr-id depth)])]{
|
||||||
|
|
||||||
|
@ -181,7 +183,8 @@ follows:
|
||||||
(code:line #:when condition-expr)
|
(code:line #:when condition-expr)
|
||||||
(code:line #:do [def-or-expr ...])]
|
(code:line #:do [def-or-expr ...])]
|
||||||
|
|
||||||
@specsubform/subs[(code:line #:declare pvar-id stxclass maybe-role)
|
@specsubform[(code:line #:declare pvar-id stxclass maybe-role)
|
||||||
|
#:grammar
|
||||||
([stxclass syntax-class-id
|
([stxclass syntax-class-id
|
||||||
(syntax-class-id arg ...)]
|
(syntax-class-id arg ...)]
|
||||||
[maybe-role (code:line)
|
[maybe-role (code:line)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user