{"record":{"id":"a0ec0d32763c3ab1","repo":"stanfordnlp/CoreNLP","slug":"error-invalid-syntax-in-macro-line","errorCode":null,"errorMessage":"ERROR: Invalid syntax in macro line: \"\"!","messagePattern":"ERROR: Invalid syntax in macro line: \"\"!","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/SemgrexBatchParser.java","lineNumber":105,"sourceCode":"  }\n\n  private static Map<String, String> preprocess(BufferedReader reader) throws IOException {\n    Map<String, String> macros = Generics.newHashMap();\n    for(String line; (line = reader.readLine()) != null; ) {\n      line = line.trim();\n      if(line.startsWith(\"macro \")){\n        Pair<String, String> macro = extractMacro(line);\n        macros.put(macro.first(), macro.second());\n      }\n    }\n    return macros;\n  }\n\n  private static Pair<String, String> extractMacro(String line) {\n    assert(line.startsWith(\"macro\"));\n    int equalPosition = line.indexOf('=');\n    if(equalPosition < 0) {\n      throw new RuntimeException(\"ERROR: Invalid syntax in macro line: \\\"\" + line + \"\\\"!\");\n    }\n    String name = line.substring(5, equalPosition).trim();\n    if(name.isEmpty()) {\n      throw new RuntimeException(\"ERROR: Invalid syntax in macro line: \\\"\" + line + \"\\\"!\");\n    }\n    String value = line.substring(equalPosition + 1).trim();\n    if(value.isEmpty()) {\n      throw new RuntimeException(\"ERROR: Invalid syntax in macro line: \\\"\" + line + \"\\\"!\");\n    }\n    return new Pair<>(name, value);\n  }\n\n}\n","sourceCodeStart":87,"sourceCodeEnd":119,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/SemgrexBatchParser.java#L87-L119","documentation":"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.","triggerScenarios":"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.","commonSituations":"Whitespace or typo where '=' was replaced by something else, editing batch files in editors that strip characters, or mixing syntax from other macro preprocessors.","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"],"exampleFix":"// before\nmacro ANIMAL dog\n// after\nmacro ANIMAL = dog","handlingStrategy":"validation","validationCode":"if (line.startsWith(\"macro\") && !line.contains(\"=\")) throw new IllegalArgumentException(\"Macro line missing '=': \" + line);","typeGuard":null,"tryCatchPattern":"try { parser.parse(lines, macros); } catch (RuntimeException e) { log.error(e.getMessage()); }","preventionTips":["Always write 'macro NAME = VALUE' with a literal '='","Avoid copying macro syntax from other preprocessors","Lint batch files for well-formed macro lines"],"tags":["java","semgrex","macro","syntax"],"backgroundTag":"invalid-argument-format","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}