MethodsDevelopmentTranslator

Форк
0
/
TranslatorFromCToCSharp.cpp 
89 строк · 2.6 Кб
1
#include "TranslatorFromCToCSharp.h"
2
using namespace System;
3

4
TranslatorFromCToCSharp::TranslatorFromCToCSharp()
5
{
6
}
7

8
TranslatorFromCToCSharp::~TranslatorFromCToCSharp()
9
{
10
}
11

12
//System::String^ StlWStringToString(std::string const& os)
13
//{
14
//	System::String^ str = gcnew System::String(os.c_str());
15
//	//String^ str = gcnew String("");
16
//	return str;
17
//}
18

19
void TranslatorFromCToCSharp::lexicalAnalyze(std::string source_file)
20
{
21
	
22
	try
23
	{
24
		makeLexicalAnalyze(source_file, "./translator_file/lexical.txt");
25
		lexicalAnalyzeIsCompleted = true;
26
	}
27
	catch (const std::exception&)
28
	{
29
		System::Windows::Forms::MessageBox::Show("Problem with lexical analyze", "Error", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Error);
30
		lexicalAnalyzeIsCompleted = false;
31
	}
32
	
33
}
34

35
void TranslatorFromCToCSharp::reversePolishNotAnalyze()
36
{
37
	try
38
	{
39
		if (lexicalAnalyzeIsCompleted == true)
40
			reversePolishNotationAnalyze("./translator_file/lexical.txt", "./translator_file/RPN.txt");
41
		else
42
		{
43
			System::Windows::Forms::MessageBox::Show("LexicalAnaylyze don't completed!", "Error", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Error);
44
			return;
45
		}
46
			
47
		reversePolishNotationIsCompleted = true;
48
	}
49
	catch (const std::exception&)
50
	{
51
		System::Windows::Forms::MessageBox::Show("Problem with RPN analyze", "Error", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Error);
52
		reversePolishNotationIsCompleted = false;
53
	}
54
}
55

56
bool TranslatorFromCToCSharp::syntaxAnalyze()
57
{
58
	try
59
	{
60
		syntaxAnalyzeIsCompleted = makeSyntaxAnalyze();
61
		return syntaxAnalyzeIsCompleted;
62
	}
63
	catch (const std::exception&)
64
	{
65
		System::Windows::Forms::MessageBox::Show("Problem with syntax analyze!", "Error", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Error);
66
		syntaxAnalyzeIsCompleted = false;
67
	}
68
}
69

70
void TranslatorFromCToCSharp::translateToCSharp()
71
{
72
	try
73
	{
74
		if (reversePolishNotationIsCompleted == true && syntaxAnalyzeIsCompleted == true)
75
		{
76
			transalteToCSharp("./translator_file/RPN.txt", "./translator_file/CodeCSharp.cs");
77
		}
78
		else
79
		{
80
			System::Windows::Forms::MessageBox::Show("Don't execution RPN || syntax analyze!", "Error", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Error);
81
			return;
82
		}
83
	}
84
	catch (std::string err)
85
	{
86
		System::Windows::Forms::MessageBox::Show("Problem with translate to C# program!" + StlWStringToString(err), "Error", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Error);
87
	}
88
	
89
}

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.