I am beginning to use JFlex and I want to try to write a lexer first, and then move onto the parser. However, it seems like there is no way to test your JFlex lexer without writing a parser in CUP as well.
All I want to do is write a lexer, give it an input file and then output the lexemes to check that it read everything correctly. Later I would like to output the tokens, but lexemes would be a good start.
Yes It is possible to write a standalone scanner. You can read the details on this page. If you specify
%standalone
directive, it will addmain
method to the generated class. You can mention input files as command line arguments to run this program. jflex tar comes with an examples directory you can find one standalone example insideexamples/standalone-maven/src/main/jflex
directory. For quick reference I am posting one example code here