2 # reads CPP output and turns #line things into appropriate Haskell
5 # considered to be GHC-project specific
8 # NOTE: this script needs RAWCPP set in order to do something
19 /^-v$/ && do { $Verbose = 1; next; };
23 die "usage: hscpp [arg...] file";
33 print STDERR "hscpp:CPP invoked: $Cpp @args - <$file\n" if $Verbose;
34 open(INPIPE, "$Cpp @args - <$file |")
35 || die "Can't open C pre-processor pipe\n";
39 # line directives come in flavo[u]rs:
40 # s/^#\s*line\s+\d+$/\{\-# LINE \-\}/; IGNORE THIS ONE FOR NOW
41 s/^#\s*line\s+(\d+)\s+(\".+\")$/\{\-# LINE \1 \2 \-\}/;
42 s/^#\s*(\d+)\s+(\".*\").*/\{\-# LINE \1 \2 \-\}/;
44 s/^#\s*(\d+)\s+(\"\").*//; # these are a result of our using stdin in
45 # the $(CPP) command line above.
50 close(INPIPE) || exit(1); # exit is so we reflect any errors.