summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/main.c b/main.c
index 778fae9..7ba3033 100644
--- a/main.c
+++ b/main.c
@@ -5,6 +5,7 @@
#include "group.h"
#include "identify.h"
#include "check.h"
+#include "scope.h"
#include <stdio.h>
#include <stdlib.h>
@@ -48,10 +49,21 @@ main(int argc, char **argv)
identify(tokens, identify_else, GROUP_ELSE, 1);
identify(tokens, identify_while, GROUP_WHILE, 1);
identify(tokens, identify_expression, GROUP_EXPRESSION, 1);
- if (check_atom(tokens))
- fprintf(stderr, "unidentified atoms are left\n");
- else
+ do {
+ if (check_atom(tokens)) {
+ fprintf(stderr, "unidentified atoms are left\n");
+ break;
+ }
+ Token *group = group_create(&tokens, tokens,
+ token_last(tokens));
+ if (group == NULL) {
+ fprintf(stderr, "group_create failed\n");
+ break;
+ }
+ group->group.type = GROUP_SCOPE;
+ scope_extract(tokens);
token_print(tokens, 1, 0);
+ } while(0);
token_destroy(tokens);
}