[racket] Changing at-expressions to other-glyph-expressions

From: Matthew Butterick (mb.list.acct at gmail.com)
Date: Sat Apr 20 11:33:58 EDT 2013

Terrific, thanks for the bug fix. This is just what I was hoping for. Works
perfectly.




>
> The `scribble/reader' library provides `make-at-reader', which lets you
> pick the escape character. You can use that with `#reader', which lets
> you pick a reader.
>
> Unfortunately, there's a bug that makes `make-at-reader; work only for
> ASCII characters; I've just pushed a fix for that to the git repo. For
> the example below, I've used a tilde to avoid the bug, but you could
> use any Unicode character with a new build from source or with the next
> nightly build.
>
> ----------------------------------------
> ;; tilde.rkt:
> ----------------------------------------
> #lang racket/base
> (require (only-in scribble/reader make-at-reader))
>
> (provide (rename-out [tilde-read read]
>                      [tilde-read-syntax read-syntax]))
>
> (define read-inner
>   (make-at-reader #:command-char #\~
>                   #:syntax? #t
>                   #:inside? #t))
>
> (define (tilde-read p)
>   (syntax->datum
>    (tilde-read-syntax (object-name p) p)))
>
> (define (tilde-read-syntax name p)
>   (define i (read-inner name p))
>   (datum->syntax i (cons 'begin i) i))
>
> ----------------------------------------
> ;; example.scrbl
> ----------------------------------------
> #lang scribble/base
> @#reader "tilde.rkt"
>
> This is an example with @ signs and a definition.
>
> ~(define x "at")
>
> Example: @ is ``~x''.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130420/ccdc3177/attachment-0001.html>

Posted on the users mailing list.