Esempio n. 1
0
        static async Task MainAsync()
        {
            var t  = new CancellationTokenSource();
            var s  = new Algebra.Core.Session();
            var a  = s.Alg;
            var r1 = await a.Parse("2+3*4+3", t.Token);

            Console.WriteLine(r1);
            Console.WriteLine($"{r1} es primo: {await a.PrimeP(r1, Algebra.Core.Math.EAlgorithmPrimeP.Default, t.Token)}");
            //var r1 = await a.ParsePrompt("2+3", t.Token);

            //Print(a, r1, t.Token);

            //if (!r1.Finished)
            //{
            //    var r2 = await a.ParsePrompt("*4;", t.Token);

            //    Print(a, r2, t.Token);
            //}

            /*
             * var pParse = new Parser();
             * var r1 = await pParse.Parse("2+3", t.Token);
             *
             * if (r1.Finished)
             *  Console.WriteLine(r1.Result);
             *
             * var r2 = await pParse.Parse("*4;", t.Token);
             *
             * if (r2.Finished)
             *  Console.WriteLine(r2.Result);
             */
        }
Esempio n. 2
0
        static async Task MainAsync()
        {
            var t  = new CancellationTokenSource();
            var s  = new Algebra.Core.Session();
            var a  = s.Alg;
            var r1 = await a.ParsePrompt("2+3", t.Token);

            Print(a, r1, t.Token);

            if (!r1.Finished)
            {
                var r2 = await a.ParsePrompt("*4;", t.Token);

                Print(a, r2, t.Token);
            }

            /*
             * var pParse = new Parser();
             * var r1 = await pParse.Parse("2+3", t.Token);
             *
             * if (r1.Finished)
             *  Console.WriteLine(r1.Result);
             *
             * var r2 = await pParse.Parse("*4;", t.Token);
             *
             * if (r2.Finished)
             *  Console.WriteLine(r2.Result);
             */
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            //var n1 = (int)decimal.Parse("1.1", NumberStyles.Float, NumberFormatInfo.InvariantInfo);
            //var n2 = double.Parse("1.1", NumberFormatInfo.InvariantInfo);
            var a1 = new Algebra.Core.Session().Alg;
            //var n1 = a1.ParseNumber("1.1");

            var e1 = new NodeExprCte(100, ETypeConstant.Number);
            var e2 = new NodeExprCte(200, ETypeConstant.Number);
            var e3 = new NodeExprBinary(ETypeBinary.Add, e1, e2);

            var e11 = new NodeExprCte(10, ETypeConstant.Number);
            var e21 = new NodeExprCte(20, ETypeConstant.Number);
            var e31 = new NodeExprBinary(ETypeBinary.Add, e11, e21);

            // (100+200)*(10+20)
            var e4 = new NodeExprBinary(ETypeBinary.Mult, e3, e31);
            // (100+200)*(10+20)+(100+200)*(10+20)
            var e5 = new NodeExprBinary(ETypeBinary.Add, e4, e4);

            Console.WriteLine(e5);
            Console.ReadLine();
        }