diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2023-03-14 14:06:07 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2023-03-14 14:06:07 -0700 |
| commit | f1f7f0744a139ca006b51975b0b998c0fe46af9a (patch) | |
| tree | 0fe9078045df549ef33949f3d59106d688804174 /src | |
| parent | f12c6c6aef0f494068bb2b05ea35da1194ac7b0b (diff) | |
added input() function
Diffstat (limited to 'src')
| -rw-r--r-- | src/eval.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -42,7 +42,7 @@ sym_t* eval(sym_t* symbol, hashtable_t* parentScope) { } } else { - printf("no matching pair in hashtable\n"); + printf("key %s not found in any scope\n", (char*)symbol->name); } } /* clear new scope, then return */ @@ -334,6 +334,17 @@ sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) { printf("\n"); return init_sym_int(1); } + else if (hash == get_hash("input")) { + if (symbol->argCount > 0) { + sym_t* v = eval(symbol->args[0], symbolScope); + printf("%s", symtos(v)); + destroy_sym(v); + } + char buffer[4096]; + fgets(buffer, sizeof(buffer), stdin); + buffer[strcspn(buffer, "\n")] = '\0'; + return init_sym_str(buffer); + } else { return NULL; } |
