From: NeilBrown Date: Sun, 7 Nov 2021 00:28:04 +0000 (+1100) Subject: oceani: perform analysis before printing X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=commitdiff_plain;h=d7e32bb049504f5e931f09ac041470f496c58b2c;hp=c9827dcb3cb79fe907633b8badd1e5fd918ca388 oceani: perform analysis before printing This will allow information attached during analysis to be printed out as comments. Signed-off-by: NeilBrown --- diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index c820d39..af24d9b 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -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("= ");