I don't know how the Axe parser does it. But what I would do is this:
- set parseVar to the name of the program, begPC and endPC to the starting and ending addresses, and curPC to the location of the error - just as if you're really executing the program
- set errNo to a valid error code greater than 128, indicating an editable error
- reset the stacks (B_CALL ResetStacks / ld sp, (onSP))
- load the cxError context (ld a, cxError / B_CALL NewContext0)
- and send a k2 keycode (ld a, k2 / B_JUMP MonForceKey)
This can only be done by a Flash app.
From an Asm( program, it's simpler: I would simply set up parseVar, begPC, curPC, and endPC, as before, then throw the desired error, and let the user choose whether to Quit or Goto it. (If the built-in error messages aren't enough for you, you can use AppErr1/AppErr2 to display a custom error message.) I don't think it would be worth trying to do anything fancier, and anything fancier would be likely to break in nasty ways.
Shell programs absolutely cannot do this kind of thing ever.
Edit: Oops, I made a couple of mistakes there. You want an error code with bit 7 set, not bit 0, and it does have to be a valid error code. And directly sending kGoto doesn't quite work because there's still a popup active.