ANTLRFileStream 已弃用,我可以使用什么来代替?
我正在尝试编译一个测试类来测试一个简单的语法。
import org.antlr.v4.runtime.*;
public class Test {
public static void main(String[] args) throws Exception
{
CharStream input = null;
// pick an input stream (filename from commandline or stdin)
if(args.length > 0) input = new ANTLRFileStream(args[0]);
else input = new ANTLRInputStream(System.in);
// create the lexer
DrinkLexer lex = new DrinkLexer(input);
// create a buffer of tokens between the lexer and parser
CommonTokenStream tokens = new CommonTokenStream(lex);
// create the parser, attaching it to the token buffer
DrinkParser p = new DrinkParser(tokens);
p.drinkSentence(); // launch parser at drinkSentence file
}
}
我将如何替换已弃用的类?
I am trying to compile a test class to test a simple grammer.
import org.antlr.v4.runtime.*;
public class Test {
public static void main(String[] args) throws Exception
{
CharStream input = null;
// pick an input stream (filename from commandline or stdin)
if(args.length > 0) input = new ANTLRFileStream(args[0]);
else input = new ANTLRInputStream(System.in);
// create the lexer
DrinkLexer lex = new DrinkLexer(input);
// create a buffer of tokens between the lexer and parser
CommonTokenStream tokens = new CommonTokenStream(lex);
// create the parser, attaching it to the token buffer
DrinkParser p = new DrinkParser(tokens);
p.drinkSentence(); // launch parser at drinkSentence file
}
}
How would I go about replacing the deprecated class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
charstreams
的各种静态方法:Use the various static methods from
CharStreams
: