degory / ghul

compiler for the ghūl programming language
https://ghul.dev
GNU Affero General Public License v3.0
4 stars 0 forks source link

Speculative parsing can cause compiler to hang #1143

Open degory opened 7 months ago

degory commented 7 months ago

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.