Example #1
0
        private static string BuildLineFromTokenList(List <Token> inp)
        {
            string ret = "";

            var    refiner = RefineResolver.ResolveRefiner(inp);
            string perams  = "";

            foreach (var i in inp)
            {
                if (i.Name == "Value")
                {
                    perams += i.Value.Trim() + ",";
                }
            }
            perams = perams.TrimEnd(',');
            refiner.ParamsArray       = perams.Split(',');
            refiner.ParamsArrayTrimed = perams.Replace("\"", "").Split(',');
            refiner.Params            = perams;
            refiner.Invoke();

            ret += "\n" + File.ReadAllText(Global.DataSetLocation + "Bootstrap/" + refiner.Name + ".ec") + "\n" + refiner.InvokeStatmentBuilded + "\n";

            foreach (var i in refiner.Imports)
            {
                if (!Import.Contains(i))
                {
                    Import.Add(i);
                }
            }
            EndCode.Add(refiner.InvokeStatmentBuildedEnd);

            return(ret);
        }
Example #2
0
        public void CompileAndRun(string English, string name)
        {
            RefineResolver.LoadRefiners();
            TokenResolver.LoadTokens();

            var tokens     = Lexser.GetCodeTokens(English);
            var CSharpCode = Parser.BuildEcCodeFromTokens(tokens);


            CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary <String, String> {
                { "CompilerVersion", "v4.0" }
            });


            CompilerParameters compilerParams = new CompilerParameters
            {
                GenerateInMemory   = true,
                GenerateExecutable = true
            };

            compilerParams.ReferencedAssemblies.Add("mscorlib.dll");
            compilerParams.OutputAssembly = name + ".exe";
            compilerParams.ReferencedAssemblies.Add("System.dll");
            compilerParams.ReferencedAssemblies.Add("System.Windows.Forms.dll");
            CompilerResults results = provider.CompileAssemblyFromSource(compilerParams, CSharpCode.Replace("{dot}", "."));

            if (results.Errors.Count != 0)
            {
                throw new Exception("Mission failed!");
            }
        }
Example #3
0
        public string GetCode(string English)
        {
            RefineResolver.LoadRefiners();
            TokenResolver.LoadTokens();

            var tokens = Lexser.GetCodeTokens(English);

            return(Parser.BuildEcCodeFromTokens(tokens));
        }