Q1. The warning you have is from this line:
"%=" { printf("%=\t"); }
You want:
"%=" { printf("%%=\t"); }
as you need to escape the '%'.
Q2. To get lex
to read from a given file, you need to use yyin
- see in lex how to make yyin point to a file with the main function in yacc? for more details.
Q3. You will need to use regexps to match them. See https://www.cs.princeton.edu/~appel/modern/c/software/flex/flex.html for example.