[plt-scheme] s-exp and custom reader

From: Anton Tayanovskyy (anton.tayanovskyy at gmail.com)
Date: Mon Jul 14 16:13:05 EDT 2008


Sorry, your URL
http://list.cs.brown.edu/pipermail/plt-scheme/2008-June/025184.htm is
giving me 404 Not Found.

From the manual:

A sequence #lang 〈name〉 is equivalent to #reader 〈name〉/lang/reader


So you can use #lang instead of #reader.

#lang s-exp

must mean

#reader s-exp/lang/reader

Not sure what your exact problem is, but I guess you can always hack
the s-exp/lang/reader.ss module to suit your needs, making, for
instance, a my-s-exp/lang/reader.ss module. Here is its source (my
installation is outdated, 4.0.0):

(module reader scheme/base

  (provide (rename-out [*read read]
                       [*read-syntax read-syntax]))

  (define (*read in)
    (wrap in read))

  (define (*read-syntax src in)
    (wrap in (lambda (in)
               (read-syntax src in))))

  (define (wrap port read)
    (let ([body
           (let loop ([a null])
             (let ([v (read port)])
               (if (eof-object? v)
                   (reverse a)
                   (loop (cons v a)))))])
      (let* ([p-name (object-name port)]
             [name (if (path? p-name)
                       (let-values ([(base name dir?) (split-path p-name)])
                         (string->symbol (path->string
(path-replace-suffix name #""))))
             [id 'doc])
        `(module ,name . ,body)))))



On Mon, Jul 14, 2008 at 10:58 PM, YC <yinso.chen at gmail.com> wrote:
> Hi -
> in thread
> http://list.cs.brown.edu/pipermail/plt-scheme/2008-June/025184.html Danny
> alluded to using the s-exp module for custom language, e.g.
> #lang s-exp <language>
> But if the language has uses its own custom reader procedure, then the above
> doesn't appear to work.  My current solution is to basically create my own
> s-exp and call it via #reader instead of #lang, e.g.
> #reader <language> ...
> Is there a simpler solution on the line of `#lang s-exp`?  It would be nice
> for `#lang` to accept language forms such as `(lib ...)` or `(planet ...)` -
> thoughts?
> Thanks,
> yc
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.