To make the output appear in the Lex file, you'd add << endl
between yytext
and its following semi-colon. Otherwise, the output is buffered until a newline appears or the file is closed at the end of the program.
Your Lex code assigns to yylval.strVal
, but your Yacc grammar doesn't define strVal
as part of your %union
. If the code is compiling, this indicates a disconnect somewhere in your use of headers. Your Lex code should be using the header generated by Yacc (yacc -d
).
With the disconnect between the union resolved, and the confirmation that adding << endl
to the Lex code showed that output, did you also think of adding << endl
to the Yacc code? If not, do so! If you did, edit the code in the question to accurately reflect what you've got; we can't read your screen from this side of the Internet.