[racket] Evaluating code written in non-SEXP language

From: Dmitry Pavlov (dpavlov at ipa.nw.ru)
Date: Tue Sep 10 11:14:22 EDT 2013

Hello,

I have developed a non-SEXP DSL called SLON, and it works
great in DrRacket via "#lang slon" declaration.

I have properly set up a lexer, a parser which returns datum
or syntax objects, slon/lang/reader.rkt,
slon/lang/lang-into.rkt, slon/lang/confugure-runtime.rkt
and all the other stuff.

Now I need it to work as a stand-alone interpreter
which runs files specified by user (outside of DrRacket).
How do I do that? The only thing I was able to come up
with is using make-evaluator for racket/sandbox:

(require slon/slon-parser
          racket/sandbox)

(call-with-input-file*
    "myprogram.slon"
    (lambda (port)
      (parameterize ((sandbox-input (current-input-port))
                     (sandbox-output (current-output-port)))
        (call-with-trusted-sandbox-configuration
         (lambda ()
           ((make-evaluator 'slon/slon-language
                            #:allow-read '("/"))
            (slon-read port))))))))

Is it the correct way to create a stand-alone interpreter?
Because I do not really need a "sandbox" of any kind,
and also I was forced to specify #:allow-read '("/")
because the SLON programs do read arbitrary files.

Also I am having a lot of trouble in making that
a stand-alone executable; but I will postpone
discussing it because I am not sure whether
I chose the right way to do the whole thing.


Best regards,

Dmitry

Posted on the users mailing list.