Example #1
0
            protected internal override void Sub(CalculatorContext context, Stack <string> stack)
            {
                Calculator ctxt = context.Owner;

                if (stack.Count >= 2)
                {
                    CalculatorState endState = context.State;

                    context.ClearState();

                    try
                    {
                        ctxt.Sub();
                    }
                    finally
                    {
                        context.State = endState;
                    }
                }
                else
                {
                    context.State.Exit(context);
                    context.State = Map1.ErrorTuple;
                    context.State.Entry(context);
                }

                return;
            }
Example #2
0
            protected internal override void Enter(CalculatorContext context, string value)
            {
                Calculator ctxt = context.Owner;

                if (double.TryParse(value, out double _))
                {
                    context.State.Exit(context);
                    context.ClearState();

                    try
                    {
                        ctxt.Push(value);
                    }
                    finally
                    {
                        context.State = Map1.Calculate;
                        context.State.Entry(context);
                    }
                }
                else
                {
                    context.State.Exit(context);
                    context.State = Map1.ErrorNumeric;
                    context.State.Entry(context);
                }

                return;
            }
Example #3
0
            protected internal override void ClrAll(CalculatorContext context, Stack <string> stack)
            {
                Calculator ctxt = context.Owner;

                CalculatorState endState = context.State;

                context.ClearState();

                try
                {
                    ctxt.ClrAll();
                }
                finally
                {
                    context.State = endState;
                }



                return;
            }