예제 #1
0
		private void TraverseReads(Transition x, int k)
		{
			this.S.Push(x);
			x.N = k;
			x.Read = new Set<Terminal>(x.DR);
			foreach (Transition current in x.next.nonTerminalTransitions.Values)
			{
				if (current.A.IsNullable())
				{
					if (current.N == 0)
					{
						this.TraverseReads(current, k + 1);
					}
					if (current.N < x.N)
					{
						x.N = current.N;
					}
					x.Read.AddRange(current.Read);
				}
			}
			if (x.N == k)
			{
				do
				{
					this.S.Peek().N = 2147483647;
					this.S.Peek().Read = new Set<Terminal>(x.Read);
				}
				while (this.S.Pop() != x);
			}
		}
예제 #2
0
        private void TraverseReads(Transition x, int k)
        {
            S.Push(x);
            x.N = k;
            x.Read = new Set<Terminal>(x.DR);

            // foreach y such that x reads y
            foreach (Transition y in x.next.nonTerminalTransitions.Values)
                if (y.A.IsNullable())
                {
                    if (y.N == 0)
                        TraverseReads(y, k + 1);

                    if (y.N < x.N)
                        x.N = y.N;

                    x.Read.AddRange(y.Read);
                }

            if (x.N == k)
                do
                {
                    S.Peek().N = int.MaxValue;
                    S.Peek().Read = new Set<Terminal>(x.Read);
                } while (S.Pop() != x);
        }
예제 #3
0
        private void TraverseFollows(Transition x, int k)
        {
            S.Push(x);
            x.N = k;
            x.Follow = new Set<Terminal>(x.Read);

            foreach (Transition y in x.includes)
                if (x != y)
                {
                    if (y.N == 0)
                        TraverseFollows(y, k + 1);

                    if (y.N < x.N)
                        x.N = y.N;

                    x.Follow.AddRange(y.Follow);
                }

            if (x.N == k)
                do
                {
                    S.Peek().N = int.MaxValue;
                    S.Peek().Follow = new Set<Terminal>(x.Follow);
                } while (S.Pop() != x);
        }
예제 #4
0
		private void TraverseFollows(Transition x, int k)
		{
			this.S.Push(x);
			x.N = k;
			x.Follow = new Set<Terminal>(x.Read);
			foreach (Transition current in x.includes)
			{
				if (x != current)
				{
					if (current.N == 0)
					{
						this.TraverseFollows(current, k + 1);
					}
					if (current.N < x.N)
					{
						x.N = current.N;
					}
					x.Follow.AddRange(current.Follow);
				}
			}
			if (x.N == k)
			{
				do
				{
					this.S.Peek().N = 2147483647;
					this.S.Peek().Follow = new Set<Terminal>(x.Follow);
				}
				while (this.S.Pop() != x);
			}
		}