I have the following code which extends ProcessBaseListener:
var myProcessListener = new MyProcessListener();
walker = new ParseTreeWalker();
walker.Walk(myProcessListener , tree);
I've overridden one method:
public override void ExitLineNumberOrLabel(ProcessParser.LineNumberOrLabelContext context)
{
var lineNumberOrLabel = context.GetText().ToUpper();
}
How do I manipulate that context or it's parent context? All the methods are read only.
For example, I may want to modify the lineNumberOrLabel or remove it from its parent context. I may even want to insert a new context of a different type before or after it.
I've tried using TokenStreamRewriter but that doesn't modify the stream. I have to invoke ToString() to see the changes and then possible parse it all over again??? Why can't I just modify the ParserRuleContexts? I used to essentially do this is SableCC.