2013-10-10 54 views
0

我已經設置了我的C#項目,以使用Antlr4構建目標和擴展來編譯g4語法。但是,當我建立我收到以下錯誤。有什麼想法嗎?Antlr4目標C#錯誤

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 
+0

你有什麼至今?根本不知道,你怎麼解釋它? –

回答

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

+0

請原諒我的無知,我是Antlr的新手。添加@members {}語句到Verilog2001.g4語法文件以糾正問題嗎?謝謝。 –

+0

由於這將是一個組合語法(在同一個文件中包含解析器和詞法分析器規則),您需要使用@lexer :: members {}語法,但是,這是我所指的文件。 –

0

對於「拉」 /「LA」部分,你可以添加一些擴展方法來解決這個問題:

namespace Antlr4.Runtime 
{ 
    public static class AntlrCsCompatability 
    { 
     public static int LA(this ICharStream self, int i) 
     { 
      return self.La(i: i); 
     } 
    } 
} 

同樣適用於詞法真:

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

}