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(); } }
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); }
//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 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 Join(ArrayList terminalNodes, BitSet lset, NamespaceList lany, BitSet rset, NamespaceList rany, out BitSet set, out NamespaceList any) { if (lset != null) { if (rset != null) { set = lset.Clone(); set.And(rset); if (!set.IsEmpty) { goto error; } set.Or(lset); set.Or(rset); } else { set = lset; } } else { set = rset; } if (lany != null) { if (rany != null) { NamespaceList list = NamespaceList.Intersection(rany, lany); if (list == null || list.IsEmpty()) { any = NamespaceList.Union(rany, lany); } else { goto error; } } else { any = lany; } } else { any = rany; } if (any != null && set != null) { for (int i = 0; i < set.Count; i++) { if (set.Get(i) && any.Allows(((TerminalNode)terminalNodes[i]).Name)) { goto error; } } } return; error: throw new XmlSchemaException(Res.Sch_NonDeterministicAny); }
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); }
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(); } }