<p dir="ltr">There is also a `with-module-reading-parameterization` that sets up the reader to do this.</p>
<br><div class="gmail_quote">On Wed, Feb 18, 2015, 10:36 PM Sam Tobin-Hochstadt <<a href="mailto:samth@cs.indiana.edu">samth@cs.indiana.edu</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Feb 18, 2015 at 10:22 PM, Thomas Gilray <<a href="mailto:thomas.gilray@gmail.com" target="_blank">thomas.gilray@gmail.com</a>> wrote:<br>
> Hi everyone,<br>
><br>
> I am trying to figure out how to use read-syntax on a port for an entire<br>
> .rkt file. I then want to call (expand ...) on this and get back a (begin<br>
> ...) or (module ...) for the entire file in fully expanded form.<br>
><br>
> If I run (expand #`(define ...)) under a #lang racket, everything works. If<br>
> I place this in a file and use read-syntax however, each top-level<br>
> expression is returned individually, the language declaration isn't<br>
> supported, and without this information the expander complains that "define"<br>
> isn't defined. How do I properly read-syntax a whole file at once?<br>
><br>
> Any ideas would be greatly appreciated.<br>
<br>
I've implemented this a couple times recently, probably the best<br>
version is here:<br>
<a href="https://github.com/samth/pycket/blob/master/pycket/pycket-lang/expand.rkt" target="_blank">https://github.com/samth/<u></u>pycket/blob/master/pycket/<u></u>pycket-lang/expand.rkt</a><br>
<br>
The short answer is that you want to use `read-accept-lang` to enable<br>
#lang, call `read-syntax` once on the port, and the call `expand` in a<br>
new namespace (probably created with `make-base-namespace`).<br>
<br>
Sam<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></div>