[英]Accessing command line arguments from eof with JFLEX
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");
一旦完成扫描,即创建输出文件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}
该语句位于%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. 但是我从eof部分看不到args。 How could I access the command line arguments from eof
in jflex? 如何在jflex中从eof
访问命令行参数?
The issues was with the %standalone
option. 问题出在%standalone
选项。 It was generating a main method automatically putting the argv list out of scope. 它正在生成一种自动将argv列表移出范围的主要方法。
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 删除此选项并定义自己的main方法可以解决问题,尽管我也必须定义自己的文件读取器和错误处理方式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.