Skip to content

CSharp and Java produce different results for identical input, identical tokens #3112

@kaby76

Description

@kaby76

Antlr 4.9.1 parsers for grammars-v4/idl/IDL.g4 with the input shown below are producing different results. To be clear, the parsers should produce identical output, but they do not. The list of tokens is identical between Java and CSharp so the lexing is identical. There are no actions/semantic predicates in IDL.g4, and I have removed the custom error listener generated by my program for both targets, so it cannot be attributed to those possible issues. I believe there is a problem in one or the other Antlr4 runtimes.

I also tested this across the other targets. After renaming the parser symbol "exports", which conflicts with certain targets, the parsers produce different results: for Dart and Go, the input is accepted; for JavaScript and Python3, the input is rejected.

The error outputted by the parser is:

line 3:2 mismatched input 'interface' expecting {'@', 'typedef', 'custom', 'struct', 'native', 'eventtype', 'enum', 'home', 'exception', 'const', 'module', 'union', 'abstract', 'typeprefix', 'typeid', 'component', 'bitset', 'bitmask', '@annotation'}

To reproduce, use dotnet-antlr v2.2.0.

module HelloApp
{
  interface Hello
  {
  string sayHello();
  oneway void shutdown();
  };
};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions