Tuesday, April 5, 2011

How to get current byte position of the parser in Antlr with c# target?

Hi,

I am interested in the current byte position in the stream when parsing something using Antlr 3.
I have seen there is a similar question but there was no real answer there. That is why I am trying again.
I am not interested in token index, byte position in a line etc...
Could you someone tell me that? It is obvious that some code has to be written/overridden. Does someone have specific code to write? I use C#.

From stackoverflow
  • if your parser is parser = new myParser(tokenStream); then
    bytepos=((CommonToken)parser.TokenStream.LT(1)).StartIndex;

0 comments:

Post a Comment