From b7bd836f0f5d0aebbeb532df407e7be1becb872c Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Fri, 29 Jul 2016 16:33:34 -0400 Subject: [PATCH] document this-syntax and #:auto-nested-attributes fixes #1185, #1350 --- .../syntax/scribblings/parse/stxclasses.scrbl | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/pkgs/racket-doc/syntax/scribblings/parse/stxclasses.scrbl b/pkgs/racket-doc/syntax/scribblings/parse/stxclasses.scrbl index 1f46ebd05b..6fef55dd0f 100644 --- a/pkgs/racket-doc/syntax/scribblings/parse/stxclasses.scrbl +++ b/pkgs/racket-doc/syntax/scribblings/parse/stxclasses.scrbl @@ -27,6 +27,7 @@ structures can share syntax class definitions. #:grammar ([stxclass-option (code:line #:attributes (attr-arity-decl ...)) + (code:line #:auto-nested-attributes) (code:line #:description description-expr) (code:line #:opaque) (code:line #:commit) @@ -71,6 +72,20 @@ depths are not included, nor are nested attributes from @tech{annotated pattern variables}. } +@specsubform[#:auto-nested-attributes]{ + +@bold{Deprecated.} This option cannot be combined with @racket[#:attributes]. + +Declares the attributes of the syntax class as the set of all +@tech{pattern variables} and nested attributes from @tech{annotated +pattern variables} occurring in every variant of the syntax +class. Only syntax classes defined strictly before the enclosing +syntax class are used to compute the nested attributes; pattern +variables annotated with not-yet-defined syntax classes contribute no +nested attributes for export. Note that with this option, reordering +syntax-class definitions may change the attributes they export. +} + @specsubform[(code:line #:description description-expr) #:contracts ([description-expr (or/c string? #f)])]{ @@ -424,4 +439,23 @@ Returns the value associated with the @tech{attribute} named error is raised. } +@defidform[this-syntax]{ + +When used as an expression within a syntax-class definition or +@racket[syntax-parse] expression, evaluates to the syntax object or +@tech[#:doc '(lib "scribblings/reference/reference.scrbl")]{syntax +pair} being matched. + +@examples[#:eval the-eval +(define-syntax-class one (pattern _ #:attr s this-syntax)) +(syntax-parse #'(1 2 3) [(1 o:one _) (attribute o.s)]) +(syntax-parse #'(1 2 3) [(1 . o:one) (attribute o.s)]) +(define-splicing-syntax-class two (pattern (~seq _ _) #:attr s this-syntax)) +(syntax-parse #'(1 2 3) [(t:two 3) (attribute t.s)]) +(syntax-parse #'(1 2 3) [(1 t:two) (attribute t.s)]) +]} + +Raises an error when used as an expression outside of a syntax-class +definition or @racket[syntax-parse] expression. + @(close-eval the-eval)