diff --git a/src/code_generator/generate.c b/src/code_generator/generate.c new file mode 100644 index 00000000..8be71475 --- /dev/null +++ b/src/code_generator/generate.c @@ -0,0 +1,24 @@ +#include "code_generator/generate.h" +#include +#include +#include +#include +#include "ast/ast_impl.h" + +void generate_code(AstRef ast) { + assert(ast); + switch (ast->tag) { + default: + error("Unimplemented: %d\n", ast->tag); + break; + } +} + +void error(const char* message, ...) { + va_list args; + va_start(args, message); + vfprintf(stderr, message, args); + va_end(args); + fprintf(stderr, "\n"); + exit(EXIT_FAILURE); +} diff --git a/src/code_generator/generate.h b/src/code_generator/generate.h new file mode 100644 index 00000000..e9cde182 --- /dev/null +++ b/src/code_generator/generate.h @@ -0,0 +1,9 @@ +#ifndef KMC_C90_COMPILER_CODE_GENERATOR_GENERATE_H +#define KMC_C90_COMPILER_CODE_GENERATOR_GENERATE_H + +#include "ast.h" + +void generate_code(AstRef ast); +void error(const char* message, ...); + +#endif /* KMC_C90_COMPILER_CODE_GENERATOR_GENERATE_H */