Re:Show HN: Writing my first interpreter in C for fun
by jhedwards on Wednesday June 22, 2016 @11:28AM
(#11954671)
I just realized reading your comment that I did implement functions but I forgot to document them! I will update the readme immediately.
If you look in the main file, huo.c, you will see something called store_defs. That function takes the ASTs of defined functions and stores them in a key-val type store. If someone invokes a user-defined function I just grab the AST, replace the variables with the values they passed in and execute it. That code is in process_defs and is invoked by execute.
(Though my changes are ugly).
If/When you get to implementing functions things will get really useful :)