コード例 #1
0
        public void Compile(string sourcecode)
        {
            CodeModifySource = string.Empty;

            DateTime date  = DateTime.Now;
            var      graph = Lex.Analysis(sourcecode);

            Utils.SaveTime("Lex", date);

            date = DateTime.Now;
            var paths = graph.AllPaths(Norm).OrderByDescending(p => p.Cost);

            Utils.SaveTime("GetPaths", date);

            date = DateTime.Now;
            for (int i = 0; i < paths.Count() && i < 3; i++)
            {
                var symbols       = GetSymbols(paths.ElementAt(i));
                var pertinenceSyn = Syn.Validate(symbols);
                if (pertinenceSyn > 0)
                {
                    FixSyntatic = new FixSyn(Syn.GraphsSyntactic[0].Root, Grammar);

                    NodeToTreeContainer nttc = new NodeToTreeContainer(FixSyntatic.NodeResult, NameVars, symbols);

                    CodeModifySource = string.Empty;
                    MountCodeModifySource(FixSyntatic.NodeResult);
                    CodeModifySource = CodeModifySource.TrimStart();
                    Compile(nttc);

                    PertinenceLex   = paths.ElementAt(i).Cost;
                    PertinenceSyn   = pertinenceSyn;
                    PertinenceTotal = Norm.Calculate(PertinenceLex, PertinenceSyn);
                    break;
                }
            }
            Utils.SaveTime("ValidateSyn", date);

            GC.Collect();
            if (OnCompile != null)
            {
                OnCompile(this);
            }
        }