Add an error message when an exception is thrown from the getFileContent() function & --parallel is not in use, and support MSVC
This commit is contained in:
parent
b42cf6953b
commit
9824dfc7fd
|
@ -1,14 +1,15 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <cstring>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
string getFileContent(const string& file)
|
string getFileContent(const string& file, const bool& parallel)
|
||||||
{
|
{
|
||||||
ifstream fileStream(file, ios::in);
|
ifstream fileStream(file, ios::in);
|
||||||
string lineinput, fullinput;
|
string lineinput, fullinput;
|
||||||
if (fileStream.is_open()) while (getline(fileStream, lineinput)) {
|
if (fileStream.is_open()) while (getline(fileStream, lineinput)) {
|
||||||
fullinput.append(lineinput += '\n');
|
fullinput.append(lineinput += '\n');
|
||||||
} else throw Yerbacon::Exception("Could not open \"" + file + "\".");
|
} else throw Yerbacon::Exception("Could not open \"" + file + "\"" + ((not parallel) ? string(" : ").append(strerror(errno)) : ".")); // TODO: Use a thread-safe function when the parallel mode is in use
|
||||||
fileStream.close();
|
fileStream.close();
|
||||||
return fullinput;
|
return fullinput;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
#error "A valid std::threads implementation is required"
|
#error "A valid std::threads implementation is required"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
// #define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <version>
|
#include <version>
|
||||||
#if not defined(__cpp_lib_concepts) || not defined(__cpp_lib_integer_comparison_functions)
|
#if not defined(__cpp_lib_concepts) || not defined(__cpp_lib_integer_comparison_functions)
|
||||||
#error "The current standard library is incomplete"
|
#error "The current standard library is incomplete"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef YERBACON_MISC_HPP
|
#ifndef YERBACON_MISC_HPP
|
||||||
#define YERBACON_MISC_HPP
|
#define YERBACON_MISC_HPP
|
||||||
|
|
||||||
string getFileContent(const string& file);
|
string getFileContent(const string& file, const bool& parallel);
|
||||||
void outputFileContent(const string& file, string_view content);
|
void outputFileContent(const string& file, string_view content);
|
||||||
|
|
||||||
#include "lex.hpp"
|
#include "lex.hpp"
|
||||||
|
|
|
@ -16,7 +16,7 @@ using namespace std;
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
#define IS(X) template<derived_from<X> T = X>
|
#define IS(X) template<derived_from<X> T = X>
|
||||||
struct ParseComponent {
|
struct ParseComponent {
|
||||||
[[nodiscard]] constexpr const type_info& getId() const { return typeid(*this); }
|
[[nodiscard]] inline const type_info& getId() const { return typeid(*this); }
|
||||||
virtual ~ParseComponent() = default;
|
virtual ~ParseComponent() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ int main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto currentTarget = Target::forName(target, newLines);
|
const auto currentTarget = Target::forName(target, newLines);
|
||||||
const auto compile = [&target, ¤tTarget](string_view name) -> string {
|
const auto compile = [&target, ¤tTarget, ¶llel](string_view name) -> string {
|
||||||
string transpiledString = currentTarget->transpileWithTree(parseString(getFileContent(name.data())));
|
string transpiledString = currentTarget->transpileWithTree(parseString(getFileContent(name.data(), parallel)));
|
||||||
name.remove_suffix(6);
|
name.remove_suffix(6);
|
||||||
string outputFile;
|
string outputFile;
|
||||||
(outputFile = name).append(target);
|
(outputFile = name).append(target);
|
||||||
|
|
Loading…
Reference in New Issue