From 05e97fc7c775162ebf05dd66aa825d7aca364e85 Mon Sep 17 00:00:00 2001 From: osku Date: Tue, 28 Mar 2006 09:32:48 +0000 Subject: [PATCH] Add make_flex.sh and update lexer/parser generation documentation. --- pars/make_bison.sh | 3 +-- pars/make_flex.sh | 20 ++++++++++++++++++++ pars/pars0lex.l | 22 +++------------------- 3 files changed, 24 insertions(+), 21 deletions(-) create mode 100755 pars/make_flex.sh diff --git a/pars/make_bison.sh b/pars/make_bison.sh index 43b0322494c..c11456230c4 100755 --- a/pars/make_bison.sh +++ b/pars/make_bison.sh @@ -1,7 +1,6 @@ #!/bin/bash # -# regenerate parser from bison input files as documented at the top of -# pars0lex.l. +# generate parser files from bison input files. set -eu diff --git a/pars/make_flex.sh b/pars/make_flex.sh new file mode 100755 index 00000000000..c015327bf8c --- /dev/null +++ b/pars/make_flex.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +# generate lexer files from flex input files. + +set -eu + +TMPFILE=_flex_tmp.c +OUTFILE=lexyy.c + +flex -o $TMPFILE pars0lex.l + +# AIX needs its includes done in a certain order, so include "univ.i" first +# to be sure we get it right. +echo '#include "univ.i"' > $OUTFILE + +# flex assigns a pointer to an int in one place without a cast, resulting in +# a warning on Win64. this adds the cast. +sed -e 's/int offset = (yy_c_buf_p) - (yytext_ptr);/int offset = (int)((yy_c_buf_p) - (yytext_ptr));/;' < $TMPFILE >> $OUTFILE + +rm $TMPFILE diff --git a/pars/pars0lex.l b/pars/pars0lex.l index 5ea3a514489..e155e0b2c00 100644 --- a/pars/pars0lex.l +++ b/pars/pars0lex.l @@ -12,27 +12,11 @@ not automatically generate them from pars0grm.y and pars0lex.l. How to make the InnoDB parser and lexer C files: -1. First do - bison -d pars0grm.y - That generates pars0grm.tab.c and pars0grm.tab.h. +1. Run ./make_flex.sh to generate lexer files. -2. Rename pars0grm.tab.c to pars0grm.c and pars0grm.tab.h to pars0grm.h. +2. Run ./make_bison.sh to generate parser files. -3. Copy pars0grm.h also to /innobase/include - -4. Do - flex pars0lex.l - That generates lex.yy.c. - -5. Rename lex.yy.c to lexyy.c. - -6. Add '#include "univ.i"' before #include in lexyy.c - (Needed for AIX) - -7. Add a type cast to int to the assignment below the comment - 'need more input.' (Removes a warning on Win64) - -These instructions seem to work at least with bison-1.28 and flex-2.5.4 on +These instructions seem to work at least with bison-1.875d and flex-2.5.31 on Linux. *******************************************************/