translator.cpp
/*
 * Translates the comments (if any) in the line which is given as an input parameter
 * parameters: Line to translate
 * Returns: A string with all comments translated
 */
Translates the comments (if any) in the line which is given as an input parameter
parameters: Line to translate
Returns: A string with all comments translated
Translates the comments ( if any ) in the line which is given as an input parameter parameters : Line to translate Returns : A string with all comments translated
wstring translator::process(wstring line) {
	wstring command;
	if (multi_line == true) {
		wcout << L"Multi line: " << line << endl;
		if (line.find(multi_line_comment_end) != wstring::npos) {
			multi_line = false;
			translated = line.substr(0, line.find(multi_line_comment_end));
		} else
			translated = line;
		command = path + command_part1 + translated + command_part2;
		translated = exec(command.c_str());
		wcout << L"\t translated: " << translated << endl;
		if (line.find(multi_line_comment_end) != wstring::npos) {
			line = translated + line.substr(line.find(multi_line_comment_end));
		} else {
			line = translated;
		}
		return line;
	}
	if (line.find(single_line_comment) != wstring::npos && translate_single_line) {
		wcout << L" Single line: " << line << endl;
		translated = line.substr(line.find(single_line_comment) + 2);
		command = path + command_part1 + translated + command_part2;
		translated = exec(command.c_str());
		wcout << L"\t Translated: " << translated << endl;
		line = line.substr(0, line.find(single_line_comment) + 2) + translated;
		return line;
	}
	if (line.find(multi_line_comment_start) != wstring::npos && translate_multi_line) {
		wcout << L"Multi line: " << line << endl;
		multi_line = true;
		if (line.find(multi_line_comment_end) != wstring::npos) {
			multi_line = false;
			translated = line.substr(line.find(multi_line_comment_start) + 2,
					(line.find(multi_line_comment_end)) - (line.find(multi_line_comment_start) + 2));
		} else
			translated = line.substr(line.find(multi_line_comment_start) + 2);
		command = path + command_part1 + translated + command_part2;
		translated = exec(command.c_str());
		wcout << L"\t translated: " << translated << endl;
		if (line.find(multi_line_comment_end) != wstring::npos) {
			wstring line1 = line.substr(0, line.find(multi_line_comment_start) + 2);
			wstring line2 = line.substr(line.find(multi_line_comment_end));
			line = line1 + translated + line2;
		} else {
			line = line.substr(0, line.find(multi_line_comment_start) + 2) + translated;
		}
		return line;
	}
	wcout << L"No comment: " << line << endl;
	return line;
}
wstring translator :: process ( wstring line ) { wstring command ; if ( multi_line == true ) { wcout << L" " << line << endl ; if ( line . find ( multi_line_comment_end ) != wstring :: npos ) { multi_line = false ; translated = line . substr ( 0 , line . find ( multi_line_comment_end ) ) ; } else translated = line ; command = path + command_part1 + translated + command_part2 ; translated = exec ( command . c_str ( ) ) ; wcout << L" \t " << translated << endl ; if ( line . find ( multi_line_comment_end ) != wstring :: npos ) { line = translated + line . substr ( line . find ( multi_line_comment_end ) ) ; } else { line = translated ; } return line ; } if ( line . find ( single_line_comment ) != wstring :: npos && translate_single_line ) { wcout << L" " << line << endl ; translated = line . substr ( line . find ( single_line_comment ) + 2 ) ; command = path + command_part1 + translated + command_part2 ; translated = exec ( command . c_str ( ) ) ; wcout << L" \t " << translated << endl ; line = line . substr ( 0 , line . find ( single_line_comment ) + 2 ) + translated ; return line ; } if ( line . find ( multi_line_comment_start ) != wstring :: npos && translate_multi_line ) { wcout << L" " << line << endl ; multi_line = true ; if ( line . find ( multi_line_comment_end ) != wstring :: npos ) { multi_line = false ; translated = line . substr ( line . find ( multi_line_comment_start ) + 2 , ( line . find ( multi_line_comment_end ) ) - ( line . find ( multi_line_comment_start ) + 2 ) ) ; } else translated = line . substr ( line . find ( multi_line_comment_start ) + 2 ) ; command = path + command_part1 + translated + command_part2 ; translated = exec ( command . c_str ( ) ) ; wcout << L" \t " << translated << endl ; if ( line . find ( multi_line_comment_end ) != wstring :: npos ) { wstring line1 = line . substr ( 0 , line . find ( multi_line_comment_start ) + 2 ) ; wstring line2 = line . substr ( line . find ( multi_line_comment_end ) ) ; line = line1 + translated + line2 ; } else { line = line . substr ( 0 , line . find ( multi_line_comment_start ) + 2 ) + translated ; } return line ; } wcout << L" " << line << endl ; return line ; }
Translates the comments (if any) in the line which is given as an input parameter
 parameters: Line to translate
 Returns: A string with all comments translated
Translates the comments ( if any ) in the line which is given as an input parameter parameters : Line to translate Returns : A string with all comments translated