Search code examples
c#antlrantlr4

TokenStream doesn't exist in ANTLR parser C# implementation


I'm currently following the "Building a Translator with a Listener" tutorial of "The Definitive ANTLR 4 Reference", but I'm using C# and translate the examples into that.

However, I got stuck at a variable declaration of the type "TokenStream" which I seem to be missing in C# (I can't find it anywhere). The tutorials Java code says

TokenStream tokens = parser.getTokenStream();

Beyond the missing TokenStream type in C#, I can't even find an equivalent method of the Parser class. How is this done with the C# implementation of ANTLR?


Solution

  • Probably ITokenStream.

    AFAIK, the ANTLR4 Java and C# runtime libraries are pretty much the same except that C#'s interfaces have an I in front of them, and the C# runtime (obviously) follows the C# naming conventions (method names start with an upper case, etc.).