示例#1
0
文件: Form1.cs 项目: hibe33/YMH319
 public static bool hafizayaKaydet(Degisken degisken)
 {
     foreach (Degisken d in degiskenListesi)
     {
         if (d.getIsim() == degisken.getIsim())
         {
             OUTPUT_PANEL.write(degisken.getIsim() + "değişkeni tekrardan atandı....");
             d.degerAta(degisken.getDeger());
             return(true);
         }
     }
     degiskenListesi.Add(degisken);
     return(true);
 }
示例#2
0
文件: Form1.cs 项目: hibe33/YMH319
        public static void LineControl(TextBox editor)
        {
            for (int lineIndex = 0; lineIndex < editor.Lines.Length; lineIndex++)
            {
                String line = editor.Lines[lineIndex];

                String[] wordList = line.Split(' ');
                try {
                    for (int wordIndex = 0; wordIndex < wordList.Length; wordIndex++)
                    {
                        if (wordList[wordIndex].ToString() == SYNTAX.NUMBER)
                        {
                            OUTPUT_PANEL.write("Değişken belirtimi algılandı...");
                            if (wordList[wordIndex + 2] == SYNTAX.ATAMA)
                            {
                                OUTPUT_PANEL.write("Atama operatörü algılandı...");
                                string degiskenAdi = wordList[wordIndex + 1];
                                double degiskenDegeri;
                                if (wordList[wordIndex + 4] == SYNTAX.END_OF_LINE && Double.TryParse(wordList[wordIndex + 3], out degiskenDegeri))
                                {
                                    Degisken degisken = new Degisken(degiskenAdi, degiskenDegeri);
                                    hafizayaKaydet(degisken);
                                }

                                else if (wordList[wordIndex + 4] == SYNTAX.END_OF_LINE && isOperantion(wordList[wordIndex + 3]))
                                {
                                    try
                                    {
                                        Degisken degisken = new Degisken(degiskenAdi, dortIslem(wordList[wordIndex + 3], lineIndex));
                                        hafizayaKaydet(degisken);
                                    }
                                    catch
                                    {
                                        OUTPUT_PANEL.write(ERRORS.INVALID_OPERATION + lineIndex);
                                    }
                                }
                            }
                        }
                        else if (wordList[wordIndex].ToString() == SYNTAX.YAZDIR)
                        {
                            if (memoryIsContain(wordList[wordIndex + 1].ToString()))
                            {
                                OUTPUT_PANEL.write(getDegiskenFromMemory(wordList[wordIndex + 1]).toString());
                            }
                            else if (isOperantion(wordList[wordIndex + 1]))
                            {
                                try
                                {
                                    OUTPUT_PANEL.write(dortIslem(wordList[wordIndex + 1].ToString(), lineIndex).ToString());
                                }
                                catch
                                {
                                    OUTPUT_PANEL.write(ERRORS.INVALID_OPERATION + lineIndex);
                                }
                            }
                        }
                        else if (wordList[wordList.Length - 1].ToString() != ";")
                        {
                            OUTPUT_PANEL.write(ERRORS.END_OF_LINE_EXPECTING + lineIndex);
                        }
                    }
                }
                catch
                {
                    StopWithError(ERRORS.INVALID_SYNTAX);
                    break;
                }
            }
        }
示例#3
0
文件: Form1.cs 项目: hibe33/YMH319
 public static void StopWithError(string error)
 {
     degiskenListesi.Clear();
     OUTPUT_PANEL.write(error);
     OUTPUT_PANEL.write("PROGRAM DURDURULDU!");
 }
示例#4
0
 public Degisken(string isim, double deger)
 {
     OUTPUT_PANEL.write(isim + " değişkeni oluşturuldu...");
     this.isim  = isim;
     this.deger = deger;
 }