- Home
- Skills
- Prompt & Skill Engineering
- intellij grammar kit
intellij grammar kit
Write and maintain IntelliJ Grammar-Kit BNF grammars and JFlex lexers with proper error recovery and PSI patterns.
Free
Works with the AI Agents you already use
intellij grammar kit
Example session with this skill installed
I need to add a 'repeat-until' loop to my BNF. It should start with 'repeat', have a body of statements, and end with 'until' followed by an expression. Add error recovery for the body.
- Read your context and instructions
- Compiled the intellij grammar kit
I have updated the BNF grammar to include the repeat_until_stmt with proper pinning and error recovery. This ensures that if the loop body contains a syntax error, the parser can still recover once it hits the UNTIL keyword.
IntelliJ Grammar-Kit BNF Update
// Token definitions to add to your 'tokens' block
tokens = [
REPEAT_KEYWORD='repeat'
UNTIL_KEYWORD='until'
]
// Rule definition with recovery
repeat_until_stmt ::= 'repeat' loop_body 'until' expr {
pin=1
recoverWhile=repeat_recover
}
// Private recovery predicate
private repeat_recover ::= !('until' | 'repeat' | '}')
// Update your statement rule to include the new loop
stmt ::= ... | repeat_until_stmt | ...
// Mixin for custom behavior (optional)
{
mixin("repeat_until_stmt")="com.example.plugin.psi.impl.MyAbstractRepeatStmt"
}
Next steps
- Run Generate Parser Code from the context menu of your
.bnffile. - If you added new literal tokens, run
Generate JFlex Lexer and then
Run JFlex Generator on the resulting .flex file.
3. Add a new test case in your ParserTest.java using a malformed loop body to verify the repeat_recover predicate works as expected.
Connects securely to your tools. The creator never sees your data.
About this skill
Writing parsers for IntelliJ plugins is manual and error-prone. One mismatch between your BNF tokens and JFlex rules leads to silent failures and broken syntax highlighting. This skill manages the specific syntax and generation logic required for Grammar-Kit and JFlex, ensuring your custom language plugin remains stable.
What it does
- BNF authoring helps you write and modify Grammar-Kit BNF files including parser rules and token definitions.
- Lexer synchronization ensures your
.flexfiles correctly emit token types defined in your BNF tokens block. - Error recovery implementation applies
pinandrecoverWhilepatterns to prevent a single typo from breaking the entire parse tree. - PSI architecture guides the implementation of behavior via mixins and
psiImplUtilClassrather than hand-editing generated code. - Expression hierarchy manages Pratt-style expression rules and handles precedence without left recursion.
How it works
- Define grammar by providing your current
.bnffile or describing the syntax of the new language construct. - Apply recovery patterns to specific rules to isolate parse errors using lookahead and predicate rules.
- Synchronize lexer by generating the necessary JFlex regex rules for new tokens.
- Update PSI logic by creating mixin classes or interface extensions for custom node behavior.
Frameworks & tools
JetBrains Grammar-Kit, JFlex, IntelliJ Platform SDK, Java, and Kotlin.
Why this beats prompting it yourself
Generic AI often suggests left-recursive grammars or incorrect recovery predicates that cause infinite loops in the IntelliJ parser. This skill follows specific JetBrains plugin development patterns, ensuring your generated PSI classes are predictable and your lexer matches your BNF exactly.
Use cases
- Add a new keyword or operator to an existing language plugin.
- Fix "red code" issues where valid source files fail to parse correctly.
- Implement robust error recovery for nested block structures or lists.
- Refactor flat grammars into efficient Pratt-style expression hierarchies.
Known limitations
Does not run the actual generation commands; you must manually trigger 'Generate Parser Code' and 'Run JFlex Generator' in the IDE. Scope is limited to the grammar and lexer logic.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Prompt & Skill Engineering.
Requires manual execution of IDE generation actions. Does not support legacy non-BNF parsers. Assumes usage of FlexAdapter for lexer testing.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 14 days ago
- Free with an Agensi account
Permissions
No special permissions declared or detected