[gambit-list] Reading S-expressions
Marc Feeley
feeley at iro.umontreal.ca
Thu Apr 30 17:29:21 EDT 2009
On 30-Apr-09, at 4:54 PM, Briggs, Jamie wrote:
> 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.
You'll have to use some of the hidden readtable features. Attached is
what you want.
Marc
(define (setup-special-readtable input-port)
(let* ((original-rt (input-port-readtable input-port))
(rt (##readtable-copy original-rt)))
(##readtable-char-class-set! rt #\' #t ##read-escaped-string)
(input-port-readtable-set! input-port rt)))
(define (process input-port)
(setup-special-readtable input-port)
(read input-port))
(define input "
(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 '))))
")
(pp (call-with-input-string input process))
;; When this program is run the output is:
#;
(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 "))))
More information about the Gambit-list
mailing list