summaryrefslogtreecommitdiff
path: root/tests/test-yydecl-gen.sh
blob: 0a70915688486f0519b85737ebdad1295060ba57 (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
#! /bin/sh
# Generate test for the %yydecl option of flex on a specified back end
backend="$1"

cat <<EOF_OUTER
#! /bin/sh
# Test %yydecl option of flex on ${backend} backend.
trap 'rm /tmp/td\$\$' EXIT HUP INT QUIT TERM

teeout=/dev/null
if [ "\$1" = "-d" ]
then
    shift
    teeout=/dev/stderr
fi

cat >/tmp/td\$\$ <<EOF
%option yydecl="int foobar(void)" emit="${backend}"
%%
%%
EOF
if ../src/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