JetBrains / Grammar-Kit

Grammar files support & parser/PSI generation for IntelliJ IDEA
Other
719 stars 125 forks source link

Consider implementing recoverWhile=auto|custom key #143

Open hurricup opened 8 years ago

hurricup commented 8 years ago

Grammar-Kit context help shows section "Followed by" with list of tokens and rules that can be after particular rule according to the grammar. You could use these tokens for auto-generating base recovery rule with possible custom tokens (rule), like:

// user puts
some_rule ::= ....  {recoverWhile=auto|custom_recovery_appendix}

// and parser using following rule (not generating it in bnf)
auto_generated_recover_rule ::= !(auto_calculated_tokens|custom_recovery_appendix)

or make a macro for it, like:

recovery_rule ::= !({AUTO_TOKENS}|..whatever user puts..)

and expand this macro on compilation phase.

Currently we can use context help to generate recovery sets, but each time grammar changes - all rules should be updated.

hurricup commented 8 years ago

seems 'followed by' tokens calculated incorrectly. Or in strange way.

calexHG commented 8 years ago

"seems 'followed by' tokens calculated incorrectly. Or in strange way."

How so? Do you have any examples of what you are expecting and what you are getting?

JojOatXGME commented 3 years ago

This comment suggests that you can already write recoverWhile="#auto". However, I haven't tested it, and maybe it is outdated.