File: __run_all.sh

package info (click to toggle)
re2c 4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 50,052 kB
  • sloc: cpp: 32,477; ml: 8,279; sh: 5,265; makefile: 968; haskell: 612; python: 428; ansic: 227; javascript: 111; java: 3
file content (37 lines) | stat: -rwxr-xr-x 1,229 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
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
root_dir=$(pwd)

for f in $(find -name '*.re'); do
    cd $(dirname $f)

    hsfile="$(basename ${f%.re}.hs)"
    hstest="example.hs"

    cat "$hsfile" \
        | egrep -v 'warning: rule .*matches empty string \[-Wmatch-empty-string\]' \
        | egrep -v 'warning: tag .* degree of nondeterminism \[-Wnondeterministic-tags\]' \
        > "$hstest"

    test -n "$(grep 'main :: IO ()' $hstest)" || continue

    # If the autogenerated message appears more than once in the file, then
    # it must have autogenerated header appended at the end. Cut it off.
    msg='Generated by re2c'
    if [ $(grep -c "$msg" "$hstest") -gt 1 ]; then
        # Get the line of the second message occurrence.
        l=$(grep -n "$msg" "$hstest" | tail -n +2 | cut -d : -f 1)
        # Cut off everything past that line.
        head -n $l "$hstest" > "$hstest".mod && mv "$hstest".mod "$hstest"
    fi

    extra_args=`egrep -o -- '--header [^ ]+' "$hstest" | sed -E 's/--header (.*)/-i \1/'`

    echo "$f"
    ghc "$hstest" $extra_args -O2 -Wall -o example && ./example \
        || { echo "*** error ***"; exit 1; }

    rm -f "$hstest" example $(find -name '*.o' -o -name '*.hi')
    cd $root_dir
done

rm -f "$hstest"
echo "All good."