예제 #1
0
        public static void debug_ListAllTermsFromString(string x, bool internalTest)
        {
            Console.WriteLine(x);

            TermLib.TermStack TStack = new TermLib.TermStack();
            TermLib.ScanExpression(x, ref TStack);
            while (!TStack.isEmpty)
            {
                try
                {
                    if (internalTest)
                    {
                        Console.Write("{0}, ", TStack.Pop().debug_GetValueAsString());
                    }
                    else
                    {
                        Console.Write("{0}, ", TStack.Pop().GetTermType);
                    }
                }
                catch (IndexOutOfRangeException e)
                {
                    Console.WriteLine(e.ToString());
                    break;
                }
            }
        }
예제 #2
0
        public static void Main(string[] args)
        {
            //Console.WriteLine("Hello World!");

            // TODO: Implement Functionality Here
            string x = "2*Variable+1";

            TermLib.TermStack TStack = new TermLib.TermStack();

            /*NumberFormatInfo provider = new NumberFormatInfo();
             * provider.CurrencyDecimalSeparator=".";
             * double l = Convert.ToDouble("69.55",provider);
             * Console.WriteLine(l);*/

            TermLib.ScanExpression(x, ref TStack);
            while (!TStack.isEmpty)
            {
                try
                {
                    Console.Write("{0}, ", TStack.Pop().GetTermType);
                }
                catch (IndexOutOfRangeException e)
                {
                    break;
                }
            }
            //Console.Write("My debug {0}, {1}, {2}, {3}, {4}",t0,t1,t2,t3,t4);
            Console.ReadKey(true);
        }
예제 #3
0
        public static void debug_GivenOperatorTest(int iterations)
        {
            for (int i = 0; i < iterations; i++)
            {
                Console.WriteLine("Write which operator would you like to test:");
                string            opr    = Console.ReadLine();
                TermLib.TermStack inpOpr = new TermLib.TermStack();
                TermLib.ScanExpression(opr, ref inpOpr);
                var term = inpOpr.Pop();

                Console.WriteLine("Write here your first number for {0} check", (TermLib.OPRType)term.GetBitValue[0]);
                string            x       = Console.ReadLine();
                TermLib.TermStack testing = new TermLib.TermStack();
                TermLib.ScanExpression(x, ref testing);
                Console.WriteLine("And second one");
                x = Console.ReadLine();
                TermLib.ScanExpression(x, ref testing);
                DebugTools.debug_TestOperator((TermLib.OPRType)term.GetBitValue[0], testing);
            }
        }
예제 #4
0
        public static void debug_ComplexOperatorTest()
        {
            Console.WriteLine("Write here your first number for plus check");
            string x = Console.ReadLine();

            TermLib.TermStack testing = new TermLib.TermStack();
            TermLib.ScanExpression(x, ref testing);
            Console.WriteLine("And second one");
            x = Console.ReadLine();
            TermLib.ScanExpression(x, ref testing);
            DebugTools.debug_TestOperator(TermLib.OPRType.PLUS, testing);

            Console.WriteLine("Write here your first number for minus check");
            x       = Console.ReadLine();
            testing = new TermLib.TermStack();
            TermLib.ScanExpression(x, ref testing);
            Console.WriteLine("and second one");
            x = Console.ReadLine();
            TermLib.ScanExpression(x, ref testing);
            DebugTools.debug_TestOperator(TermLib.OPRType.MINUS, testing);

            Console.WriteLine("Write here your first number for mult check");
            x       = Console.ReadLine();
            testing = new TermLib.TermStack();
            TermLib.ScanExpression(x, ref testing);
            Console.WriteLine("and second one");
            x = Console.ReadLine();
            TermLib.ScanExpression(x, ref testing);
            DebugTools.debug_TestOperator(TermLib.OPRType.MULT, testing);

            Console.WriteLine("Write here your first number for division check");
            x       = Console.ReadLine();
            testing = new TermLib.TermStack();
            TermLib.ScanExpression(x, ref testing);
            Console.WriteLine("and second one");
            x = Console.ReadLine();
            TermLib.ScanExpression(x, ref testing);
            DebugTools.debug_TestOperator(TermLib.OPRType.DIV, testing);

            Console.WriteLine("Write here your first number for modular check");
            x       = Console.ReadLine();
            testing = new TermLib.TermStack();
            TermLib.ScanExpression(x, ref testing);
            Console.WriteLine("and second one");
            x = Console.ReadLine();
            TermLib.ScanExpression(x, ref testing);
            DebugTools.debug_TestOperator(TermLib.OPRType.PERCENT, testing);

            Console.WriteLine("Write here your first number for more-then-operator check");
            x       = Console.ReadLine();
            testing = new TermLib.TermStack();
            TermLib.ScanExpression(x, ref testing);
            Console.WriteLine("and second one");
            x = Console.ReadLine();
            TermLib.ScanExpression(x, ref testing);
            DebugTools.debug_TestOperator(TermLib.OPRType.MORE, testing);

            Console.WriteLine("Write here your first number for less-then-operator check");
            x       = Console.ReadLine();
            testing = new TermLib.TermStack();
            TermLib.ScanExpression(x, ref testing);
            Console.WriteLine("and second one");
            x = Console.ReadLine();
            TermLib.ScanExpression(x, ref testing);
            DebugTools.debug_TestOperator(TermLib.OPRType.LESS, testing);
        }