[plt-scheme] #%app literal does not match in syntax-case pattern

From: Marco Monteiro (masm at acm.org)
Date: Thu Nov 19 16:54:58 EST 2009


I have this reader in pltcollects/masm/lang/reader.ss

(module reader syntax/module-reader
  ;; Reads and expands the module; then, use process-body on the module
definitions and
  ;; expressions, to efectivelly remove (replace by (void)) the application
expressions and
  ;; define all variables to be null.
  (lambda (in read stx?)
    (let ([mod (let ([m (read in)])
                 (if stx? m (datum->syntax #f m)))])
      (syntax-case mod ()
        [(module name lang* . body)
         (let ([lang `(file ,(path->string (resolved-module-path-name
           (with-syntax ([lang (datum->syntax #'lang* lang #'lang*)])
             (let ([expanded-mod (parameterize ([current-namespace
                                   (expand #'(module name lang . body)))])
               (let ([r (syntax-case expanded-mod ()
                          [(module name lang (module-begin . body*))
                           (with-syntax ([body (process-body #'body*)])
                             (syntax/loc mod (module name lang (module-begin
. body))))])])
                 (if stx? r (syntax->datum r))))))])))

  (require scheme/runtime-path)
  (define-runtime-module-path masm-lang-path "../masm-lang.ss")

  (define (process-body body)
    (datum->syntax body (map process-form (syntax->list body))))

  (define (process-form stx)
    (syntax-case stx (define-values #%app)
      [(define-values (id) value)
       #'(define-values (id) (void))]
      [(#%app . _)
       (error "unsupported form" (syntax->datum stx))]))

and this in pltcollects/masm/masm-lang.ss

#lang scheme

(define-syntax (_#%module-begin stx)
  (syntax-case stx ()
    [(_ . forms)
     #'(#%plain-module-begin . forms)]))

(provide (rename-out (_#%module-begin #%module-begin))

. When I tried to use this language with the code

#lang masm

(define x (2 1))

(1 2)

I was expecting no error. But I got "pltcollects/masm/lang/reader.ss:36:7:
unsupported form (#%app (quote 1) (quote 2))".
The process-form procedure matches the literal define-values, but not the
literal #%app. Why does this happen?
I tried to require #%app from scheme module both at phases 0 an 1, but it
still does not work. I was thinking that the problem could be the
(make-base-namespace), but using module->namespace with the masm-lang.ss
module does not work. What am I missing?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091119/0bf25e83/attachment.html>

Posted on the users mailing list.