// ***************************************************************************** // IMatchable implementation // ***************************************************************************** public override IMatchable FindObject(MatchNode matchNode, int index) { if (matchNode.GetType() != MatchNode.Matchnode_Exprent) { return(null); } List <Exprent> lstAllExprents = GetAllExprents(); if (lstAllExprents == null || (lstAllExprents.Count == 0)) { return(null); } string position = (string)matchNode.GetRuleValue(IMatchable.MatchProperties.Exprent_Position ); if (position != null) { if (position.Matches("-?\\d+")) { return(lstAllExprents[(lstAllExprents.Count + System.Convert.ToInt32(position)) % lstAllExprents.Count]); } } else if (index < lstAllExprents.Count) { // care for negative positions // use 'index' parameter return(lstAllExprents[index]); } return(null); }
public override bool Match(MatchNode matchNode, MatchEngine engine) { if (matchNode.GetType() != MatchNode.Matchnode_Statement) { return(false); } foreach (KeyValuePair <IMatchable.MatchProperties, MatchNode.RuleValue> rule in matchNode .GetRules()) { switch (rule.Key.ordinal()) { case 0: { if (this.type != (int)rule.Value.value) { return(false); } break; } case 2: { if (this.stats.Count != (int)rule.Value.value) { return(false); } break; } case 3: { int exprsize = (int)rule.Value.value; if (exprsize == -1) { if (this.exprents != null) { return(false); } } else if (this.exprents == null || this.exprents.Count != exprsize) { return(false); } break; } case 1: { if (!engine.CheckAndSetVariableValue((string)rule.Value.value, this)) { return(false); } break; } } } return(true); }
// ***************************************************************************** // IMatchable implementation // ***************************************************************************** public override IMatchable FindObject(MatchNode matchNode, int index) { int node_type = matchNode.GetType(); if (node_type == MatchNode.Matchnode_Statement && !(this.stats.Count == 0)) { string position = (string)matchNode.GetRuleValue(IMatchable.MatchProperties.Statement_Position ); if (position != null) { if (position.Matches("-?\\d+")) { return(this.stats[(this.stats.Count + System.Convert.ToInt32(position)) % this.stats .Count]); } } else if (index < this.stats.Count) { // care for negative positions // use 'index' parameter return(this.stats[index]); } } else if (node_type == MatchNode.Matchnode_Exprent && this.exprents != null && !(this .exprents.Count == 0)) { string position = (string)matchNode.GetRuleValue(IMatchable.MatchProperties.Exprent_Position ); if (position != null) { if (position.Matches("-?\\d+")) { return(this.exprents[(this.exprents.Count + System.Convert.ToInt32(position)) % this .exprents.Count]); } } else if (index < this.exprents.Count) { // care for negative positions // use 'index' parameter return(this.exprents[index]); } } return(null); }
// ***************************************************************************** // IMatchable implementation // ***************************************************************************** public override IMatchable FindObject(MatchNode matchNode, int index) { IMatchable @object = base.FindObject(matchNode, index); if (@object != null) { return(@object); } if (matchNode.GetType() == MatchNode.Matchnode_Exprent) { string position = (string)matchNode.GetRuleValue(IMatchable.MatchProperties.Exprent_Position ); if ("head".Equals(position)) { return(GetHeadexprent()); } } return(null); }
public override bool Match(MatchNode matchNode, MatchEngine engine) { if (matchNode.GetType() != MatchNode.Matchnode_Exprent) { return(false); } foreach (KeyValuePair <IMatchable.MatchProperties, MatchNode.RuleValue> rule in matchNode .GetRules()) { IMatchable.MatchProperties key = rule.Key; if (key == IMatchable.MatchProperties.Exprent_Type && this.type != (int)rule.Value .value) { return(false); } if (key == IMatchable.MatchProperties.Exprent_Ret && !engine.CheckAndSetVariableValue ((string)rule.Value.value, this)) { return(false); } } return(true); }