The current problem I'm working on is how to make the lexical analyzer generated by FLEX analyze the contents of a string and not a file or console input.
Normally what you do is if you want FLEX to analuze the contents of the console input you assign the varibale yyin to stdin or for a file a file pointer.
yyin = stdin;
yyin = fopen("filename","attribute r/w/r+/w+/a");
Now, according to this manual, you can use the function yy_scan_string(char *) to scan the contents of a string. Actually, a copy of the contents of a string would be more accurate since the string contents are put in a buffer, which is modified, so this function's default implementation is to copy the contents.
URL: FLEX Manual describging yy_scan_string
We use yy_scan_string(char *statement)
NOTE: The input string that you pass has to be a NULL terminated string.
char *input = "This is my input string.\0"
So the usage is as follows:
/*Copy string into new buffer and Switch buffers*/
/*Analyze the string*/
/*Delete the new buffer*/