]> ocean-lang.org Git - ocean/commitdiff
oceani: perform analysis before printing
authorNeilBrown <neil@brown.name>
Sun, 7 Nov 2021 00:28:04 +0000 (11:28 +1100)
committerNeilBrown <neil@brown.name>
Mon, 8 Nov 2021 09:56:36 +0000 (20:56 +1100)
This will allow information attached during analysis to
be printed out as comments.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/oceani.mdc

index c820d39153674dcc75fcb2fa5022e60c2624ffce..af24d9becd86326c48633e66cd0718a5510479da 100644 (file)
@@ -242,18 +242,19 @@ structures can be used.
                        fprintf(stderr, "oceani: no main function found.\n");
                        context.parse_error = 1;
                }
+               if (context.prog && !context.parse_error) {
+                       if (!analyse_prog(context.prog, &context)) {
+                               fprintf(stderr, "oceani: type error in program - not running.\n");
+                               context.parse_error = 1;
+                       }
+               }
                if (context.prog && doprint) {
                        ## print const decls
                        ## print type decls
                        print_exec(context.prog, 0, brackets);
                }
-               if (context.prog && doexec && !context.parse_error) {
-                       if (!analyse_prog(context.prog, &context)) {
-                               fprintf(stderr, "oceani: type error in program - not running.\n");
-                               exit(1);
-                       }
+               if (context.prog && doexec && !context.parse_error)
                        interp_prog(&context, context.prog, argc - optind, argv+optind);
-               }
                free_exec(context.prog);
 
                while (s) {
@@ -3582,19 +3583,17 @@ it is declared, and error will be raised as the name is created as
                do_indent(indent, "");
                print_exec(b->left, indent, bracket);
                if (cast(var, b->left)->var->constant) {
+                       printf("::");
                        if (v->where_decl == v->where_set) {
-                               printf("::");
                                type_print(v->type, stdout);
                                printf(" ");
-                       } else
-                               printf(" ::");
+                       }
                } else {
+                       printf(":");
                        if (v->where_decl == v->where_set) {
-                               printf(":");
                                type_print(v->type, stdout);
                                printf(" ");
-                       } else
-                               printf(" :");
+                       }
                }
                if (b->right) {
                        printf("= ");