suggest-tokens-from-errors
Analyze parser error logs and automatically suggest missing tokens to add to ANTLR grammar, with confidence scoring.
Instructions
Parse error logs and automatically suggest missing tokens to add to grammar.
When to use:
Debugging parser failures with error logs
Identifying missing tokens from Batfish errors
Analyzing ANTLR parse error output
Incremental grammar development based on test failures
Supported error log formats:
Batfish-style: "unexpected token: 'word'"
ANTLR-style: "mismatched input 'word'"
ANTLR-style: "no viable alternative at input 'word'"
Generic: any quoted strings in error context
Example - Analyze Batfish error log: error_log: "Error parsing config: unexpected token: 'ftm-push' at line 10" → Suggests: FTM_PUSH token with pattern 'ftm-push'
Example - Parse ANTLR errors: error_log: "line 5:10 mismatched input 'admin' expecting {CONFIG, SYSTEM}" → Suggests: ADMIN token with pattern 'admin'
Features:
Multi-format error log parsing
Confidence scoring (high/medium/low)
Automatic deduplication
Skips tokens that already exist in grammar
Provides reasoning for each suggestion
Handles multiple errors in batch
Returns:
List of suggested tokens with:
Token name (uppercase with underscores)
Pattern (string literal)
Reason for suggestion
Confidence level
Summary of suggestions found
Note: This tool only suggests tokens. Use add-lexer-rules to actually add them to your grammar.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error_log | Yes | Error log content to analyze (supports Batfish and ANTLR error formats) | |
| from_file | No | Optional: path to a grammar file to read | |
| grammar_content | No | The ANTLR4 grammar file content |