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 set -xe
export LEX=flex export LEX=flex
export LEX_OUT=gribl.c export LEX_OUT=gribl.cpp
$LEX -o gribl.c gribl.l $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.c 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.c > grib_lex.c sed 's/fgetc/getc/g' < grib_lex1.cpp > grib_lex.cpp
rm -f grib_lex1.c rm -f grib_lex1.cpp
rm -f $LEX_OUT rm -f $LEX_OUT
# This invokes bison # This invokes bison
yacc -v -d griby.y yacc -v -d griby.y
sed 's/yy/grib_yy/g' < y.tab.c > grib_yacc1.c # This creates y.tab.h and y.tab.c
sed 's/fgetc/getc/g' < grib_yacc1.c > grib_yacc.c sed 's/yy/grib_yy/g' < y.tab.c > grib_yacc1.cpp
rm -f grib_yacc1.c 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 sed 's/yy/grib_yy/g' < y.tab.h > grib_yacc.h
rm -f y.tab.c y.tab.h rm -f y.tab.c y.tab.h