[racket] Literate programming: help with @chunks

From: Tim Brown (tim.brown at cityc.co.uk)
Date: Fri May 20 08:33:48 EDT 2011

Robby...k

My "<*>" chunk was called "*" (my mistake) and the e.g. I posted was typed
straight into the mail, and not properly tested.

Thanks for taking the time to respond, despite this accumulated muppetry.

Regards,

Tim

On 20/05/11 13:22, Robby Findler wrote:
> That should work. When I require that file I get this:
>
>    compile: unbound identifier in module in: define-empty-tokens
>
> and then when I fix it like this:
>
> @chunk[<*>
>         (require parser-tools/lex)
>         (define-empty-tokens mt-token-group (<empty-tokens>))]
>
> things seem to work fine.
>
> Robby
>
> On Fri, May 20, 2011 at 6:45 AM, Tim Brown<tim.brown at cityc.co.uk>  wrote:
>> Hello,
>>
>> I'm writing a literate program which includes a lexer/parser.
>> I am trying to build up the lexer a token at a time...
>>
>> ---------
>> #lang scribble/lp
>> @section{newlines}
>> A newline is at the end of a line... in fact we'll consume all newlines,
>> since we don't care how many there are.
>> @chunk[<empty-tokens>  new-line]
>> @chunk[<lex-rules>  ((:+ (:or #\newline #\return)) (token-new-line))]
>>
>> @section{End of file}
>> The parser would like to know when I've run out of file...
>> @chunk[<empty-tokens>  end-of-file]
>> @chunk[<lex-rules>  ((eof) (token-end-of-file))]
>>
>>
>> @chunk[<*>
>> (define-empty-tokens mt-token-group (<empty-tokens>))
>> ]
>> -------------
>>
>> Upon requiring this module; I get:
>>   "lex-lp.rkt:5:22: compile: unbound identifier in module in: new-line"
>>
>> Should I be able to do this? Should the LP code replace<*>  with:
>> (define-empty-tokens mt-token-group (new-line end-of-file))
>> and then evaluate it?
>>
>> Or am I doing something horribly wrong (again).
>>
>> Regards,
>>
>> Tim

-- 
Tim Brown <tim.brown at cityc.co.uk>  | City Computing Limited            |
T: +44 20 8770 2110                | City House, Sutton Park Road      |
F: +44 20 8770 2130                | Sutton, Surrey, SM1 2AE, GB       |
-----------------------------------------------------------------------|
BEAUTY:  What's in your eye when you have a bee in your hand           |
-----------------------------------------------------------------------'
City Computing Limited registered in London No. 1767817.
Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE
VAT number 372 8290 34.


Posted on the users mailing list.