I have created a module which provides various functions, including #%module-begin. I want to use it with at-exp syntax, which I can do using the following #lang line:
#lang at-exp s-exp "my-library.rkt"
However, this does not read unknown symbols as strings, as would happen for example when using the scribble/text language. How can I provide this functionality from my library, to save me writing quote marks around all my strings?
I think it may have something to do with the #%top function. Perhaps I can require it somehow from scribble/text and then provide it from my library?
What
scribble/textdoes, is it starts reading the file in "text" mode, whereasat-expstarts reading the file in "racket" mode. Messing with#%topis not what you want here. To do the same thing asscribble/text, you would need a version ofat-expthat starts in text mode. That doesn't exist (yet) though.The function
read-syntax-insidefromscribble/readerdoes this. However, you will have to define your own#langlanguage that uses it. For that, you might find this documentation helpful, but there's no quick answer.Update:
I looked at the implementation of
scribble/text, and the answer seems a lot quicker than I thought it would be. Something like this should work:my-library/lang/reader.rkt:Testing it:
I tested this with
my-library/main.rktre-providing everything fromracket/base.