/// <summary> /// 指示当前对象是否等于同一类型的另一个对象。 /// </summary> /// <param name="other">与此对象进行比较的对象。</param> /// <returns>如果当前对象等于 <paramref name="other"/> 参数,则为 <c>true</c>; /// 否则为 <c>false</c>。</returns> /// <overloads> /// <summary> /// 指示当前对象是否等于另一个对象。 /// </summary> /// </overloads> public bool Equals(ProductionData <T> other) { if (object.ReferenceEquals(other, this)) { return(true); } if (this.head != other.head) { return(false); } if (this.bodySize != other.bodySize) { return(false); } return(this.action == other.action); }
/// <summary> /// 使用指定的产生式归约。 /// </summary> /// <param name="index">归约使用的产生式的索引。</param> private void Reduce(int index) { ProductionData <T> info = rule.Productions[index]; int size = info.BodySize; controller.InternalAdd(tokenStack, size); while (size-- > 0) { stateStack.Pop(); } object value = rule.Productions[index].Action(controller); tokenStack.Push(new Token <T>((T)(object)(info.Head + rule.NonTerminalOffset), null, controller.Start, controller.End, value)); stateStack.Push(rule.States[stateStack.Peek()].Gotos[info.Head]); }