Re: [racket-users] Getting a sandboxed evaluator to work with a custom #lang's reader

2015-05-12 Thread Alexander D. Knauth
I managed to put this together:
https://github.com/AlexKnauth/scribble-code-examples

On May 12, 2015, at 7:10 AM, Alexis King  wrote:

> Continuing my attempts to make a working meta-language, I'm now working on 
> improving the documentation. I'd like to be able to use “interaction” from 
> scribble/eval with a custom evaluator, but I'm having trouble getting a 
> custom evaluator to work with my language.
> 
> I've tried using (make-module-evaluator "#lang curly-fn racket/base"), but 
> that only enables the curly-fn reader for reading the initial program, not 
> the additional input passed to the evaluator.
> 
> I have managed to do this sort of thing to get it working.
> 
> (parameterize ([sandbox-output 'string]
>   [sandbox-error-output 'string]
>   [sandbox-reader
>(λ (in)
>  (parameterize ([current-readtable (make-curly-fn-readtable)])
>(reverse
> (let loop ([acc null])
>   (define r (read-syntax in (current-input-port)))
>   (if (eof-object? r) acc (loop (cons r acc)))])
>  (make-module-evaluator "#lang curly-fn racket/base"))
> 
> That works, but I'm wondering if there's a better way.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Getting a sandboxed evaluator to work with a custom #lang's reader

2015-05-12 Thread Alexander D. Knauth
Is there a way to show examples in scribble docs that uses code?
If there’s not, would something like this be good:
@code-examples[#:lang “at-exp racket”]|{
(+ 1 2)
@+[1 2]
}|

Renders as:
Examples:
  > (+ 1 2)
  3
  > @+[1 2]
  3
?

On May 12, 2015, at 7:10 AM, Alexis King  wrote:

> Continuing my attempts to make a working meta-language, I'm now working on 
> improving the documentation. I'd like to be able to use “interaction” from 
> scribble/eval with a custom evaluator, but I'm having trouble getting a 
> custom evaluator to work with my language.
> 
> I've tried using (make-module-evaluator "#lang curly-fn racket/base"), but 
> that only enables the curly-fn reader for reading the initial program, not 
> the additional input passed to the evaluator.
> 
> I have managed to do this sort of thing to get it working.
> 
> (parameterize ([sandbox-output 'string]
>   [sandbox-error-output 'string]
>   [sandbox-reader
>(λ (in)
>  (parameterize ([current-readtable (make-curly-fn-readtable)])
>(reverse
> (let loop ([acc null])
>   (define r (read-syntax in (current-input-port)))
>   (if (eof-object? r) acc (loop (cons r acc)))])
>  (make-module-evaluator "#lang curly-fn racket/base"))
> 
> That works, but I'm wondering if there's a better way.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Getting a sandboxed evaluator to work with a custom #lang's reader

2015-05-12 Thread Alexis King
Continuing my attempts to make a working meta-language, I'm now working on 
improving the documentation. I'd like to be able to use “interaction” from 
scribble/eval with a custom evaluator, but I'm having trouble getting a custom 
evaluator to work with my language.

I've tried using (make-module-evaluator "#lang curly-fn racket/base"), but that 
only enables the curly-fn reader for reading the initial program, not the 
additional input passed to the evaluator.

I have managed to do this sort of thing to get it working.

(parameterize ([sandbox-output 'string]
   [sandbox-error-output 'string]
   [sandbox-reader
(λ (in)
  (parameterize ([current-readtable (make-curly-fn-readtable)])
(reverse
 (let loop ([acc null])
   (define r (read-syntax in (current-input-port)))
   (if (eof-object? r) acc (loop (cons r acc)))])
  (make-module-evaluator "#lang curly-fn racket/base"))

That works, but I'm wondering if there's a better way.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.