Reputation: 379
I have setup my C# project to use the Antlr4 build targets and extension for compiling the g4 grammer. However, when I build I am getting the following errors. Any thoughts?
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
Upvotes: 1
Views: 976
Reputation: 5205
For the "La" / "LA" part you can add some extension methods to fix it:
namespace Antlr4.Runtime
{
public static class AntlrCsCompatability
{
public static int LA(this ICharStream self, int i)
{
return self.La(i: i);
}
}
}
Same holds true for the Lexer:
namespace GeneratedCode.ANTLR4
{
public partial class STLexer
{
public const int EOF = Eof;
public const int HIDDEN = Hidden;
}
}
Upvotes: -1
Reputation: 99859
This, along with a few other related issues, was fixed in the following recent series of commits:
https://github.com/sharwell/antlr4cs/compare/2ac3c964...c0aa59cb
These changes will be included in the next release. Until then you can use the following in your lexer grammar (for combined grammars use @lexer::members
):
@members {
public const int EOF = Eof;
public const int HIDDEN = Hidden;
}
Errors 5-8 are related to semantic predicates in your grammar. In the C# target, the lookahead method is La
, not LA
.
Upvotes: 2