Hello all,

I'm trying to traverse and process the algebra expression tree for a
SPARQL query. For this purpose, I have created a class that implements
OpVisitor and visits the entire tree in a top-down fashion. Ideally, I
would like to be able to pass information from a visited operator to
its children and vice versa, but I'm not sure how I can do this in an
elegant way (using just some global class variables does not seem
sufficient).

I guess a naive way to deal with it would be to start from the top of
the tree, visit every Op, transform it to a custom extension of the
respective Op that will maybe hold a link to the parent (already
transformed) Op and store the information that will get passed to its
children. At the same time, every such transformed Op will be inserted
into a Stack and, after the top-down traversal is done, popped out in
reverse order in order to go back up the tree and pass information
from children Ops to parent Ops.

Is there another more straightforward procedure to accomplish this?

Sorry for sounding completely abstract, I hope I'm making (some)
sense, any ideas/hints/pointers to examples would be very much
appreciated!

Dimitris

Reply via email to