0

Can anyone help me with this problem. I need to traverse an Abstract Syntax Tree to replace all the Children's Text in C#

Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
hienvd
  • 346
  • 1
  • 5
  • 17

1 Answers1

1

I would say the CommonTree.Text property is provided for that purpose, but as you can see the method literally does nothing. The CommonTreeAdaptor.SetText method (inherited from BaseTreeAdaptor at least throws a NotSupportedException.

What you need to do is get the IToken associated with the tree node, probably by calling CommonTreeAdaptor.GetToken. You can then set the IToken.Text property of the token, which at least for CommonToken is implemented.

Sam Harwell
  • 97,721
  • 20
  • 209
  • 280