chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Handling unstandard reader macros.


From: felix winkelmann
Subject: Re: [Chicken-users] Handling unstandard reader macros.
Date: Thu, 24 Nov 2005 08:17:54 +0100

On 11/24/05, Pupeno <address@hidden> wrote:
> On Wednesday 23 November 2005 03:37, felix winkelmann wrote:
> > On 11/23/05, Pupeno <address@hidden> wrote:
> > > > Sorry, what kind of procedures are that?
> > >
> > > The procedure that is set by set-read-syntax![1].
> >
> > Just return the value that is whatever your reader-procedure
> > wants the read datum to be.
> It doesn't want it to be anything, I am ignoring any extension, I am only
> looking for includes.
>
> > > [1] In my case:
> > >   (set-read-syntax! #\#
> >
> > ...
> >
> > Here you are overriding all #... read syntax. You want to use
> > `set-dispatch-read-syntax!' instead (which allows you to
> > add/redefine #... syntax without stomping over everything
> > already available.
>
> Ok, I changed to set-dispatch-read-syntax!, still, I need to implement cases
> for such basic things as characters: #\d.
> --

Then you must been doing something wrong...

(set-dispatch-read-syntax!
 #\>
 (lambda (p)
   (let loop ()
     (let ((c (read-char p)))
       (cond ((eof-object? c) (error "unexpected end of file"))
             ((char=? c #\<)
              (if (char=? #\# (read-char p))
                  #f
                  (loop)))
             (else (loop)))))))

(pp (with-input-from-string "(1 2 #\\d #t)" read))
(pp (with-input-from-string "#> ... nothing ... <#" read))


cheers,
felix




reply via email to

[Prev in Thread] Current Thread [Next in Thread]