So I've used flex to generate a c file from my lex code, and then used gcc to create the corresponding actual parser .exe. However, I can't figure out how to get it to read from anything other than my own typed input. I am trying to get it to parse a huge dictionary file. Can anyone help?
You have two ways of solving it. The first is to redirect input from standard input with the command prompt <
operation:
> parser.exe < some_file.txt
The other solution is to let the program open the file, and tell the lexer what the file is. For more information about it see the Flex manual. The important functions are yy_create_buffer
and yy_switch_to_buffer
.