File: preprocess

package info (click to toggle)
haskelldb 0.9.cvs.601-13
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 680 kB
  • ctags: 33
  • sloc: haskell: 4,392; sh: 1,900; makefile: 130
file content (19 lines) | stat: -rwxr-xr-x 774 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
     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);