[racket] Typesetting with subscripts in Redex

From: Nada Amin (namin at alum.mit.edu)
Date: Mon Sep 10 01:05:43 EDT 2012

On Mon, Sep 10, 2012 at 6:46 AM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> On Sun, Sep 9, 2012 at 6:52 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>> Getting the line, column, and span for a rewriter result can be tricky.
>> Usually, you want the result of a rewriter to have the same start and
>> span as the input. I think I got that part right, below, too.
>
> with-compound-rewriter has some smarts about how to insert lw structs
> when it sees non-lws in the resulting list. So you can exploit that by
> writing something like this (and thus avoid the need for "collapse"):
>
> (define (dummy-rewriters thunk)
>   (with-compound-rewriters
>    (['n (lambda (lws)
>           (list ""
>                 (list-ref lws 2)
>                 (text (symbol->string (lw-e (list-ref lws 1)))
>                       `(subscript . ,(default-style))
>                       (default-font-size))
>                 ""))])
>    (thunk)))
>
> I've added a note about this trick to the docs.
The behavior is not the same as Matthew Flatt's solution. With:
(dummy-rewriters (lambda () (render-term dummy (
  (n 112221111) (n
  1223333)))))
I get just one garbled line with this trick, while with Matthew
Flatt's solution, I get two lines as expected.
Is this bug in the trick's implementation?

In any case, a big thank you, since I've been able to get the ball
rolling on my typesetting project.

Best regards,
~n
>
> Robby

Posted on the users mailing list.