aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorkatherine <shmibs@airen-no-jikken.icu>2019-05-20 19:23:47 -0700
committerkatherine <shmibs@airen-no-jikken.icu>2019-05-20 19:23:47 -0700
commit24eeb2825c9f755c92812ec3a257e6709ccb6576 (patch)
treead7f22f0bf1865de584bd4e1244fc336233af279 /src/main.c
parent326646d14100c43f8cb64e7673f36fcc2b01eb6d (diff)
downloadconfconf-24eeb2825c9f755c92812ec3a257e6709ccb6576.tar.gz
implement analyse function
anlyises the parse results to build a tree for deterministic parser generation
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;
}