public void CloseGroup() { SyntaxTreeNode node = (SyntaxTreeNode)this.stack.Pop(); if (node != null) { if (this.stack.Count == 0) { this.contentNode = node; this.isPartial = false; } else { InteriorNode node2 = (InteriorNode)this.stack.Pop(); if (node2 != null) { node2.RightChild = node; node = node2; this.isPartial = true; } else { this.isPartial = false; } this.stack.Push(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; } }
public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) { this.leftChild.ExpandTree(this, symbols, positions); if (this.rightChild != null) { this.rightChild.ExpandTree(this, symbols, positions); } }
public override SyntaxTreeNode Clone(Positions positions) { InteriorNode node = (InteriorNode)base.MemberwiseClone(); node.LeftChild = this.leftChild.Clone(positions); if (this.rightChild != null) { node.RightChild = this.rightChild.Clone(positions); } return(node); }
private void AddLeafNode(SyntaxTreeNode node) { if (this.stack.Count > 0) { InteriorNode node2 = (InteriorNode)this.stack.Pop(); if (node2 != null) { node2.RightChild = node; node = node2; } } this.stack.Push(node); this.isPartial = true; }
private void Closure(InteriorNode node) { if (this.stack.Count > 0) { SyntaxTreeNode node2 = (SyntaxTreeNode)this.stack.Pop(); InteriorNode node3 = node2 as InteriorNode; if (this.isPartial && (node3 != null)) { node.LeftChild = node3.RightChild; node3.RightChild = node; } else { node.LeftChild = node2; node2 = node; } this.stack.Push(node2); } else if (this.contentNode != null) { node.LeftChild = this.contentNode; this.contentNode = node; } }
public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) { }
public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) { Debug.Assert(parent is SequenceNode); Debug.Assert(this == parent.RightChild); //change the range node min to zero if left is nullable if (parent.LeftChild.IsNullable) { min = 0; } }
/// <summary> /// Expand tree will replace a{min, max} using following algorithm. Bare in mind that this sequence will have at least two leaves /// if min == 0 (max cannot be unbounded) /// a?, ... a? /// \__ __/ /// max /// else /// if max == unbounded /// a, ... a, a* /// \__ __/ /// min /// else /// a, ... a, a?, ... a? /// \__ __/ \__ __/ /// min max - min /// </summary> public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) { LeftChild.ExpandTree(this, symbols, positions); SyntaxTreeNode replacementNode = null; if (min == 0) { Debug.Assert(max != int.MaxValue); replacementNode = NewQmark(LeftChild); for (int i = 0; i < max - 1; i ++) { replacementNode = NewSequence(replacementNode, NewQmark(LeftChild.Clone(positions))); } } else { replacementNode = LeftChild; for (int i = 0; i < min - 1; i ++) { replacementNode = NewSequence(replacementNode, LeftChild.Clone(positions)); } if (max == int.MaxValue) { replacementNode = NewSequence(replacementNode, NewStar(LeftChild.Clone(positions))); } else { for (int i = 0; i < max - min; i ++) { replacementNode = NewSequence(replacementNode, NewQmark(LeftChild.Clone(positions))); } } } if (parent.LeftChild == this) { parent.LeftChild = replacementNode; } else { parent.RightChild = replacementNode; } }
public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) { ExpandTreeNoRecursive(parent, symbols, positions); }
//no recursive version of expand tree for Sequence and Choice node protected void ExpandTreeNoRecursive(InteriorNode parent, SymbolsDictionary symbols, Positions positions) { Stack<InteriorNode> nodeStack = new Stack<InteriorNode>(); InteriorNode this_ = this; while (true) { if (this_.leftChild is ChoiceNode || this_.leftChild is SequenceNode) { nodeStack.Push(this_); this_ = (InteriorNode)this_.leftChild; continue; } this_.leftChild.ExpandTree(this_, symbols, positions); ProcessRight: if (this_.rightChild != null) { this_.rightChild.ExpandTree(this_, symbols, positions); } if (nodeStack.Count == 0) break; this_ = nodeStack.Pop(); goto ProcessRight; } }
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 void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) { // do nothing }
/// <summary> /// Expand NamesapceListNode and RangeNode nodes. All other nodes /// </summary> public abstract void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions);
private void Closure(InteriorNode node) { if (stack.Count > 0) { SyntaxTreeNode topNode = (SyntaxTreeNode)stack.Pop(); InteriorNode inNode = topNode as InteriorNode; if (isPartial && inNode != null) { // need to reach in and wrap right hand side of element. // and n remains the same. node.LeftChild = inNode.RightChild; inNode.RightChild = node; } else { // wrap terminal or any node node.LeftChild = topNode; topNode = node; } stack.Push(topNode); } else if (contentNode != null) { //If there is content to wrap // wrap whole content node.LeftChild = contentNode; contentNode = node; } }
private void Closure(InteriorNode node) { if (this.stack.Count > 0) { SyntaxTreeNode node2 = (SyntaxTreeNode) this.stack.Pop(); InteriorNode node3 = node2 as InteriorNode; if (this.isPartial && (node3 != null)) { node.LeftChild = node3.RightChild; node3.RightChild = node; } else { node.LeftChild = node2; node2 = node; } this.stack.Push(node2); } else if (this.contentNode != null) { node.LeftChild = this.contentNode; this.contentNode = node; } }
public abstract void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions);