@@ -11,12 +11,7 @@ SyntaxAnalisator::~SyntaxAnalisator()
1111{
1212}
1313
14- System::String^ StlWStringToString(std::string const & os)
15- {
16- System::String^ str = gcnew System::String (os.c_str ());
17- // String^ str = gcnew String("");
18- return str;
19- }
14+
2015
2116std::string SyntaxAnalisator::getServiceWordCode (std::string str)
2217{
@@ -66,40 +61,22 @@ std::string SyntaxAnalisator::getSymbolsConstCode(std::string str)
6661 return " \0 " ;
6762}
6863
64+ System::String^ StlWStringToString(std::string const & os)
65+ {
66+ System::String^ str = gcnew System::String (os.c_str ());
67+ // String^ str = gcnew String("");
68+ return str;
69+ }
6970
70- void SyntaxAnalisator::addCode (std::string str, std::map<std::string, std::string> & table, int numTable)
71+ void SyntaxAnalisator::addCode (std::string str, std::map<std::string, std::string>& table, int numTable)
7172{
72- int indexCode = 0 ;
73- for (const auto & word : table)
74- {
75- indexCode++;
76- }
77- indexCode++;
78- if (numTable == 1 )
79- {
80- if (isIdentifier (str)==true )
81- table.insert (std::pair<std::string, std::string>(str, " I" + std::to_string (indexCode)));
82- else
83- {
84-
85- System::String^ temp = StlWStringToString (str);
86- System::Windows::Forms::MessageBox::Show (" Error with identifier" , temp, System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Error);
87- return ;
88- }
89- }
90- if (numTable == 2 )
73+ std::string result = fillTable (str, table, numTable);
74+ if (result.find (" Error" ) != std::string::npos)
9175 {
92- if (isNumber (str)==true )
93- table.insert (std::pair<std::string, std::string>(str, " N" + std::to_string (indexCode)));
94- else
95- {
96- System::String^ temp = StlWStringToString (str);
97- System::Windows::Forms::MessageBox::Show (" Error with number" , temp, System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Error);
98- return ;
99- }
76+ System::String^ temp = StlWStringToString (str);
77+ System::String^ tempResult = StlWStringToString (result);
78+ System::Windows::Forms::MessageBox::Show (tempResult, temp, System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Error);
10079 }
101- if (numTable == 3 )
102- table.insert (std::pair<std::string, std::string>(str, " C" + std::to_string (indexCode)));
10380}
10481
10582int SyntaxAnalisator::checkStringSingleElem (std::string const & word)
@@ -190,7 +167,7 @@ bool SyntaxAnalisator::skipAnalyzeOneLineComment(bool readComment, std::string l
190167 return false ;
191168}
192169
193- bool skipAnalyzeComment (bool & readComment, std::string line, __int64& index, std::ofstream& file, std::string& word)
170+ bool SyntaxAnalisator:: skipAnalyzeComment (bool & readComment, std::string line, __int64& index, std::ofstream& file, std::string& word)
194171{
195172 if (readComment == true && isComment ((int )line[index + 1 ], (int )line[index]) == true )
196173 {
@@ -205,7 +182,10 @@ bool skipAnalyzeComment(bool& readComment, std::string line, __int64& index, std
205182 }
206183 return false ;
207184}
208-
185+ bool SyntaxAnalisator::isLibrary_header (std::string const & word)
186+ {
187+ return (int )word[0 ] == 34 && (int )word[word.length () - 1 ] == 34 && (int )word[word.length () - 2 ] == 104 && (int )word[word.length () - 3 ] == 46 ? true : false ;
188+ }
209189
210190void SyntaxAnalisator::analyze (std::string filePathOrName_C, std::string fileName_Path_SaveAnalis)
211191{
@@ -304,7 +284,7 @@ void SyntaxAnalisator::analyze(std::string filePathOrName_C, std::string fileNam
304284 if (isLetter ((int )stringLanguageC[i]) == true && (isLetter ((int )stringLanguageC[i + 1 ]) == false && isDigit ((int )stringLanguageC[i + 1 ]) == false ))
305285 {
306286 word += stringLanguageC[i];
307- if (isType (word) && (stringLanguageC[i + 1 ] == ' *' || stringLanguageC[i + 2 ] == ' *' ))
287+ if (isTypeDeclaration (word) && (stringLanguageC[i + 1 ] == ' *' || stringLanguageC[i + 2 ] == ' *' ))
308288 {
309289 word += ' *' ;
310290 if (stringLanguageC[i + 2 ] == ' *' )
@@ -366,4 +346,10 @@ void SyntaxAnalisator::analyze(std::string filePathOrName_C, std::string fileNam
366346
367347 fileC.close ();
368348 fileAnalysis.close ();
369- }
349+ }
350+
351+ void SyntaxAnalisator::initialize ()
352+ {
353+ }
354+
355+
0 commit comments