Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 Antlr 3 解析某些内容时,我对流中的当前字节位置感兴趣。 我看到有一个类似的问题,但那里没有真正的答案。这就是我再次尝试的原因。 我对令牌索引、一行中的字节位置等不感兴趣…… 有人能告诉我吗?很明显,必须编写/覆盖一些代码。有人要写特定的代码吗?我使用 C#。
如果您的解析器是 parser = new myParser(tokenStream); 然后 bytepos=((CommonToken)parser.TokenStream.LT(1)).StartIndex;