<HTML><BODY>I think, you may simply add #lang into input-port when reading the file.<br><br><br>Среда, 11 сентября 2013, 12:08 -05:00 от Robby Findler <robby@eecs.northwestern.edu>:<br>
<blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;" class="mailru-blockquote">
<div id="">
<div class="js-helper js-readmsg-msg">
<style type="text/css"></style>
<div id="style_13789196240000000676" class="mr_read__body">
<base target="_self" href="https://e.mail.ru/">
<div id="style_13789196240000000676_BODY"><div dir="ltr">Generally speaking, Racket is set up to work well with the #lang lines, but not as well without. Lots of things get easier if they are there.<br><div><br></div><div>Robby</div></div><div>
<br><br><div>On Wed, Sep 11, 2013 at 11:57 AM, Dmitry Pavlov <span dir="ltr"><<a href="sentmsg?mailto=mailto%3adpavlov@ipa.nw.ru" target="_blank">dpavlov@ipa.nw.ru</a>></span> wrote:<br><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Joe,<br>
<br>
Thank you. Actually my goal is to run files that do<br>
not contain the #lang declaration--only pure non-Racket<br>
non-sexp code. Is there a way to (dynamic-require)<br>
a module with an externally preset language? I do not know.<br>
<br>
I tried your approach anyway. It works well itself,<br>
but I have failed (as with all the other approaches)<br>
to make a standalone executable from my "interpreter"<br>
program. I wonder if anybody tried that with programs<br>
of this kind.<br>
<br>
Best regards,<br>
<br>
Dmitry<div><div><br>
<br>
<br>
<br>
<br>
On 09/11/2013 05:46 PM, Joe Gibbs Politz wrote:<br>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Dmitry,<br>
<br>
I've been using `dynamic-require` for Pyret, a non-SEXP based<br>
language. For example, here's part of our command-line interface:<br>
<br>
<a href="https://github.com/brownplt/pyret-lang/blob/master/src/cmdline.rkt#L116" target="_blank">https://github.com/brownplt/<u></u>pyret-lang/blob/master/src/<u></u>cmdline.rkt#L116</a><br>
<br>
You can ignore the parameterization under `check-mode`, which is Pyret<br>
specific. The point is that `pyret-file` is a filename handed in as a<br>
command-line argument, and we load the module via `dynamic-require`.<br>
`dynamic-require` does the work of using the reader/environment<br>
specified for the #lang declared in the file, and gets things like<br>
relative module imports right, too (at least I haven't been able to do<br>
anything too unexpected).<br>
<br>
This should work for any language that you want to build a<br>
file-accepting interface for, not just non-sexp ones. I'm not sure if<br>
this is the preferred style or not; if it's not, Pyret should probably<br>
use whatever better method there is as well.<br>
<br>
Cheers,<br>
Joe P<br>
<br>
<br>
<br>
On Tue, Sep 10, 2013 at 11:14 AM, Dmitry Pavlov <<a href="sentmsg?mailto=mailto%3adpavlov@ipa.nw.ru" target="_blank">dpavlov@ipa.nw.ru</a>> wrote:<br>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
I have developed a non-SEXP DSL called SLON, and it works<br>
great in DrRacket via "#lang slon" declaration.<br>
<br>
I have properly set up a lexer, a parser which returns datum<br>
or syntax objects, slon/lang/reader.rkt,<br>
slon/lang/lang-into.rkt, slon/lang/confugure-runtime.<u></u>rkt<br>
and all the other stuff.<br>
<br>
Now I need it to work as a stand-alone interpreter<br>
which runs files specified by user (outside of DrRacket).<br>
How do I do that? The only thing I was able to come up<br>
with is using make-evaluator for racket/sandbox:<br>
<br>
(require slon/slon-parser<br>
racket/sandbox)<br>
<br>
(call-with-input-file*<br>
"myprogram.slon"<br>
(lambda (port)<br>
(parameterize ((sandbox-input (current-input-port))<br>
(sandbox-output (current-output-port)))<br>
(call-with-trusted-sandbox-<u></u>configuration<br>
(lambda ()<br>
((make-evaluator 'slon/slon-language<br>
#:allow-read '("/"))<br>
(slon-read port))))))))<br>
<br>
Is it the correct way to create a stand-alone interpreter?<br>
Because I do not really need a "sandbox" of any kind,<br>
and also I was forced to specify #:allow-read '("/")<br>
because the SLON programs do read arbitrary files.<br>
<br>
Also I am having a lot of trouble in making that<br>
a stand-alone executable; but I will postpone<br>
discussing it because I am not sure whether<br>
I chose the right way to do the whole thing.<br>
<br>
<br>
Best regards,<br>
<br>
Dmitry<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/<u></u>users</a><br>
</blockquote>
<br>
<br>
</blockquote>
<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/<u></u>users</a><br>
</div></div></blockquote></div><br></div>
</div>
<div>____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
</div>
<base target="_self" href="https://e.mail.ru/">
</div>
</div>
</div>
</blockquote>
<br>
<br>--
<br>Roman Klochkov<br></BODY></HTML>