diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2023-02-20 22:16:26 -0800 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2023-02-20 22:16:26 -0800 |
| commit | a51e3c9173b5314d7ba79033f94b82014175ab82 (patch) | |
| tree | d56366fb821bd2e326b7cef2854d1e9adf753cb9 | |
| parent | 84ba393f95aa85d975b4bb9f816be4babd1d50d5 (diff) | |
cleaned up stuff
| -rw-r--r-- | src/eval.c | 14 | ||||
| -rw-r--r-- | src/parse.c | 2 |
2 files changed, 3 insertions, 13 deletions
@@ -11,8 +11,7 @@ sym_t* eval(sym_t* symbol, hashtable_t* parentScope) { return init_sym_int(*((int*)symbol->name)); } else if (symbol->litType == FLOAT) { - /* TODO: float */ - return NULL; + return init_sym_float*((float*)symbol->name); } else if (symbol->litType == STRING) { return init_sym_str((char*)symbol->name); @@ -32,7 +31,6 @@ sym_t* eval(sym_t* symbol, hashtable_t* parentScope) { else { /* not an internal function, search hashtable for next symbol */ - /* TODO: scope */ pair_t p = hashtable_get_pair_recurse(parentScope, (char*)symbol->name); if (p.key != NULL) { sym_t* nextSym = (sym_t*)p.value; @@ -98,7 +96,6 @@ sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) { return symbol->args[0]; } else if (hash == get_hash("eval")) { - //hashtable_t* newScope = init_hashtable(50, symbolScope); sym_t* v; if (symbol->argCount > 1) { v = eval_with_args(eval(symbol->args[0], symbolScope), symbol->args + 1, symbol->argCount - 1, symbolScope); @@ -106,12 +103,10 @@ sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) { else { v = eval(eval(symbol->args[0], symbolScope), symbolScope); } - //destroy_hashtable(newScope); return v; } else if (hash == get_hash("store")) { - /* first arg is value, remaining args are names */ - /* TODO: recursion for multiple pairs */ + /* first arg is value, second arg is key */ sym_t* v = eval(symbol->args[1], symbolScope); char* k = symtos(v); destroy_sym(v); @@ -122,8 +117,7 @@ sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) { return init_sym_int(1); } else if (hash == get_hash("update")) { - /* first arg is value, remaining args are names */ - /* TODO: recursion for multiple pairs */ + /* first arg is value, second arg is key */ sym_t* v = eval(symbol->args[1], symbolScope); char* k = symtos(v); destroy_sym(v); @@ -133,7 +127,6 @@ sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) { hashtable_update_pair_recurse(symbolScope->parent, p); return init_sym_int(1); } - /* TODO: release()/free() method? */ else if (hash == get_hash("eq")) { litType_t type = NO_TYPE; int firstInt = 0; @@ -195,7 +188,6 @@ sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) { exec_all(symbol->args + 1, symbol->argCount - 1, symbolScope); return init_sym_int(1); } - /* TODO: free other args if condition fails */ return init_sym_int(0); } else if (hash == get_hash("not")) { diff --git a/src/parse.c b/src/parse.c index fcaab5d..18425ac 100644 --- a/src/parse.c +++ b/src/parse.c @@ -102,9 +102,7 @@ symset_t* parse_symbols(char** str) { sym_t* symbol; /* TODO: float */ /* string */ - /* TODO: more frees in here */ if (isalpha(symbolName[0])) { - //TODO: realloc this symbol = init_sym_str(symbolName); } /* int */ |
