changes in code after tests on windows

This commit is contained in:
jorenchik
2024-12-08 09:39:03 +02:00
parent a94b01751e
commit 0d53d4fd7b
5 changed files with 148 additions and 108 deletions

View File

@@ -108,6 +108,24 @@ Result<ParseInfo> transpile(std::string fileContent) {
start = std::chrono::high_resolution_clock::now();
end = std::chrono::high_resolution_clock::now();
// Apstrādā jaunas rindas simbolus gan DOS,
// gan UNIX formātā vienādi.
std::string normalized;
for (int i = 0; i < fileContent.size(); ++i) {
if (fileContent[i] == '\r') {
if (
i + 1 < fileContent.size() &&
fileContent[i + 1] == '\n'
) {
++i;
}
normalized.push_back('\n');
} else {
normalized.push_back(fileContent[i]);
}
}
fileContent = normalized;
auto lexRes = tokenizeMdem(fileContent);
auto tokens = lexRes.value;
if (lexRes.error.length() > 0) {

View File

@@ -10,6 +10,11 @@
#include "config.h"
#include "result.h"
// Uz Windows sistēmās timegm funkcijai ir atšķirīgs nosaukums.
#ifdef _WIN32
#define timegm _mkgmtime
#endif
std::vector<Token> tokens;
std::vector<char> buffer;
int32_t row;