Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Отчет Л.р.4 ШАВРОВА.docx
Скачиваний:
5
Добавлен:
31.03.2015
Размер:
1.49 Mб
Скачать

Оглавление

Main.cpp

__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) 17

void Prints(rez &R) 17

void __fastcall TForm1::BitBtn1Click(TObject *Sender) 18

LeksBlok.h

void Strcpy(char mas[], int n, char *txt, int m); 19

void LeksichBlok(Ident &I, char *txt); 19

LeksBlok.cpp

void Strcpy(char mas[], int n, char *txt, int m) 19

void LeksichBlok(Ident &I, char *txt) 20

Sintaksis.h

void Sint(Ident &I, rez &R); 21

Sintaksis.cpp

void Sint(Ident &I, rez &R) 21

Interpretator.h

void Inter(Ident &I, rez &R); 27

Interpretator.cpp

int pow (int x, int y) 27

void Inter(Ident &I, rez &R) 28

Data.h

struct elem 28

struct rez 29

class ErrOverFlow 29

class ErrIdent 29

class ErrSimb 29

class ErrSearch 29

class ErrInvChain 29

class Ident 29

Data.cpp

Ident::Ident() 29

Ident::~Ident() 29

int Hesh (int d, char *c, char name[] = 0) 30

int Ident::Add(elem z) 30

int Ident::Search (elem el) 30

void Ident::Delete(elem el) 30

Stack_mass.h

class ErrEmptyStack {}; 31

template <class TYPE> class Stack 31

Main.cpp

#include <vcl.h>

#pragma hdrstop

#include "Main.h"

#include "DataBase.h"

#include "Stack_mass.h"

#include "Sintaksis.h"

#include "Interpretator.h"

#include "LeksBlok.h"

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//------------------------------------------------------------------------------------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

StringGrid1->Cells[0][0] = "№";

StringGrid1->Cells[1][0] = "Имя";

StringGrid1->Cells[2][0] = "Значение";

StringGrid2->Cells[0][0] = "№";

StringGrid2->Cells[1][0] = "Команда";

}

//------------------------------------------------------------------------------------------------------------------------------------------------------

Void Prints(rez &r)

{

int size = R.Data.Size();

Form1->StringGrid1->RowCount = size;

for (int i = 0; i < size; ++i)

{

Form1->StringGrid1->Cells[0][i + 1] = i;

elem el = R.Data[i];

if (el.clas < 4)

Form1->StringGrid1->Cells[1][i + 1] = el.name;

else

Form1->StringGrid1->Cells[1][i + 1] = "NEW";

Form1->StringGrid1->Cells[2][i + 1] = el.value;

}

size = R.Command.Size();

Form1->StringGrid2->RowCount = size + 1;

for (int i = 0; i < size; ++i)

Form1->StringGrid2->Cells[0][i + 1] = i;

for (int i = 0; i < size; )

{

int el = R.Command[i];

switch (el)

{

case K_PRISV:

Form1->StringGrid2->Cells[1][++i] = "Присвоить";

for (int ptr = 0; ptr < 2; ++ptr)

Form1->StringGrid2->Cells[1][++i] = R.Command[i];

break;

case K_SLOJ:

Form1->StringGrid2->Cells[1][++i] = "Сложить";

for (int ptr = 0; ptr < 3; ++ptr)

Form1->StringGrid2->Cells[1][++i] = R.Command[i];

break;

case K_UMNOJ:

Form1->StringGrid2->Cells[1][++i] = "Умножить";

for (int ptr = 0; ptr < 3; ++ptr)

Form1->StringGrid2->Cells[1][++i] = R.Command[i];

break;

case K_V_STEP:

Form1->StringGrid2->Cells[1][++i] = "Возвести в степень";

for (int ptr = 0; ptr < 3; ++ptr)

Form1->StringGrid2->Cells[1][++i] = R.Command[i];

break;

case K_PEREHOD_0:

Form1->StringGrid2->Cells[1][++i] = "Переход по 0";

Form1->StringGrid2->Cells[1][++i] = R.Command[i];

Form1->StringGrid2->Cells[1][++i] = R.Label[R.Command[i]];

break;

case K_PEREHOD_BEZ_USL:

Form1->StringGrid2->Cells[1][++i] = "Безусловный переход";

Form1->StringGrid2->Cells[1][++i] = R.Label[R.Command[i]];

break;

case K_PEREHOD_SRAVN:

Form1->StringGrid2->Cells[1][++i] = "Переход по сравнению";

Form1->StringGrid2->Cells[1][++i] = R.Command[i];

Form1->StringGrid2->Cells[1][++i] = R.Label[R.Command[i]];

break;

case K_RAVNO:

Form1->StringGrid2->Cells[1][++i] = "Логическое \"равно\"";

for (int ptr = 0; ptr < 3; ++ptr)

Form1->StringGrid2->Cells[1][++i] = R.Command[i];

break;

case K_NE_RAVNO:

Form1->StringGrid2->Cells[1][++i] = "Логическое \"не равно\"";

for (int ptr = 0; ptr < 3; ++ptr)

Form1->StringGrid2->Cells[1][++i] = R.Command[i];

break;

}

}

}

//------------------------------------------------------------------------------------------------------------------------------------------------------