I have a set S of "small" trees S[i] , which I need to find for larger ones , which are used as templates for finding matching subtrees in a larger tree T I know S before starting to create T (which is a parsing tree), so I’m thinking about using the secant plane method to match nodes along the way (since the parser generates CST).
The trees in S are not the same AST as T - think about XPath and XML - S stores the XPaths tree view, while T is the actual AST of the source code - I need maps between i and the vector of matching T nodes.
However, I'm not sure about the names of the algorithms that I would use.
Basically, I know what I want to do, it feels like “divide et impera for trees” with a stack where I hold possible candidates to match, each time I change the LALR analyzer I duplicate the top of the stack and remove the candidates i from S[i] which will not match, and after cutting I exit the stack. In the beginning, all participants from S are potential candidates.
Please note: this is just about AST, ASG is another story ...
Adding
There will be a parsing tree T

The parsing function will know a list of what I call "treepaths", in canonical form, also represented as trees stored in S But they will not look like parsetree, they have their own language in which they will be presented, similar to XPath.
An example of a tree-like path for obtaining all functions that have a variable as the return value:
function[body[return[expr[@type="variable"]]]]]
- So what should I look for in existing literature?
- Any other tips?
- Are there languages that meta-annotated trees can query for? The original C library (not C ++) would be ideal.