[racket] meta-languages and going back to the "normal" reader

From: Alexander D. Knauth (alexander at knauth.org)
Date: Sat Jul 5 13:33:27 EDT 2014

If I have a meta-language like this:
 #lang my-meta-lang <language>
And my-meta-lang is similar to at-exp in that it can accept any arbitrary language with any arbitrary reader
(as long as it looks at the readtable), then how do I escape back to the reader specified by <language>
from inside a reader macro from my-meta-lang?

What I’m trying to do is something like #lang afl <language> where afl adds rackjure-like anonymous function literals
to <language>.  

So to parse this:
#lang afl racket
#λ(+ % 1)
It would use the racket reader but wrap it to use the afl-readtable, which includes dispatch-macros that would
read the (+ % 1) and parse the result into a lambda expression.  

But if <language> was something else, with a different reader, then how could I use that to read the (+ %1 1).

For example if it was something like this:
#lang afl at-exp racket
#λ@+[% 1]

There’s also another problem.  If it was this:
#lang afl <language>
#f
Or this:
#lang afl <language>
#false
Or some other thing starting with f that means something to <language>,
Then it would see the #f and hope that it would turn out to be #fn.  If it doesn’t, then it uses the racket reader
(instead of the one provided by <language>) to read the #f or the #false.  

So back to my original question: How do I escape back to the reader specified by <language>
from inside a reader macro?  

By the way I can’t find anything in the docs about what the arguments to the read and read-syntax functions
provided by <language>/lang/reader.rkt are supposed to be or mean.  



Posted on the users mailing list.