Ejemplo n.º 1
0
        private void OpenFile()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.InitialDirectory = @"C:\";
            ofd.Title            = "Browse Text Files";
            ofd.CheckFileExists  = true;
            ofd.CheckPathExists  = true;
            ofd.DefaultExt       = "txt";
            ofd.Filter           = "Text files (*.txt)|*.txt|Megazord files (*.mgzd)|*.mgzd";
            ofd.FilterIndex      = 2;
            ofd.RestoreDirectory = true;
            ofd.ReadOnlyChecked  = true;
            ofd.ShowReadOnly     = true;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(ofd.FileName);
                //richTextBox.Text = sr.ReadToEnd();
                fileOpenNow = ofd.FileName;

                string filenameWithoutPath = Path.GetFileName(ofd.FileName);

                var tabControl = new CustomTab(filenameWithoutPath, sr.ReadToEnd(), fileOpenNow, this);
                richTextBox = tabControl.getRichTextBox();

                tabControl1.TabPages.Add(tabControl);
                tabControl1.SelectedIndex = tabControl1.TabCount - 1;
                showHideItens();
                sr.Close();
            }
        }
Ejemplo n.º 2
0
        private void NewFile()
        {
            if (tabControl1.TabPages.Count <= 0)
            {
                fileOpenNow = "";
            }

            var tabControl = new CustomTab("New file", "", "", this);

            richTextBox = tabControl.getRichTextBox();

            tabControl1.TabPages.Add(tabControl);
            tabControl1.SelectedIndex = tabControl1.TabCount - 1;
            showHideItens();
        }
Ejemplo n.º 3
0
        private void RunFile()
        {
            TS    TabelaSimbolos = new TS();
            Token token;

            textOutput.Clear();
            textError.Clear();

            if (tabControl1.TabPages.Count <= 0)
            {
                return;
            }

            CustomTab customTab = (CustomTab)tabControl1.TabPages[tabControl1.SelectedIndex];

            customTab.panelError.getRichOutput.Text = "";
            customTab.panelError.getRichError.Text  = "";

            if (string.IsNullOrEmpty(fileOpenNow))
            {
                SaveFile();
            }

            try
            {
                Analise_Lexica analise = new Analise_Lexica(fileOpenNow, TabelaSimbolos);

                do
                {
                    //chamda parao proximo token que sera lido
                    token = analise.ProximoToken(ref textOutput, ref textError);

                    if (token != null)
                    {
                        //imprime o token com linas e colunas
                        textOutput.Text += "Token: " + token.toString() + "\t Linha: " + analise.linha + "\t Coluna: " + analise.coluna + "\n";
                    }
                } while (token != null && token.Classe != Lexer.Tag.EOF); // do while só para se chegar no fim do arquivo

                textOutput.Text += "\n";
                textOutput.Text += "Tabela de simbolos: \n";
                textOutput.Text += TabelaSimbolos.toString();

                customTab.panelError.getRichOutput.Text = textOutput.Text;
                customTab.panelError.hideError();
                customTab.panelError.showOutput();

                if (!string.IsNullOrEmpty(textError.Text))
                {
                    customTab.panelError.getRichError.Text = textError.Text;
                }
                //customTab.panelError.showError();

                //var outputForm = new OutputForm(this);
                //outputForm.Show();

                //tabControl1.SelectedIndex = tabControl1.TabCount - 1;

                //fecha o arquivo depos de ter terminado a analise
                analise.Fechar_Arquivo();
            }
            catch (Exception)
            {
                throw;
            }
        }