Skip to content
Snippets Groups Projects
Commit 1e1ea39d authored by Rui Ueyama's avatar Rui Ueyama
Browse files

Add a do-nothing preprocessor

parent 8b726b54
Branches
No related merge requests found
......@@ -72,11 +72,18 @@ void error_tok(Token *tok, char *fmt, ...);
bool equal(Token *tok, char *op);
Token *skip(Token *tok, char *op);
bool consume(Token **rest, Token *tok, char *str);
void convert_keywords(Token *tok);
Token *tokenize_file(char *filename);
#define unreachable() \
error("internal error at %s:%d", __FILE__, __LINE__)
//
// preprocess.c
//
Token *preprocess(Token *tok);
//
// parse.c
//
......
......@@ -168,6 +168,7 @@ static void run_cc1(int argc, char **argv, char *input, char *output) {
static void cc1(void) {
// Tokenize and parse.
Token *tok = tokenize_file(base_file);
tok = preprocess(tok);
Obj *prog = parse(tok);
// Traverse the AST to emit assembly.
......
#include "chibicc.h"
// Entry point function of the preprocessor.
Token *preprocess(Token *tok) {
convert_keywords(tok);
return tok;
}
......@@ -350,7 +350,7 @@ static Token *read_number(char *start) {
return tok;
}
static void convert_keywords(Token *tok) {
void convert_keywords(Token *tok) {
for (Token *t = tok; t->kind != TK_EOF; t = t->next)
if (is_keyword(t))
t->kind = TK_KEYWORD;
......@@ -446,7 +446,6 @@ static Token *tokenize(char *filename, char *p) {
cur = cur->next = new_token(TK_EOF, p, p);
add_line_numbers(head.next);
convert_keywords(head.next);
return head.next;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment