Пример #1
0
		private void TraverseReads(Transition x, int k)
		{
			S.Push(x);
			x.N = k;
			x.Read = new SetCollection<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 SetCollection<Terminal>(x.Read);
				} while (S.Pop() != x);
		}
Пример #2
0
		private void TraverseFollows(Transition x, int k)
		{
			S.Push(x);
			x.N = k;
			x.Follow = new SetCollection<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 SetCollection<Terminal>(x.Follow);
				} while (S.Pop() != x);
		}