antlr/antlr4 · error · IllegalArgumentException
ruleName cannot be null or empty.
Error message
ruleName cannot be null or empty.
What it means
Error "ruleName cannot be null or empty." thrown in antlr/antlr4.
Source
Thrown at runtime/Java/src/org/antlr/v4/runtime/tree/pattern/RuleTagToken.java:61
public RuleTagToken(String ruleName, int bypassTokenType) {
this(ruleName, bypassTokenType, null);
}
/**
* Constructs a new instance of {@link RuleTagToken} with the specified rule
* name, bypass token type, and label.
*
* @param ruleName The name of the parser rule this rule tag matches.
* @param bypassTokenType The bypass token type assigned to the parser rule.
* @param label The label associated with the rule tag, or {@code null} if
* the rule tag is unlabeled.
*
* @exception IllegalArgumentException if {@code ruleName} is {@code null}
* or empty.
*/
public RuleTagToken(String ruleName, int bypassTokenType, String label) {
if (ruleName == null || ruleName.isEmpty()) {
throw new IllegalArgumentException("ruleName cannot be null or empty.");
}
this.ruleName = ruleName;
this.bypassTokenType = bypassTokenType;
this.label = label;
}
/**
* Gets the name of the rule associated with this rule tag.
*
* @return The name of the parser rule associated with this rule tag.
*/
public final String getRuleName() {
return ruleName;
}
/**View on GitHub (pinned to 7d5770395b)
Solutions
- Pass a non-null, non-empty rule name to the RuleTagToken constructor.
- Let ParseTreePatternMatcher.compile build tag tokens for you rather than constructing RuleTagToken manually.
Example fix
RuleTagToken t = new RuleTagToken("expr", MyParser.RULE_expr); When it happens
Trigger: RuleTagToken constructed with a null or empty ruleName.
Common situations: Supply a valid parser rule name when creating RuleTagToken; empty tags like <> are rejected.
AI-assisted analysis of antlr/antlr4@7d5770395b (2026-08-14).
Data as JSON: /api/errors/cbdfb6237199964f.
Report an issue: GitHub.