Exemple #1
0
        /// <summary>
        /// constructorul clasei sintactic, creaza un analizor sintactic
        /// </summary>
        /// <param name="lista">codul pascal inpartit pe linii</param>
        /// <param name="text">obiect de tip textbox in care se va afisa codul C care se produce in urma compilarii</param>
        public Sintactic(string[] lista, TextBox text)
        {
            this.lex = new Lexical(lista);
            this.text = text;
            this.text.Text = "";
            this.codPascal = lista;
            this.lex.Analizare();
            urmator_atom = lex.UrmatorAtom();

            lista_variabile.Add("integer", "tipvariabila");
            lista_variabile.Add("char", "tipvariabila");
            lista_variabile.Add("real", "tipvariabila");
            lista_variabile.Add("longint", "tipvariabila");
            lista_variabile.Add("record", "tipvariabila");
        }
Exemple #2
0
        private void analizaCod(object sender, EventArgs e)
        {
            if (pascalBox.Text != "")
            {
                cBox.Text = "";
                rightLabel.Text = "Identificatori Atomi";
                pascalCode = pascalBox.Text.Split('\r');
                for (int i = 0; i < pascalCode.Length; i++)
                {
                    pascalCode[i] = pascalCode[i].Replace("\n", "");
                    pascalCode[i] = pascalCode[i].Replace("\r", "");
                }

                cBox.Text = "";
                Lexical lex = new Lexical(pascalCode);
                lex.Analizare();
                Atom get = lex.UrmatorAtom();
                while (get != null)
                {
                    cBox.Text += get.indice + "\t-\t" + get.valoare + "\r\n";
                    get = lex.UrmatorAtom();
                }
            }
        }