#!/bin/bash
# we expect input from stdin
#the warning: is sycklex in HsSyck
perl -nlwe 'print if / ROOT FAILURE /;print if / ERROR /;
print "$1      INLINE $2" if /^(\S+:).*hsc?:\d+:\d+: error: (.*)/;
print "$1      INLINE $2" if /^(\S+:).*:\d+:\d+: fatal error: (.*)/;
print "$1    $2" if /^(\S+:)(.*Missing \(or bad\).*(librar|header file).*)/;
print "$1    $2" if /^(\S+:)(.*No executables and no library found\. Nothing to do\..*)/;
print "$1    $2" if /^(\S+:)(.*cabal: can\x27t find source.*)/;
if($n){
  unless(/^\S+:\s+warning:/ or /^\S+:\s*$/){print};  # weird C warnings in HsSyck
  $n=0
}
if(/((hsc?)|(\.c)):\d+:\d+: error:$/){
$n=1
}' | perl -nlwe 'if(/ROOT FAILURE/){print;$squelch=0}else{print unless$squelch;$squelch=1}'
    #| perl -nlwe 'next if /true ROOT FAILURE/;s/^\S+:\s*//g;print'
