Hi have the following code
%s expectWord
%%
<expectWord>"and"+{word} { BEGIN( INITIAL );}
<expectWord>["and"]* { /* Skip */;}
"and" { BEGIN( expectWordAfterAND ); return AND; }
The code is supposed to check if user entered "and" and if they did then if user enters multiple ands after that, they will be ignored and when finally there is a word that word will be returned. So if user enters: a and and and and and and b, lexer should return: a and b. so Only one and will be returned.
Right now, it's returning: a b. how do I fix this code?
Thanks