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 FindTreeWizardContextVisitor( TreeWizard outer, TreeWizard.TreePattern tpattern, IList subtrees) { this._outer = outer; this._tpattern = tpattern; this._subtrees = subtrees; }
public VisitTreeWizardContextVisitor( TreeWizard outer, TreeWizard.IContextVisitor visitor, IDictionary <string, object> labels, TreeWizard.TreePattern tpattern) { this._outer = outer; this._visitor = visitor; this._labels = labels; this._tpattern = tpattern; }
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); }
public bool Parse(object t, string pattern, IDictionary <string, object> labels) { TreeWizard.TreePattern tpattern = (TreeWizard.TreePattern) new TreePatternParser(new TreePatternLexer(pattern), this, (ITreeAdaptor) new TreeWizard.TreePatternTreeAdaptor()).Pattern(); return(this.ParseCore(t, tpattern, labels)); }
public VisitTreeWizardContextVisitor(TreeWizard outer, TreeWizard.IContextVisitor visitor, IDictionary<string, object> labels, TreeWizard.TreePattern tpattern) { this._outer = outer; this._visitor = visitor; this._labels = labels; this._tpattern = tpattern; }
public FindTreeWizardContextVisitor(TreeWizard outer, TreeWizard.TreePattern tpattern, IList subtrees) { this._outer = outer; this._tpattern = tpattern; this._subtrees = subtrees; }
public virtual object ParseNode() { string str1 = (string)null; if (this.ttype == 5) { this.ttype = this.tokenizer.NextToken(); if (this.ttype != 3) { return((object)null); } str1 = this.tokenizer.sval.ToString(); this.ttype = this.tokenizer.NextToken(); if (this.ttype != 6) { return((object)null); } this.ttype = this.tokenizer.NextToken(); } if (this.ttype == 7) { this.ttype = this.tokenizer.NextToken(); TreeWizard.TreePattern treePattern = (TreeWizard.TreePattern) new TreeWizard.WildcardTreePattern((IToken) new CommonToken(0, ".")); if (str1 != null) { treePattern.label = str1; } return((object)treePattern); } if (this.ttype != 3) { return((object)null); } string tokenName = this.tokenizer.sval.ToString(); this.ttype = this.tokenizer.NextToken(); if (tokenName.Equals("nil")) { return(this.adaptor.Nil()); } string text = tokenName; string str2 = (string)null; if (this.ttype == 4) { str2 = this.tokenizer.sval.ToString(); text = str2; this.ttype = this.tokenizer.NextToken(); } int tokenType = this.wizard.GetTokenType(tokenName); if (tokenType == 0) { return((object)null); } object obj = this.adaptor.Create(tokenType, text); if (str1 != null && obj.GetType() == typeof(TreeWizard.TreePattern)) { ((TreeWizard.TreePattern)obj).label = str1; } if (str2 != null && obj.GetType() == typeof(TreeWizard.TreePattern)) { ((TreeWizard.TreePattern)obj).hasTextArg = true; } return(obj); }