0

我已经将我的 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
4

2 回答 2

1

这与其他一些相关问题一起在以下最近的一系列提交中得到修复:

https://github.com/sharwell/antlr4cs/compare/2ac3c964...c0aa59cb

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

@members {
    public const int EOF = Eof;
    public const int HIDDEN = Hidden;
}

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

于 2013-10-11T01:17:32.973 回答
0

对于“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;
    }

}
于 2014-03-27T13:48:51.200 回答