a/src/ylwrap b/src/ylwrap
1
#! /bin/sh
1
#! /bin/sh
2
2
3
# ylwrap - wrapper for lex/yacc invocations.  Local version, the
3
# ylwrap - wrapper for lex/yacc invocations.  Local version, the
4
# autotools scriptversion=2015-08-05.09; # UTC doesnt work for us
4
# autotools scriptversion=2015-08-06.06; # UTC doesnt work for us
5
# because it does not move location.hh position.hh stack.hh into the
5
# because it does not move location.hh position.hh stack.hh into the
6
# appropriate directory (which is a bug, but it's simpler to rewrite a
6
# appropriate directory (which is a bug, but it's simpler to rewrite a
7
# simple version for our needs than to fix the original).
7
# simple version for our needs than to fix the original).
8
8
9
fatal() {
9
fatal() {
10
    echo $* 1>&2
10
    echo $* 1>&2
11
    exit 1
11
    exit 1
12
}
12
}
13
usage() {
13
usage() {
14
    fatal "Usage: ylwrap query/wasaparse.ypp"
14
    fatal "Usage: ylwrap query/wasaparse.y"
15
}
15
}
16
16
17
test $# -ge 1 || usage
17
test $# -ge 1 || usage
18
18
19
toptmpdir=/tmp/rclylwrap$$
19
toptmpdir=/tmp/rclylwrap$$
...
...
40
40
41
for f in location.hh position.hh stack.hh; do
41
for f in location.hh position.hh stack.hh; do
42
    cmp -s "${tmpdir}"/$f "${inputdir}"/$f || cp -p "${tmpdir}"/$f "${inputdir}"
42
    cmp -s "${tmpdir}"/$f "${inputdir}"/$f || cp -p "${tmpdir}"/$f "${inputdir}"
43
done
43
done
44
44
45
# Fix the include line in y.tab.c (it wants to include y.tab.h, but we already
46
# include it as wasaparse.h
47
(cd "${tmpdir}"; \
48
    sed -e 's/#include "y.tab.h"//' < y.tab.c > toto; \
49
    mv -f toto y.tab.c)
50
45
cmp -s "${tmpdir}"/y.tab.c "${inputdir}"/wasaparse.cpp || \
51
cmp -s "${tmpdir}"/y.tab.c "${inputdir}"/wasaparse.cpp || \
46
        cp -p "${tmpdir}"/y.tab.c "${inputdir}"/wasaparse.cpp
52
        cp -p "${tmpdir}"/y.tab.c "${inputdir}"/wasaparse.cpp
47
cmp -s "${tmpdir}"/y.tab.h "${inputdir}"/wasaparse.hpp || \
53
cmp -s "${tmpdir}"/y.tab.h "${inputdir}"/wasaparse.h || \
48
        cp -p "${tmpdir}"/y.tab.h "${inputdir}"/wasaparse.hpp
54
        cp -p "${tmpdir}"/y.tab.h "${inputdir}"/wasaparse.h