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

Add a do-nothing preprocessor

parent f51e65a0
Branches
No related merge requests found
......@@ -69,11 +69,18 @@ void warn_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
//
......
......@@ -183,6 +183,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);
Var *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;
}
......@@ -332,7 +332,7 @@ static Token *read_number(Token *cur, 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_RESERVED;
......@@ -449,7 +449,6 @@ static Token *tokenize(char *filename, char *p) {
new_token(TK_EOF, cur, p, 0);
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