knot-dns/scripts/update_parser.sh

58 lines
1.2 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
2025-03-22 06:00:44 -04:00
# Copyright (C) CZ.NIC, z.s.p.o. and contributors
# SPDX-License-Identifier: GPL-2.0-or-later
# For more information, see <https://www.knot-dns.cz/>
2015-01-15 12:50:51 -05:00
### ZSCANNER ###
IN="./scanner.rl"
2015-01-15 12:50:51 -05:00
OUT_T0="./scanner.c.t0"
OUT_G2="./scanner.c.g2"
pushd $(dirname "$0")
2018-03-12 06:16:20 -04:00
pushd ../src/libzscanner/
2015-01-15 12:50:51 -05:00
# Generate slower/small zone parser.
ragel -T0 -s -o $OUT_T0 $IN
# Remove redundant comments and unused constants (clang warnings).
sed -i '/#line/d' $OUT_T0
sed -i '/static\ const\ int\ zone_scanner_/d' $OUT_T0
2015-01-15 12:50:51 -05:00
# Remove trailing white spaces.
sed -i 's/\s*$//g' $OUT_T0
2015-01-15 12:50:51 -05:00
# Generate fast/huge zone parser.
ragel -G2 -s -o $OUT_G2 $IN
# Remove redundant comments and unused constants (clang warnings).
sed -i '/#line/d' $OUT_G2
sed -i '/static\ const\ int\ zone_scanner_/d' $OUT_G2
2015-01-15 12:50:51 -05:00
# Remove trailing white spaces.
sed -i 's/\s*$//g' $OUT_G2
2015-01-15 12:50:51 -05:00
popd
### YPARSER ###
IN_Y="./ypbody.rl"
OUT_Y="./ypbody.c"
2015-02-19 05:14:20 -05:00
pushd ../src/libknot/yparser/
2015-01-15 12:50:51 -05:00
# Generate yparser.
ragel -T0 -s -o $OUT_Y $IN_Y
2015-01-15 12:50:51 -05:00
# Remove redundant comments and unused constants (clang warnings).
sed -i '/#line/d' $OUT_Y
sed -i '/static\ const\ int\ yparser_/d' $OUT_Y
# Remove trailing white spaces.
sed -i 's/\s*$//g' $OUT_Y
popd
popd