Search code examples
flex-lexer

How reconize a flex token with another token?


I'm trying to reconize the next token with Flex

trasnicion \(simbolo\,simbolo\;simbolo\) 

using the token simbolo [a-zA-Z0-9] but when I execute my program doesn't work.

However, if I do trasnicion \([a-zA-Z0-9]\,[a-zA-Z0-9]\;[a-zA-Z0-9]\) works perfecly.

Can someone explain me why?

Thanks


Solution

  • A macro expansion in (f)lex is written {simbolo}. If you just write simbolo, that requires a match of the literal string "simbolo".

    In this case, you might consider not using macros, since the standard character class [[:alnum:]] means exactly the same thing.