[plt-scheme] Re: professorj
On Jan 27, 2006, at 6:02 PM, Kathy Gray wrote:
>
>> 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
> windows.
>
> 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
> interface.
>
> (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 expression
> ;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))
>
There's actually a typo in the first definition: corrected below
(define (java->scheme lang prog)
(let ((output (compile-java 'port 'port lang #f (open-input-
string prog) (open-input-string prog))))
(map compilation-unit-code output)))
-Kathy