[plt-scheme] language module: macros + checker/interpreter functions

From: Jordan Johnson (jmj at soe.ucsc.edu)
Date: Fri Aug 11 14:52:22 EDT 2006

Hi all,

I have an interpreter whose front-end I implemented as a language  
module.  My first pass at it was as follows:

(module my-lang mzscheme
   (require "internal-lang.ss") ;; provides (run : expr -> value)

   (define-syntax (t-atom stx)
     (syntax-case stx ()
       [(_ . d) #'(run 'd)]

   (define-syntax t-app
     (syntax-rules ()
       [(_ e1 e2) (run '(e1 e2))]))

   (define-syntax mbegin
     (syntax-rules ()
       [(_ e1 e2 ...)
        (#%module-begin (map (lambda (x) (run x)) (list 'e1  
'e2 ...)))]))

   (provide (rename t-atom #%top)
            (rename t-atom #%datum)
            (rename t-app #%app)
            (rename mbegin #%module-begin)
            )
   )

This seems clunky to me.  More importantly, for a typechecker I'm  
writing, I need to extract location information via macros.  What I  
want is a round of macro expansion, then processing of the result by  
my typechecker and interpreter.

Is this a feasible approach?  I've spent a few hours already fiddling  
with it (trying to set current-eval, or get a macro to expand into a  
form in my internal language, and various other approaches) and come  
up dry, so I'd appreciate any suggestions as I continue working on it.

Thanks,
jmj


Posted on the users mailing list.