mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 18:52:07 +00:00
Refactor how Makefile invokes Bison for reusability (#1259)
Co-authored-by: Eldred Habert <eldredhabert0@gmail.com>
This commit is contained in:
26
src/bison.sh
Executable file
26
src/bison.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
BISONFLAGS=-Wall
|
||||
|
||||
readonly BISON_VER=$(bison -V)
|
||||
add_flag () {
|
||||
if awk <<<"$BISON_VER" -v major="$1" -v minor="$2" '
|
||||
/^bison.*[0-9]+(\.[0-9]+)(\.[0-9]+)?$/ {
|
||||
match($0, /[0-9]+(\.[0-9]+)(\.[0-9]+)?$/);
|
||||
split(substr($0, RSTART), ver, ".");
|
||||
if (ver[1] == major && ver[2] >= minor) { exit 0 } else { exit 1 }
|
||||
}'; then
|
||||
BISONFLAGS="-D$3 $BISONFLAGS"
|
||||
fi
|
||||
}
|
||||
|
||||
add_flag 3 5 api.token.raw=true
|
||||
add_flag 3 6 parse.error=detailed
|
||||
add_flag 3 0 parse.error=verbose
|
||||
add_flag 3 0 parse.lac=full
|
||||
add_flag 3 0 lr.type=ielr
|
||||
|
||||
echo "BISONFLAGS=$BISONFLAGS"
|
||||
|
||||
exec bison $BISONFLAGS -d -o "$1" "$2"
|
||||
Reference in New Issue
Block a user