[plt-scheme] read-syntax/recursive in reader problem

From: Jos Koot (jos.koot at telefonica.net)
Date: Sun Dec 21 08:56:15 EST 2008

Please help me with the following problem extracted from a larger piece of code.
I have in .../collects/problem/lang the following two files:

;file reader.ss
(module reader syntax/module-reader scheme
 #:wrapper1
 (lambda (t)
  (parameterize ((current-readtable readtable))
   (t)))

 (define read-braces
  (case-lambda
   ((ch port src line col pos)
  #`(lambda #,@(read-syntax/recursive 'problem port #\{)))
   ((ch port)
    (cons 'lambda (read/recursive port #\{)))))

 (define readtable
  (make-readtable #f #\{
  'terminating-macro read-braces)))

and

;file test.ss
#lang problem
({x x} 1 2 3) ; to be read as ((lambda x x) 1 2 3)
; mark the two braces.

When I try to run test.ss it keeps eating memory in the compilation phase until memory limits are exceeded (700Mb) DrScheme's run icon remains standing still. I guess the reader is getting into an infinite regression, but I fail to see how to avoid that problem. I use:
Welcome to DrScheme, version 4.1.3.6-svn20dec2008 [3m].
Language: Module; memory limit: 700 megabytes.
The readtable works correctly when used at top level.
Help please,
Jos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20081221/b8c35540/attachment.html>

Posted on the users mailing list.