gemstone/src/main.c

65 lines
899 B
C
Raw Normal View History

#include <stdlib.h>
#include <sys/log.h>
2024-02-04 15:23:32 +00:00
#include <yacc/parser.tab.h>
#define LOG_LEVEL LOG_LEVEL_DEBUG
extern FILE* yyin;
2024-04-12 15:29:39 +00:00
/**
* @brief Log a debug message to inform about beginning exit procedures
*
*/
void notify_exit(void)
{
DEBUG("Exiting gemstone...");
}
2024-04-12 15:29:39 +00:00
/**
* @brief Run compiler setup here
*
*/
void setup(void)
{
2024-04-12 15:29:39 +00:00
// setup preample
log_init();
DEBUG("starting gemstone...");
#if LOG_LEVEL <= LOG_LEVEL_DEBUG
atexit(&notify_exit);
#endif
2024-04-12 15:29:39 +00:00
// actual setup
DEBUG("finished starting up gemstone...");
}
/**
* @brief Closes File after compiling.
*
*/
void close_file(void)
{
fclose(input);
}
int main(void) {
setup();
atexit(close_file);
FILE* input = fopen("program.gem", "r");
2024-04-22 10:57:49 +00:00
if (NULL == input)
{
ERROR("File couldn't be opened!");
}
yyin = input;
2024-02-04 15:23:32 +00:00
yyparse();
2024-02-04 15:23:32 +00:00
return 0;
}