blob: f97a61ca81558e3e981e8b3135fe29e21d9e4dca (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#! /bin/sh
# Generate test for the %yydecl option of flex on a specified back end
backend="$1"
FLEX="$2"
cat <<EOF_OUTER
#! /bin/sh
# Test %yydecl option of flex on ${backend} backend.
set -eu
trap 'rm /tmp/td\$\$' EXIT HUP INT QUIT TERM
teeout=/dev/null
DEBUG=0
while getopts d OPTION ; do
case \$OPTION in
d) DEBUG=1 ;;
*) echo "Usage: \${0} [-d]"
exit 1
;;
esac
done
shift \$((OPTIND-1))
if [ "\${DEBUG}" = "1" ] ; then
teeout=/dev/stderr
fi
cat >/tmp/td\$\$ <<EOF
%option yydecl="int foobar(void)" emit="${backend}"
%%
%%
EOF
if "${FLEX}" -t /tmp/td\$\$ | tee \${teeout} | grep "int foobar(void)" >/dev/null
then
echo "%yydecl test on ${backend} SUCCEEDED"
exit 0
else
echo "%yydecl test on ${backend} FAILED." >&2;
exit 1
fi
EOF_OUTER
|