stanfordnlp/CoreNLP · error · ParserException
Expected right paren!
Error message
Expected right paren!
What it means
StringParsingTask.readRightParen consumes whitespace and expects the next character to be a closing parenthesis ')'. If it is not, ParserException('Expected right paren!') is thrown, meaning the encoded expression ended or deviated before the closing paren was found.
Solutions
- Check the input string for balanced parentheses and completeness
- Print/log the string being parsed and inspect the position where parsing fails
- Regenerate the value using the library's encoder/toString method
Example fix
// before String input = "(a,b"; // truncated // after String input = "(a,b)";
Defensive patterns
Strategy: validation
Validate before calling
String t = input.trim();
if (!t.endsWith(")")) throw new IllegalArgumentException("Encoded value must end with ')': " + input); Try / catch
try {
task.parse();
} catch (ParserException e) {
log.error("Malformed encoded value '" + input + "': " + e.getMessage());
} Prevention
- Check inputs for balanced parentheses before parsing
- Regenerate truncated data from source files rather than repairing by hand
- Catch ParserException at parse boundaries and log the offending string
When it happens
Trigger: Parsing an encoded string where after reading the inner elements the next character is not ')', e.g. truncated input like '(a,b', extra tokens inside the parens, or a wrong closing character.
Common situations: Truncated files or cut-and-paste that dropped the final character; strings built manually with unbalanced parentheses; mixing encodings produced by different writers.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- invalid format: ||
- Dependencies should be for the format 'type(arg-idx…
- Expected left paren!
- Unclosed paren in encoded array: " + encoded
- Tag did not start with <
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/868afc0087d1fdc3.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/util/StringParsingTask.java:98
return sb.toString().intern();
}
// .....................................................................
protected void readLeftParen() {
// System.out.println("Read left.");
readWhiteSpace();
char ch = read();
if (!isLeftParen(ch))
throw new ParserException("Expected left paren!");
}
protected void readRightParen() {
// System.out.println("Read right.");
readWhiteSpace();
char ch = read();
if (!isRightParen(ch))
throw new ParserException("Expected right paren!");
}
protected void readDot() {
readWhiteSpace();
if (isDot(peek())) read();
}
protected void readWhiteSpace() {
char ch = read();
while (isWhiteSpace(ch) && !isEOF()) {
ch = read();
}
unread();
}
// .....................................................................
protected char read() {View on GitHub (pinned to 1b7edd19c4)