The state is certainly being changed to DEFN
when a |
is encountered in state WORD
. However, the next time yylex
is called (to get the token following the pipe), the state is reset to WORD
by the block
%{
BEGIN(WORD);
%}
From the flex manual (emphasis added):
In the rules section, any indented or %{ %} enclosed text appearing before the first rule may be used to declare variables which are local to the scanning routine and (after the declarations) code which is to be executed whenever the scanning routine is entered.
You're really better off using the INITIAL
start condition to represent the, well, initial start condition.