summarylogtreecommitdiffstats
path: root/tlc-colour
blob: 9339fa77b74cac922c690418ef2382ce8bc174a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash

if [ $# -eq 0 ]; then

  # Colour stdin
  exec perl -pe '

    s/^(.?Warning:.*)$/\e[30;43m$1\e[0m/mg;
    s/^(.?Error:(?! The behavior up to this point is).*|\*\*\*.*Error.*)$/\e[97;41m$1\e[0m/mg;
    s/^(.*Attempted to select nonexistent field.*)$/\e[97;41m$1\e[0m/mg;
    s/^(Lexical error at .*)$/\e[97;41m$1\e[0m/mg;
    s/^(State \d+: <)(\S+?)( line.+)$/\e[93m$1\e[0;30;43m$2\e[0;93m$3\e[0m/mg;
    s/^(State \d+:.*)$/\e[93m$1\e[0m/mg;
    s/^(Model checking completed. No error.*)$/\e[30;42m$1\e[0m/mg;

    #s/[Ll]ine (\d+?), col(?:umn)? (\d+)/$1:$2/g;
    s/^(\d+\.) Line (\d+?), column (\d+?) to line (\d+?), column (\d+?)/$1 $2:$3 to $4:$5/mg;

    s/^(The exception was .+?[\r\n]+.*?)$/\e[97;41m$1\e[0m/mg;
  '

else

  # Run tlc
  exec "$(dirname "$0")"/tlc "$@" | "$0"

fi