2 /* This Lex script acts as a filter to pre-process Latex files.
4 It surrounds groups of lines beginning with a ">" sign, and
5 preceded and followed by a blank line, with \begin{verbatim}
6 and \end{verbatim}. The ">" may be preceded by a digit or digit
7 range (eg 4>, 2-5>, 3->); in this case the digits are removed.
8 They are meant to be used for filtering out versions.
10 It takes words surrounded with @ signs (thus @letrec@) and makes them
11 come out in typewriter font, regardless of the current mode.
14 %START NORM VERB MIRANDA VERBATIM VERBATIMSIM
17 miranda ([0-9]+(\-([0-9]+)?)?)?>
19 #define PUSH states[top++] =
20 #define POP BEGIN states[--top]
28 <NORM>@@ { printf ("@"); }
29 <NORM>@ { printf ("\\mbox{\\tt "); PUSH NORM; BEGIN VERB; }
30 <VERB>@ { printf ("}"); POP; }
31 <VERB>\n { printf ("}\\\\{}\n\\mbox{\\tt "); }
32 <VERB>" " { printf ("\\ "); }
33 <VERB>@@ { printf ("@"); }
34 <VERB>\# { printf ("{\\char'43}"); }
35 <VERB>\$ { printf ("{\\char'44}"); }
36 <VERB>\% { printf ("{\\char'45}"); }
37 <VERB>\& { printf ("{\\char'46}"); }
38 <VERB>\~ { printf ("{\\char'176}"); }
39 <VERB>\_ { printf ("{\\char'137}"); }
40 <VERB>\^ { printf ("{\\char'136}"); }
41 <VERB>\\ { printf ("{\\char'134}"); }
42 <VERB>\{ { printf ("{\\char'173}"); }
43 <VERB>\} { printf ("{\\char'175}"); }
45 <NORM>^@{sp}\n { printf( "\\begin{verbatim}\n" );
46 PUSH NORM; BEGIN VERBATIMSIM; }
47 <VERBATIMSIM>^@{sp}\n { printf( "\\end{verbatim}\n" ); POP; }
49 <NORM>\\"begin{verbatim}" { printf( "\\begin{verbatim}" );
50 PUSH NORM; BEGIN VERBATIM; }
51 <VERBATIM>\\"end{verbatim}" { printf( "\\end{verbatim}" ); POP; }
53 <NORM>^\n{miranda} { printf ("\\begin{verbatim}\n>" );
54 PUSH NORM; BEGIN MIRANDA; }
55 <MIRANDA>\n{miranda} { printf( "\n>" ); }
56 <MIRANDA>^\n { printf ("\\end{verbatim}\n"); POP; }