diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/driver.c | 8 | ||||
-rw-r--r-- | src/interpreter.c | 2 | ||||
-rw-r--r-- | src/repl.c | 14 |
3 files changed, 11 insertions, 13 deletions
diff --git a/src/driver.c b/src/driver.c index 8902a55..441ee40 100644 --- a/src/driver.c +++ b/src/driver.c @@ -24,17 +24,15 @@ int main(int argc, char **argv) { while ((opt = getopt(argc, argv, "i:a:h")) != -1) { switch (opt) { case 'i': - interpret_file(optarg); - return EXIT_SUCCESS; + return interpret_file(optarg) ? EXIT_FAILURE : EXIT_SUCCESS; case 'a': - print_ast_file(optarg); - return EXIT_SUCCESS; + return print_ast_file(optarg) ? EXIT_FAILURE : EXIT_SUCCESS; case 'h': default: fprintf(stderr, "Usage: %s [ARGS]\n" " (no args) start REPL\n" - " -i <program.imp> interpret program and exit\n" + " -i <program.imp> interpret program\n" " -a <program.imp> print ast\n" " -h print this message\n", argv[0]); diff --git a/src/interpreter.c b/src/interpreter.c index 2de5b63..8176bad 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -92,8 +92,8 @@ void context_print_proc_table(Context *context) { vargs = vargs->next; if (vargs) printf(", "); } + printf(")\n"); } - printf(")\n"); hashmap_keys_iter_free(iter); } @@ -14,12 +14,12 @@ static void print_help(void) { printf( "IMP REPL (type IMP statements or commands starting with '%%')\n" "Commands:\n" - " %%quit exit\n" - " %%run <path/to/file.imp> interpret program\n" - " %%set <var> <val> set variable\n" - " %%print [<var>] print variable, or all variables\n" - " %%proc print declared procedures\n" - " %%help show this message\n"); + " %%quit exit\n" + " %%run <program.imp> interpret program\n" + " %%set <var> <val> set variable\n" + " %%print [<var>] print variable, or all variables\n" + " %%procedures list declared procedures\n" + " %%help show this message\n"); } static void repl_exec_command(context_t context, char *command) { @@ -44,7 +44,7 @@ static void repl_exec_command(context_t context, char *command) { char *var = strtok(NULL, " \t"); if (var) printf("%s = %d\n", var, context_get_var(context, var)); else context_print_var_table(context); - } else if (strcmp(cmd, "%proc") == 0) { + } else if (strcmp(cmd, "%procedures") == 0) { context_print_proc_table(context); } else { fprintf(stderr, "Unknown command: %s\n", cmd); |