stanfordnlp/CoreNLP · error · RuntimeException
ERROR: Invalid syntax in macro line: ""!
Error message
ERROR: Invalid syntax in macro line: ""!
What it means
SemgrexBatchParser.extractMacro parses 'macro NAME = VALUE' lines; if the line contains no '=' character, it cannot be split into name/value and throws RuntimeException. This is a strict syntax check on macro definition lines.
Solutions
- Add the missing '=' in the macro line: 'macro NAME = VALUE'
- Ensure the line is actually intended as a macro definition; otherwise remove/fix the 'macro' prefix
- Check for invisible characters or full-width '=' copied from docs
Example fix
// before macro ANIMAL dog // after macro ANIMAL = dog
Defensive patterns
Strategy: validation
Validate before calling
if (line.startsWith("macro") && !line.contains("=")) throw new IllegalArgumentException("Macro line missing '=': " + line); Try / catch
try { parser.parse(lines, macros); } catch (RuntimeException e) { log.error(e.getMessage()); } Prevention
- Always write 'macro NAME = VALUE' with a literal '='
- Avoid copying macro syntax from other preprocessors
- Lint batch files for well-formed macro lines
When it happens
Trigger: A line starting with 'macro' (or routed to macro()) with no '=' present, e.g. 'macro NAME value' or a comment/blank line misinterpreted as a macro definition.
Common situations: Whitespace or typo where '=' was replaced by something else, editing batch files in editors that strip characters, or mixing syntax from other macro preprocessors.
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
- ERROR: Unknown macro ""!
- Cannot process a single key/value from annotation as it is…
- Child should only be set on a UniqPattern at creation time
- Coordination node must have at least 2 children.
- Duplicate attribute found in semgrex expression
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/a0ec0d32763c3ab1.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/semgrex/SemgrexBatchParser.java:105
}
private static Map<String, String> preprocess(BufferedReader reader) throws IOException {
Map<String, String> macros = Generics.newHashMap();
for(String line; (line = reader.readLine()) != null; ) {
line = line.trim();
if(line.startsWith("macro ")){
Pair<String, String> macro = extractMacro(line);
macros.put(macro.first(), macro.second());
}
}
return macros;
}
private static Pair<String, String> extractMacro(String line) {
assert(line.startsWith("macro"));
int equalPosition = line.indexOf('=');
if(equalPosition < 0) {
throw new RuntimeException("ERROR: Invalid syntax in macro line: \"" + line + "\"!");
}
String name = line.substring(5, equalPosition).trim();
if(name.isEmpty()) {
throw new RuntimeException("ERROR: Invalid syntax in macro line: \"" + line + "\"!");
}
String value = line.substring(equalPosition + 1).trim();
if(value.isEmpty()) {
throw new RuntimeException("ERROR: Invalid syntax in macro line: \"" + line + "\"!");
}
return new Pair<>(name, value);
}
}
View on GitHub (pinned to 1b7edd19c4)