aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index a101849..0c0e510 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,12 +1,34 @@
#include "err.h"
#include "opt.h"
#include "parse.h"
+#include "analyse.h"
+
+static void print_tree(struct analyse_tree_s *t)
+{
+ unsigned i;
+ if (t->is_terminal)
+ printf("!");
+
+ if (t->branch_count > 1)
+ printf("(");
+
+ for (i = 0; i < t->branch_count; i++) {
+ printf("%c", t->branch_chars[i]);
+ print_tree(t->branches[i]);
+ if (t->branch_count > 1 && i < t->branch_count - 1)
+ printf("|");
+ }
+
+ if (t->branch_count > 1)
+ printf(")");
+}
int main(int argc, char **argv)
{
FILE *fi = stdin;
const char *finame = "stdin";
struct parse_result_s pr;
+ struct analyse_result_s ar;
opt_parse(argc, argv);
@@ -21,7 +43,15 @@ int main(int argc, char **argv)
if (fi != stdin)
fclose(fi);
+ ar = analyse(pr);
+
+ print_tree(&ar.deftype_tree);
+ puts("");
+ print_tree(&ar.var_tree);
+ puts("");
+
parse_result_wipe(&pr);
+ analyse_result_wipe(&ar);
return 0;
}