Simple recursion example

Figure 1. Simple example showing recursion
The figure shows the use of recursion to process an example structure, as explained in the text above.
Consider the following simplified version of the hierarchy as given in Figure 1. The step references refer to steps in the list in the section Recursion.
  1. Start with pattern P1. Call its associated builder (step 3). This creates node N1.
  2. All the patterns below P1 are processed, the first of which is P2.
  3. Call DFHTBSBP passing P2, N1, BUILDER parameters, and others:
    1. Using the passed pattern (now P2), call the builder. This creates node N2.
    2. Process all patterns below P2; there are no subpatterns, so steps 6 through 9 6 are not performed.
    3. Call the CONNECT entry of the builder, passing higher node N1 and the node just created, N2. This makes N1 point to N2.
    4. Return to caller.
  4. Get the next pattern, P3.
  5. Call DFHTBSBP passing P3, N1, BUILDER parameters, and others:
    1. Using the passed pattern (now P3), call the builder. This creates node N3.
    2. Process all patterns below P3; there are no subpatterns, so steps 6 through 9 6 are not performed.
    3. Call the CONNECT entry of the builder passing in higher node N1 and the node just created N3. This makes N1 point to N3.
    4. Return to caller.
  6. Last pattern processed (step 10).
  7. Call the builder associated with P1 to connect node N1 to HIGHERNODE. (This is zero because there is no higher node. Usually, a main builder’s CONNECT function either does nothing or adds the TCTTE name and address into the table management tables.)