Example #1
0
 public void AddSequence(Member mem, TypeNode type) {
   ContentNode n = (ContentNode)stack.Pop();
   InternalNode inNode = new SequenceNode(mem, type);
   inNode.LeftChild = n;
   n.Parent = inNode;
   stack.Push(inNode);
 }
Example #2
0
 public bool CloseGroup() {
   ContentNode node = (ContentNode)stack.Pop();
   if (node == null) {
     return false;
   }
   if (stack.Count == 0) {
     contentNode = node;
     isPartial = false;
   }
   else {
     if (stack.Peek() == null) {
       stack.Pop();
       contentNode = node;
       isPartial = false;
     } else {
       isPartial = true;
       // we are extending an existing content model (probably via subclassing,
       // so we simply add the node to the existing model as a new child particle).
       ContentNode parentModel = (ContentNode)stack.Pop();
       if (parentModel is InternalNode) {
         InternalNode pc = (InternalNode)parentModel;
         if (pc.RightChild == null) {
           pc.RightChild = node;
           node.Parent = pc;
         } else {
           InternalNode nc = pc.Clone();
           nc.LeftChild = pc;
           nc.RightChild = node;
           node.Parent = pc.Parent = nc;
           pc = nc;
         }            
         node = pc;
       } else {
         SequenceNode nc = new SequenceNode(null, null);
         nc.LeftChild = parentModel;
         nc.RightChild = node;    
         parentModel.Parent = node.Parent = nc;
         node = nc;
       }
     }
     stack.Push(node);
   }
   return true;
 }