X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=glafp-utils%2Fverbatim%2Fverbatim.lex;fp=glafp-utils%2Fverbatim%2Fverbatim.lex;h=bafcfab5774deeca149c556a386b4063db8556d5;hb=e7d21ee4f8ac907665a7e170c71d59e13a01da09;hp=0000000000000000000000000000000000000000;hpb=e48474bff05e6cfb506660420f025f694c870d38;p=ghc-hetmet.git diff --git a/glafp-utils/verbatim/verbatim.lex b/glafp-utils/verbatim/verbatim.lex new file mode 100644 index 0000000..bafcfab --- /dev/null +++ b/glafp-utils/verbatim/verbatim.lex @@ -0,0 +1,63 @@ + + /* This Lex script acts as a filter to pre-process Latex files. + + It surrounds groups of lines beginning with a ">" sign, and + preceded and followed by a blank line, with \begin{verbatim} + and \end{verbatim}. The ">" may be preceded by a digit or digit + range (eg 4>, 2-5>, 3->); in this case the digits are removed. + They are meant to be used for filtering out versions. + + It takes words surrounded with @ signs (thus @letrec@) and makes them + come out in typewriter font, regardless of the current mode. + */ + +%START NORM VERB MIRANDA VERBATIM VERBATIMSIM +sp [ \t]* +nl {sp}\n{sp} +miranda ([0-9]+(\-([0-9]+)?)?)?> +%{ +#define PUSH states[top++] = +#define POP BEGIN states[--top] +#define yywrap() 1 +%} +%% + int states[256]; + int top; + BEGIN NORM; + top = 0; +@@ { printf ("@"); } +@ { printf ("\\mbox{\\tt "); PUSH NORM; BEGIN VERB; } +@ { printf ("}"); POP; } +\n { printf ("}\\\\{}\n\\mbox{\\tt "); } +" " { printf ("\\ "); } +@@ { printf ("@"); } +\# { printf ("{\\char'43}"); } +\$ { printf ("{\\char'44}"); } +\% { printf ("{\\char'45}"); } +\& { printf ("{\\char'46}"); } +\~ { printf ("{\\char'176}"); } +\_ { printf ("{\\char'137}"); } +\^ { printf ("{\\char'136}"); } +\\ { printf ("{\\char'134}"); } +\{ { printf ("{\\char'173}"); } +\} { printf ("{\\char'175}"); } + +^@\n { printf( "\\begin{verbatim}\n" ); + PUSH NORM; BEGIN VERBATIMSIM; } +^@\n { printf( "\\end{verbatim}\n" ); POP; } + +\\"begin{verbatim}" { printf( "\\begin{verbatim}" ); + PUSH NORM; BEGIN VERBATIM; } +\\"end{verbatim}" { printf( "\\end{verbatim}" ); POP; } + +^\n{miranda} { printf ("\\begin{verbatim}\n>" ); + PUSH NORM; BEGIN MIRANDA; } +\n{miranda} { printf( "\n>" ); } +^\n { printf ("\\end{verbatim}\n"); POP; } +%% +int +main() +{ + yylex(); + return(0); +}