aboutsummaryrefslogtreecommitdiff
path: root/src/driver.c
diff options
context:
space:
mode:
authorFlavian Kaufmann <flavian@flaviankaufmann.ch>2025-05-22 11:32:03 +0200
committerFlavian Kaufmann <flavian@flaviankaufmann.ch>2025-05-22 11:32:03 +0200
commitbe21cdaa9f408535379360b401089c8e2335e818 (patch)
treec271335e930e3da3244c69503980581a340c3cf2 /src/driver.c
parentfba0e505aaa067d3e19849536aa0142ab6fe187d (diff)
downloadimp-be21cdaa9f408535379360b401089c8e2335e818.tar.gz
imp-be21cdaa9f408535379360b401089c8e2335e818.zip
print ast
Diffstat (limited to 'src/driver.c')
-rw-r--r--src/driver.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/driver.c b/src/driver.c
index c9ac098..8902a55 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -21,17 +21,22 @@ static int interpret_file(const char *path) {
int main(int argc, char **argv) {
int opt;
- while ((opt = getopt(argc, argv, "i:h")) != -1) {
- switch (opt){
+ while ((opt = getopt(argc, argv, "i:a:h")) != -1) {
+ switch (opt) {
case 'i':
interpret_file(optarg);
return EXIT_SUCCESS;
+ case 'a':
+ print_ast_file(optarg);
+ return EXIT_SUCCESS;
case 'h':
default:
fprintf(stderr,
- "Usage: %s [-i program.imp]\n"
+ "Usage: %s [ARGS]\n"
+ " (no args) start REPL\n"
" -i <program.imp> interpret program and exit\n"
- " (no args) start REPL\n",
+ " -a <program.imp> print ast\n"
+ " -h print this message\n",
argv[0]);
return (opt == 'h') ? EXIT_SUCCESS : EXIT_FAILURE;
}