[racket] Literate programming: help with @chunks

From: Tim Brown (tim.brown at cityc.co.uk)
Date: Fri May 20 07:45:06 EDT 2011


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
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))]

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



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.