I'm trying to rewrite `make-meta-reader` to hopefully make more sense.

A racket #lang language normally defines and provides a `get-info` function in 
its reader module along with `read` and `read-syntax`. However, there seems to 
be very little documentation about what this is supposed to do, and there are 
different versions for bare #langs versus `syntax/module-reader` versus 
`make-meta-reader` versus `read-language`.

Is there anyone who can explain what is allowed and what isn't for the 
`get-info` function that a #lang is supposed to provide?

;; ----------------

The only documentation I could find was in the Source-Handling Configuration 
part of the Creating Languages section of the Racket Guide, here:
http://docs.racket-lang.org/guide/language-get-info.html 
<http://docs.racket-lang.org/guide/language-get-info.html>

It gives this example

> (define (get-info in mod line col pos)
>   (lambda (key default)
>     (case key
>       [(color-lexer)
>        (dynamic-require 'syntax-color/default-lexer
>                         'default-lexer)]
>       [else default])))


And this explanation

> The get-info function is called by read-language (which DrRacket calls) with 
> the source input stream and location information, in case query results 
> should depend on the content of the module after the language name (which is 
> not the case for literal). The result of get-info is a function of two 
> arguments.

So the `in` argument is the input stream, and the `line`, `col`, and `pos` 
arguments specify positions of something (what?). 

What is the second argument, the `mod` argument?

At the top I mentioned I was trying to rewrite `make-meta-reader`, which needs 
to return a valid `get-info` function as one of its 3 return values. As it does 
that it needs to go to the module returned by the `module-path-parser` argument 
and use the original `get-info` function from there. It seems to be doing some 
pretty weird stuff, having a `get` helper function which return 2 values, the 
second of which is a `next-mod` thing, which it passes as the second argument 
to the original `get-info` function, and then passes the result of that to the 
`convert-get-info` function.

I am thoroughly confused by all of this. Can someone explain how the `get-info` 
function is supposed to work?

Alex Knauth


-- 
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.

Reply via email to