struct parse_context {
struct token_config config;
char *file_name;
+ int parse_error;
## parse context
};
} else
prog = parse_oceani(s->code, &context.config,
dotrace ? stderr : NULL);
+ if (!prog) {
+ fprintf(stderr, "oceani: fatal parser error.\n");
+ context.parse_error = 1;
+ }
if (prog && doprint)
print_exec(*prog, 0, brackets);
- if (prog && doexec) {
+ if (prog && doexec && !context.parse_error) {
if (!analyse_prog(*prog, &context)) {
fprintf(stderr, "oceani: type error in program - not running.\n");
exit(1);
s = t;
}
## free context
- exit(0);
+ exit(context.parse_error ? 1 : 0);
}
### Analysis
}
}
fputs("\n", stderr);
+ c->parse_error = 1;
}
## Data Structures
$0->right = $<4;
var_block_close(config2context(config), CloseSequential);
if (config2context(config)->scope_stack) abort();
- }$
+ }$
+ | ERROR ${
+ fprintf(stderr, "%s:%d:%d: error: unhandled parse error.\n",
+ config2context(config)->file_name, $1.line, $1.col);
+ config2context(config)->parse_error = 1;
+ }$
Varlist -> Varlist ArgDecl ${
$0 = new(binode);