Курсовая работа: Конструирование модели лексического и синтаксического анализа

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам

// Column2

//

this->Column2->HeaderText = L"д/к";

this->Column2->Name = L"Column2";

this->Column2->Width = 40;

//

// Column3

//

this->Column3->HeaderText = L"п/к";

this->Column3->Name = L"Column3";

this->Column3->Width = 40;

//

// label1

//

this->label1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom));

this->label1->AutoSize = true;

this->label1->Location = System::Drawing::Point(12, 300);

this->label1->Name = L"label1";

this->label1->Size = System::Drawing::Size(67, 13);

this->label1->TabIndex = 10;

this->label1->Text = L"Ключ.Слова";

//

// label2

//

this->label2->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom));

this->label2->AutoSize = true;

this->label2->Location = System::Drawing::Point(131, 300);

this->label2->Name = L"label2";

this->label2->Size = System::Drawing::Size(64, 13);

this->label2->TabIndex = 11;

this->label2->Text = L"Операторы";

//

// label3

//

this->label3->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom));

this->label3->AutoSize = true;

this->label3->Location = System::Drawing::Point(252, 300);

this->label3->Name = L"label3";

this->label3->Size = System::Drawing::Size(89, 13);

this->label3->TabIndex = 12;

this->label3->Text = L"Оператор.сравн";

//

// op1

//

this->op1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom));

this->op1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;

this->op1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^>(3) {

this->dataGridViewTextBoxColumn1,

this->dataGridViewTextBoxColumn2, this->dataGridViewTextBoxColumn3

});

this->op1->EnableHeadersVisualStyles = false;

this->op1->Location = System::Drawing::Point(133, 316);

this->op1->Name = L"op1";

this->op1->RightToLeft = System::Windows::Forms::RightToLeft::No;

this->op1->RowHeadersVisible = false;

this->op1->Size = System::Drawing::Size(113, 103);

this->op1->TabIndex = 13;

//

// dataGridViewTextBoxColumn1

//

this->dataGridViewTextBoxColumn1->HeaderText = L"20";

this->dataGridViewTextBoxColumn1->Name = L"dataGridViewTextBoxColumn1";

this->dataGridViewTextBoxColumn1->Width = 30;

//

// dataGridViewTextBoxColumn2

//

this->dataGridViewTextBoxColumn2->HeaderText = L"д/к";

this->dataGridViewTextBoxColumn2->Name = L"dataGridViewTextBoxColumn2";

this->dataGridViewTextBoxColumn2->Width = 40;

//

// dataGridViewTextBoxColumn3

//

this->dataGridViewTextBoxColumn3->HeaderText = L"п/к";

this->dataGridViewTextBoxColumn3->Name = L"dataGridViewTextBoxColumn3";

this->dataGridViewTextBoxColumn3->Width = 40;

//

// ops1

//

this->ops1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom));

this->ops1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;

this->ops1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^>(3) {

this->dataGridViewTextBoxColumn4,

this->dataGridViewTextBoxColumn5, this->dataGridViewTextBoxColumn6

});

this->ops1->EnableHeadersVisualStyles = false;

this->ops1->Location = System::Drawing::Point(252, 316);

this->ops1->Name = L"ops1";

this->ops1->RightToLeft = System::Windows::Forms::RightToLeft::No;

this->ops1->RowHeadersVisible = false;

this->ops1->Size = System::Drawing::Size(113, 103);

this->ops1->TabIndex = 14;

//

// dataGridViewTextBoxColumn4

//

this->dataGridViewTextBoxColumn4->HeaderText = L"30";

this->dataGridViewTextBoxColumn4->Name = L"dataGridViewTextBoxColumn4";

this->dataGridViewTextBoxColumn4->Width = 30;

//

// dataGridViewTextBoxColumn5

//

this->dataGridViewTextBoxColumn5->HeaderText = L"д/к";

this->dataGridViewTextBoxColumn5->Name = L"dataGridViewTextBoxColumn5";

this->dataGridViewTextBoxColumn5->Width = 40;

//

// dataGridViewTextBoxColumn6

//

this->dataGridViewTextBoxColumn6->HeaderText = L"п/к";

this->dataGridViewTextBoxColumn6->Name = L"dataGridViewTextBoxColumn6";

this->dataGridViewTextBoxColumn6->Width = 40;

//

// constant1

//

this->constant1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom));

this->constant1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;

this->constant1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^>(3) {

this->dataGridViewTextBoxColumn7,

this->dataGridViewTextBoxColumn8, this->dataGridViewTextBoxColumn9

});

this->constant1->EnableHeadersVisualStyles = false;

this->constant1->Location = System::Drawing::Point(614, 316);

this->constant1->Name = L"constant1";

this->constant1->RightToLeft = System::Windows::Forms::RightToLeft::No;

this->constant1->RowHeadersVisible = false;

this->constant1->Size = System::Drawing::Size(113, 103);

this->constant1->TabIndex = 15;

this->constant1->CellContentClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &MyForm::constant1_CellContentClick);

//

// dataGridViewTextBoxColumn7

//

this->dataGridViewTextBoxColumn7->HeaderText = L"60";

this->dataGridViewTextBoxColumn7->Name = L"dataGridViewTextBoxColumn7";

this->dataGridViewTextBoxColumn7->Width = 30;

//

// dataGridViewTextBoxColumn8

//

this->dataGridViewTextBoxColumn8->HeaderText = L"д/к";

this->dataGridViewTextBoxColumn8->Name = L"dataGridViewTextBoxColumn8";

this->dataGridViewTextBoxColumn8->Width = 40;

//

// dataGridViewTextBoxColumn9

//

this->dataGridViewTextBoxColumn9->HeaderText = L"п/к";

this->dataGridViewTextBoxColumn9->Name = L"dataGridViewTextBoxColumn9";

this->dataGridViewTextBoxColumn9->Width = 40;

//

// ident1

//

this->ident1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom));

this->ident1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;

this->ident1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^>(3) {

this->dataGridViewTextBoxColumn10,

this->dataGridViewTextBoxColumn11, this->dataGridViewTextBoxColumn12

});

this->ident1->EnableHeadersVisualStyles = false;

this->ident1->Location = System::Drawing::Point(371, 316);

this->ident1->Name = L"ident1";

this->ident1->RightToLeft = System::Windows::Forms::RightToLeft::No;

this->ident1->RowHeadersVisible = false;

this->ident1->Size = System::Drawing::Size(113, 103);

this->ident1->TabIndex = 16;

//

// dataGridViewTextBoxColumn10

//

this->dataGridViewTextBoxColumn10->HeaderText = L"40";

this->dataGridViewTextBoxColumn10->Name = L"dataGridViewTextBoxColumn10";

this->dataGridViewTextBoxColumn10->Width = 30;

//

// dataGridViewTextBoxColumn11

//

this->dataGridViewTextBoxColumn11->HeaderText = L"д/к";

this->dataGridViewTextBoxColumn11->Name = L"dataGridViewTextBoxColumn11";

this->dataGridViewTextBoxColumn11->Width = 40;

//

// dataGridViewTextBoxColumn12

//

this->dataGridViewTextBoxColumn12->HeaderText = L"п/к";

this->dataGridViewTextBoxColumn12->Name = L"dataGridViewTextBoxColumn12";

this->dataGridViewTextBoxColumn12->Width = 40;

//

// label4

//

this->label4->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom));

this->label4->AutoSize = true;

this->label4->Location = System::Drawing::Point(371, 300);

this->label4->Name = L"label4";

this->label4->Size = System::Drawing::Size(62, 13);

this->label4->TabIndex = 17;

this->label4->Text = L"идентифик";

//

// label5

//

this->label5->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom));

this->label5->AutoSize = true;

this->label5->Location = System::Drawing::Point(611, 300);

this->label5->Name = L"label5";

this->label5->Size = System::Drawing::Size(33, 13);

this->label5->TabIndex = 18;

this->label5->Text = L"const";

//

// label6

//

this->label6->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom));

this->label6->AutoSize = true;

this->label6->Location = System::Drawing::Point(490, 300);

this->label6->Name = L"label6";

this->label6->Size = System::Drawing::Size(64, 13);

this->label6->TabIndex = 19;

this->label6->Text = L"пунктуация";

//

// punctuation1

//

this->punctuation1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom));

this->punctuation1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;

this->punctuation1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^>(3) {

this->dataGridViewTextBoxColumn13,

this->dataGridViewTextBoxColumn14, this->dataGridViewTextBoxColumn15

});

this->punctuation1->EnableHeadersVisualStyles = false;

this->punctuation1->Location = System::Drawing::Point(490, 316);

this->punctuation1->Name = L"punctuation1";

this->punctuation1->RightToLeft = System::Windows::Forms::RightToLeft::No;

this->punctuation1->RowHeadersVisible = false;

this->punctuation1->Size = System::Drawing::Size(113, 103);

this->punctuation1->TabIndex = 20;

//

// dataGridViewTextBoxColumn13

//

this->dataGridViewTextBoxColumn13->HeaderText = L"50";

this->dataGridViewTextBoxColumn13->Name = L"dataGridViewTextBoxColumn13";

this->dataGridViewTextBoxColumn13->Width = 30;

//

// dataGridViewTextBoxColumn14

//

this->dataGridViewTextBoxColumn14->HeaderText = L"д/к";

this->dataGridViewTextBoxColumn14->Name = L"dataGridViewTextBoxColumn14";

this->dataGridViewTextBoxColumn14->Width = 40;

//

// dataGridViewTextBoxColumn15

//

this->dataGridViewTextBoxColumn15->HeaderText = L"п/к";

this->dataGridViewTextBoxColumn15->Name = L"dataGridViewTextBoxColumn15";

this->dataGridViewTextBoxColumn15->Width = 40;

//

// richTextBox3

//

this->richTextBox3->Anchor = System::Windows::Forms::AnchorStyles::Top;

this->richTextBox3->Location = System::Drawing::Point(415, 12);

this->richTextBox3->Name = L"richTextBox3";

this->richTextBox3->Size = System::Drawing::Size(312, 139);

this->richTextBox3->TabIndex = 21;

this->richTextBox3->Text = L"";

//

// richTextBox4

//

this->richTextBox4->Anchor = System::Windows::Forms::AnchorStyles::Top;

this->richTextBox4->Location = System::Drawing::Point(415, 157);

this->richTextBox4->Name = L"richTextBox4";

this->richTextBox4->Size = System::Drawing::Size(312, 139);

this->richTextBox4->TabIndex = 22;

this->richTextBox4->Text = L"";

//

// label7

//

this->label7->Anchor = System::Windows::Forms::AnchorStyles::Top;

this->label7->AutoSize = true;

this->label7->Location = System::Drawing::Point(330, 62);

this->label7->Name = L"label7";

this->label7->Size = System::Drawing::Size(65, 26);

this->label7->TabIndex = 23;

this->label7->Text = L"количество\r\nстрок:";

//

// textBox1

//

this->textBox1->Anchor = System::Windows::Forms::AnchorStyles::Top;

this->textBox1->BorderStyle = System::Windows::Forms::BorderStyle::None;

this->textBox1->Location = System::Drawing::Point(370, 75);

this->textBox1->Name = L"textBox1";

this->textBox1->Size = System::Drawing::Size(24, 13);

this->textBox1->TabIndex = 26;

this->textBox1->TextChanged += gcnew System::EventHandler(this, &MyForm::textBox1_TextChanged_1);

//

// button2

//

this->button2->Anchor = System::Windows::Forms::AnchorStyles::Top;

this->button2->Location = System::Drawing::Point(330, 94);

this->button2->Name = L"button2";

this->button2->Size = System::Drawing::Size(75, 47);

this->button2->TabIndex = 27;

this->button2->Text = L"error processing";

this->button2->UseVisualStyleBackColor = true;

this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);

//

// button3

//

this->button3->Location = System::Drawing::Point(333, 273);

this->button3->Name = L"button3";

this->button3->Size = System::Drawing::Size(75, 23);

this->button3->TabIndex = 28;

this->button3->Text = L"clear";

this->button3->UseVisualStyleBackColor = true;

this->button3->Click += gcnew System::EventHandler(this, &MyForm::button3_Click);

//

// MyForm

//

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Inherit;

this->ClientSize = System::Drawing::Size(739, 430);

this->Controls->Add(this->button3);

this->Controls->Add(this->button2);

this->Controls->Add(this->textBox1);

this->Controls->Add(this->label7);

this->Controls->Add(this->richTextBox4);

this->Controls->Add(this->richTextBox3);

this->Controls->Add(this->punctuation1);

this->Controls->Add(this->label6);

this->Controls->Add(this->label5);

this->Controls->Add(this->label4);

this->Controls->Add(this->ident1);

this->Controls->Add(this->constant1);

this->Controls->Add(this->ops1);

this->Controls->Add(this->op1);

this->Controls->Add(this->label3);

this->Controls->Add(this->label2);

this->Controls->Add(this->label1);

this->Controls->Add(this->keyWord1);

this->Controls->Add(this->richTextBox2);

this->Controls->Add(this->button1);

this->Controls->Add(this->richTextBox1);

this->Name = L"MyForm";

this->Text = L"MyForm";

this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->keyWord1))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->op1))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->ops1))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->constant1))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->ident1))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->punctuation1))->EndInit();

this->ResumeLayout(false);

this->PerformLayout();

}

#pragma endregion

String^ code;

String^ code1;

String^ code2;

bool err;

int lastRow;

bool nlol;

private: void keyWord(int i,int pr) {

if (!err) {

//для возврата к символу-разделителю

String^ tmp = code->Substring(pr, i - pr);

nlol = true;

int j = 0;

//проверка на повторяемость

for (; j < keyWord1->RowCount - 1; j++)

if (keyWord1[1, j]->Value->ToString() == tmp) {

nlol = false;

break;

}

if (nlol) {

keyWord1->Rows->Add();

lastRow = keyWord1->RowCount - 2;

keyWord1->Rows[lastRow]->Cells[0]->Value = keyWord1->RowCount - 1;

keyWord1->Rows[lastRow]->Cells[1]->Value = tmp;

keyWord1->Rows[lastRow]->Cells[2]->Value = tmp;

}

richTextBox3->Text += "(10," + (j + 1).ToString() + ") ";

if (code->Substring(i, 1) == " ")

tmp += " ";

richTextBox4->Text += tmp;

}

}

private: void o_peratr(int i, int pr) {

if (!err) {

//для возврата к символу-разделителю

String^ tmp = code->Substring(pr, i - pr);

nlol = true;

//проверка на повторяемость

int j = 0;

for (; j < op1->RowCount - 1; j++)

if (op1[1, j]->Value->ToString() == tmp) {

nlol = false;

break;

}

if (nlol) {

op1->Rows->Add();

lastRow = op1->RowCount - 2;

op1->Rows[lastRow]->Cells[0]->Value = op1->RowCount - 1;

op1->Rows[lastRow]->Cells[1]->Value = tmp;

op1->Rows[lastRow]->Cells[2]->Value = tmp;

}

richTextBox3->Text += "(20," + (j + 1).ToString() + ")";

richTextBox4->Text += tmp;

}

}

private: void o_peratr_sravn(int i, int pr) {

if (!err) {

//для возврата к символу-разделителю

String^ tmp = code->Substring(pr, i - pr);

nlol = true;

//проверка на повторяемость

int j = 0;

for (; j < ops1->RowCount - 1; j++)

if (ops1[1, j]->Value->ToString() == tmp) {

nlol = false;

break;

}

if (nlol) {

ops1->Rows->Add();

Источник: https://otherreferats.allbest.ru/download/1282040/