Im writing a small lexical analyzer which needs to write some outputs to a file. Once Im done scanning im creating an output file
PrintWriter writer = new PrintWriter(args[0].substring(0,4)+"output.txt");
So essentially im trying to use the prefix of my input file as the prefix of my output. This statement is located in %eof{ %eof}
error: cannot find symbol
PrintWriter writer = new PrintWriter(args[0].substring(0,4)+"output.txt");
^
symbol: variable args
location: class classname
However I cannot see args from the eof section. How could I access the command line arguments from eof
in jflex?
The issues was with the %standalone
option. It was generating a main method automatically putting the argv list out of scope.
Removing this option and defining my own main method did the trick, though I did also have to define my own file reader and error handling this way