2024-05-08 20:10:14 +00:00
|
|
|
#include <ast/ast.h>
|
2024-04-12 15:28:20 +00:00
|
|
|
#include <stdlib.h>
|
2024-04-12 15:24:12 +00:00
|
|
|
#include <sys/log.h>
|
2024-05-13 14:13:49 +00:00
|
|
|
#include <sys/col.h>
|
|
|
|
#include <lex/util.h>
|
2024-06-02 22:24:17 +00:00
|
|
|
#include <cfg/opt.h>
|
2024-06-02 18:57:59 +00:00
|
|
|
#include <compiler.h>
|
2024-04-26 14:21:54 +00:00
|
|
|
|
2024-04-12 15:29:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Log a debug message to inform about beginning exit procedures
|
2024-05-07 11:04:22 +00:00
|
|
|
*
|
2024-04-12 15:29:39 +00:00
|
|
|
*/
|
2024-05-08 20:10:14 +00:00
|
|
|
void notify_exit(void) { DEBUG("Exiting gemstone..."); }
|
2024-04-12 15:28:20 +00:00
|
|
|
|
2024-04-12 15:29:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Run compiler setup here
|
2024-05-07 11:04:22 +00:00
|
|
|
*
|
2024-04-12 15:29:39 +00:00
|
|
|
*/
|
2024-06-02 22:24:17 +00:00
|
|
|
void setup(int argc, char *argv[]) {
|
2024-05-30 19:06:03 +00:00
|
|
|
// setup preample
|
2024-06-02 22:24:17 +00:00
|
|
|
parse_options(argc, argv);
|
2024-04-12 15:29:39 +00:00
|
|
|
|
2024-05-30 19:06:03 +00:00
|
|
|
log_init();
|
|
|
|
DEBUG("starting gemstone...");
|
2024-04-12 15:24:12 +00:00
|
|
|
|
2024-05-07 11:04:22 +00:00
|
|
|
#if LOG_LEVEL <= LOG_LEVEL_DEBUG
|
2024-05-30 19:06:03 +00:00
|
|
|
atexit(¬ify_exit);
|
2024-05-07 11:04:22 +00:00
|
|
|
#endif
|
2024-04-12 15:28:20 +00:00
|
|
|
|
2024-05-30 19:06:03 +00:00
|
|
|
// actual setup
|
|
|
|
AST_init();
|
2024-05-07 11:04:22 +00:00
|
|
|
|
2024-05-30 19:06:03 +00:00
|
|
|
col_init();
|
2024-05-13 14:13:49 +00:00
|
|
|
|
2024-05-30 19:06:03 +00:00
|
|
|
lex_init();
|
2024-05-13 14:13:49 +00:00
|
|
|
|
2024-05-30 19:06:03 +00:00
|
|
|
DEBUG("finished starting up gemstone...");
|
2024-04-22 11:41:37 +00:00
|
|
|
}
|
|
|
|
|
2024-05-31 19:25:37 +00:00
|
|
|
int main(int argc, char *argv[]) {
|
2024-06-02 22:24:17 +00:00
|
|
|
if (argc <= 1) {
|
|
|
|
print_help();
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
setup(argc, argv);
|
2024-05-31 19:25:37 +00:00
|
|
|
|
2024-06-03 08:14:25 +00:00
|
|
|
if (is_option_set("help")) {
|
|
|
|
print_help();
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2024-06-03 09:08:25 +00:00
|
|
|
if (is_option_set("version")) {
|
|
|
|
printf("Running GSC version %s\n", GSC_VERSION);
|
|
|
|
exit(0);
|
|
|
|
}
|
2024-05-30 19:46:44 +00:00
|
|
|
|
2024-06-02 22:24:17 +00:00
|
|
|
run_compiler();
|
2024-04-22 10:53:48 +00:00
|
|
|
|
2024-05-30 19:06:03 +00:00
|
|
|
return 0;
|
2024-05-08 20:10:14 +00:00
|
|
|
}
|