Skip to content

Commit

Permalink
todo: self-host
Browse files Browse the repository at this point in the history
  • Loading branch information
diohabara committed Aug 10, 2023
1 parent 9387598 commit 5aaa7c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ make help
When you want to check/format source code,

```bash
make lintx
make lint
```

### test

When you want to see if the compiler is working,

```bash
make testx
make test
```

### debug

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`,
Expand All @@ -66,6 +66,11 @@ When you want to remove object files,
make clean
```

## TODO

- [ ] self host
- `make self-host`

## references

- <https://www.sigbus.info/compilerbook>
Expand Down
7 changes: 2 additions & 5 deletions src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -362,9 +361,7 @@ Type *type_specifier() {
break;
}
Type *ty = find_typedef(token);
if (!ty) {
break;
}
assert(ty);
token = token->next;
user_type = ty;
}
Expand Down

0 comments on commit 5aaa7c0

Please sign in to comment.