Add() public method

public Add ( int symbol, object particle ) : int
symbol int
particle object
return int
Ejemplo n.º 1
0
        public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions)
        {
            SyntaxTreeNode node = null;

            foreach (int num in this.GetResolvedSymbols(symbols))
            {
                if (symbols.GetParticle(num) != this.particle)
                {
                    symbols.IsUpaEnforced = false;
                }
                LeafNode node2 = new LeafNode(positions.Add(num, this.particle));
                if (node == null)
                {
                    node = node2;
                }
                else
                {
                    InteriorNode node3 = new ChoiceNode {
                        LeftChild  = node,
                        RightChild = node2
                    };
                    node = node3;
                }
            }
            if (parent.LeftChild == this)
            {
                parent.LeftChild = node;
            }
            else
            {
                parent.RightChild = node;
            }
        }
 public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions)
 {
     SyntaxTreeNode node = null;
     foreach (int num in this.GetResolvedSymbols(symbols))
     {
         if (symbols.GetParticle(num) != this.particle)
         {
             symbols.IsUpaEnforced = false;
         }
         LeafNode node2 = new LeafNode(positions.Add(num, this.particle));
         if (node == null)
         {
             node = node2;
         }
         else
         {
             InteriorNode node3 = new ChoiceNode {
                 LeftChild = node,
                 RightChild = node2
             };
             node = node3;
         }
     }
     if (parent.LeftChild == this)
     {
         parent.LeftChild = node;
     }
     else
     {
         parent.RightChild = node;
     }
 }
Ejemplo n.º 3
0
 public override SyntaxTreeNode Clone(Positions positions)
 {
     return(new LeafNode(positions.Add(positions[this.pos].symbol, positions[this.pos].particle)));
 }
 public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) {
     SyntaxTreeNode replacementNode = null;
     foreach(int symbol in GetResolvedSymbols(symbols)) {
         if (symbols.GetParticle(symbol) != particle) {
             symbols.IsUpaEnforced = false;
         }
         LeafNode node = new LeafNode(positions.Add(symbol, particle));
         if (replacementNode == null) {
             replacementNode = node;
         }
         else {
             InteriorNode choice = new ChoiceNode();
             choice.LeftChild = replacementNode;
             choice.RightChild = node;
             replacementNode = choice;
         }
     }
     if (parent.LeftChild == this) {
         parent.LeftChild = replacementNode;
     }
     else {
         parent.RightChild = replacementNode;
     }
 }
 public override SyntaxTreeNode Clone(Positions positions) {
     return new LeafNode(positions.Add(positions[pos].symbol, positions[pos].particle));
 }