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
|
for f in $(find -name '*.re'); do
echo $f
zfile="${f%.re}.zig"
ztest="$(dirname $zfile)/example.zig"
cat "$zfile" \
| egrep -v 'warning: rule .*matches empty string \[-Wmatch-empty-string\]' \
| egrep -v 'warning: tag .* degree of nondeterminism \[-Wnondeterministic-tags\]' \
> "$ztest"
test -z "$(grep 're2c: error:' $ztest)" || 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='// Code generated by re2c, DO NOT EDIT.'
if [ $(grep -c "$msg" "$ztest") -gt 1 ]; then
# Get the line of the second message occurrence.
l=$(grep -n "$msg" "$ztest" | tail -n +2 | cut -d : -f 1)
# Cut off everything past that line.
head -n $l "$ztest" > "$ztest".mod && mv "$ztest".mod "$ztest"
fi
zig test "$ztest" || { echo "*** error ***"; exit 1; }
rm -f "$ztest"
done
rm -f "$ztest"
echo "All good."
|