diff options
author | Camil Staps | 2016-10-12 09:26:57 +0200 |
---|---|---|
committer | Camil Staps | 2016-10-12 09:26:57 +0200 |
commit | f3f81123c2082672dd5bbd47520bd5fdce9a066a (patch) | |
tree | 1907f61551badef1f1ae2bb61b7acbe90f930816 /interpreter/fuspel.c | |
parent | Fix initialisation warning (diff) |
Make debug graphs a command line option (-g)
Diffstat (limited to 'interpreter/fuspel.c')
-rw-r--r-- | interpreter/fuspel.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/interpreter/fuspel.c b/interpreter/fuspel.c index b9ccd12..736a1c3 100644 --- a/interpreter/fuspel.c +++ b/interpreter/fuspel.c @@ -64,11 +64,17 @@ static char doc[] = "Interpret a fuspel program"; static char args_doc[] = "MODULE [MODULE [MODULE [..]]]"; static struct argp_option options[] = { { "print-program", 'P', 0, 0, "Print the parsed program before execution" }, +#ifdef _FUSPEL_DEBUG + { "debug-graphs", 'g', 0, 0, "Make a dot graph after every rewriting step" }, +#endif // _FUSPEL_DEBUG { 0 } }; struct environment { struct fuspel *program; bool printProgram; +#ifdef _FUSPEL_DEBUG + bool debugGraphs; +#endif // _FUSPEL_DEBUG }; static error_t parse_opt(int key, char *arg, struct argp_state *state) { @@ -77,6 +83,11 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { case 'P': env->printProgram = true; break; +#ifdef _FUSPEL_DEBUG + case 'g': + env->debugGraphs = true; + break; +#endif // _FUSPEL_DEBUG case ARGP_KEY_ARG: env->program = import(env->program, arg); return 0; @@ -107,7 +118,11 @@ int main(int argc, char *argv[]) { printf("\n\n"); } +#ifdef _FUSPEL_DEBUG + result = eval_main(env.program, env.debugGraphs); +#else result = eval_main(env.program); +#endif if (result) { print_expression(result); printf("\n"); @@ -121,4 +136,4 @@ int main(int argc, char *argv[]) { return 0; } -#endif +#endif // _FUSPEL_CLI |