{"record":{"id":"2f37d7cecb7c9020","repo":"stanfordnlp/CoreNLP","slug":"use-of-in-semgrex-patterns-is-now-illegal-it-i","errorCode":null,"errorMessage":"Use of & in semgrex patterns is now illegal.  It is equivalent to the same expression without the &.  Offending expression: ","messagePattern":"Use of & in semgrex patterns is now illegal\\.  It is equivalent to the same expression without the &\\.  Offending expression: ","errorType":"validation","errorClass":"SemgrexParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/SemgrexParser.java","lineNumber":98,"sourceCode":"        default:\n          jj_la1[0] = jj_gen;\n          break label_1;\n        }\n        jj_consume_token(10);\n        node = SubNode(GraphRelation.ITERATOR);\nchildren.add(node);\n      }\n      break;\n      }\n    default:\n      jj_la1[1] = jj_gen;\n      jj_consume_token(-1);\n      throw new ParseException();\n    }\nif (children.size() > 1)\n        node = new CoordinationPattern(true, children, true, true);\n      if (deprecatedAmp) {\n        {if (true) throw new SemgrexParseException(\"Use of & in semgrex patterns is now illegal.  It is equivalent to the same expression without the &.  Offending expression: \" + startToken);}\n      }\n      if (deprecatedNodeConj) {\n        {if (true) throw new SemgrexParseException(\"Use of node conjugation (expressions such as '< [foo bar]' or '< [foo & bar]') is now illegal.  The issue is that expressions such as '[foo bar] < zzz' may intuitively mean that foo < zzz, bar < zzz, zzz the same for both cases, but that is not the way the parser interpreted this expression.  Changing the functionality might break existing expressions, and anyway this can be rewritten in various ways such as 'zzz > foo > bar' or 'foo < zzz=a : bar < zzz=a'.  Offending expression: \" + startToken);}\n      }\n    switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {\n    case 11:{\n      jj_consume_token(11);\n      jj_consume_token(UNIQ);\nuniqKeys = new ArrayList<>();\n      label_2:\n      while (true) {\n        switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {\n        case UNIQ:\n        case IDENTIFIER:{\n          ;\n          break;\n          }\n        default:","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/SemgrexParser.java#L80-L116","documentation":"The semgrex grammar's Root production throws SemgrexParseException when the parsed expression used '&' (deprecatedAmp). '&' in semgrex used to behave identically to plain juxtaposition (conjunction), so it was deprecated and is now illegal to avoid confusion with intended boolean semantics.","triggerScenarios":"Parsing a semgrex pattern containing a '&' between node/conjunction elements (e.g. '[foo & bar]' or '< [foo & bar]'), which sets deprecatedAmp during tokenization and triggers the exception at the end of Root.","commonSituations":"Users familiar with boolean-query syntaxes (or Tregex conventions) writing '&' for conjunction in semgrex; older patterns written before '&' was deprecated now failing after a CoreNLP upgrade.","solutions":["Remove '&' — replace 'foo & bar' with 'foo bar' (whitespace already means conjunction)","Rewrite patterns like '< [foo & bar]' as 'zzz > foo > bar' or use named-edge forms","Audit legacy semgrex patterns and strip all '&' occurrences before upgrading CoreNLP"],"exampleFix":"// before\n[{tag:NN} & {word:dog}]\n// after\n[{tag:NN} {word:dog}]","handlingStrategy":"validation","validationCode":"if (pattern.contains(\"&\")) throw new IllegalArgumentException(\"'&' is illegal in semgrex; use whitespace for conjunction: \" + pattern);","typeGuard":null,"tryCatchPattern":"try { SemgrexPattern.compile(pattern); } catch (SemgrexParseException e) { log.error(e.getMessage()); }","preventionTips":["Strip '&' from legacy patterns before compiling with newer CoreNLP","Use whitespace for conjunction in semgrex","Run pattern suites against the target CoreNLP version in CI before upgrading"],"tags":["java","semgrex","deprecated","parse-error"],"backgroundTag":"deprecated-api-usage","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}