[gambit-list] Reading S-expressions

Briggs, Jamie Jamie.Briggs at ca.weatherford.com
Thu Apr 30 16:54:42 EDT 2009


I've been dabbling with scheme off and on for a while but I am just
getting started with Gambit-C.

I am trying to read the output of a  program printing information in the
form of s-expressions.  The problem is that it puts single quotes around
strings.  

eg.

   (domain
       (domid 1)
       (on_crash restart)
       (image
           (linux
               (kernel /boot/vmlinuz-2.6.18-5-xen-amd64)
               (ramdisk /boot/initrd.img-2.6.18-5-xen-amd64)
               (args 'root=/dev/sda1 ro ')
   ... and so on

I have an mzscheme script that reads it by messing with the readtable;
the code looks like:

   ; (mzscheme code)   
   ; Read after redefining so that single quotes are handled like pipe
quotes
   (define (read-data inport)
     (parameterize ((current-readtable
                     (make-readtable #f #\' #\| #f)))
         (let ((domain (read inport)))
           (if (eof-object? domain) '()
               (cons domain (read-data inport))))))

The readtable stuff in gambit is different, obviously, so how would I go
about tackling this problem?
I've done some reading and trying different things but my scheme chops
are weak and at this point I'm stumped.

Thanks for your help.

- Jamie

===============================
CONFIDENTIAL & PRIVILEGED COMMUNICATION 

The information contained in this message is privileged, confidential, and protected from disclosure. This message is intended for the individual or entity addressed herein. If you are not the intended recipient,please do not read, copy, use or disclose this communication to others. Also please notify the sender by replying to this message, and then delete it from your system. The sender totally disclaims, and will not accept, any responsibility or liability for the unauthorized use, or the consequences of any unauthorized use, of this communication or message.




More information about the Gambit-list mailing list