protected virtual bool ParseCore( object t1, TreeWizard.TreePattern tpattern, IDictionary <string, object> labels) { if (t1 == null || tpattern == null || tpattern.GetType() != typeof(TreeWizard.WildcardTreePattern) && (this.adaptor.GetType(t1) != tpattern.Type || tpattern.hasTextArg && !this.adaptor.GetText(t1).Equals(tpattern.Text))) { return(false); } if (tpattern.label != null && labels != null) { labels[tpattern.label] = t1; } int childCount1 = this.adaptor.GetChildCount(t1); int childCount2 = tpattern.ChildCount; if (childCount1 != childCount2) { return(false); } for (int i = 0; i < childCount1; ++i) { if (!this.ParseCore(this.adaptor.GetChild(t1, i), (TreeWizard.TreePattern)tpattern.GetChild(i), labels)) { return(false); } } return(true); }
public void Visit(object t, string pattern, TreeWizard.IContextVisitor visitor) { TreeWizard.TreePattern tpattern = (TreeWizard.TreePattern) new TreePatternParser(new TreePatternLexer(pattern), this, (ITreeAdaptor) new TreeWizard.TreePatternTreeAdaptor()).Pattern(); if (tpattern == null || tpattern.IsNil || tpattern.GetType() == typeof(TreeWizard.WildcardTreePattern)) { return; } IDictionary <string, object> labels = (IDictionary <string, object>) new Dictionary <string, object>(); int type = tpattern.Type; this.Visit(t, type, (TreeWizard.IContextVisitor) new TreeWizard.VisitTreeWizardContextVisitor(this, visitor, labels, tpattern)); }
public virtual IList Find(object t, string pattern) { IList subtrees = (IList) new List <object>(); TreeWizard.TreePattern tpattern = (TreeWizard.TreePattern) new TreePatternParser(new TreePatternLexer(pattern), this, (ITreeAdaptor) new TreeWizard.TreePatternTreeAdaptor()).Pattern(); if (tpattern == null || tpattern.IsNil || tpattern.GetType() == typeof(TreeWizard.WildcardTreePattern)) { return((IList)null); } int type = tpattern.Type; this.Visit(t, type, (TreeWizard.IContextVisitor) new TreeWizard.FindTreeWizardContextVisitor(this, tpattern, subtrees)); return(subtrees); }