[racket] examples of hooking a #lang into DrRacket?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sun Jul 20 02:05:33 EDT 2014

I did these steps:

"raco pkg install scratchy"
mkdir pollen
raco pkg install --link pollen
cat <the code from your message> > pollen/main.rkt

and after that, drracket turns #lang pollen black for me.

Robby


On Sun, Jul 20, 2014 at 12:48 AM, Matthew Butterick <mb at mbtype.com> wrote:
> Still having some trouble with this:
>
> When I use '#lang scratchy' in DrRacket, the #lang line is black and the DrRacket toolbar buttons show up, as they should.
>
> After some trial & error, what I found is that if I simply change pollen/main.rkt to use the Scratchy parser and reader, like so:
>
> ;;--------------------------------pollen/main.rkt
> #lang racket/base
>
> (require scratchy/scratchy)
> (provide (all-from-out scratchy/scratchy))
>
> (module reader racket/base
>   (require scratchy/reader)
>   (provide (all-from-out scratchy/reader)))
>
>
> ... then '#lang pollen' invokes the Scratchy parser & reader correctly (= it will run sample Scratchy code).
>
> Unfortunately the '#lang pollen' line still shows up in red, and there are still no DrRacket toolbar buttons (and still no error message in the bottom of the window)
>
> Since a brain transplant hasn't fixed the problem, what else might DrRacket be looking for to validate '#lang pollen'?
>
>
>
> On Jul 14, 2014, at 12:53 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>
>> The most relevant section of the documentation is
>>
>>  http://docs.racket-lang.org/guide/language-get-info.html
>>
>>
>> The Scratchy language is intended to be an example:
>>
>>  https://github.com/mflatt/scratchy
>>
>>
>> You could also check "reader.rkt" as part of
>>
>> http://queue.acm.org/downloads/2011/racket/6-color/README.txt
>> http://queue.acm.org/downloads/2011/racket/6-color/txtadv.rkt
>> http://queue.acm.org/downloads/2011/racket/6-color/world.rkt
>> http://queue.acm.org/downloads/2011/racket/6-color/lang/color.rkt
>> http://queue.acm.org/downloads/2011/racket/6-color/lang/reader.rkt
>>
>> which is from "Creating Languages in Racket" in "Queue". The
>> "reader.rkt" module has the relevant part at the end:
>>
>> ;; DrRacket asks `get-info' for a 'color-lexer module:
>> (require racket/runtime-path)
>> (define-runtime-path color-lexer-path "color.rkt")
>> (define (get-info in mod line col pos)
>>   (lambda (key default)
>>     (case key
>>       [(color-lexer)
>>        (dynamic-require color-lexer-path 'color-lexer)]
>>       [else default])))
>>
>> The Scratchy example is more recent and I think better organized,
>> though.
>>
>>
>> At Mon, 14 Jul 2014 00:18:27 -0700, Matthew Butterick wrote:
>>> Pollen source files run fine in DrRacket. But the `#lang pollen` line shows up
>>> as red (though no error is reported in the bottom of the window) and no toolbar
>>> buttons are available. So something is not quite right.
>>>
>>> I gather that this has something to do with telling DrRacket about
>>> language-specific capabilities. [1]
>>>
>>> However, many of the custom #langs in Racket use the standard #lang s-exp
>>> syntax/module-reader, which seems to eliminate these problems from the start.
>>>
>>> Q: To supplement the documentation, are there particular #langs that show
>>> examples of this kind of configuration file?
>>>
>>> [1]
>>> http://docs.racket-lang.org/tools/Language-Specific_Capabilities.html?q=Customiz
>>> ing%20DrRacket%u2019s%20Behavior
>>
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.