aboutsummaryrefslogtreecommitdiff
path: root/interpreter/fuspel.c
diff options
context:
space:
mode:
Diffstat (limited to 'interpreter/fuspel.c')
-rw-r--r--interpreter/fuspel.c17
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