I am trying to match the strings in a file with the regular expressions in flex. For example, to match with assignment operator, I write:
= printf("tASSIGN token");
But when I want to match with the operator <
, it doesn't accept the following line:
< printf("tLT token");
What can I do?
The <
character is special to lex -- it is used to mark a pattern as only applying in certain states. To get a literal <
you need to escape or quote it:
"<" printf("tLT token");