public void AddSequence() { SyntaxTreeNode node = (SyntaxTreeNode)this.stack.Pop(); InteriorNode node2 = new SequenceNode { LeftChild = node }; this.stack.Push(node2); }
public void AddLeafRange(decimal min, decimal max) { LeafRangeNode particle = new LeafRangeNode(min, max); int num = this.positions.Add(-2, particle); particle.Pos = num; InteriorNode node = new SequenceNode { RightChild = particle }; this.Closure(node); this.minMaxNodesCount++; }
private SyntaxTreeNode NewSequence(SyntaxTreeNode leftChild, SyntaxTreeNode rightChild) { InteriorNode sequence = new SequenceNode(); sequence.LeftChild = leftChild; sequence.RightChild = rightChild; return sequence; }
public SequenceConstructPosContext(SequenceNode node, BitSet firstpos, BitSet lastpos) { this_ = node; this.firstpos = firstpos; this.lastpos = lastpos; lastposLeft = null; firstposRight = null; }
public ContentValidator Finish(bool useDFA) { Debug.Assert(ContentType == XmlSchemaContentType.ElementOnly || ContentType == XmlSchemaContentType.Mixed); if (contentNode == null) { if (ContentType == XmlSchemaContentType.Mixed) { string ctype = IsOpen ? "Any" : "TextOnly"; Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "\t\t\tContentType: " + ctype); return IsOpen ? ContentValidator.Any : ContentValidator.TextOnly; } else { Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "\t\t\tContent: EMPTY"); Debug.Assert(!IsOpen); return ContentValidator.Empty; } } #if DEBUG StringBuilder bb = new StringBuilder(); contentNode.Dump(bb, symbols, positions); Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "\t\t\tContent : " + bb.ToString()); #endif // Add end marker InteriorNode contentRoot = new SequenceNode(); contentRoot.LeftChild = contentNode; LeafNode endMarker = new LeafNode(positions.Add(symbols.AddName(XmlQualifiedName.Empty, null), null)); contentRoot.RightChild = endMarker; // Eliminate NamespaceListNode(s) and RangeNode(s) contentNode.ExpandTree(contentRoot, symbols, positions); #if DEBUG bb = new StringBuilder(); contentRoot.LeftChild.Dump(bb, symbols, positions); Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "\t\t\tExpended: " + bb.ToString()); #endif // calculate followpos int symbolsCount = symbols.Count; int positionsCount = positions.Count; BitSet firstpos = new BitSet(positionsCount); BitSet lastpos = new BitSet(positionsCount); BitSet[] followpos = new BitSet[positionsCount]; for (int i = 0; i < positionsCount; i++) { followpos[i] = new BitSet(positionsCount); } contentRoot.ConstructPos(firstpos, lastpos, followpos); #if DEBUG Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, "firstpos, lastpos, followpos"); SequenceNode.WritePos(firstpos, lastpos, followpos); #endif if (minMaxNodesCount > 0) { //If the tree has any terminal range nodes BitSet positionsWithRangeTerminals; BitSet[] minMaxFollowPos = CalculateTotalFollowposForRangeNodes(firstpos, followpos, out positionsWithRangeTerminals); if (enableUpaCheck) { CheckCMUPAWithLeafRangeNodes(GetApplicableMinMaxFollowPos(firstpos, positionsWithRangeTerminals, minMaxFollowPos)); for (int i = 0; i < positionsCount; i++) { CheckCMUPAWithLeafRangeNodes(GetApplicableMinMaxFollowPos(followpos[i], positionsWithRangeTerminals, minMaxFollowPos)); } } return new RangeContentValidator(firstpos, followpos, symbols, positions, endMarker.Pos, this.ContentType, contentRoot.LeftChild.IsNullable, positionsWithRangeTerminals, minMaxNodesCount); } else { int[][] transitionTable = null; // if each symbol has unique particle we are golden if (!symbols.IsUpaEnforced) { if (enableUpaCheck) { // multiple positions that match the same symbol have different particles, but they never follow the same position CheckUniqueParticleAttribution(firstpos, followpos); } } else if (useDFA) { // Can return null if the number of states reaches higher than 8192 / positionsCount transitionTable = BuildTransitionTable(firstpos, followpos, endMarker.Pos); } #if DEBUG bb = new StringBuilder(); Dump(bb, followpos, transitionTable); Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, bb.ToString()); #endif if (transitionTable != null) { return new DfaContentValidator(transitionTable, symbols,this.ContentType, this.IsOpen, contentRoot.LeftChild.IsNullable); } else { return new NfaContentValidator(firstpos, followpos, symbols, positions, endMarker.Pos, this.ContentType, this.IsOpen, contentRoot.LeftChild.IsNullable); } } }
public void AddLeafRange(decimal min, decimal max) { LeafRangeNode rNode = new LeafRangeNode(min, max); int pos = positions.Add(-2, rNode); rNode.Pos = pos; InteriorNode sequence = new SequenceNode(); sequence.RightChild = rNode; Closure(sequence); minMaxNodesCount++; }
public void AddSequence() { SyntaxTreeNode node = (SyntaxTreeNode)stack.Pop(); InteriorNode sequence = new SequenceNode(); sequence.LeftChild = node; stack.Push(sequence); }
public void AddSequence() { SyntaxTreeNode node = (SyntaxTreeNode) this.stack.Pop(); InteriorNode node2 = new SequenceNode { LeftChild = node }; this.stack.Push(node2); }
public ContentValidator Finish(bool useDFA) { if (this.contentNode == null) { if (base.ContentType != XmlSchemaContentType.Mixed) { return ContentValidator.Empty; } bool isOpen = base.IsOpen; if (!base.IsOpen) { return ContentValidator.TextOnly; } return ContentValidator.Any; } InteriorNode parent = new SequenceNode { LeftChild = this.contentNode }; LeafNode node2 = new LeafNode(this.positions.Add(this.symbols.AddName(XmlQualifiedName.Empty, null), null)); parent.RightChild = node2; this.contentNode.ExpandTree(parent, this.symbols, this.positions); int count = this.symbols.Count; int num = this.positions.Count; BitSet firstpos = new BitSet(num); BitSet lastpos = new BitSet(num); BitSet[] followpos = new BitSet[num]; for (int i = 0; i < num; i++) { followpos[i] = new BitSet(num); } parent.ConstructPos(firstpos, lastpos, followpos); if (this.minMaxNodesCount > 0) { BitSet set3; BitSet[] minmaxFollowPos = this.CalculateTotalFollowposForRangeNodes(firstpos, followpos, out set3); if (this.enableUpaCheck) { this.CheckCMUPAWithLeafRangeNodes(this.GetApplicableMinMaxFollowPos(firstpos, set3, minmaxFollowPos)); for (int j = 0; j < num; j++) { this.CheckCMUPAWithLeafRangeNodes(this.GetApplicableMinMaxFollowPos(followpos[j], set3, minmaxFollowPos)); } } return new RangeContentValidator(firstpos, followpos, this.symbols, this.positions, node2.Pos, base.ContentType, parent.LeftChild.IsNullable, set3, this.minMaxNodesCount); } int[][] transitionTable = null; if (!this.symbols.IsUpaEnforced) { if (this.enableUpaCheck) { this.CheckUniqueParticleAttribution(firstpos, followpos); } } else if (useDFA) { transitionTable = this.BuildTransitionTable(firstpos, followpos, node2.Pos); } if (transitionTable != null) { return new DfaContentValidator(transitionTable, this.symbols, base.ContentType, base.IsOpen, parent.LeftChild.IsNullable); } return new NfaContentValidator(firstpos, followpos, this.symbols, this.positions, node2.Pos, base.ContentType, base.IsOpen, parent.LeftChild.IsNullable); }
public ContentValidator Finish(bool useDFA) { if (this.contentNode == null) { if (base.ContentType != XmlSchemaContentType.Mixed) { return(ContentValidator.Empty); } bool isOpen = base.IsOpen; if (!base.IsOpen) { return(ContentValidator.TextOnly); } return(ContentValidator.Any); } InteriorNode parent = new SequenceNode { LeftChild = this.contentNode }; LeafNode node2 = new LeafNode(this.positions.Add(this.symbols.AddName(XmlQualifiedName.Empty, null), null)); parent.RightChild = node2; this.contentNode.ExpandTree(parent, this.symbols, this.positions); int count = this.symbols.Count; int num = this.positions.Count; BitSet firstpos = new BitSet(num); BitSet lastpos = new BitSet(num); BitSet[] followpos = new BitSet[num]; for (int i = 0; i < num; i++) { followpos[i] = new BitSet(num); } parent.ConstructPos(firstpos, lastpos, followpos); if (this.minMaxNodesCount > 0) { BitSet set3; BitSet[] minmaxFollowPos = this.CalculateTotalFollowposForRangeNodes(firstpos, followpos, out set3); if (this.enableUpaCheck) { this.CheckCMUPAWithLeafRangeNodes(this.GetApplicableMinMaxFollowPos(firstpos, set3, minmaxFollowPos)); for (int j = 0; j < num; j++) { this.CheckCMUPAWithLeafRangeNodes(this.GetApplicableMinMaxFollowPos(followpos[j], set3, minmaxFollowPos)); } } return(new RangeContentValidator(firstpos, followpos, this.symbols, this.positions, node2.Pos, base.ContentType, parent.LeftChild.IsNullable, set3, this.minMaxNodesCount)); } int[][] transitionTable = null; if (!this.symbols.IsUpaEnforced) { if (this.enableUpaCheck) { this.CheckUniqueParticleAttribution(firstpos, followpos); } } else if (useDFA) { transitionTable = this.BuildTransitionTable(firstpos, followpos, node2.Pos); } if (transitionTable != null) { return(new DfaContentValidator(transitionTable, this.symbols, base.ContentType, base.IsOpen, parent.LeftChild.IsNullable)); } return(new NfaContentValidator(firstpos, followpos, this.symbols, this.positions, node2.Pos, base.ContentType, base.IsOpen, parent.LeftChild.IsNullable)); }