Nim's optimizer does not understand control flow hiding in `emit` and is free to break your program. Instead of goto, use structured programming constructs like `if` and `while` (there is also `return` and `break`).
Do yourself a favor and read books about basic programming techniques -- you misuse regular expressions to the point that you need to know the used PCRE version, now you ask for `goto`, and I can already predict your next questions. This is not a comfortable position to be in.
