public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) { BitSet set = new BitSet(lastpos.Count); base.LeftChild.ConstructPos(firstpos, set, followpos); BitSet set2 = new BitSet(firstpos.Count); base.RightChild.ConstructPos(set2, lastpos, followpos); if (base.LeftChild.IsNullable && !base.RightChild.IsRangeNode) { firstpos.Or(set2); } if (base.RightChild.IsNullable) { lastpos.Or(set); } for (int i = set.NextSet(-1); i != -1; i = set.NextSet(i)) { followpos[i].Or(set2); } if (base.RightChild.IsRangeNode) { ((LeafRangeNode)base.RightChild).NextIteration = firstpos.Clone(); } }
public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode) { BitSet set = context.CurPos[context.CurrentState.CurPosIndex]; int index = (context.CurrentState.CurPosIndex + 1) % 2; BitSet set2 = context.CurPos[index]; set2.Clear(); int num2 = this.symbols[name]; object particle = null; errorCode = 0; for (int i = set.NextSet(-1); i != -1; i = set.NextSet(i)) { if (num2 == this.positions[i].symbol) { set2.Or(this.followpos[i]); particle = this.positions[i].particle; break; } } if (!set2.IsEmpty) { context.CurrentState.CurPosIndex = index; return(particle); } if (!base.IsOpen || !set[this.endMarkerPos]) { context.NeedValidateChildren = false; errorCode = -1; } return(null); }
public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly) { ArrayList list = null; BitSet set = context.CurPos[context.CurrentState.CurPosIndex]; for (int i = set.NextSet(-1); i != -1; i = set.NextSet(i)) { if (list == null) { list = new ArrayList(); } XmlSchemaParticle particle = (XmlSchemaParticle)this.positions[i].particle; if (particle == null) { string str = this.symbols.NameOf(this.positions[i].symbol); if (str.Length != 0) { list.Add(str); } } else { string nameString = particle.NameString; if (!list.Contains(nameString)) { list.Add(nameString); } } } return(list); }
public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet) { ArrayList particles = new ArrayList(); if (context.RunningPositions != null) { List <RangePositionInfo> runningPositions = context.RunningPositions; BitSet set = new BitSet(this.positions.Count); for (int i = context.CurrentState.NumberOfRunningPos - 1; i >= 0; i--) { set.Or(runningPositions[i].curpos); } for (int j = set.NextSet(-1); j != -1; j = set.NextSet(j)) { if (this.positions[j].symbol >= 0) { XmlSchemaParticle p = this.positions[j].particle as XmlSchemaParticle; if (p != null) { ContentValidator.AddParticleToExpected(p, schemaSet, particles); } } } } return(particles); }
public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) { base.LeftChild.ConstructPos(firstpos, lastpos, followpos); for (int i = lastpos.NextSet(-1); i != -1; i = lastpos.NextSet(i)) { followpos[i].Or(firstpos); } }
private int[][] BuildTransitionTable(BitSet firstpos, BitSet[] followpos, int endMarkerPos) { int count = this.positions.Count; int num2 = 0x2000 / count; int index = this.symbols.Count; ArrayList list = new ArrayList(); Hashtable hashtable = new Hashtable(); hashtable.Add(new BitSet(count), -1); Queue queue = new Queue(); int num4 = 0; queue.Enqueue(firstpos); hashtable.Add(firstpos, 0); list.Add(new int[index + 1]); while (queue.Count > 0) { BitSet set = (BitSet)queue.Dequeue(); int[] numArray = (int[])list[num4]; if (set[endMarkerPos]) { numArray[index] = 1; } for (int i = 0; i < index; i++) { BitSet set2 = new BitSet(count); for (int j = set.NextSet(-1); j != -1; j = set.NextSet(j)) { if (i == this.positions[j].symbol) { set2.Or(followpos[j]); } } object obj2 = hashtable[set2]; if (obj2 != null) { numArray[i] = (int)obj2; } else { int num7 = hashtable.Count - 1; if (num7 >= num2) { return(null); } queue.Enqueue(set2); hashtable.Add(set2, num7); list.Add(new int[index + 1]); numArray[i] = num7; } } num4++; } return((int[][])list.ToArray(typeof(int[]))); }
public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet) { ArrayList particles = new ArrayList(); BitSet set = context.CurPos[context.CurrentState.CurPosIndex]; for (int i = set.NextSet(-1); i != -1; i = set.NextSet(i)) { XmlSchemaParticle p = (XmlSchemaParticle)this.positions[i].particle; if (p != null) { ContentValidator.AddParticleToExpected(p, schemaSet, particles); } } return(particles); }
private BitSet GetApplicableMinMaxFollowPos(BitSet curpos, BitSet posWithRangeTerminals, BitSet[] minmaxFollowPos) { if (curpos.Intersects(posWithRangeTerminals)) { BitSet set = new BitSet(this.positions.Count); set.Or(curpos); set.And(posWithRangeTerminals); curpos = curpos.Clone(); for (int i = set.NextSet(-1); i != -1; i = set.NextSet(i)) { LeafRangeNode particle = this.positions[i].particle as LeafRangeNode; curpos.Or(minmaxFollowPos[particle.Pos]); } } return(curpos); }
private void CheckUniqueParticleAttribution(BitSet curpos) { object[] objArray = new object[this.symbols.Count]; for (int i = curpos.NextSet(-1); i != -1; i = curpos.NextSet(i)) { int symbol = this.positions[i].symbol; if (objArray[symbol] == null) { objArray[symbol] = this.positions[i].particle; } else if (objArray[symbol] != this.positions[i].particle) { throw new UpaException(objArray[symbol], this.positions[i].particle); } } }
private void CheckCMUPAWithLeafRangeNodes(BitSet curpos) { object[] objArray = new object[this.symbols.Count]; for (int i = curpos.NextSet(-1); i != -1; i = curpos.NextSet(i)) { Position position = this.positions[i]; int symbol = position.symbol; if (symbol >= 0) { if (objArray[symbol] != null) { throw new UpaException(objArray[symbol], position.particle); } objArray[symbol] = position.particle; } } }
public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly) { ArrayList list = null; if (context.RunningPositions != null) { List <RangePositionInfo> runningPositions = context.RunningPositions; BitSet set = new BitSet(this.positions.Count); for (int i = context.CurrentState.NumberOfRunningPos - 1; i >= 0; i--) { set.Or(runningPositions[i].curpos); } for (int j = set.NextSet(-1); j != -1; j = set.NextSet(j)) { if (list == null) { list = new ArrayList(); } if (this.positions[j].symbol >= 0) { XmlSchemaParticle particle = this.positions[j].particle as XmlSchemaParticle; if (particle == null) { string str = this.symbols.NameOf(this.positions[j].symbol); if (str.Length != 0) { list.Add(str); } } else { string nameString = particle.NameString; if (!list.Contains(nameString)) { list.Add(nameString); } } } } } return(list); }
private BitSet[] CalculateTotalFollowposForRangeNodes(BitSet firstpos, BitSet[] followpos, out BitSet posWithRangeTerminals) { int count = this.positions.Count; posWithRangeTerminals = new BitSet(count); BitSet[] setArray = new BitSet[this.minMaxNodesCount]; int index = 0; for (int i = count - 1; i >= 0; i--) { Position position = this.positions[i]; if (position.symbol == -2) { LeafRangeNode particle = position.particle as LeafRangeNode; BitSet set = new BitSet(count); set.Clear(); set.Or(followpos[i]); if (particle.Min != particle.Max) { set.Or(particle.NextIteration); } for (int j = set.NextSet(-1); j != -1; j = set.NextSet(j)) { if (j > i) { Position position2 = this.positions[j]; if (position2.symbol == -2) { LeafRangeNode node2 = position2.particle as LeafRangeNode; set.Or(setArray[node2.Pos]); } } } setArray[index] = set; particle.Pos = index++; posWithRangeTerminals.Set(i); } } return(setArray); }
//For each position, this method calculates the additional follows of any range nodes that need to be added to its followpos //((ab?)2-4)c, Followpos of a is b as well as that of node R(2-4) = c private BitSet GetApplicableMinMaxFollowPos(BitSet curpos, BitSet posWithRangeTerminals, BitSet[] minmaxFollowPos) { if (curpos.Intersects(posWithRangeTerminals)) { BitSet newSet = new BitSet(positions.Count); //Doing work again newSet.Or(curpos); newSet.And(posWithRangeTerminals); curpos = curpos.Clone(); for (int pos = newSet.NextSet(-1); pos != -1; pos = newSet.NextSet(pos)) { LeafRangeNode lrNode = positions[pos].particle as LeafRangeNode; curpos.Or(minmaxFollowPos[lrNode.Pos]); } } return curpos; }
private void CheckCMUPAWithLeafRangeNodes(BitSet curpos) { object[] symbolMatches = new object[symbols.Count]; for (int pos = curpos.NextSet(-1); pos != -1; pos = curpos.NextSet(pos)) { Position currentPosition = positions[pos]; int symbol = currentPosition.symbol; if (symbol >= 0) { //its not a range position if (symbolMatches[symbol] != null) { throw new UpaException(symbolMatches[symbol], currentPosition.particle); } else { symbolMatches[symbol] = currentPosition.particle; } } } }
private BitSet[] CalculateTotalFollowposForRangeNodes(BitSet firstpos, BitSet[] followpos, out BitSet posWithRangeTerminals) { int positionsCount = positions.Count; //terminals posWithRangeTerminals = new BitSet(positionsCount); //Compute followpos for each range node //For any range node that is surrounded by an outer range node, its follow positions will include those of the outer range node BitSet[] minmaxFollowPos = new BitSet[minMaxNodesCount]; int localMinMaxNodesCount = 0; for (int i = positionsCount - 1; i >= 0; i--) { Position p = positions[i]; if (p.symbol == -2) { //P is a LeafRangeNode LeafRangeNode lrNode = p.particle as LeafRangeNode; Debug.Assert(lrNode != null); BitSet tempFollowPos = new BitSet(positionsCount); tempFollowPos.Clear(); tempFollowPos.Or(followpos[i]); //Add the followpos of the range node if (lrNode.Min != lrNode.Max) { //If they are the same, then followpos cannot include the firstpos tempFollowPos.Or(lrNode.NextIteration); //Add the nextIteration of the range node (this is the firstpos of its parent's leftChild) } //For each position in the bitset, if it is a outer range node (pos > i), then add its followpos as well to the current node's followpos for (int pos = tempFollowPos.NextSet(-1); pos != -1; pos = tempFollowPos.NextSet(pos)) { if (pos > i) { Position p1 = positions[pos]; if (p1.symbol == -2) { LeafRangeNode lrNode1 = p1.particle as LeafRangeNode; Debug.Assert(lrNode1 != null); tempFollowPos.Or(minmaxFollowPos[lrNode1.Pos]); } } } //set the followpos built to the index in the BitSet[] minmaxFollowPos[localMinMaxNodesCount] = tempFollowPos; lrNode.Pos = localMinMaxNodesCount++; posWithRangeTerminals.Set(i); } } return minmaxFollowPos; }
private BitSet GetApplicableMinMaxFollowPos(BitSet curpos, BitSet posWithRangeTerminals, BitSet[] minmaxFollowPos) { if (curpos.Intersects(posWithRangeTerminals)) { BitSet set = new BitSet(this.positions.Count); set.Or(curpos); set.And(posWithRangeTerminals); curpos = curpos.Clone(); for (int i = set.NextSet(-1); i != -1; i = set.NextSet(i)) { LeafRangeNode particle = this.positions[i].particle as LeafRangeNode; curpos.Or(minmaxFollowPos[particle.Pos]); } } return curpos; }
public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) { LeftChild.ConstructPos(firstpos, lastpos, followpos); for (int pos = lastpos.NextSet(-1); pos != -1; pos = lastpos.NextSet(pos)) { followpos[pos].Or(firstpos); } }
public override ArrayList ExpectedParticles(ValidationState context, bool isRequiredOnly, XmlSchemaSet schemaSet) { ArrayList particles = new ArrayList(); BitSet expectedPos; if (context.RunningPositions != null) { List<RangePositionInfo> runningPositions = context.RunningPositions; expectedPos = new BitSet(positions.Count); for (int i = context.CurrentState.NumberOfRunningPos - 1; i >=0; i--) { Debug.Assert(runningPositions[i].curpos != null); expectedPos.Or(runningPositions[i].curpos); } for (int pos = expectedPos.NextSet(-1); pos != -1; pos = expectedPos.NextSet(pos)) { int symbol = positions[pos].symbol; if (symbol >= 0) { //non range nodes XmlSchemaParticle p = positions[pos].particle as XmlSchemaParticle; if (p == null) { continue; } AddParticleToExpected(p, schemaSet, particles); } } } return particles; }
public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode) { RangePositionInfo info; errorCode = 0; int num = this.symbols[name]; bool flag = false; List <RangePositionInfo> runningPositions = context.RunningPositions; int numberOfRunningPos = context.CurrentState.NumberOfRunningPos; int count = 0; int index = -1; int num5 = -1; bool flag2 = false; while (count < numberOfRunningPos) { info = runningPositions[count]; BitSet curpos = info.curpos; for (int i = curpos.NextSet(-1); i != -1; i = curpos.NextSet(i)) { if (num == this.positions[i].symbol) { index = i; if (num5 == -1) { num5 = count; } flag2 = true; break; } } if (flag2 && (this.positions[index].particle is XmlSchemaElement)) { break; } count++; } if ((count == numberOfRunningPos) && (index != -1)) { count = num5; } if (count < numberOfRunningPos) { if (count != 0) { runningPositions.RemoveRange(0, count); } numberOfRunningPos -= count; count = 0; while (count < numberOfRunningPos) { info = runningPositions[count]; if (info.curpos.Get(index)) { info.curpos = this.followpos[index]; runningPositions[count] = info; count++; } else { numberOfRunningPos--; if (numberOfRunningPos > 0) { RangePositionInfo info2 = runningPositions[numberOfRunningPos]; runningPositions[numberOfRunningPos] = runningPositions[count]; runningPositions[count] = info2; } } } } else { numberOfRunningPos = 0; } if (numberOfRunningPos > 0) { if (numberOfRunningPos >= 0x2710) { context.TooComplex = true; numberOfRunningPos /= 2; } for (count = numberOfRunningPos - 1; count >= 0; count--) { int num7 = count; BitSet set2 = runningPositions[count].curpos; flag = flag || set2.Get(this.endMarkerPos); while ((numberOfRunningPos < 0x2710) && set2.Intersects(this.positionsWithRangeTerminals)) { BitSet set3 = set2.Clone(); set3.And(this.positionsWithRangeTerminals); int num8 = set3.NextSet(-1); LeafRangeNode particle = this.positions[num8].particle as LeafRangeNode; info = runningPositions[num7]; if ((numberOfRunningPos + 2) >= runningPositions.Count) { RangePositionInfo item = new RangePositionInfo(); runningPositions.Add(item); RangePositionInfo info5 = new RangePositionInfo(); runningPositions.Add(info5); } RangePositionInfo info3 = runningPositions[numberOfRunningPos]; if (info3.rangeCounters == null) { info3.rangeCounters = new decimal[this.minMaxNodesCount]; } Array.Copy(info.rangeCounters, 0, info3.rangeCounters, 0, info.rangeCounters.Length); decimal num9 = info3.rangeCounters[particle.Pos] = decimal.op_Increment(info3.rangeCounters[particle.Pos]); if (num9 == particle.Max) { info3.curpos = this.followpos[num8]; info3.rangeCounters[particle.Pos] = 0M; runningPositions[numberOfRunningPos] = info3; num7 = numberOfRunningPos++; } else { if (num9 < particle.Min) { info3.curpos = particle.NextIteration; runningPositions[numberOfRunningPos] = info3; numberOfRunningPos++; break; } info3.curpos = particle.NextIteration; runningPositions[numberOfRunningPos] = info3; num7 = numberOfRunningPos + 1; info3 = runningPositions[num7]; if (info3.rangeCounters == null) { info3.rangeCounters = new decimal[this.minMaxNodesCount]; } Array.Copy(info.rangeCounters, 0, info3.rangeCounters, 0, info.rangeCounters.Length); info3.curpos = this.followpos[num8]; info3.rangeCounters[particle.Pos] = 0M; runningPositions[num7] = info3; numberOfRunningPos += 2; } set2 = runningPositions[num7].curpos; flag = flag || set2.Get(this.endMarkerPos); } } context.HasMatched = flag; context.CurrentState.NumberOfRunningPos = numberOfRunningPos; return(this.positions[index].particle); } errorCode = -1; context.NeedValidateChildren = false; return(null); }
private void CheckUniqueParticleAttribution(BitSet curpos) { // particles will be attributed uniquely if the same symbol never poins to two different ones object[] particles = new object[symbols.Count]; for (int pos = curpos.NextSet(-1); pos != -1; pos = curpos.NextSet(pos)) { // if position can follow int symbol = positions[pos].symbol; if (particles[symbol] == null) { // set particle for the symbol particles[symbol] = positions[pos].particle; } else if (particles[symbol] != positions[pos].particle) { throw new UpaException(particles[symbol], positions[pos].particle); } // two different position point to the same symbol and particle - that's OK } }
public override ArrayList ExpectedElements(ValidationState context, bool isRequiredOnly) { ArrayList names = null; BitSet expectedPos; if (context.RunningPositions != null) { List<RangePositionInfo> runningPositions = context.RunningPositions; expectedPos = new BitSet(positions.Count); for (int i = context.CurrentState.NumberOfRunningPos - 1; i >=0; i--) { Debug.Assert(runningPositions[i].curpos != null); expectedPos.Or(runningPositions[i].curpos); } for (int pos = expectedPos.NextSet(-1); pos != -1; pos = expectedPos.NextSet(pos)) { if (names == null) { names = new ArrayList(); } int symbol = positions[pos].symbol; if (symbol >= 0) { //non range nodes XmlSchemaParticle p = positions[pos].particle as XmlSchemaParticle; if (p == null) { string s = symbols.NameOf(positions[pos].symbol); if (s.Length != 0) { names.Add(s); } } else { string s = p.NameString; if (!names.Contains(s)) { names.Add(s); } } } } } return names; }
private BitSet[] CalculateTotalFollowposForRangeNodes(BitSet firstpos, BitSet[] followpos, out BitSet posWithRangeTerminals) { int count = this.positions.Count; posWithRangeTerminals = new BitSet(count); BitSet[] setArray = new BitSet[this.minMaxNodesCount]; int index = 0; for (int i = count - 1; i >= 0; i--) { Position position = this.positions[i]; if (position.symbol == -2) { LeafRangeNode particle = position.particle as LeafRangeNode; BitSet set = new BitSet(count); set.Clear(); set.Or(followpos[i]); if (particle.Min != particle.Max) { set.Or(particle.NextIteration); } for (int j = set.NextSet(-1); j != -1; j = set.NextSet(j)) { if (j > i) { Position position2 = this.positions[j]; if (position2.symbol == -2) { LeafRangeNode node2 = position2.particle as LeafRangeNode; set.Or(setArray[node2.Pos]); } } } setArray[index] = set; particle.Pos = index++; posWithRangeTerminals.Set(i); } } return setArray; }
internal static void WriteBitSet(BitSet curpos) { int[] list = new int[curpos.Count]; for (int pos = curpos.NextSet(-1); pos != -1; pos = curpos.NextSet(pos)) { list[pos] = 1; } for(int i = 0; i < list.Length; i++) { Debug.WriteIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, list[i] + " "); } Debug.WriteLineIf(DiagnosticsSwitches.XmlSchemaContentModel.Enabled, ""); }
public override void ConstructPos(BitSet firstpos, BitSet lastpos, BitSet[] followpos) { BitSet lastposLeft = new BitSet(lastpos.Count); LeftChild.ConstructPos(firstpos, lastposLeft, followpos); BitSet firstposRight = new BitSet(firstpos.Count); RightChild.ConstructPos(firstposRight, lastpos, followpos); if (LeftChild.IsNullable && !RightChild.IsRangeNode) { firstpos.Or(firstposRight); } if (RightChild.IsNullable) { lastpos.Or(lastposLeft); } for (int pos = lastposLeft.NextSet(-1); pos != -1; pos = lastposLeft.NextSet(pos)) { followpos[pos].Or(firstposRight); } if (RightChild.IsRangeNode) { //firstpos is leftchild.firstpos as the or with firstposRight has not been done as it is a rangenode ((LeafRangeNode)RightChild).NextIteration = firstpos.Clone(); } }