예제 #1
0
 /// <summary>
 /// Called when [variable substituter] is visited.
 /// </summary>
 /// <param name="substituter">The substituter.</param>
 public override void OnVariableSubstituter(VariableSubstituter substituter)
 {
     _sb.AppendLine(substituter.ToString());
 }
예제 #2
0
 /// <summary>
 /// Called when [variable substituter] is visited.
 /// </summary>
 /// <param name="substituter">The substituter.</param>
 public virtual void OnVariableSubstituter(VariableSubstituter substituter)
 {
 }
예제 #3
0
        /// <summary>
        /// Build_builtin_nodes the specified parent.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="c">The c.</param>
        /// <param name="earlier_conds">The earlier_conds.</param>
        /// <returns></returns>
        private BuiltinMemory build_builtin_node(ReteNode parent, Condition c, IList<LeftHandSideCondition> earlier_conds)
        {
            BuiltinMemory new_node = new BuiltinMemory(c.ToString());
            new_node.Type = ReteNodeType.Builtin;
            new_node.Parent = parent;

            parent.Children.AddToFront(new_node);

            new_node.Builtin = ((FuncTerm) c.Attribute).Builtin;

            int cntOfEarlierConditions = earlier_conds.Count - 1;

            if (c.Id.TermType == TermType.Variable)
            {
                for (int i = cntOfEarlierConditions; i >= 0; i--)
                {
                    Condition earlier_cond = earlier_conds[i];
                    if (earlier_cond.ConditionType == ConditionType.Positive)
                    {
                        for (int f2 = 0; f2 < 3; f2++)
                        {
                            Variable o = earlier_cond.Fields[f2] as Variable;
                            if (o != null && o.Equals(c.Id))
                            {
                                VariableSubstituter vs = new VariableSubstituter();
                                vs.FieldNumber = f2;
                                vs.NumberOfLevelsUp = (cntOfEarlierConditions - i);
                                vs.BindingPair.Variable = o;
                                new_node.LeftArgument = vs;
                                f2 = 3;
                                i = -1; //escape loop of cntOfEarlierConditions
                            }
                        }
                    }
                }
            }
            else
            {
                new_node.LeftArgument = new ConstantSubstitutor(c.Id);
            }

            if (c.Value.TermType == TermType.Variable)
            {
                for (int i = cntOfEarlierConditions; i >= 0; i--)
                {
                    Condition earlier_cond = earlier_conds[i];
                    if (earlier_cond.ConditionType == ConditionType.Positive)
                    {
                        for (int f2 = 0; f2 < 3; f2++)
                        {
                            Variable o = earlier_cond.Fields[f2] as Variable;
                            if (o != null && o.Equals(c.Value))
                            {
                                VariableSubstituter vs = new VariableSubstituter();
                                vs.FieldNumber = f2;
                                vs.NumberOfLevelsUp = (cntOfEarlierConditions - i);
                                vs.BindingPair.Variable = o;
                                new_node.RightArgument = vs;
                                f2 = 3;
                                i = -1; //escape loop of cntOfEarlierConditions
                            }
                        }
                    }
                }
            }
            else
            {
                new_node.RightArgument = new ConstantSubstitutor(c.Value);
            }

            update_new_node_with_matches_from_above(new_node);
            return new_node;
        }