Esempio n. 1
0
        void dataProgram()
        {
            Console.WriteLine(".DATA");
            fOut.WriteLine(".DATA");
            Console.WriteLine("; Переменные из С++");
            fOut.WriteLine("; Переменные из С++");
            foreach (var variable in Identificators.variable_table.Keys)
            {
                Console.Write(variable + " ");
                fOut.Write(variable + " ");
                if (Identificators.GetTypeByName(variable) == "int")
                {
                    Console.WriteLine("DD ?");
                    fOut.WriteLine("DD ?");
                }
                if (Identificators.GetTypeByName(variable) == "float")
                {
                    Console.WriteLine("REAL8 ?");
                    fOut.WriteLine("REAL8 ?");
                }
                if (Identificators.GetTypeByName(variable) == "char")
                {
                    Console.WriteLine("DB ?");
                    fOut.WriteLine("DB ?");
                }
            }

            Console.WriteLine("; Константы из С++");
            fOut.WriteLine("; Константы из С++");
            foreach (var constant in Constants.variable_table.Keys)
            {
                Console.Write("Const" + Constants.SearchIdByName(constant).ToString());
                fOut.Write("Const" + Constants.SearchIdByName(constant).ToString());

                if (Constants.GetTypeByName(constant) == "int")
                {
                    Console.WriteLine(" DD " + constant);
                    fOut.WriteLine(" DD " + constant);
                }
                if (Constants.GetTypeByName(constant) == "float")
                {
                    Console.WriteLine(" REAL8 " + constant);
                    fOut.WriteLine(" REAL8 " + constant);
                }
                if (Constants.GetTypeByName(constant) == "char")
                {
                    Console.WriteLine(" DB " + constant + ", 0");
                    fOut.WriteLine(" DB " + constant + ", 0");
                }
            }
            Console.WriteLine();
            fOut.WriteLine();
        }
        private int[] GetToken(string name, bool flag)
        {
            int id = -1;

            if (!flag)
            {
                if (name.Length <= 2)
                {
                    if ((id = Operations.SearchIdByName(name)) != -1)
                    {
                        return new int[] { 0, id }
                    }
                    ;
                    if ((id = Divisions.SearchIdByName(name)) != -1)
                    {
                        return new int[] { 1, id }
                    }
                    ;
                }

                if ((id = KeyWords.SearchIdByName(name)) != -1)
                {
                    return new int[] { 2, id }
                }
                ;
            }
            if (flag)
            {
                id = Constants.SearchIdByName(name);
                Constants.SetType(name, typeconst);
                return(new int[] { 3, id });
            }
            else
            {
                if (name.Length != 0)
                {
                    id = Identificators.SearchIdByName(name);
                }
                return(new int[] { 4, id });
            }
        }