In this lex part of a lex-yacc program what is the purpose of adding the lines
. return yytext[0];
\n return yytext[0];
This the lex part
%{
#include "y.tab.h"
%}
%%
a return A;
b return B;
. return yytext[0];
\n return yytext[0];
%%
What does it return when it encounters \n ?
Not sure why Ajay2707 posted a comment and not an answer, because he is right. According to http://dinosaur.compilertools.net/flex/manpage.html yytext is a string containing the token matched by flex. Taking [0] takes the first character. So
This is because the pattern '.' does not match \n
To put it short this lexer changes a and b to upper caps, and nothing else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With