Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ANTLRInputStream and ANTLRFileStream are deprecated, what are the alternatives?

Tags:

antlr

antlr4

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?

like image 511
Ameer Tamboli Avatar asked May 26 '18 09:05

Ameer Tamboli


1 Answers

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(); 
like image 182
Ameer Tamboli Avatar answered Nov 19 '22 04:11

Ameer Tamboli