From 9a7e88e33213135da7c8fa3607ca455d997f4a39 Mon Sep 17 00:00:00 2001 From: c Date: Mon, 4 Mar 2024 13:11:29 -0500 Subject: One can now load simple variables into memory. --- src/include/doer.h | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'src/include/doer.h') diff --git a/src/include/doer.h b/src/include/doer.h index 8f51266..afa80dd 100644 --- a/src/include/doer.h +++ b/src/include/doer.h @@ -4,8 +4,29 @@ #include "util.h" #include "tree.h" +typedef struct TARGET { + char* name; // The name of the target (unique). + tree_t* tree; // The tree to which the target refers. + struct TARGET* nxt; // The next target in the list. +} target_t; + +target_t* target_init(char* name, tree_t* tree); +/* + Destroy a target. + - Destroys all subsequent targets. + - Frees `name`. + - Does not free `tree`. + Remember to NULL a parent target's `nxt`. +*/ +void target_destroy(target_t* target); +// Print out the target list. Useful for debugging. +void target_print(target_t* target); + typedef struct DOER { - tree_t* tree; + tree_t* tree; // The tree the doer is reading from. + target_t* targets; // The targets the doer must remember. + target_t* ltarget; // The last target in the list (after which new + // targets will be appended.) } doer_t; /* Creates a new parser. */ @@ -23,8 +44,13 @@ typedef struct BLINF { char name[24]; } blinf_t; -void doer_do_blin_print(doer_t* tree); // Built-in function `print`. -void doer_do_blin_printl(doer_t* tree); // Built-in function `print`. +void doer_add_target(doer_t* doer, target_t* target); + +// Built-in functions. +// `print`: print a string. +void blin_print(doer_t* tree); +// `printl`: print a string, and add a newline. +void blin_printl(doer_t* tree); void doer_do_block(doer_t* tree); void doer_do_expr(doer_t* tree); @@ -37,8 +63,8 @@ void doer_do_def(doer_t* tree); void doer_do_call(doer_t* tree); const static blinf_t blinfs[] = { - { doer_do_blin_print, "print" }, - { doer_do_blin_printl, "printl" } + { blin_print, "print" }, + { blin_printl, "printl" } }; #endif -- cgit v1.2.3