aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-05-05 19:21:37 +0900
committernsfisis <nsfisis@gmail.com>2025-05-05 19:21:37 +0900
commitfdbae4406db4f0ae51f1d01053281295458b8963 (patch)
tree4b70ec7587b9ed64e9a81481fc178202c0430b48
parent777fa18fe1c3e55a2845d15947ece03c489f950f (diff)
downloadP4Dcc-fdbae4406db4f0ae51f1d01053281295458b8963.tar.gz
P4Dcc-fdbae4406db4f0ae51f1d01053281295458b8963.tar.zst
P4Dcc-fdbae4406db4f0ae51f1d01053281295458b8963.zip
update readme
-rw-r--r--README.md8
-rw-r--r--main.c10
2 files changed, 9 insertions, 9 deletions
diff --git a/README.md b/README.md
index 086d50e..ec6e1bb 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
# P4Dcc
-P4Dcc is a tiny, but self-hosted C compiler. It takes C source code and compiles it to assembly language. For assembling and linking, I use gcc as-is.
+P4Dcc is a tiny, but self-hosted C compiler. It takes C source code and compiles it to assembly language. For assembling and linking, it deletegates to gcc as-is.
-This project was started to test the hypothesis: "Could a self-hostable C compiler be built in four days, if the feature set is carefully limited?" - "P4D" stands for the ISO 8601 notation meaning "four days." However, I actually completed the project by the morning of the third day.
+This project was started to prove the hypothesis: "Could a self-hostable C compiler be built in four days, if the feature set is carefully limited?" - "P4D" stands for the ISO 8601 notation meaning "four days." However, I actually completed the project by the morning of the third day.
The code is written following the instructions at https://www.sigbus.info/compilerbook, and several key design decisions were inspired by the book.
@@ -32,7 +32,7 @@ $ just test-all # test all things, including binary equiality between generatio
To meet the four-day goal, many design decisions were made to reduce complexity (ideas directly taken from https://www.sigbus.info/compilerbook are not listed):
-* Simplify declaration syntax
+* Simplified declaration syntax
* No support for `typedef`
* Structs always begin with `struct` keyword
* No support for array types
@@ -40,7 +40,7 @@ To meet the four-day goal, many design decisions were made to reduce complexity
* All arrays are heap-allocated and accessed via pointers
* No support for function types
* Type information always precede the variable name
-* Most syntax sugar is not implemented
+* Minimal syntax sugar
* No increment/decrement operators
* ~~No compound assignment operators~~
* Implemented after self-hosting
diff --git a/main.c b/main.c
index cac8915..53d6d38 100644
--- a/main.c
+++ b/main.c
@@ -412,7 +412,7 @@ int type_alignof(struct Type* ty) {
#define AST_VAR_DECL 25
#define node_items __n1
-#define node_len ival
+#define node_len __i
#define node_expr __n1
#define node_lhs __n1
#define node_rhs __n2
@@ -426,19 +426,19 @@ int type_alignof(struct Type* ty) {
#define node_members __n1
#define node_params __n1
#define node_args __n1
-#define node_int_value ival
-#define node_index ival
-#define node_op ival
+#define node_int_value __i
+#define node_index __i
+#define node_op __i
struct AstNode {
int kind;
char* name;
- int ival;
struct Type* ty;
struct AstNode* __n1;
struct AstNode* __n2;
struct AstNode* __n3;
struct AstNode* __n4;
+ int __i;
};
struct Program {