Beispiel #1
0
        private void runLexico(object sender, EventArgs e)
        {
            runLexico();
            runSintactico();
            runSemantico();
            sintaxTreeView.Nodes.Clear();
            semanticTreeView.Nodes.Clear();
            //READ SINTAX TREE
            Node root = JsonConvert.DeserializeObject <Node>(sintaxJsonText);
            //TreeNode rootNode = populateSintaxTree(root);
            TreeNode rootNode = new TreeNode(root.name);

            populateTreeV2(rootNode, root);
            sintaxTreeView.Nodes.Add(rootNode);
            sintaxTreeView.ExpandAll();
            //READ SEMANTIC TREE
            Node2 rootSemantic = JsonConvert.DeserializeObject <Node2>(semanticJsonText);
            //TreeNode rootNode = populateSintaxTree(root);
            TreeNode semanticRootNode = new TreeNode(rootSemantic.name);

            populateTreeV2Semantic(semanticRootNode, rootSemantic);
            semanticTreeView.Nodes.Add(semanticRootNode);
            semanticTreeView.ExpandAll();
            //Leer hash table: hashTableTextBox
            CodeTabPage tabPage   = (CodeTabPage)codeTabControl.SelectedTab;
            Char        delimiter = '.';
            String      fName     = tabPage.getCodeEditor().getName().Split(delimiter)[0];
            String      fullName  = tabPage.getCodeEditor().getName();
            String      path      = tabPage.getCodeEditor().getPath();
            String      okPath    = path.Substring(0, path.Length - fullName.Length);
            String      filePath  = okPath + "/target_" + fName + "/sem/tabla.sem";

            cargarTabla(filePath);
            lexerErrTextBox.Text.Contains('E');

            MessageBox.Show("Resultados de errores: " + lexerErrTextBox.Text.Contains('E') + " " + semanticErrorTextBox.Text.Contains('S') + " " + sintaxErrorTextBox.Text.Contains('S'));
            if (!lexerErrTextBox.Text.Contains('E') && !sintaxErrorTextBox.Text.Contains('S'))
            {
                runCodeGen();
                tabContenedor.SelectedIndex = 4;
                Consola.ClearOutput();
                Consola.StopProcess();
                Consola.StartProcess(@"cmd", "/c tinym code.tm");
            }
            else
            {
                MessageBox.Show("No se puede ejecutar ya que hay errores.");
            }
        }
Beispiel #2
0
        private void runSemantico()
        {
            CodeTabPage tabPage = (CodeTabPage)codeTabControl.SelectedTab;
            Process     process = new Process();

            semanticErrorTextBox.Text                = "";
            CheckForIllegalCrossThreadCalls          = false;
            process.StartInfo.FileName               = @"cmd";
            process.StartInfo.Arguments              = "/c tiny -c \"" + tabPage.getCodeEditor().getPath() + "\"";
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;


            process.ErrorDataReceived += new DataReceivedEventHandler(OutputHandlerSemantic);
            process.Start();
            //* Read one element asynchronously
            process.BeginErrorReadLine();
            //* Read the other one synchronously
            semanticJsonText = "";
            string output = process.StandardOutput.ReadToEnd();

            //Console.Write(output);
            semanticJsonText += output;
            process.Close();
        }
Beispiel #3
0
        private void codeTabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            CodeTabPage tabPage = (CodeTabPage)codeTabControl.SelectedTab;

            if (tabPage != null && tabPage.getCodeEditor().hasPath())
            {
                enableCompilationButtons();
            }
            else
            {
                disableCompilationButtons();
            }
        }
Beispiel #4
0
        private void runCodeGen()
        {
            CodeTabPage tabPage = (CodeTabPage)codeTabControl.SelectedTab;
            Process     process = new Process();

            semanticErrorTextBox.Text                = "";
            CheckForIllegalCrossThreadCalls          = false;
            process.StartInfo.FileName               = @"cmd";
            process.StartInfo.Arguments              = "/c tiny -g \"" + tabPage.getCodeEditor().getPath() + "\"";
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = false;
            process.Start();
            //* Read one element asynchronously
            //* Read the other one synchronously
            string output = process.StandardOutput.ReadToEnd();

            //Console.Write(output);
            process.Close();
            cargarCodigoIntermedio();
        }