ECC-1508: Lex and Yacc rules

This commit is contained in:
Shahram Najm 2023-01-28 22:28:34 +00:00
parent a269951e83
commit 0579ed8e82
1 changed files with 9 additions and 8 deletions

View File

@ -1,18 +1,19 @@
set -xe
export LEX=flex
export LEX_OUT=gribl.c
$LEX -o gribl.c gribl.l
sed 's/yy/grib_yy/g' < $LEX_OUT | sed 's/static void grib_yyunput/void grib_yyunput/' > grib_lex1.c
sed 's/fgetc/getc/g' < grib_lex1.c > grib_lex.c
rm -f grib_lex1.c
export LEX_OUT=gribl.cpp
$LEX -o gribl.cpp gribl.l
sed 's/yy/grib_yy/g' < $LEX_OUT | sed 's/static void grib_yyunput/void grib_yyunput/' > grib_lex1.cpp
sed 's/fgetc/getc/g' < grib_lex1.cpp > grib_lex.cpp
rm -f grib_lex1.cpp
rm -f $LEX_OUT
# This invokes bison
yacc -v -d griby.y
sed 's/yy/grib_yy/g' < y.tab.c > grib_yacc1.c
sed 's/fgetc/getc/g' < grib_yacc1.c > grib_yacc.c
rm -f grib_yacc1.c
# This creates y.tab.h and y.tab.c
sed 's/yy/grib_yy/g' < y.tab.c > grib_yacc1.cpp
sed 's/fgetc/getc/g' < grib_yacc1.cpp > grib_yacc.cpp
rm -f grib_yacc1.cpp
sed 's/yy/grib_yy/g' < y.tab.h > grib_yacc.h
rm -f y.tab.c y.tab.h