Skip to content

Antlr 4.13.2 generating incorrect c# code #4701

Answered by kaby76
RossFaneuf asked this question in Q&A
Discussion options

You must be logged in to vote

We need a minimal reproducible example. I.e., the .g4 grammar, driver, and most importantly the .csproj. But, I suspect that you are using the wrong "Antlr4"!

TokenStream.LT(1) is correct. Parser.TokenStream is the property that accesses the private backing field _input. It is LT(int):

IToken LT(int k);
There is no Lt(int) in file ITokenStream.cs.

It sounds like you are using the old Antlr4cs fork and all its associated packages: Antlr4, Antlr4.Runtime, Antlr4.CodeGenerator. These packages are ancient, and completely incompatible with "official Antlr4".

Instead, use Antlr4.Runtime.Standard and my build package A…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@RossFaneuf
Comment options

Answer selected by RossFaneuf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants