{"record":{"id":"2be07fce675d6f96","repo":"stanfordnlp/CoreNLP","slug":"warning-fullexpression-starttoken-c","errorCode":null,"errorMessage":"${warning}\n    ${fullExpression(startToken)}\n    Current stack: ${trace}","messagePattern":"(.+?)\n    (.+?)\n    Current stack: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/semgraph/semgrex/SemgrexParser.java","lineNumber":46,"sourceCode":"  private String fullExpression(Token startToken) {\n    StringBuilder result = new StringBuilder();\n    for (Token p = startToken; p != null; p = p.next) {\n      if (p.specialToken != null) {\n        result.append(p.specialToken.image);\n      }\n      result.append(p.image);\n    }\n    return result.toString();\n  }\n\n  private void warnDeprecated(String warning, Token startToken) {\n    StringWriter sw = new StringWriter();\n    PrintWriter pw = new PrintWriter(sw);\n    (new RuntimeException()).printStackTrace(pw);\n    String trace = sw.toString();\n    trace = trace.substring(trace.lastIndexOf(\"SemgrexParser\"));\n    trace = trace.substring(trace.indexOf(\"at \"));\n    log.warn(warning + \"\\n    \" + fullExpression(startToken) + \"\\n    Current stack: \" + trace);\n  }\n\n  final public SemgrexPattern Root() throws ParseException {// Root pattern for the semgrex parser.  Doesn't necessarily represent matching the root.\n  SemgrexPattern node;\n  Token reverse = null;\n  List<SemgrexPattern> children = new ArrayList<SemgrexPattern>();\n  Token startToken = null;\n\n  List<String> uniqKeys = null;\n  Token nextIdentifier = null;\n  // a local variable\n\n// start from 1 since we haven't parsed anything yet\n    startToken = getToken(1);\n    switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {\n    case ALIGNRELN:{\n      reverse = jj_consume_token(ALIGNRELN);\n      node = SubNode(GraphRelation.ALIGNED_ROOT);","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/SemgrexParser.java#L28-L64","documentation":"The SemgrexParser (JavaCC-generated) prints a deprecation warning when a deprecated syntax form is parsed. warnDeprecated logs the warning text, the full matched expression, and a trimmed current stack trace so the offending call site can be located. Parsing still succeeds.","triggerScenarios":"Parsing a Semgrex pattern string containing deprecated syntax (e.g. legacy operators) via SemgrexPattern.compile, which routes through the generated parser and calls warnDeprecated.","commonSituations":"Old Semgrex patterns written for earlier CoreNLP versions still in use; copied example queries from outdated documentation or codebases; patterns in saved configuration files.","solutions":["Rewrite the pattern using current Semgrex syntax per the latest Semgrex documentation.","Use the logged stack trace to find the code/config line containing the deprecated pattern.","Update the pattern programmatically with the semgrex migration notes (e.g. replace deprecated operators with new equivalents).","Pin/upgrade the CoreNLP version consistently to avoid mixed-version pattern syntax."],"exampleFix":"// before\nSemgrexPattern p = SemgrexPattern.compile(\"{}>nsubj {}\"); // deprecated form\n// after\nSemgrexPattern p = SemgrexPattern.compile(\"{} <<nsubj {}\"); // current syntax","handlingStrategy":"validation","validationCode":"if (pattern.contains(\">nsubj\") /* example deprecated syntax */) { log.warn(\"Pattern uses deprecated Semgrex syntax: \" + pattern); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Audit stored Semgrex patterns against current syntax docs periodically","Capture and review warnDeprecated stack traces in logs during test runs","Pin one CoreNLP version and test all shipped patterns against it"],"tags":["nlp","semgrex","deprecated-syntax","parser"],"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"}