Search code examples
callbacklexflex-lexer

lex|flex rule action ignored


All,

I have a specified type of pattern in my lex file:

 "#"[ \\t]*"ifdef".*                { action_ifdef_manager(yytext);}

if a text like this encoutred #ifdef GLOBALVAR the action action_ifdef_manager is not called

Thanks for any Help.


Solution

  • The only problem is ambiguity of patterns. You should have a similar pattern like '#ifdef'

              a        |
              ab       |
              abc      |
              abcd     ECHO; REJECT;
    

    The lexer here returns in "abcd" stream all four validated patterns a , ab , abc, abcd

    Take a look at the Flex manual