Greetings Kind Regards I am learning to utilize flex and bison but for now my question is re/ flex i.e. to wit in particular how to input a string via
stdin
to be recognized by the generated lexer. The flex input file is below and lexer generated via
win_flex --wincompat --noyywrap flex.y
The token rule is merely that for the C language identifier.
flex.y
%%
\b[_a-zA-Z][_a-zA-Z0-9]*\b printf("hello, world\n");
%%
main()
{
yylex();
}
Upon compilation and execution of generated file I merely type in e.g. "abc" w/o quotes then <enter> and expect "hello, world\n" to be printed as it is the action associated w/ the rule, however it is not, only ECHO is called in the switch statement below i.e. case 2:
switch ( yy_act )
{
case 0:
*yy_cp = (yy_hold_char);
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
goto yy_find_action;
case 1:
YY_RULE_SETUP
printf("hello, world\n");
YY_BREAK
case 2:
YY_RULE_SETUP
ECHO;
YY_BREAK
case YY_STATE_EOF(INITIAL):
yyterminate();
case YY_END_OF_BUFFER:
{
int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
...}
So I do not know if I am specigying input file incorrectly, generating incorrectly or entering via stdin incorrectly. Kindly Advise - Thank You
What I have tried:
Every conceivable string termination via keyboard i.e. to wit in particular <enter>, <ctrl>+c, <ctrl>+z, space character, and the usual internet search