[racket] Syntax class patterns and nested attributes

From: Jack Firth (jackhfirth at gmail.com)
Date: Tue Feb 3 19:11:15 EST 2015

Is #:auto-nested-attributes documented anywhere? I can't seem to find it in
the syntax class documentation

On Tue, Feb 3, 2015 at 3:28 PM, Alexander D. Knauth <alexander at knauth.org>
wrote:

> If you switch the order in which the syntax-classes are defined and add
> #:auto-nested-attribustes, this works:
> #lang racket
> (require syntax/parse)
> (define-syntax-class B
>   (pattern (b1 b2 b3)))
> (define-syntax-class A
>   #:auto-nested-attributes
>   (pattern (a1 a2:B a3)))
> (define foo
>   (syntax-parser
>     [blah:A #'blah.a2.b1]))
> (syntax->datum (foo #'(1 (2 3 4) 5))) ; 2
>
> But for some reason this doesn’t work:
> #lang at-exp racket
> (require syntax/parse)
> (define-syntax-class A
>   #:auto-nested-attributes
>   (pattern (a1 a2:B a3)))
> (define-syntax-class B
>   (pattern (b1 b2 b3)))
> (define foo
>   (syntax-parser
>     [blah:A #'blah.a2.b1]))
> (syntax->datum (foo #'(1 (2 3 4) 5))) ; 'blah.a2.b1
>
> But this does:
> #lang at-exp racket
> (require syntax/parse)
> (define-syntax-class A
>   #:attributes (a2.b1)
>   (pattern (a1 a2:B a3)))
> (define-syntax-class B
>   (pattern (b1 b2 b3)))
> (define foo
>   (syntax-parser
>     [blah:A #'blah.a2.b1]))
> (syntax->datum (foo #'(1 (2 3 4) 5))) ; 2
>
> On Feb 3, 2015, at 5:30 PM, Jack Firth <jackhfirth at gmail.com> wrote:
>
> > Suppose I have these syntax classes:
> >
> > (define-syntax-class A
> >   (pattern (a1 a2:B a3)))
> >
> > (define-syntax-class B
> >   (pattern (b1 b2 b3)))
> >
> > I'd like to be able to access nested attributes, like so:
> >
> > (define foo
> >   (syntax-parser
> >     [blah:A #'blah.a2.b1]))
> >
> > Currently, this doesn't work (and it doesn't even throw an error
> either). How could I do this?
> > ____________________
> >  Racket Users list:
> >  http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20150203/a5fea943/attachment.html>

Posted on the users mailing list.