SSLR PEG timeout

Hi,

I have a question to the SSLR PEG parser com.sonar.sslr.impl.Parser.

Due to the unlimited lookahead capability that the grammar formalism provides, the resulting parser could exhibit exponential time performance in the worst case. I wonder if there is a way to implement a timeout that stops the parser after a certain amount of time?

Is there an existing mechanism or method in the parser which can be overwritten to implement something like this?

Regards,
Günter

Hi,

I don’t think that there’s anything like that which is built-in and I suppose it should be possible to run the parser in a separate thread and stop it after some time.

SonarSource products use SSLR for quite a few languages and I think that we never considered stopping the parser to workaround performance problems. We encountered several cases of exponential time performances and we considered them as bugs. For each case, it took some time to understand the root cause of the problem and the fix required changing 1 or 2 lines in our grammar.

Pierre-Yves

Hi Pierre-Yves,

Thanks for your answer. Agree, best solution is always to optimize the grammar. But I was looking for a safety net…

Regards,
Günter