Spend a little while trying to understand the rewrite, but so far no luck with this line - what is the point re-running `scanner` with the same `idx` as the original one? This is probably to mitigate intermediate comments which does not have an `@import` inside them.

It could probably lead to stack overflow exception unless there is something tricky in it :-)