3

I'm using the grammar on the Antlr github page: https://github.com/antlr/grammars-v4/tree/master/scala

But the grammar has a problem based on reading the reported issue on GitHub.

Here is my code:

 InputStream targetStream = new FileInputStream(file);
 System.out.println(targetStream.toString());
 ANTLRInputStream input = new ANTLRInputStream(targetStream);
 ScalaLexer lexer = new ScalaLexer(input);    
 CommonTokenStream tokens = new CommonTokenStream(lexer);
 ...

The error message is:

line 1:0 no viable alternative at input 'object HelloWorld {'

I searched the issue, several other people also found the problem. It is hard to understand why such a state-of-the-art tool has such an obvious issue, but the issue is there. I'm not an export of parsing and just need a working scala parser in Java. Are there any other grammar I can use for scala? Or are there any other scala parser written in Java?

Ryan
  • 2,825
  • 9
  • 36
  • 58
  • 5
    The grammars posted there are user contributions. They are not part of ANTLR. – Bart Kiers Jun 12 '17 at 05:53
  • 1
    Welcome to open source. If it doesn't work, its your problem to fix it. – Ira Baxter Apr 24 '21 at 14:07
  • This is a pronouncement that you found an error in community contributed code, then a request for another off-site resource. Off-topic. Fix it yourself, or find your own alternative, but this is not topical question. – TomServo Apr 24 '21 at 23:10

0 Answers0