Great minds think alike

I ended up implementing it almost exactly as you described, but as a set of VArray of RECORDS. (the records for each type of clause element is slightly different, e.g. selects have aliases) In this way I was able to contain all the type creation in the package itself, no external scripts needed.

I was hoping for dynamic arrays within dynamic arrays, oh well.

Thanks