analyze-mode-transitions
Builds a mode transition graph for ANTLR4 lexers to detect circular transitions, unbalanced pushMode/popMode, and modes lacking exits, providing suggestions for better mode structure.
Instructions
Analyze mode transition graph and detect issues in ANTLR4 lexer modes.
When to use: Debugging mode switching logic, ensuring balanced push/pop, detecting circular transitions.
Features:
Builds complete mode transition graph
Detects circular mode transitions
Checks for balanced pushMode/popMode usage
Identifies modes with no exit points
Suggests improvements for mode structure
Returns:
transitions: List of all mode transitions (from, to, via action, rule)
issues: Problems detected (circular transitions, unbalanced push/pop)
suggestions: Recommendations for improving mode structure
Example usage: from_file: "MyLexer.g4"
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "analyze-mode-transitions"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from_file | No | Optional: path to a grammar file to read | |
| grammar_content | No | The ANTLR4 grammar file content |