Ejemplo n.º 1
0
        private void FastColoredTextBox1_TextChangedDelayed(object sender, TextChangedEventArgs e)
        {
            SudoC_Lexxer    sudoC_Lexxer    = new SudoC_Lexxer();
            SudoC_Assembler sudoC_Assembler = new SudoC_Assembler();
            CompilerStats   compilerStats   = new CompilerStats();

            try
            {
                Statics.reset();
                var CurrentTime0 = DateTime.Now;
                var Lexxed       = sudoC_Lexxer.Lex(fctbMainEditor.Text);
                var CurrentTime1 = DateTime.Now;

                var CurrentTime2 = DateTime.Now;
                var Assembled    = sudoC_Assembler.Assemble(Lexxed);
                var CurrentTime3 = DateTime.Now;
                compilerStats.LexxerStartTime    = CurrentTime0;
                compilerStats.LexxerEndTime      = CurrentTime1;
                compilerStats.LexxerTime         = CurrentTime1.Subtract(CurrentTime0);
                compilerStats.AssemblerStartTime = CurrentTime2;
                compilerStats.AssemblerEndTime   = CurrentTime3;
                compilerStats.AssemblerTime      = CurrentTime3.Subtract(CurrentTime2);

                fctbCWindow.Text = Assembled;

                lStatus.Text = ("Finished!");


                BuildAutocompleteMenu();
            }
            catch (Exception ex)
            {
                lStatus.Text = ex.Message;
                if (bThrow)
                {
                    throw;
                }
            }
            var statics = new LocalStatics();

            statics.fVersionNumber     = Statics.fVersionNumber;
            statics.dContexts          = Statics.dContexts;
            statics.dDefines           = Statics.dDefines;
            statics.lImports           = Statics.lImports;
            statics.lVars              = Statics.lVars;
            statics.iStringNameCounter = Statics.iStringNameCounter;
            CompilerValues compilerValues = new CompilerValues();

            compilerValues.LocalStatics    = statics;
            compilerValues.SudoC_Assembler = sudoC_Assembler;
            compilerValues.SudoC_Lexxer    = sudoC_Lexxer;
            fctbCompilerValues.Text        = JsonConvert.SerializeObject(compilerValues, Formatting.Indented);
            fctbCompilerStats.Text         = JsonConvert.SerializeObject(compilerStats, Formatting.Indented);
            jsonTreeView.ShowJson(fctbCompilerValues.Text);
        }
Ejemplo n.º 2
0
        public string Do(string Command, string[] Args)
        {
            switch (Command)
            {
            case "compile":
                SudoC_Lexxer    Sdk_Lexxer    = new SudoC_Lexxer();
                SudoC_Assembler Sdk_Assembler = new SudoC_Assembler();
                return(Sdk_Assembler.Assemble(Sdk_Lexxer.Lex(Args[0])));

            case "clr":
                Statics.reset();
                return("true");

            case "open":
                try
                {
                    Process compilerProcces = new Process();

                    ProcessStartInfo compilerProcessStartInfo = new ProcessStartInfo("SudoC_Windows.exe", Args[0] + @" \o");
                    compilerProcces.OutputDataReceived             += GccProcess_OutputDataReceived;;
                    compilerProcessStartInfo.UseShellExecute        = false;
                    compilerProcessStartInfo.CreateNoWindow         = true;
                    compilerProcessStartInfo.RedirectStandardOutput = true;
                    compilerProcces.StartInfo = compilerProcessStartInfo;
                    compilerProcces.Start();
                    compilerProcces.BeginOutputReadLine();
                    compilerProcces.WaitForExit();
                    sOutput  = sBuilder;
                    sBuilder = "";
                    return(sOutput);
                }
                catch (Exception x)
                {
                    return(x.Message);
                }

            default:
                return("Can't Recognize Command");
            }
        }
Ejemplo n.º 3
0
        public SudoC_Pair[] Loop(string sCompleteName, string sRepeater, string sConstructor)
        {
            //     sConstructor.Replace(@"\;", ";");
            List <SudoC_Pair> Lexxed_Code = new List <SudoC_Pair>();
            bool   bDoInput            = false;
            bool   bGenerateName       = false;
            string sPrivateConstructor = "";
            var    sVarName            = "Input" + Statics.iStringNameCounter;
            string sBuilder            = "";

            if (sRepeater.Contains("input"))
            {
                foreach (char Char in sRepeater)
                {
                    sBuilder += Char;
                    if (sBuilder.Contains("input"))
                    {
                        bDoInput = true;
                        if (Char == '>')
                        {
                            if (sPrivateConstructor != string.Empty)
                            {
                                sVarName = sPrivateConstructor;
                            }
                            else
                            {
                                sVarName = "Input" + Statics.iStringNameCounter;
                            }
                        }
                        if (bGenerateName)
                        {
                            sPrivateConstructor += Char;
                        }
                        if (Char == '<')
                        {
                            bGenerateName = true;
                        }
                    }
                }
            }
            if (bDoInput)
            {
                if (!Statics.lVars.Contains(sVarName))
                {
                    Lexxed_Code.Add(new SudoC_Pair(SudoCInnerCode.vstring, new string[2] {
                        sVarName, string.Empty
                    }));
                    Statics.iStringNameCounter++;
                }
                Lexxed_Code.Add(new SudoC_Pair(SudoCInnerCode.scan, new string[1] {
                    sVarName
                }));
                Statics.lVars.Add(sVarName);
                var sudoc_lexxerSecondary    = new SudoC_Lexxer();
                var soduc_assemblerSecondary = new SudoC_Assembler();
                Lexxed_Code.Add(new SudoC_Pair(SudoCInnerCode.foreachloop, new string[3] {
                    sVarName, sCompleteName, soduc_assemblerSecondary.Assemble(sudoc_lexxerSecondary.Lex(sConstructor), true)
                }));
            }
            else
            {
                var sudoc_lexxerSecondary    = new SudoC_Lexxer();
                var soduc_assemblerSecondary = new SudoC_Assembler();
                Lexxed_Code.Add(new SudoC_Pair(SudoCInnerCode.foreachloop, new string[3] {
                    sRepeater, sCompleteName, soduc_assemblerSecondary.Assemble(sudoc_lexxerSecondary.Lex(sConstructor), true)
                }));
            }
            return(Lexxed_Code.ToArray());
        }