ANTLRInputStream and ANTLRFileStream are deprecate

2019-02-25 20:03发布

If I use

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

or

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

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

标签: antlr antlr4
1条回答
甜甜的少女心
2楼-- · 2019-02-25 20:39

You can use CharStream 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(); 
查看更多
登录 后发表回答