Beispiel #1
0
        /// <summary>
        /// Raises a reduce/reduce conflict
        /// </summary>
        /// <param name="state">The parent state</param>
        /// <param name="currentItem">The conflictuous reduction item (current)</param>
        /// <param name="previousItem">The conflictuous reduction item (previous)</param>
        /// <param name="lookahead">The lookahead creating the conflict</param>
        protected void RaiseConflictReduceReduce(State state, Item currentItem, Item previousItem, Terminal lookahead)
        {
            // Look for previous conflict
            foreach (Conflict previous in conflicts)
            {
                if (previous.ErrorType == ErrorType.ConflictReduceReduce && previous.ConflictSymbol == lookahead)
                {
                    // Previous conflict
                    previous.AddItem(currentItem);
                    return;
                }
            }
            // No previous conflict was found
            Conflict conflict = new Conflict(state, ErrorType.ConflictReduceReduce, lookahead);

            conflict.AddItem(previousItem);
            conflict.AddItem(currentItem);
            conflicts.Add(conflict);
        }