Ejemplo n.º 1
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!");
            }
        }
Ejemplo n.º 2
0
        public string GetCode(string English)
        {
            RefineResolver.LoadRefiners();
            TokenResolver.LoadTokens();

            var tokens = Lexser.GetCodeTokens(English);

            return(Parser.BuildEcCodeFromTokens(tokens));
        }
Ejemplo n.º 3
0
        // return a list with all the statmenst in and ther etokens
        public static List <List <Token> > GetCodeTokens(string English)
        {
            var ret = new List <List <Token> >();

            /*
             * We need to split the sentinces like follow
             * Content(, | .) = Statment
             * then get all the tokens in a statment
             * add them to a list then ad the list to the statment list
             */
            string[] Statments = BuildIt(English).Split('.');
            foreach (var i in Statments)
            {
                if (!string.IsNullOrEmpty(i))
                {
                    ret.Add(TokenResolver.ResolveTextToToken(i));
                }
            }

            return(ret);
        }