[plt-scheme] New language plugin: sPico

From: Daniel Silva (daniel.silva at gmail.com)
Date: Sat Nov 20 04:32:12 EST 2004

I think you're misunderstanding the purpose of DrScheme languages. 
Right now you grab the input string, parse and evaluate it, and return
the result of the program as another string.
What you probably should do is grab the input string, parse it and
compile it into Scheme code for mzscheme/mred/drscheme to evaluate. 
You should represent the generated Scheme code as syntax objects --
that's the data type DrScheme expects from the front-end method.
Take a look at the algol60 front-end method (in tool.ss) for an
example, and here's my implementation for Spy:

(define/public (front-end input settings)
  ;; first convert 'input' into a normal port
  (let-values ([(port name)
                (if (string? input)
                    (values (open-input-file input) (path->complete-path input))
                    (let ([text (drscheme:language:text/pos-text input)])
                      (values (open-input-string
                               (send text
                                     get-text
                                     (drscheme:language:text/pos-start input)
                                     (drscheme:language:text/pos-end input)))
                              text)))])
    ;; now read and compile the source code into Scheme
    (let ([ast-list (read-python-port port name)])
      (close-input-port port)
      (lambda ()
        (if (null? ast-list)
            eof
            (begin0 (compile-python-ast (car ast-list))
                    (set! ast-list (cdr ast-list))))))))

Daniel


On Thu, 18 Nov 2004 09:11:28 +0100, Kim Gybels <ryu at igwe.vub.ac.be> wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> Hi,
> 
> We are trying to create a plugin for a language called pico.
> This actually already works, but we are trying to get rid
> of a strange error that we always get when we read-eval-print
> anything. (the program has its own read-eval-print-loop)
> 
> The thing we get is the following:
> 
> > 5
> 5
> eval-syntax: expects argument of type <syntax>; given
> 
> Or program does this:
> (redefinition of both front-ends)
> 
>           (define/private (front-end input settings)
>             (let ((done? #f)
>                   (str
>                    (if (string? input)
>                        input
>                        (let ([text (drscheme:language:text/pos-text input)])
>                          (send text
>                                get-text
>                                (drscheme:language:text/pos-start input)
>                                (drscheme:language:text/pos-end input))))))
>               (lambda ()
>                 (if done?
>                     eof
>                     (let [(result (pico-eval str))]
>                       (set! done? #t)
>                       result)))))
> 
> (we want the lambda to be evaluated only once because it has its own
> read-eval-print) The result is always a string-scheme-object
> 
> And another small thing: our output (which we display or write to the current
> output-window) is always in a box, like the normal display in scheme.
> We would like it to be displayed in normally, like normal scheme-output (the
> blue one :)) But this last thing is secondary.
> 
> Greetz & thnx
> 
> Kim & Toon
> 
> PS: You can download the source-code we use at infogroep.be/sPico
> (just type make in the /usr/plt/collects/spico folder (or whatever
> your path is, just extract the files to your collects path, and make
> in that dir :))
> Sorry that we are setup-plt-noobs :)
> 
>


Posted on the users mailing list.