Add support for cancellation of the parsing process
FirstTimeInForever opened this issue · comments
Ivan Posti commented
Sometimes it is needed to cancel the currently running parsing process (e.g. if the input was updated and the parsing result would be immediately outdated). Typing in some editor can be considered an example of such a case.
To achieve this, we can provide an instance of CancellationToken
to the parser:
fun interface CancellationToken {
fun checkCancelled()
}
The parser can then call checkCancelled
in relevant places (loops/ast construction/html generation/...) to abort its execution if needed.