%{ %} /* Only multiline comments are supported, not comments that start with // */ /* This is a definition, it's in the format "NAME regex" */ DIGIT [0-9] %% /* Comments in here have to be indented, otherwise you'll get an error */ /* ? means 0 or 1 of the preceding group */ /* + means 1 or more of the preceding group */ /* the backward slashes are used because . and + have special meaning in regexes */ [\+-]?{DIGIT}+(\.{DIGIT}+)? { printf("%s", yytext); } /* [^] is a group of characters, like [], however it specifies "all characters except the ones given" */ /* this way if we have "This is a string with " three quotes" it's not going to match the whole thing */ \"[^"]*\"|'[^']*' { printf("%s", yytext); } %%