Compare commits
No commits in common. "1b98d599a186f1574537a4ff8c108971d022c7bf" and "95871ff6bfc6dcda7dc51bd95d6232ecfc1965e6" have entirely different histories.
1b98d599a1
...
95871ff6bf
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
build
|
build
|
||||||
cov
|
|
||||||
*.out
|
*.out
|
||||||
*.o
|
*.o
|
||||||
*.s
|
*.s
|
@ -1,11 +1,10 @@
|
|||||||
# RVBTCC
|
# RVBTCC
|
||||||
|
|
||||||
不到 2000 行的轻量级自举编译器。
|
- 约 1900 行的轻量级自举编译器。
|
||||||
|
- 编译器和自举编译器行为一致。
|
||||||
- 旨在展示如何迅速编写一个自举编译器。
|
|
||||||
- 语法类似 C,输出 RISC-V 汇编。
|
- 语法类似 C,输出 RISC-V 汇编。
|
||||||
- 仅依赖几个 glibc 函数用于输入输出。
|
- 依赖几个 libc 函数用于输入输出。
|
||||||
- 仅作学习用途,请勿在生产环境中使用。
|
- 不使用动态内存分配,嵌入式友好。
|
||||||
|
|
||||||
## 用法
|
## 用法
|
||||||
|
|
||||||
|
15
boot.c
15
boot.c
@ -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
|
// libc dependency
|
||||||
|
|
||||||
extern void* stdin;
|
extern void* stdin;
|
||||||
@ -1151,7 +1140,9 @@ int parse_function_call(int id) {
|
|||||||
|
|
||||||
int parse_primary_expr() {
|
int parse_primary_expr() {
|
||||||
next_token();
|
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);
|
return load_imm(token_data);
|
||||||
} else if (token_type == TOKEN_ID) {
|
} else if (token_type == TOKEN_ID) {
|
||||||
next_token();
|
next_token();
|
||||||
|
Loading…
Reference in New Issue
Block a user