ANTLRInputStream 和 ANTLRFileStream 已弃用,有哪些替代方案? [英] ANTLRInputStream and ANTLRFileStream are deprecated, what are the alternatives?

查看:71
本文介绍了ANTLRInputStream 和 ANTLRFileStream 已弃用,有哪些替代方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用

ANTLRFileStream antlrFileStream = new ANTLRFileStream("myfile.testlang");

ANTLRInputStream input = new ANTLRInputStream( new FileInputStream("myfile.testlang") );

编译器显示两个类的弃用错误有什么替代方法?

Compiler shows deprecation error for both the classes what is alternative?

推荐答案

您可以使用 CharStreams 类代替下面的弃用类.

You can use the CharStreams class instead of the deprecated classes as below.

CharStream codePointCharStream = CharStreams.fromFileName("myfile.testlang");
TESTLANGLexer lexer = new TESTLANGLexer(codePointCharStream);
TESTLANGParser parser = new TESTLANGParser(new CommonTokenStream(lexer));
parser.addParseListener(new TESTLANGEventListener());

// Start parsing
parser.testlangFile(); 

这篇关于ANTLRInputStream 和 ANTLRFileStream 已弃用,有哪些替代方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆