Re: [racket] read-syntax for an entire .rkt file

2015-02-20 Thread Greg Hendershott
A few more points I've discovered: - If you might want source position info, you need to use `port-count-lines!`. - If the file has relative requires -- e.g. `(require "foo.rkt")` -- you need to set `current-load-relative-directory`. And you want to do the `expand` while this is set. - `wi

Re: [racket] read-syntax for an entire .rkt file

2015-02-20 Thread Thomas Gilray
Thank you both for your help! This is what I ended up with: (define port (open-input-file "...")) (with-module-reading-parameterization (lambda () (pretty-print (syntax->datum (parameterize ([current-namespace (make-base-namespace)]) (expand (read-syntax (o

Re: [racket] Read-syntax for an entire .rkt file

2015-02-19 Thread Spencer Florence
What you want is `with-module-reading-parameterization `: (with-module-reading-parameterization

[racket] Read-syntax for an entire .rkt file

2015-02-19 Thread Thomas Gilray
Hi, I am trying to figure out how to use read-syntax on a port for an entire .rkt file. I want to then call (expand ...) on this and get back a (begin ...) or (module ...) form for the entire file in fully expanded form. Right now I have three issues: a) I have to skip over the #lang as this is n

Re: [racket] read-syntax for an entire .rkt file

2015-02-18 Thread Spencer Florence
There is also a `with-module-reading-parameterization` that sets up the reader to do this. On Wed, Feb 18, 2015, 10:36 PM Sam Tobin-Hochstadt wrote: > On Wed, Feb 18, 2015 at 10:22 PM, Thomas Gilray > wrote: > > Hi everyone, > > > > I am trying to figure out how to use read-syntax on a port for

Re: [racket] read-syntax for an entire .rkt file

2015-02-18 Thread Sam Tobin-Hochstadt
On Wed, Feb 18, 2015 at 10:22 PM, Thomas Gilray wrote: > Hi everyone, > > I am trying to figure out how to use read-syntax on a port for an entire > .rkt file. I then want to call (expand ...) on this and get back a (begin > ...) or (module ...) for the entire file in fully expanded form. > > If I

[racket] read-syntax for an entire .rkt file

2015-02-18 Thread Thomas Gilray
Hi everyone, I am trying to figure out how to use read-syntax on a port for an entire .rkt file. I then want to call (expand ...) on this and get back a (begin ...) or (module ...) for the entire file in fully expanded form. If I run (expand #`(define ...)) under a #lang racket, everything works.