Search code examples
javacc

In jjtree, is there a way to traverse the generated parse tree and track changes to the value


I'm new to JJTree parsing. I've gone through basics. In jjtree, is there a way to traverse the generated parse tree and track changes to the value?

Say for example I've a JJTree which produces the following tree structure:

<parent name="xx">
 <child age="21" family="true">
 </child>
<parent>
<parent name="xy">
 <child age="21" family="true">
 </child>
<parent>

Here, i'd like to change the family as "false" for parent having name "xy". I'm struggling in this part.

My code needs a similar change. As my code increases complexity to understand, I've given here a sample which is understandable.


Solution

  • To traverse the tree, you can use a visitor object. See the documentation.