/// <summary> /// Recursive DFS from bottom to top (children to parents). /// (takes each parent in depth) /// </summary> internal IEnumerable <SymbolT> LookupRec(SymbolContext <SymbolT, CtxKey> ctx, String symbName) { var t = ctx.LookupAll(symbName); if (t != null) { return(t); } foreach (var p in ctx.parents) { if ((t = LookupRec(p, symbName)) != null) { return(t); } } return(null); }
IEnumerable <SymbolT> LookupRec(SymbolContext <SymbolT, CtxKey> ctx, String symbName, CtxKey key) { IEnumerable <SymbolT> t; if (ReferenceEquals(ctx.Key, key)) { if ((t = ctx.LookupAll(symbName)) != null) { return(t); } } foreach (var p in ctx.parents) { if ((t = LookupRec(p, symbName)) != null) { return(t); } } return(null); }