Every tutorial begins with Flex lexer only. And then they introduce Bison. I can run Flex and run Bison and compile just fine - I've written myself a shell script for it - but shouldn't I be able to generate and compile just from Flex as well? Or must I give up on that?
There are numerous errors had from omitting my Bison. Some sources include:
<tab>{FLA} {yylval.midi = midi(yytext[1],yytext[0],1) ; return FLA;}
With error "undefined reference to `yylval'. And:
#include "y.tab.h"
Which cannot locate the .h file. I have taken to including sed regex in my compile script to generate a kinder .l file omitting these problematic things, which I can then flex into C code and compile alone, in order to keep track of my lexer which I develop next to my parser for my notation.
Is that something that people do? Is there a different way to keep the Flex code valid by itself? Or do people just give up on that?
yylval
is in fact a global variable defined in bison. You can declare your one global yylval and for example write amain
with awhile(t=yylex()){ print t and yylval }
- JJoao