aboutsummaryrefslogtreecommitdiff
path: root/src/driver.c
diff options
context:
space:
mode:
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;
}