Files
jak-project/goalc/main.cpp
T
water111 09142d1712 Support "game count" and v4 objects (#140)
* generate object, but not supported in linker yet

* add link and tests

* update types
2020-11-24 20:48:38 -05:00

55 lines
1.5 KiB
C++

#include <cstdio>
#include "goalc/compiler/Compiler.h"
#include "common/versions.h"
#include "third-party/spdlog/include/spdlog/spdlog.h"
#include "third-party/spdlog/include/spdlog/sinks/basic_file_sink.h"
#include "third-party/spdlog/include/spdlog/sinks/stdout_color_sinks.h"
void setup_logging(bool verbose) {
spdlog::set_level(spdlog::level::debug);
if (verbose) {
auto game_logger = spdlog::stdout_color_mt("GOAL Compiler");
spdlog::set_default_logger(game_logger);
spdlog::flush_on(spdlog::level::info);
spdlog::set_pattern("%v");
spdlog::info("Verbose logging enabled");
} else {
auto game_logger = spdlog::basic_logger_mt("GOAL Compiler", "logs/compiler.log");
spdlog::set_default_logger(game_logger);
spdlog::flush_on(spdlog::level::debug);
printf("OpenGOAL Compiler %d.%d\n", versions::GOAL_VERSION_MAJOR, versions::GOAL_VERSION_MINOR);
}
}
int main(int argc, char** argv) {
(void)argc;
(void)argv;
std::string argument;
bool verbose = false;
for (int i = 1; i < argc; i++) {
if (std::string("-v") == argv[i]) {
verbose = true;
break;
}
if (std::string("-cmd") == argv[i] && i < argc - 1) {
argument = argv[++i];
}
}
setup_logging(verbose);
spdlog::info("OpenGOAL Compiler {}.{}", versions::GOAL_VERSION_MAJOR,
versions::GOAL_VERSION_MINOR);
Compiler compiler;
if (argument.empty()) {
compiler.execute_repl();
} else {
compiler.run_front_end_on_string(argument);
}
return 0;
}