首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Antlr4目标C#误差

Antlr4目标C#误差
EN

Stack Overflow用户
提问于 2013-10-10 21:18:23
回答 2查看 919关注 0票数 0

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

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-10-11 01:17:32

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

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

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

代码语言:javascript
复制
@members {
    public const int EOF = Eof;
    public const int HIDDEN = Hidden;
}

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

票数 1
EN

Stack Overflow用户

发布于 2014-03-27 13:48:51

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

代码语言:javascript
复制
namespace Antlr4.Runtime
{
    public static class AntlrCsCompatability
    {
        public static int LA(this ICharStream self, int i)
        {
            return self.La(i: i);
        }
    }
}

对于Lexer来说,情况也是如此:

代码语言:javascript
复制
namespace GeneratedCode.ANTLR4
{
    public partial class STLexer
    {
        public const int EOF = Eof;
        public const int HIDDEN = Hidden;
    }

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19306401

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档