infer-formatting
Infer the formatting style of an ANTLR4 grammar, including indentation and symbol placement, to preserve conventions when editing.
Instructions
Analyze an ANTLR4 grammar and infer its formatting style.
When to use: Understand the formatting conventions used in a grammar, or verify that formatting will be preserved when making changes.
Example usage: from_file: "MyGrammar.g4"
Analyzes:
Colon placement (same-line vs new-line after rule name)
Semicolon placement (same-line vs new-line after definition)
Space before colon (e.g., "rule :" vs "rule:")
Indentation style (spaces or tabs, and how many)
Blank lines between rules
Returns: Formatting style object with detected patterns.
Note: The update-rule, add-lexer-rule, and add-parser-rule tools automatically use this inference to preserve your grammar's formatting style.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from_file | No | Optional: path to a grammar file to read | |
| grammar_content | No | The content of the ANTLR4 grammar file |