[plt-scheme] Re: professorj

From: Kathy Gray (kathyg at cs.utah.edu)
Date: Fri Jan 27 20:02:01 EST 2006

> Date: Fri, 27 Jan 2006 18:31:05 -0600
> From: Corey Sweeney <corey.sweeney at gmail.com>
> Subject: [plt-scheme] professorj
> To: PLT Scheme <plt-scheme at list.cs.brown.edu>
> Message-ID:
> 	<d1c0755b0601271631q66053055m7606be3ebe009f06 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> I was playing with professorJ today and I was wondering, how can I  
> view the
> generated scheme code for a java program i typed in?
> Corey
> --
> ((lambda (y) (y y)) (lambda (y) (y y)))

There's no built-in support for this, especially with the editor  

The following two programs will let you see the generated syntax- 
objects from Java code (in strings). Be forewarned, these two  
functions are part of my debugging tools and are not a great user  

(require (lib "compile.ss" "profj"))

;Calls the Java compiler on prog, which should be a complete Java  
program in a string
;lang should be one of : 'beginner 'intermediate 'advanced 'full
;To see inside the syntax-objects, call (print-struct #t first)
;java->scheme: symbol string -> (list (list syntax-object))
(define (java->scheme lang prog)
     (let ((output (compile-java 'port 'port lang (open-input-string  
prog) (open-input-string prog))))
       (map compilation-unit-code output)))

;Calls the Java compiler on prog, which should be a Java statement or  
;lang should be one of the same symbols as for java->scheme
;java-interact->scheme symbol string -> syntax-object
(define (java-interact->scheme lang prog)
     (compile-interactions (open-input-string prog) (open-input- 
string prog) (create-type-record) lang))


Posted on the users mailing list.