Beispiel #1
0
        public RunApp(string fileName)
        {
            var b       = new BuildLanguage();
            var classes = b.Run(File.ReadAllText(fileName));


            var r = new BuildExpressions();
            List <SpokeClass> cla = r.Run(classes.Item1, classes.Item2);

            var    br = new PrintExpressions(cla, false);
            string f;

            File.WriteAllText("C:\\spokes.txt", f = br.Run());
            //    Console.WriteLine(f);
        }
Beispiel #2
0
        public Tuple<SpokeQuestion, string, GameBoard> Begin(string fileName, Dictionary<string, Func<SpokeObject[], SpokeObject>> rv, Dictionary<string, SpokeType> intenMethodTypes, string stack, int returnIndex)
        {
            CompiledApp cp;
            if (CompiledApps.TryGetValue(fileName, out cp))
            {
                return runInstructions(cp.Ce, cp.Dfe, stack, returnIndex);
            }


            Stopwatch sw = new Stopwatch();
            // try { 

            Console.WriteLine(fileName);

            Console.WriteLine("Building language...");
            sw.Start();
            var b = new BuildLanguage();
            Tuple<List<Class>, List<TokenMacroPiece>> classes = b.Run(File.ReadAllText(fileName));
            sw.Stop();
            Console.WriteLine("Building language done in " + sw.ElapsedMilliseconds + " milliseconds");

            sw.Reset();

            Console.WriteLine("Builing expressions...");
            sw.Restart();
            var r = new BuildExpressions();
            List<SpokeClass> cla = r.Run(classes.Item1, classes.Item2);
            sw.Stop();
            Console.WriteLine("Building expressions done in " + sw.ElapsedMilliseconds + " milliseconds");

            sw.Reset();




            Console.WriteLine("Preparsing expressions...");
            sw.Restart();
            Tuple<SpokeMethod[], SpokeConstruct, Dictionary<string, string[]>> dfe = preparse(intenMethodTypes, cla);
            sw.Stop();
            Console.WriteLine("Preparsing expressions done in " + sw.ElapsedMilliseconds + " milliseconds");
            sw.Reset();


            Console.WriteLine("Printing expressions...");
            sw.Restart();
            var br = new PrintExpressions(cla, false);

            File.WriteAllText("C:\\spokesi.txt", br.Run());
            sw.Stop();
            Console.WriteLine("Printing expressions done in " + sw.ElapsedMilliseconds + " milliseconds");
            sw.Reset();

            Console.WriteLine("Preparsing Instructions...");
            sw.Restart();
            new PreparseInstructions(dfe.Item1);

            File.WriteAllText("C:\\spokesi.txt", br.Run());
            sw.Stop();
            Console.WriteLine("Preparsing Instructions done in " + sw.ElapsedMilliseconds + " milliseconds");
            sw.Reset();

            Func<SpokeObject[], SpokeObject>[] ce = rv.Select(a => a.Value).ToArray();

#if runExpressions
            
            Console.WriteLine("RUNNING Expressions" + fileName.Split('.')[0] + "...");
            sw.Restart();
            
            
            runExpression(ce,dfe);
            sw.Stop();


            Console.WriteLine("Done in " + sw.ElapsedMilliseconds + " milliseconds");
            Console.WriteLine("");
            Console.WriteLine("------------------------------------------------");
            Console.WriteLine("");
#endif
#if runExpressions && runInstructions
            Console.ReadLine();
#endif
#if runInstructions
            Console.WriteLine("RUNNING Instructions" + fileName.Split('.')[0] + "...");
            sw.Restart();

            var Saver = new CompiledApp(ce, dfe);
            CompiledApps.Add(fileName, Saver);

            return runInstructions(ce, dfe, stack, returnIndex);
            sw.Stop();


            Console.WriteLine("Done in " + sw.ElapsedMilliseconds + " milliseconds");
            Console.WriteLine("");
            Console.WriteLine("------------------------------------------------");
            Console.WriteLine("");
#endif
#if runClass && runInstructions
            Console.ReadLine();
#endif

#if runClass || runClass2
            var com = buildClass(ce, dfe);
#endif
#if runClass 
            Console.WriteLine("Running Class " + fileName.Split('.')[0] + "...");
            sw.Restart();
            runClass(com, ce, dfe.Item1);
            sw.Stop();
            Console.WriteLine("Done in " + sw.ElapsedMilliseconds + " milliseconds");
            Console.WriteLine("");
            Console.WriteLine("------------------------------------------------");
            Console.WriteLine("");

#endif
#if runClass && runClass2
            Console.ReadLine();
#endif

#if runClass2
            Console.WriteLine("Running Class2 " + fileName.Split('.')[0] + "...");
            sw.Restart();

            runClass2(ce, dfe.Item1, dfe.Item2);
            sw.Stop();
            Console.WriteLine("Done in " + sw.ElapsedMilliseconds + " milliseconds");
            Console.WriteLine("");
            Console.WriteLine("------------------------------------------------");
            Console.WriteLine("");

#endif

            //  } catch(Exception ecx) {
            //    Console.WriteLine(ecx.ToString());


            //  Console.WriteLine("Failed in " + sw.ElapsedMilliseconds + " milliseconds");
            Console.WriteLine("");
            Console.WriteLine("------------------------------------------------");
            Console.WriteLine("");

            // }
#if !dontwrite
            Console.ReadLine();
#endif

        }
Beispiel #3
0
        public RunApp(string fileName, Dictionary <string, Func <SpokeObject[], SpokeObject> > rv, Dictionary <string, SpokeType> intenMethodTypes)
        {
            Stopwatch sw = new Stopwatch();

            // try {

            Console.WriteLine(fileName);
            string name = fileName.Split('.')[0];

            Console.WriteLine("Building language...");
            sw.Start();
            var b = new BuildLanguage();
            Tuple <List <Class>, List <TokenMacroPiece> > classes = b.Run(File.ReadAllText(fileName));

            sw.Stop();
            Console.WriteLine("Building language done in " + sw.ElapsedMilliseconds + " milliseconds");

            sw.Reset();

            Console.WriteLine("Builing expressions...");
            sw.Restart();
            var r = new BuildExpressions();
            List <SpokeClass> cla = r.Run(classes.Item1, classes.Item2);

            sw.Stop();
            Console.WriteLine("Building expressions done in " + sw.ElapsedMilliseconds + " milliseconds");

            sw.Reset();



            Console.WriteLine("Preparsing expressions...");
            sw.Restart();
            Tuple <SpokeMethod[], SpokeConstruct> dfe = preparse(intenMethodTypes, cla);

            sw.Stop();
            Console.WriteLine("Preparsing expressions done in " + sw.ElapsedMilliseconds + " milliseconds");
            sw.Reset();


            Console.WriteLine("Printing expressions...");
            sw.Restart();
            var br = new PrintExpressions(cla, false);

            File.WriteAllText("C:\\spokesi.txt", br.Run());
            sw.Stop();
            Console.WriteLine("Printing expressions done in " + sw.ElapsedMilliseconds + " milliseconds");
            sw.Reset();

            Console.WriteLine("Preparsing Instructions...");
            sw.Restart();
            new PreparseInstructions(dfe.Item1);

            File.WriteAllText("C:\\spokesi.txt", br.Run());
            sw.Stop();
            Console.WriteLine("Preparsing Instructions done in " + sw.ElapsedMilliseconds + " milliseconds");
            sw.Reset();

            Func <SpokeObject[], SpokeObject>[] ce = rv.Select(a => a.Value).ToArray();

#if runExpressions
            Console.WriteLine("RUNNING Expressions" + fileName.Split('.')[0] + "...");
            sw.Restart();


            runExpression(ce, dfe);
            sw.Stop();


            Console.WriteLine("Done in " + sw.ElapsedMilliseconds + " milliseconds");
            Console.WriteLine("");
            Console.WriteLine("------------------------------------------------");
            Console.WriteLine("");
#endif
#if runExpressions && runInstructions
            Console.ReadLine();
#endif
#if runInstructions
            Console.WriteLine("RUNNING Instructions" + fileName.Split('.')[0] + "...");
            sw.Restart();


            runInstructions(ce, dfe);
            sw.Stop();


            Console.WriteLine("Done in " + sw.ElapsedMilliseconds + " milliseconds");
            Console.WriteLine("");
            Console.WriteLine("------------------------------------------------");
            Console.WriteLine("");
#endif
#if runClass && runInstructions
            Console.ReadLine();
#endif

#if runClass || runClass2
            var com = buildClass(ce, dfe, name);
#endif
#if runClass
            Console.WriteLine("Running Class " + fileName.Split('.')[0] + "...");
            sw.Restart();
            runClass(com.Item1, ce, dfe.Item1);
            sw.Stop();
            BuildFile.Cleanup(com);
            Console.WriteLine("Done in " + sw.ElapsedMilliseconds + " milliseconds");
            Console.WriteLine("");
            Console.WriteLine("------------------------------------------------");
            Console.WriteLine("");
#endif
#if runClass && runClass2
            Console.ReadLine();
#endif

#if runClass2
            Console.WriteLine("Running Class2 " + fileName.Split('.')[0] + "...");
            sw.Restart();

            runClass2(ce, dfe.Item1, dfe.Item2);
            sw.Stop();
            Console.WriteLine("Done in " + sw.ElapsedMilliseconds + " milliseconds");
            Console.WriteLine("");
            Console.WriteLine("------------------------------------------------");
            Console.WriteLine("");
#endif

            //  } catch(Exception ecx) {
            //    Console.WriteLine(ecx.ToString());


            //  Console.WriteLine("Failed in " + sw.ElapsedMilliseconds + " milliseconds");
            Console.WriteLine("");
            Console.WriteLine("------------------------------------------------");
            Console.WriteLine("");

            // }
#if !dontwrite
            Console.ReadLine();
#endif
        }