Antlr4目标C#错误

Antlr4目标C#错误,c#,antlr4,C#,Antlr4,我已经将我的C#项目设置为使用Antlr4构建目标和扩展来编译g4语法。然而,当我构建时,我得到了以下错误。有什么想法吗 Error 1 The name 'HIDDEN' does not exist in the current context C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs 131 22 oracle Error 2 The name 'HIDDEN'

我已经将我的C#项目设置为使用Antlr4构建目标和扩展来编译g4语法。然而,当我构建时,我得到了以下错误。有什么想法吗

Error   1   The name 'HIDDEN' does not exist in the current context C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs   131 22  oracle
Error   2   The name 'HIDDEN' does not exist in the current context C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs   136 22  oracle
Error   4   The name 'HIDDEN' does not exist in the current context C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs   145 22  oracle
Error   5   'Antlr4.Runtime.ICharStream' does not contain a definition for 'LA' and no extension method 'LA' accepting a first argument of type 'Antlr4.Runtime.ICharStream' could be found (are you missing a using directive or an assembly reference?)   C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs   156 25  oracle
Error   6   'Antlr4.Runtime.ICharStream' does not contain a definition for 'LA' and no extension method 'LA' accepting a first argument of type 'Antlr4.Runtime.ICharStream' could be found (are you missing a using directive or an assembly reference?)   C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs   156 44  oracle
Error   7   'Antlr4.Runtime.ICharStream' does not contain a definition for 'LA' and no extension method 'LA' accepting a first argument of type 'Antlr4.Runtime.ICharStream' could be found (are you missing a using directive or an assembly reference?)   C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs   156 64  oracle
Error   8   'Antlr4.Runtime.ICharStream' does not contain a definition for 'LA' and no extension method 'LA' accepting a first argument of type 'Antlr4.Runtime.ICharStream' could be found (are you missing a using directive or an assembly reference?)   C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Lexer.cs   156 84  oracle
Error   9   The name 'EOF' does not exist in the current context    C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Parser.cs  920 23  oracle
Error   10  'oracle.Verilog2001Parser' does not contain a definition for 'EOF'  C:\gNOSIS\Oracle\Software\oracle\oracle\obj\x64\Debug\Verilog2001Parser.cs  875 66  oracle

这一问题以及其他一些相关问题在最近的一系列提交中得到了解决:

这些更改将包含在下一版本中。在此之前,您可以在lexer语法中使用以下内容(对于组合语法,请使用
@lexer::members
):


错误5-8与语法中的语义谓词有关。在C#target中,前瞻方法是
La
,而不是
La

对于“La”/“La”部分,您可以添加一些扩展方法来修复它:

namespace Antlr4.Runtime
{
    public static class AntlrCsCompatability
    {
        public static int LA(this ICharStream self, int i)
        {
            return self.La(i: i);
        }
    }
}
对于Lexer来说也是如此:

namespace GeneratedCode.ANTLR4
{
    public partial class STLexer
    {
        public const int EOF = Eof;
        public const int HIDDEN = Hidden;
    }

}

到目前为止你得到了什么?完全不知道,你怎么解释?请原谅我的无知,我是Antlr的新手。我是否要将@members{}语句添加到Verilog2001.g4语法文件中以更正该问题?谢谢。因为这将是一个组合语法(在同一个文件中包含解析器和lexer规则),所以您需要使用@lexer::members{}语法,但是是的,这就是我所指的文件。
namespace GeneratedCode.ANTLR4
{
    public partial class STLexer
    {
        public const int EOF = Eof;
        public const int HIDDEN = Hidden;
    }

}