Добавил:
Tushkan
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Курсовой проект / Unit1
.cpp// ---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Analiz.cpp"
#include "post.cpp"
#include "calc.cpp"
// ---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
Analiz an;
Post bn;
Calc cn;
list<ItemD> output;
// ---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) {
}
// ---------------------------------------------------------------------------
void __fastcall TForm1::edtInputChange(TObject *Sender) {
btnCalc->Enabled = false;
btnPost->Enabled = false;
edtError->Text = "";
edtOutput->Text = "";
edtPostfix->Text = "";
edtResult->Text = "";
edtRes->Text = "";
StringGrid1->RowCount = 1;
}
// ---------------------------------------------------------------------------
void __fastcall TForm1::btnAnalizClick(TObject *Sender) {
btnPost->Enabled =an.analiz(edtInput->Text);
edtError->Text = an.text;
edtOutput->Text = an.output;
edtPostfix->Text = "";
edtResult->Text = "";
edtRes->Text = "";
}
// ---------------------------------------------------------------------------
void __fastcall TForm1::btnPostClick(TObject *Sender) {
StringGrid1->RowCount = 1;
output = bn.convert(an.lex);
btnCalc->Enabled = btnPost->Enabled;
edtPostfix->Text = "";
edtResult->Text = "";
edtRes->Text = "";
for (list<ItemD>::iterator it = output.begin(); it != output.end(); it++) {
edtPostfix->Text = edtPostfix->Text + (*it).value + " ";
if ((*it).type == 7) {
bool flag = true;
for (int j = 0; flag && (j < StringGrid1->RowCount); j++)
if (StringGrid1->Cells[0][j] == (*it).value)
flag = false;
if (flag) {
StringGrid1->RowCount++;
StringGrid1->Cells[0][ StringGrid1->RowCount-1] = (*it).value;
StringGrid1->Cells[1][ StringGrid1->RowCount-1] = "0x00000000";
}
}
}
try {
StringGrid1->FixedRows = 1;
} catch (...) {};
}
// ---------------------------------------------------------------------------
void __fastcall TForm1::btnCalcClick(TObject *Sender) {
list<ItemD> input = output;
for (int i = 1; i < StringGrid1->RowCount; i++) {
for (list<ItemD>::iterator it = input.begin(); it != input.end(); it++)
if (((*it).type == 7) && (*it).value == StringGrid1->Cells[0][i]) {
(*it).value = StringGrid1->Cells[1][i];
(*it).type = 6;
}
}
edtResult->Text = "";
for (list<ItemD>::iterator it = input.begin(); it != input.end(); it++)
{
if ((*it).type == 6) {
(*it).value.Delete(1, 2);
if ((*it).value.Length() > 8)
(*it).value.Delete(1, (*it).value.Length() - 8);
el
for (; (*it).value.Length() < 8; )
(*it).value = "0" + (*it).value;
(*it).value = "0x" + (*it).value;
}
edtResult->Text = edtResult->Text + (*it).value + " ";
}
edtRes->Text = cn.calc(input);
}
// ---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
StringGrid1->Cells[0][0] = "Имя переменной";
StringGrid1->Cells[1][0] = "Значение";
}
//---------------------------------------------------------------------------
Соседние файлы в папке Курсовой проект