detect-quantifier-issues
Identifies suspicious quantifier patterns in ANTLR4 grammars that cause parsing failures, and suggests corrected quantifier usage.
Instructions
Detect suspicious quantifier patterns that may prevent parsing real configs.
When to use: After seeing "unrecognized syntax" warnings or when rules don't match multi-line configs.
Common patterns detected:
Rule names with _rule, _setting, _property using ? instead of * → bgpp_export: EXPORT bgp_policy_rule? should be *
Multiple optional elements that should be alternatives → source? destination? action? should be (source | destination | action)*
Same optional reference appearing multiple times → rule: setting? ... setting? should use setting*
Real-world example: Rule: srs_definition: ... source_setting? destination_setting? action_setting? Issue: Config has multiple 'set source', 'set destination' lines Fix: Change to (source_setting | destination_setting | action_setting)*
Returns: List of suspicious patterns with suggestions and reasoning.
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 |