From f4c5577153f85948ebde15a7c0535f75aeb1ee03 Mon Sep 17 00:00:00 2001 From: zongor Date: Tue, 10 Feb 2026 00:43:27 -0800 Subject: [PATCH] Add compiler todo note --- tools/compiler.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/compiler.c b/tools/compiler.c index 51019aa..47367b1 100644 --- a/tools/compiler.c +++ b/tools/compiler.c @@ -4,6 +4,23 @@ #include #include +/* + +TODO: + +For expressions we should use the shunting yard algorithem. +This will be useful because it will make it trivial to track types. +If the type is a literal, we just read it, if it is a variable we read the variable type from the info. + +During the first pass we count the number of variables. We assign a local to each variable. + +When parsing a expression, we assign any function call or literal to a temp variable slot, +(3 maybe?) First one goes in 0, then 2nd in 1, then do operation. Store the operation in 0. +If it is a function call, use 1 to load and push the args, then use 1 for the return variable. +If both happen to be function calls use 0, 1, 2. Where 1 & 2 are the function calls, and the result operation gets stored in 0. + +*/ + #define DEBUG_COMPILER void emit_byte(u8 byte) {