antlr/antlr4 · error · IllegalArgumentException
missing start tag in pattern: "+pattern
Error message
missing start tag in pattern: "+pattern
What it means
Error "missing start tag in pattern: "+pattern" thrown in antlr/antlr4.
Source
Thrown at runtime/Java/src/org/antlr/v4/runtime/tree/pattern/ParseTreePatternMatcher.java:448
}
else if ( p == pattern.indexOf(stop,p) ) {
stops.add(p);
p += stop.length();
}
else {
p++;
}
}
// System.out.println("");
// System.out.println(starts);
// System.out.println(stops);
if ( starts.size() > stops.size() ) {
throw new IllegalArgumentException("unterminated tag in pattern: "+pattern);
}
if ( starts.size() < stops.size() ) {
throw new IllegalArgumentException("missing start tag in pattern: "+pattern);
}
int ntags = starts.size();
for (int i=0; i<ntags; i++) {
if ( starts.get(i)>=stops.get(i) ) {
throw new IllegalArgumentException("tag delimiters out of order in pattern: "+pattern);
}
}
// collect into chunks now
if ( ntags==0 ) {
String text = pattern.substring(0, n);
chunks.add(new TextChunk(text));
}
if ( ntags>0 && starts.get(0)>0 ) { // copy text up to first tag into chunks
String text = pattern.substring(0, starts.get(0));
chunks.add(new TextChunk(text));View on GitHub (pinned to 7d5770395b)
Solutions
- Every stop delimiter must be preceded by a start delimiter; remove the stray stop delimiter or open a tag first.
- If the character is literal text, change delimiters with setDelimiters to characters not used in the pattern.
Example fix
matcher.setDelimiters("<<", ">>", "$");
ParseTreePattern p = matcher.compile("a > b", MyParser.RULE_rel); When it happens
Trigger: Pattern contains a stop tag delimiter with no preceding start delimiter.
Common situations: Ensure stop delimiters only appear after a matching start delimiter in the pattern.
AI-assisted analysis of antlr/antlr4@7d5770395b (2026-08-14).
Data as JSON: /api/errors/0cc823e5f0f5468a.
Report an issue: GitHub.