summaryrefslogtreecommitdiff
path: root/utils/verbatim
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2006-04-07 02:05:11 +0000
committerSimon Marlow <simonmar@microsoft.com>2006-04-07 02:05:11 +0000
commit0065d5ab628975892cea1ec7303f968c3338cbe1 (patch)
tree8e2afe0ab48ee33cf95009809d67c9649573ef92 /utils/verbatim
parent28a464a75e14cece5db40f2765a29348273ff2d2 (diff)
downloadhaskell-0065d5ab628975892cea1ec7303f968c3338cbe1.tar.gz
Reorganisation of the source tree
Most of the other users of the fptools build system have migrated to Cabal, and with the move to darcs we can now flatten the source tree without losing history, so here goes. The main change is that the ghc/ subdir is gone, and most of what it contained is now at the top level. The build system now makes no pretense at being multi-project, it is just the GHC build system. No doubt this will break many things, and there will be a period of instability while we fix the dependencies. A straightforward build should work, but I haven't yet fixed binary/source distributions. Changes to the Building Guide will follow, too.
Diffstat (limited to 'utils/verbatim')
-rw-r--r--utils/verbatim/Makefile17
-rw-r--r--utils/verbatim/verbatim.lex63
2 files changed, 80 insertions, 0 deletions
diff --git a/utils/verbatim/Makefile b/utils/verbatim/Makefile
new file mode 100644
index 0000000000..4a4301dfe0
--- /dev/null
+++ b/utils/verbatim/Makefile
@@ -0,0 +1,17 @@
+TOP=../..
+include $(TOP)/mk/boilerplate.mk
+
+C_SRCS = verbatim.c
+C_PROG = verbatim
+LIBS = $(FLEX_LIB)
+
+override SRC_FLEX_OPTS=-8
+
+#
+# For src distributions, include flex output.
+#
+SRC_DIST_FILES += verbatim.c
+
+CLEAN_FILES += verbatim.c
+
+include $(TOP)/mk/target.mk
diff --git a/utils/verbatim/verbatim.lex b/utils/verbatim/verbatim.lex
new file mode 100644
index 0000000000..bac87cc45f
--- /dev/null
+++ b/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;
+<NORM>@@ { printf ("@"); }
+<NORM>@ { printf ("\\mbox{\\tt "); PUSH NORM; BEGIN VERB; }
+<VERB>@ { printf ("}"); POP; }
+<VERB>\n { printf ("}\\\\{}\n\\mbox{\\tt "); }
+<VERB>" " { printf ("\\ "); }
+<VERB>@@ { printf ("@"); }
+<VERB>\# { printf ("{\\char'43}"); }
+<VERB>\$ { printf ("{\\char'44}"); }
+<VERB>\% { printf ("{\\char'45}"); }
+<VERB>\& { printf ("{\\char'46}"); }
+<VERB>\~ { printf ("{\\char'176}"); }
+<VERB>\_ { printf ("{\\char'137}"); }
+<VERB>\^ { printf ("{\\char'136}"); }
+<VERB>\\ { printf ("{\\char'134}"); }
+<VERB>\{ { printf ("{\\char'173}"); }
+<VERB>\} { printf ("{\\char'175}"); }
+
+<NORM>^@{sp}\n { printf( "\\begin{verbatim}\n" );
+ PUSH NORM; BEGIN VERBATIMSIM; }
+<VERBATIMSIM>^@{sp}\n { printf( "\\end{verbatim}\n" ); POP; }
+
+<NORM>\\"begin{verbatim}" { printf( "\\begin{verbatim}" );
+ PUSH NORM; BEGIN VERBATIM; }
+<VERBATIM>\\"end{verbatim}" { printf( "\\end{verbatim}" ); POP; }
+
+<NORM>^\n{miranda} { printf ("\\begin{verbatim}\n>" );
+ PUSH NORM; BEGIN MIRANDA; }
+<MIRANDA>\n{miranda} { printf( "\n>" ); }
+<MIRANDA>^\n { printf ("\\end{verbatim}\n"); POP; }
+%%
+int
+main()
+{
+ yylex();
+ return(0);
+}