I'm trying to create my first antlr4 grammar for C# and I'm getting the following exception:
System.NotSupportedException: Could not deserialize ATN with UUID aadb8d7e-aeef-4415-ad2b-8204d6cf042e (expected ab35191a-1603-487e-b75a-479b831eaf6d or a legacy UUID). at Antlr4.Runtime.Atn.ATNDeserializer.Deserialize(Char[] data)
My grammar is fairly simple just recognizing numbers and identifiers from the expression string. I have only lexer grammar because I want to get tokens (number and words) from text, without some AST. It fails immediately on init:
lexer = new MyLexer(new AntlrInputStream("3"));
// fails in this line in constructor: Interpreter = new LexerATNSimulator(this,_ATN);
I'm not using Antlr language support for VS because I'm using dotnet core where I have .xproj instead of .csproj so I'm not sure is it supported. However, I think that this doesn't make a difference since I'm using command line:
java -jar antlr-4.5.3-complete.jar -Dlanguage=CSharp MyLexer.g4
I have added 4.5.3 nuget package and I can see in project.json that the version is the same as version of jar:
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Antlr4": "4.5.3"
}
...
}
I have also tried with pre-release but I'm getting the same error.
I have found the similar issue in java version: Initialising my Lexer throws an error in Antlr4 However, it cannot help in my C# case because there was a problem with mismatched versions of ANTLR and here I'm using 4.5.3 to generate both .cs file and in the runtime.