aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlavian Kaufmann <flavian@flaviankaufmann.ch>2025-05-22 13:23:18 +0200
committerFlavian Kaufmann <flavian@flaviankaufmann.ch>2025-05-22 13:23:18 +0200
commit6ef8829451871b534572d47312ae255dee088588 (patch)
tree3652795378f330452d8752dd9d1783a74a620d78 /src
parent027fc783faa9a25b373099e0e0f86d3859b7235d (diff)
downloadimp-6ef8829451871b534572d47312ae255dee088588.tar.gz
imp-6ef8829451871b534572d47312ae255dee088588.zip
cleanup
Diffstat (limited to 'src')
-rw-r--r--src/driver.c8
-rw-r--r--src/interpreter.c2
-rw-r--r--src/repl.c14
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);
}
diff --git a/src/repl.c b/src/repl.c
index d61ccd4..82480bd 100644
--- a/src/repl.c
+++ b/src/repl.c
@@ -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);