diff options
author | kdx <kdx@42l.fr> | 2023-03-17 02:26:25 +0100 |
---|---|---|
committer | kdx <kdx@42l.fr> | 2023-03-17 02:26:25 +0100 |
commit | 4160e9650bcfe7449beb150cdf8196b768a92eb3 (patch) | |
tree | 14d4e2d4131d3c7a198466ba899efa5978808686 /main.c | |
parent | a60f03db9ef3eb65b8898a9bf0ad70fbc2d2cc53 (diff) | |
download | golem-4160e9650bcfe7449beb150cdf8196b768a92eb3.tar.gz |
extract scope
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -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); } |