Compare commits

..

No commits in common. "1b98d599a186f1574537a4ff8c108971d022c7bf" and "95871ff6bfc6dcda7dc51bd95d6232ecfc1965e6" have entirely different histories.

4 changed files with 7 additions and 23 deletions

1
.gitignore vendored
View File

@ -1,5 +1,4 @@
build
cov
*.out
*.o
*.s

View File

@ -1,11 +1,10 @@
# RVBTCC
不到 2000 行的轻量级自举编译器。
- 旨在展示如何迅速编写一个自举编译器。
- 约 1900 行的轻量级自举编译器。
- 编译器和自举编译器行为一致。
- 语法类似 C输出 RISC-V 汇编。
- 依赖几个 glibc 函数用于输入输出。
- 仅作学习用途,请勿在生产环境中使用
- 依赖几个 libc 函数用于输入输出。
- 不使用动态内存分配,嵌入式友好
## 用法

15
boot.c
View File

@ -1,14 +1,3 @@
/*
* RVBTCC By Yaossg
* A lightweight bootstrapping compiler in less than 2000 lines.
*
* It aims to demonstrate how to write a bootstrapping compiler in no time.
* Syntax is similar to C, output is RISC-V assembly.
* Only dependent on some glibc functions for I/O.
* Purely for educational purposes. Do not use in production.
*
*/
// libc dependency
extern void* stdin;
@ -1151,7 +1140,9 @@ int parse_function_call(int id) {
int parse_primary_expr() {
next_token();
if (token_type == TOKEN_NUMBER) {
if (token_type == TOKEN_EOF) {
exit(1);
} else if (token_type == TOKEN_NUMBER) {
return load_imm(token_data);
} else if (token_type == TOKEN_ID) {
next_token();

5
cov.sh
View File

@ -1,5 +0,0 @@
mkdir -p cov && cd cov &&
rm *
gcc --coverage -g -O0 ../boot.c
./a.out < ../boot.c > /dev/null
gcov a-boot.c