Ejemplo n.º 1
0
        public string[][] CompleteStates(string[] stack)
        {
            string[] substack = new string[stack.Length - 1];
            Array.Copy(stack, substack, substack.Length);
            ObjectTree pnode = GetObjectTreeAt(substack);

            if (substack.Length == 0)
            {
                pnode = this;
            }
            else
            {
                if (pnode == null || pnode.child == null)
                {
                    return(new string[0][]);
                }
                else
                {
                    pnode = pnode.child;
                }
            }

            Set allres = new Set();

            while (pnode != null)
            {
                int index = pnode.AcceptStateCount;
                int size  = index;

                string[]   buffer  = new string[pnode.Depth(2)];
                string[][] results = new string[size][];

                pnode.MatchItem(buffer, ref index, 0, size, results);

                foreach (string[] r in results)
                {
                    if (r.Length > 0 && r[0].ToLower().StartsWith(stack[stack.Length - 1].ToLower()))
                    {
                        allres.Add(r);
                    }
                }

                pnode = pnode.next;
            }

            return(allres.ToArray(typeof(string[])) as string[][]);
        }
Ejemplo n.º 2
0
        public string[][] AcceptStates(string[] stack)
        {
            ObjectTree pnode = GetObjectTreeAt(stack);

            if (stack == null || stack.Length == 0)
            {
                pnode = this;
            }
            else
            {
                if (pnode == null || pnode.child == null)
                {
                    return(new string[0][]);
                }
                else
                {
                    pnode = pnode.child;
                }
            }

            ArrayList allres = new ArrayList();

            while (pnode != null)
            {
                int index = pnode.AcceptStateCount;
                int size  = index;

                string[]   buffer  = new string[pnode.Depth(2)];
                string[][] results = new string[size][];

                pnode.MatchItem(buffer, ref index, 0, size, results);

                allres.AddRange(results);

                pnode = pnode.next;
            }

            return(allres.ToArray(typeof(string[])) as string[][]);
        }
Ejemplo n.º 3
0
        int Depth(int depth)
        {
            int c = 0, n = 0;

            if (child != null)
            {
                c = child.Depth(depth + 1);
            }
            if (next != null)
            {
                n = next.Depth(depth);
            }
            if (c > depth)
            {
                depth = c;
            }
            if (n > depth)
            {
                depth = n;
            }

            return(depth);
        }