private bool TryResolveShiftReduce(int actionX, int actionY, int incomingToken, out int output)
        {
            output = 0;

            int shiftAction, reduceAction;

            if (ParserAction.IsShift(actionX) &&
                ParserAction.GetKind(actionY) == ParserActionKind.Reduce)
            {
                shiftAction  = actionX;
                reduceAction = actionY;
            }
            else if (ParserAction.IsShift(actionY) &&
                     ParserAction.GetKind(actionX) == ParserActionKind.Reduce)
            {
                shiftAction  = actionY;
                reduceAction = actionX;
            }
            else
            {
                // Unsupported conflict type. Use first action
                output = actionX;
                return(false);
            }

            var shiftTokenPrecedence = grammar.GetTermPrecedence(incomingToken);
            var reduceRulePrecedence = grammar.GetProductionPrecedence(ParserAction.GetId(reduceAction));

            if (shiftTokenPrecedence == null && reduceRulePrecedence == null)
            {
                // In case of conflict prefer shift over reduce
                output = shiftAction;
                return(false);
            }
            else if (shiftTokenPrecedence == null)
            {
                output = reduceAction;
            }
            else if (reduceRulePrecedence == null)
            {
                output = shiftAction;
            }
            else if (Precedence.IsReduce(reduceRulePrecedence, shiftTokenPrecedence))
            {
                output = reduceAction;
            }
            else
            {
                output = shiftAction;
            }

            return(true);
        }