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

0

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

0
Avatar
Permanently deleted user

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.

 

 

0

请先登录再写评论。