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 46 47 48 49 50 51 52 53 54 55 56
|
#! /bin/sh
# ylwrap - wrapper for lex/yacc invocations. Local version, the
# autotools scriptversion=2015-08-06.06; # UTC doesnt work for us
# because it does not move location.hh position.hh stack.hh into the
# appropriate directory (which is a bug, but it's simpler to rewrite a
# simple version for our needs than to fix the original).
fatal() {
echo $* 1>&2
exit 1
}
usage() {
fatal "Usage: ylwrap query/wasaparse.y"
}
test $# -ge 1 || usage
toptmpdir=/tmp/rclylwrap$$
tmpdir=${toptmpdir}/tmp
mkdir -p "${tmpdir}"
cleanup() {
rm -rf "${toptmpdir}"/tmp/*
rmdir "${tmpdir}"
rmdir "${toptmpdir}"
}
trap cleanup 0 2 15
# First arg is the input file
input=$1
inputdir=`dirname $1`
curdir=`pwd` || exit 1
absinput="${curdir}/${input}"
bname=`basename $1 .ypp`
(cd "${tmpdir}"; bison -d $absinput)
ls $tmpdir
for f in location.hh position.hh stack.hh; do
cmp -s "${tmpdir}"/$f "${inputdir}"/$f || cp -p "${tmpdir}"/$f "${inputdir}"
done
# Fix the include line in y.tab.c (it wants to include y.tab.h, but we already
# include it as wasaparse.hpp
(cd "${tmpdir}"; sed -i -e "s/#include \"${bname}.tab.hpp\"//" ${bname}.tab.cpp)
# Note that we'd prefer to use wasaparse.h instead of wasaparse.hpp,
# but automake generates a dist list with wasaparse.hpp, so no choice.
cmp -s "${tmpdir}"/${bname}.tab.cpp "${inputdir}"/wasaparse.cpp || \
cp -p "${tmpdir}"/${bname}.tab.cpp "${inputdir}"/wasaparse.cpp
cmp -s "${tmpdir}"/${bname}.tab.hpp "${inputdir}"/wasaparse.hpp || \
cp -p "${tmpdir}"/${bname}.tab.hpp "${inputdir}"/wasaparse.hpp
|