Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/code_generator/generate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "code_generator/generate.h"
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#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);
}
9 changes: 9 additions & 0 deletions src/code_generator/generate.h
Original file line number Diff line number Diff line change
@@ -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 */