Recently i've been working with Jflex and i noticed that when i try to construct the Yylex object it only accepts java.io.Reader
and java.io.InputStream
. How could i do if i just want to build the object by using only a String?, like this:
String myString = "Hello world";
String token;
Yylex scanner = new Yylex(myString);
while ((token = scanner.yylex()) != null) {
//do something
}
In the system i'm trying to build i want the user to write something and then apply the Yylex method to it. In the models i saw that were similar to my idea the user inputs an String and then it is written into a file from where the Yylex will read.
Is it possible to do that? or i'm misunderstanding something?. Is there any other tool you would reccomend instead of Jflex?
Thanks!