Code for hugs and ghc

Alastair David Reid reid@cs.utah.edu
16 Nov 2001 11:52:41 -0700


Another approach is to use the script included in hugs98/Install (attached).

I'd use Sigbjorn's approach for simple config cases and only use this
if things get complicated (different versions, etc.)

Also, keep us informed about incompatabilities.  We've been trying to
fix as many as possible for the next release but we might have missed
some.

--
Alastair Reid


 --with-preprocessor

   This is an experimental feature and may change in future versions.

   Enable the use of a preprocessor for processing Haskell source files
   before compiling them with Hugs.  When configured with preprocessing
   on, you can use the "-F" option to specify which preprocessor to use.
   For example, if your preprocessor is in /users/JFH/bin/hscpp, you might
   say

     :set -F"/users/JFH/bin/hscpp"

   If you have perl and gcc installed on your machine, the following
   script provides a simple cpp-like preprocessor.

     eval "exec perl -S $0 $*"
	  if $running_under_some_random_shell;
     #
     # Reads CPP output and turns #line things into appropriate Haskell
     # pragmas.  This program is derived from the "hscpp" script
     # distributed with the Glasgow Haskell Compiler.
     #
     $Cpp = 'gcc -E -xc -traditional';
     open(INPIPE, "$Cpp @ARGV |") || die "Can't open C pre-processor pipe\n";
     while (<INPIPE>) {
     # line directives come in flavo[u]rs:
     #   s/^#\s*line\s+\d+$/\{\-# LINE \-\}/;   IGNORE THIS ONE FOR NOW
	 s/^#\s*line\s+(\d+)\s+(\".+\")$/\{\-# LINE \1 \2 \-\}/;
	 s/^#\s*(\d+)\s+(\".*\").*/\{\-# LINE \1 \2 \-\}/;
	 print $_;
     }
     close(INPIPE) || exit(1); # exit is so we reflect any errors.
     exit(0);

   Note that Hugs currently ignores the {-# LINE _ _ #-} pragmas so error
   messages will refer to the wrong line numbers.