diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/doer.h | 36 |
1 files changed, 31 insertions, 5 deletions
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 |