1

I'm using VS2010 Exp. C# XP SP3 environment

My current issue is with SerializedVersion value

Run-Time ERROR: System.TypeInitializationException: 
The type initializer for 'Antlr4.Runtime.Verilog2001Lexer' threw an exception. ---> System.NotSupportedException: Could not deserialize ATN with version 5 (expected 3).

I found the root cause but I don’t know a work around so I’m stuck

ATNSimulator.cs:

public abstract class ATNSimulator
{
    public static readonly int SerializedVersion = 3;
       …………………

    public static ATN Deserialize(char[] data, bool optimize)
    {
        data = (char[])data.Clone();
        // don't adjust the first value since that's the version number
        for (int i = 1; i < data.Length; i++)
        {
            data[i] = (char)(data[i] - 2);
        }
        int p = 0;
        int version = ToInt(data[p++]);
        if (version != SerializedVersion)      <<<<<< mismatch 5 vs. 3
        {

But in the generated lexer

  {     public static readonly string _serializedATN =
              "\x5\x4\xB5\x638\b\x1\x4\x2\t\x2\x4\x3\t\x3\x4\x4\t\x4\x4\x5\t\x5\x4\x6"+ }

Any comment is appreciated Thanks

4

1 回答 1

0

这种情况意味着您使用旧版本的 C# 目标生成词法分析器,但正在使用新版本运行代码。如果您最近更新了项目中的库,则 Clean+Build 将使用正确的目标重新生成语法。

如果您按照这些说明进行操作,请从 NuGet 重新安装 antlr4 加载项。

https://github.com/sharwell/antlr4cs

于 2014-10-06T07:28:17.570 回答