Search code examples
parsingcompiler-constructionantlrantlr4

Inconsistent TokenStreamRewriter.InsertBefore() behavior with C "do-while();" statements


I am trying to instrument C code with ANTLR listener mechanism. But I found some inconsistent behavior of the TokenStreamRewriter.InsertBefore() API with the C do-while(); statement.

I have posted a detailed description as ANTLR Issue #2252. So I won't duplicate it here.

Anyone met the same issue?


Solution

  • Issue solved. Turns out my assumption of the behavior of InsertBefore/After() is incorrect. I posted the detailed explanation to the Issue #2252. Hope it can help someone as confused.