void Abort(ParseContext *c, const char *fmt, ...) { char buf[100], *p = buf; va_list ap; va_start(ap, fmt); VM_printf("error: "); vsnprintf(buf, sizeof(buf), fmt, ap); while (*p != '\0') VM_putchar(*p++); VM_putchar('\n'); va_end(ap); longjmp(c->errorTarget, 1); }
/* Fatal - report a fatal error and exit */ void Fatal(ParseContext *c, char *fmt, ...) { va_list ap; va_start(ap, fmt); VM_printf("error: "); VM_vprintf(fmt, ap); VM_putchar('\n'); va_end(ap); longjmp(c->errorTarget, 1); }
/* ParseError - report a parsing error */ void ParseError(ParseContext *c, char *fmt, ...) { va_list ap; /* print the error message */ va_start(ap, fmt); VM_printf("error: "); VM_vprintf(fmt, ap); VM_putchar('\n'); va_end(ap); /* show the context */ VM_printf(" line %d\n", c->lineNumber); VM_printf(" %s\n", c->sys->lineBuf); VM_printf(" %*s\n", c->tokenOffset, "^"); /* exit until we fix the compiler so it can recover from parse errors */ longjmp(c->errorTarget, 1); }
void ShowStack(Interpreter *i) { VMHANDLE *hp; VMVALUE *p; for (hp = (VMHANDLE *)i->stack; hp <= i->hsp; ++hp) { if (hp == i->hfp) VM_printf(str_hfp_tag); VM_printf(str_hstack_entry_fmt, (VMUVALUE)*hp); } VM_printf(str_stack_separator); for (p = i->sp; p < i->stackTop; ++p) { if (p == i->fp) VM_printf(str_fp_tag); VM_printf(str_stack_entry, *p); } VM_putchar('\n'); }