When speculating the parser can get stuck in endless loops, which causes compilation to hang. This can cause VSCode to become unresponsive and the VSCE watchdog isn't always able to restart the compiler.
Need a mechanism that detects if no progress has been made after a few iterations and throws an unwind exception to force the parser to give up on the current construct.
The tokenizer lookahead queue is the obvious place to put this watchdog mechanism. The tokenizer can look at the ratio of token reads vs forward movement through the queue: if we keep finding ourselves back at the same speculation mark then, we're stuck in a loop.
When speculating the parser can get stuck in endless loops, which causes compilation to hang. This can cause VSCode to become unresponsive and the VSCE watchdog isn't always able to restart the compiler.
Need a mechanism that detects if no progress has been made after a few iterations and throws an unwind exception to force the parser to give up on the current construct.
The tokenizer lookahead queue is the obvious place to put this watchdog mechanism. The tokenizer can look at the ratio of token reads vs forward movement through the queue: if we keep finding ourselves back at the same speculation mark then, we're stuck in a loop.