Grammar-kit: struggling with recoverWhile
已回答
I've forked Simple Plugin and edited its grammar a bit, trying to figure out recoverWhile. The source can be found here:
https://github.com/OptimisticLock/intellij-sdk-docs/tree/master/code_samples/MySimple
I just added the following (my changes in bold)
simpleFile ::= item_*
private item_ ::= (property|COMMENT|CRLF)
property ::= (KEY? SEPARATOR VALUE?) | KEY {
mixin="com.simpleplugin.psi.impl.SimpleNamedElementImpl"
implements="com.simpleplugin.psi.SimpleNamedElement"
methods=[getKey getValue getName setName getNameIdentifier getPresentation]
pin=1
recoverWhile="recover"
}
recover ::= ! (COMMENT| CRLF)
Am I doing it wrong? I am getting

Help!
Thank you,
Irina
请先登录再写评论。
Hello Irina,
The problem is that the sample is broken. I've explained it here to some degree:
https://youtrack.jetbrains.com/issue/IJSDK-203
Hi Gregory,
Thank you for your answer. I was suspecting something like that.
Json perhaps is not the best example for me, because I need a line-aware grammar (I am writing a CSV plugin at the moment).
What I don't get about `pin` and `recoverWhile` is: how (and why) are they affecting otherwise successfully matching rules? I was expecting them to only take effect when matching fails.
Here's recoverWhile HOWTO:
https://github.com/JetBrains/Grammar-Kit/blob/master/HOWTO.md#22-using-recoverwhile-attribute .