SymbolsDictionary is a map between names that ContextValidator recognizes and symbols - int symbol[XmlQualifiedName name]. There are two types of name - full names and wildcards (namespace is specified, local name is anythig). Wildcard excludes all full names that would match by the namespace part. SymbolsDictionry alwas recognizes all the symbols - the last one is a true wildcard - both name and namespace can be anything that none of the other symbols matched.
 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;
     }
 }
Example #2
0
        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;
            }
        }
Example #3
0
 internal NfaContentValidator(BitSet firstpos, BitSet[] followpos, SymbolsDictionary symbols, Positions positions, int endMarkerPos, XmlSchemaContentType contentType, bool isOpen, bool isEmptiable) : base(contentType, isOpen, isEmptiable)
 {
     this.firstpos     = firstpos;
     this.followpos    = followpos;
     this.symbols      = symbols;
     this.positions    = positions;
     this.endMarkerPos = endMarkerPos;
 }
 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);
     }
 }
Example #5
0
 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);
     }
 }
 internal NfaContentValidator(BitSet firstpos, BitSet[] followpos, SymbolsDictionary symbols, Positions positions, int endMarkerPos, XmlSchemaContentType contentType, bool isOpen, bool isEmptiable) : base(contentType, isOpen, isEmptiable)
 {
     this.firstpos = firstpos;
     this.followpos = followpos;
     this.symbols = symbols;
     this.positions = positions;
     this.endMarkerPos = endMarkerPos;
 }
 internal RangeContentValidator(BitSet firstpos, BitSet[] followpos, SymbolsDictionary symbols, Positions positions, int endMarkerPos, XmlSchemaContentType contentType, bool isEmptiable, BitSet positionsWithRangeTerminals, int minmaxNodesCount) : base(contentType, false, isEmptiable)
 {
     this.firstpos  = firstpos;
     this.followpos = followpos;
     this.symbols   = symbols;
     this.positions = positions;
     this.positionsWithRangeTerminals = positionsWithRangeTerminals;
     this.minMaxNodesCount            = minmaxNodesCount;
     this.endMarkerPos = endMarkerPos;
 }
 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 virtual ICollection GetResolvedSymbols(SymbolsDictionary symbols)  {
     return symbols.GetNamespaceListSymbols(namespaceList);
 }
 public override void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions) {
     bb.Append("\"" + symbols.NameOf(positions[pos].symbol) + "\"");
 }
 public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) {
     // do nothing
 }
 internal DfaContentValidator(int[][] transitionTable, SymbolsDictionary symbols, XmlSchemaContentType contentType, bool isOpen, bool isEmptiable) : base(contentType, isOpen, isEmptiable)
 {
     this.transitionTable = transitionTable;
     this.symbols         = symbols;
 }
 public void Start() {
     symbols = new SymbolsDictionary();
     positions = new Positions();
     stack = new Stack();
 }
 public override void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions) {
     LeftChild.Dump(bb, symbols, positions);
     bb.Append("{" + Convert.ToString(min, NumberFormatInfo.InvariantInfo) + ", " + Convert.ToString(max, NumberFormatInfo.InvariantInfo) + "}");
 }
 public override void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions) {
     LeftChild.Dump(bb, symbols, positions);
     bb.Append("*");
 }
        public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions) {
 	        ExpandTreeNoRecursive(parent, symbols, positions);
        }
 public override void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions) {
     bb.Append("[" + namespaceList.ToString() + "]");
 }
 public void Start()
 {
     this.symbols = new SymbolsDictionary();
     this.positions = new Positions();
     this.stack = new Stack();
 }
 public abstract void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions);
Example #20
0
 public void Start()
 {
     this.symbols   = new SymbolsDictionary();
     this.positions = new Positions();
     this.stack     = new Stack();
 }
        //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;
            }
        }
Example #22
0
 public virtual ICollection GetResolvedSymbols(SymbolsDictionary symbols)
 {
     return(symbols.GetNamespaceListSymbols(this.namespaceList));
 }
        public override void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions) {
            Stack<ChoiceNode> nodeStack = new Stack<ChoiceNode>();
            ChoiceNode this_ = this;

            while (true) {
                bb.Append("(");
                if (this_.LeftChild is ChoiceNode) {
                    nodeStack.Push(this_);
                    this_ = (ChoiceNode)this_.LeftChild;
                    continue;
                }
                this_.LeftChild.Dump(bb, symbols, positions);

            ProcessRight:
                bb.Append(" | ");
                this_.RightChild.Dump(bb, symbols, positions);
                bb.Append(")");
                if (nodeStack.Count == 0)
                    break;

                this_ = nodeStack.Pop();
                goto ProcessRight;
            }
        }
 /// <summary>
 /// Algorithm 3.5 Construction of a DFA from a regular expression
 /// </summary>
 internal DfaContentValidator(
     int[][] transitionTable, SymbolsDictionary symbols,
     XmlSchemaContentType contentType, bool isOpen, bool isEmptiable)  : base(contentType, isOpen, isEmptiable) {
     this.transitionTable = transitionTable;
     this.symbols = symbols;
 }
 /// <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;
     }
 }
 internal RangeContentValidator(
     BitSet firstpos, BitSet[] followpos, SymbolsDictionary symbols, Positions positions, int endMarkerPos, XmlSchemaContentType contentType, bool isEmptiable, BitSet positionsWithRangeTerminals, int minmaxNodesCount)  : base(contentType, false, isEmptiable) {
     this.firstpos = firstpos;
     this.followpos = followpos;
     this.symbols = symbols;
     this.positions = positions;
     this.positionsWithRangeTerminals = positionsWithRangeTerminals;
     this.minMaxNodesCount = minmaxNodesCount;
     this.endMarkerPos = endMarkerPos;
 }
 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 NamesapceListNode and RangeNode nodes. All other nodes
 /// </summary>
 public abstract void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions);
Example #29
0
 public override void ExpandTree(InteriorNode parent, SymbolsDictionary symbols, Positions positions)
 {
 }
        /// <summary>
        /// Print syntax tree
        /// </summary>
#if DEBUG        
        public abstract void Dump(StringBuilder bb, SymbolsDictionary symbols, Positions positions);