private static void ValidateAction(ParserAction expectedAction, ParserAction actualAction)
        {
            if (expectedAction == null)
            {
                Assert.IsNull(actualAction);
                return;
            }

            Assert.IsInstanceOfType(actualAction, expectedAction.GetType());

            var shiftAction = expectedAction as ShiftParserAction;
            if (shiftAction != null)
            {
                Assert.AreEqual(shiftAction.NextState.Id, ((ShiftParserAction)actualAction).NextState.Id);
                return;
            }

            var reduceAction = expectedAction as ReduceParserAction;
            if (reduceAction != null)
            {
                Assert.AreEqual(reduceAction.Reduction, ((ReduceParserAction)actualAction).Reduction);
                return;
            }
        }
        private void WriteAction(SerializerContext context, ParserAction action)
        {
            var shiftAction = action as ShiftParserAction;
            var writer = context.Writer;
            if (shiftAction != null)
            {
                writer.Write(ShiftParserActionId);
                writer.Write((ushort)shiftAction.NextState.Id);
                return;
            }

            var reduceAction = action as ReduceParserAction;
            if (reduceAction != null)
            {
                writer.Write(ReduceParserActionId);
                writer.Write((ushort)Data.AllReductions.IndexOf(reduceAction.Reduction));
                return;
            }

            if (action is AcceptParserAction)
            {
                writer.Write(AcceptarserActionId);
                return;
            }

            throw new NotSupportedException("Action is not supported.");
        }