{"record":{"id":"0f2cfe34480dad4d","repo":"antlr/antlr4","slug":"unknowth-path-element-el","errorCode":null,"errorMessage":"Unknowth path element \"+el","messagePattern":"Unknowth path element \"\\+el","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPath.java","lineNumber":146,"sourceCode":"\t\t\t\t\t}\n\t\t\t\t\tXPathElement pathElement = getXPathElement(next, anywhere);\n\t\t\t\t\tpathElement.invert = invert;\n\t\t\t\t\telements.add(pathElement);\n\t\t\t\t\ti++;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase XPathLexer.TOKEN_REF :\n\t\t\t\tcase XPathLexer.RULE_REF :\n\t\t\t\tcase XPathLexer.WILDCARD :\n\t\t\t\t\telements.add( getXPathElement(el, false) );\n\t\t\t\t\ti++;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase Token.EOF :\n\t\t\t\t\tbreak loop;\n\n\t\t\t\tdefault :\n\t\t\t\t\tthrow new IllegalArgumentException(\"Unknowth path element \"+el);\n\t\t\t}\n\t\t}\n\t\treturn elements.toArray(new XPathElement[0]);\n\t}\n\n\t/**\n\t * Convert word like {@code *} or {@code ID} or {@code expr} to a path\n\t * element. {@code anywhere} is {@code true} if {@code //} precedes the\n\t * word.\n\t */\n\tprotected XPathElement getXPathElement(Token wordToken, boolean anywhere) {\n\t\tif ( wordToken.getType()==Token.EOF ) {\n\t\t\tthrow new IllegalArgumentException(\"Missing path element at end of path\");\n\t\t}\n\t\tString word = wordToken.getText();\n\t\tint ttype = parser.getTokenType(word);\n\t\tint ruleIndex = parser.getRuleIndex(word);\n\t\tswitch ( wordToken.getType() ) {","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/antlr/antlr4/blob/7d5770395bb7b02eb56e7c62662cb1d7c08f42a3/runtime/Java/src/org/antlr/v4/runtime/tree/xpath/XPath.java#L128-L164","documentation":"After lexing, XPath.split switches on each token's type; the default branch throws IllegalArgumentException ('Unknowth path element ...' — typo is in the ANTLR source) when a token type is neither a separator, token/rule ref, wildcard, nor EOF. With the stock XPathLexer this is unreachable; it guards against lexer/runtime version mismatches or custom lexers.","triggerScenarios":"Mixing an XPathLexer (or lexer token types) from a different ANTLR version than the XPath class; subclassing XPathLexer to emit custom token types.","commonSituations":"Conflicting antlr4 jar versions on the classpath (e.g. tool 4.x with runtime 4.y) so token type constants no longer line up.","solutions":["Align antlr4 tool and runtime jar versions on the classpath","If subclassing XPathLexer, only emit token types the XPath splitter understands","Run dependency:tree / gradle dependencies to find duplicate antlr4 artifacts"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { xpath.split(path); } catch (IllegalArgumentException e) { /* suspect mixed ANTLR versions; fail fast with context */ }","preventionTips":["Pin a single antlr4 version across the project","Check for duplicate antlr4 jars when this appears"],"tags":["antlr","xpath","version-mismatch","java"],"backgroundTag":null,"analyzedSha":"7d5770395bb7b02eb56e7c62662cb1d7c08f42a3","analyzedAt":"2026-08-14T14:47:56.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}