Flex reads data from the yyin
variable, which is a file or a file type.
By default, this variable is associated with the STDIN
entry.
You can associate this variable with another file or file (eg in a parameter) with the command yyin = fopen("nome_do_arquivo.zzz", "r");
.
Here's an example, taken from the Flex manual:
main( argc, argv )
{
int argc;
char **argv;
if ( argc > 0 )
yyin = fopen( argv[0], "r" );
else
yyin = stdin;
yylex();
}
If the function is in a DLL
, you can send the file name as a function parameter. Example:
__attribute__ ((dllexport)) int funcao_da_dll(const char *nome_arquivo)
{
yyin = fopen(nome_arquivo, "r" );
yylex();
}
For more references (in the item THE GENERATED SCANNER
):
FLEX