create-grammar-template
Create a new ANTLR4 grammar from scratch with optional lexer modes and boilerplate rules. Scaffold lexer, parser, or combined grammar.
Instructions
Create a new ANTLR4 grammar from scratch with optional mode structure.
When to use: Starting a new grammar project, scaffolding grammar structure, creating grammar templates.
Features:
Creates lexer, parser, or combined grammar
Optionally includes boilerplate rules (WS, ID, NUMBER, STRING, comments)
Adds specified modes with placeholder comments
Ready-to-use structure for common patterns
Example - Simple lexer grammar: grammar_name: "MyLexer" type: "lexer"
Example - Lexer with modes: grammar_name: "TemplateLexer" type: "lexer" modes: ["STRING_MODE", "COMMENT_MODE", "INTERPOLATION_MODE"] include_boilerplate: true
Example - Combined grammar: grammar_name: "Calculator" type: "combined" include_boilerplate: true
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | No | Type of grammar to create (default: lexer) | |
| modes | No | List of mode names to include in the grammar | |
| grammar_name | Yes | Name for the new grammar | |
| grammar_content | No | Placeholder - not required for this tool | |
| include_boilerplate | No | Include common rules like WS, ID, NUMBER, STRING (default: true) |