From 5aaa7c08feddfe337f1666b08650bec42c9c8046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=8Ddiohabara=E5=8D=8D?= Date: Wed, 9 Aug 2023 22:40:04 -0500 Subject: [PATCH] todo: self-host --- README.md | 11 ++++++++--- src/parse.c | 7 ++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 08fda8e..c269988 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ make help When you want to check/format source code, ```bash -make lintx +make lint ``` ### test @@ -41,7 +41,7 @@ make lintx When you want to see if the compiler is working, ```bash -make testx +make test ``` ### debug @@ -49,7 +49,7 @@ make testx If you want to debug interactively, use `gdb`. ```bash -docker run -i --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --platform=linux/amd64 -v "${PWD}:/src" -w/src ccc bash -c "make; gdb ./ccc" +gdb ./ccc ``` If you want to debug `main() { a = 1; b = 2; return 3; }` in `gdb`, @@ -66,6 +66,11 @@ When you want to remove object files, make clean ``` +## TODO + +- [ ] self host + - `make self-host` + ## references - diff --git a/src/parse.c b/src/parse.c index c428081..885be1b 100644 --- a/src/parse.c +++ b/src/parse.c @@ -233,7 +233,6 @@ void global_var() { // // TODO: write tyepdef here if (ty->is_typedef) { expect(";"); - ty->is_typedef = false; push_scope(name)->type_def = ty; return; } @@ -322,7 +321,7 @@ Type *type_specifier() { bool is_static = false; bool is_extern = false; - for (;;) { + while (is_typename()) { // read one token at a time Token *tok = token; if (consume("typedef")) { @@ -362,9 +361,7 @@ Type *type_specifier() { break; } Type *ty = find_typedef(token); - if (!ty) { - break; - } + assert(ty); token = token->next; user_type = ty; }