Program: 23429
Project: 23429
Buggy source:
private ExpressionNode parseExpression(FHIRLexer lexer,boolean proximal) throws FHIRLexerException {
  ExpressionNode result=new ExpressionNode(lexer.nextId());
  SourceLocation c=lexer.getCurrentStartLocation();
  result.setStart(lexer.getCurrentLocation());
  if (lexer.getCurrent().equals("String_Node_Str")) {
    lexer.take();
    lexer.setCurrent("String_Node_Str" + lexer.getCurrent());
  }
  if (lexer.getCurrent().equals("String_Node_Str")) {
    lexer.take();
    lexer.setCurrent("String_Node_Str" + lexer.getCurrent());
  }
  if (lexer.isConstant(false)) {
    checkConstant(lexer.getCurrent(),lexer);
    result.setConstant(lexer.take());
    result.setKind(Kind.Constant);
    result.setEnd(lexer.getCurrentLocation());
  }
 else   if ("String_Node_Str".equals(lexer.getCurrent())) {
    lexer.next();
    result.setKind(Kind.Group);
    result.setGroup(parseExpression(lexer,true));
    if (!"String_Node_Str".equals(lexer.getCurrent()))     throw lexer.error("String_Node_Str" + lexer.getCurrent() + "String_Node_Str");
    result.setEnd(lexer.getCurrentLocation());
    lexer.next();
  }
 else {
    if (!lexer.isToken() && !lexer.getCurrent().startsWith("String_Node_Str"))     throw lexer.error("String_Node_Str" + lexer.getCurrent() + "String_Node_Str");
    if (lexer.getCurrent().startsWith("String_Node_Str"))     result.setName(lexer.readConstant("String_Node_Str"));
 else     result.setName(lexer.take());
    result.setEnd(lexer.getCurrentLocation());
    if (!result.checkName())     throw lexer.error("String_Node_Str" + result.getName() + "String_Node_Str");
    if ("String_Node_Str".equals(lexer.getCurrent())) {
      Function f=Function.fromCode(result.getName());
      FunctionDetails details=null;
      if (f == null) {
        details=hostServices.resolveFunction(result.getName());
        if (details == null)         throw lexer.error("String_Node_Str" + result.getName() + "String_Node_Str");
        f=Function.Custom;
      }
      result.setKind(Kind.Function);
      result.setFunction(f);
      lexer.next();
      while (!"String_Node_Str".equals(lexer.getCurrent())) {
        result.getParameters().add(parseExpression(lexer,true));
        if ("String_Node_Str".equals(lexer.getCurrent()))         lexer.next();
 else         if (!"String_Node_Str".equals(lexer.getCurrent()))         throw lexer.error("String_Node_Str" + lexer.getCurrent() + "String_Node_Str");
      }
      result.setEnd(lexer.getCurrentLocation());
      lexer.next();
      checkParameters(lexer,c,result,details);
    }
 else     result.setKind(Kind.Name);
  }
  ExpressionNode focus=result;
  if ("String_Node_Str".equals(lexer.getCurrent())) {
    lexer.next();
    ExpressionNode item=new ExpressionNode(lexer.nextId());
    item.setKind(Kind.Function);
    item.setFunction(ExpressionNode.Function.Item);
    item.getParameters().add(parseExpression(lexer,true));
    if (!lexer.getCurrent().equals("String_Node_Str"))     throw lexer.error("String_Node_Str" + lexer.getCurrent() + "String_Node_Str");
    lexer.next();
    result.setInner(item);
    focus=item;
  }
  if ("String_Node_Str".equals(lexer.getCurrent())) {
    lexer.next();
    focus.setInner(parseExpression(lexer,false));
  }
  result.setProximal(proximal);
  if (proximal) {
    while (lexer.isOp()) {
      focus.setOperation(ExpressionNode.Operation.fromCode(lexer.getCurrent()));
      focus.setOpStart(lexer.getCurrentStartLocation());
      focus.setOpEnd(lexer.getCurrentLocation());
      lexer.next();
      focus.setOpNext(parseExpression(lexer,false));
      focus=focus.getOpNext();
    }
    result=organisePrecedence(lexer,result);
  }
  return result;
}

Fixed version (ground truth):
private ExpressionNode parseExpression(FHIRLexer lexer,boolean proximal) throws FHIRLexerException {
  ExpressionNode result=new ExpressionNode(lexer.nextId());
  SourceLocation c=lexer.getCurrentStartLocation();
  result.setStart(lexer.getCurrentLocation());
  if (lexer.getCurrent().equals("String_Node_Str")) {
    lexer.take();
    lexer.setCurrent("String_Node_Str" + lexer.getCurrent());
  }
  if (lexer.getCurrent().equals("String_Node_Str")) {
    lexer.take();
    lexer.setCurrent("String_Node_Str" + lexer.getCurrent());
  }
  if (lexer.isConstant(false)) {
    checkConstant(lexer.getCurrent(),lexer);
    result.setConstant(lexer.take());
    result.setKind(Kind.Constant);
    result.setEnd(lexer.getCurrentLocation());
  }
 else   if ("String_Node_Str".equals(lexer.getCurrent())) {
    lexer.next();
    result.setKind(Kind.Group);
    result.setGroup(parseExpression(lexer,true));
    if (!"String_Node_Str".equals(lexer.getCurrent()))     throw lexer.error("String_Node_Str" + lexer.getCurrent() + "String_Node_Str");
    result.setEnd(lexer.getCurrentLocation());
    lexer.next();
  }
 else {
    if (!lexer.isToken() && !lexer.getCurrent().startsWith("String_Node_Str"))     throw lexer.error("String_Node_Str" + lexer.getCurrent() + "String_Node_Str");
    if (lexer.getCurrent().startsWith("String_Node_Str"))     result.setName(lexer.readConstant("String_Node_Str"));
 else     result.setName(lexer.take());
    result.setEnd(lexer.getCurrentLocation());
    if (!result.checkName())     throw lexer.error("String_Node_Str" + result.getName() + "String_Node_Str");
    if ("String_Node_Str".equals(lexer.getCurrent())) {
      Function f=Function.fromCode(result.getName());
      FunctionDetails details=null;
      if (f == null) {
        details=hostServices != null ? hostServices.resolveFunction(result.getName()) : null;
        if (details == null)         throw lexer.error("String_Node_Str" + result.getName() + "String_Node_Str");
        f=Function.Custom;
      }
      result.setKind(Kind.Function);
      result.setFunction(f);
      lexer.next();
      while (!"String_Node_Str".equals(lexer.getCurrent())) {
        result.getParameters().add(parseExpression(lexer,true));
        if ("String_Node_Str".equals(lexer.getCurrent()))         lexer.next();
 else         if (!"String_Node_Str".equals(lexer.getCurrent()))         throw lexer.error("String_Node_Str" + lexer.getCurrent() + "String_Node_Str");
      }
      result.setEnd(lexer.getCurrentLocation());
      lexer.next();
      checkParameters(lexer,c,result,details);
    }
 else     result.setKind(Kind.Name);
  }
  ExpressionNode focus=result;
  if ("String_Node_Str".equals(lexer.getCurrent())) {
    lexer.next();
    ExpressionNode item=new ExpressionNode(lexer.nextId());
    item.setKind(Kind.Function);
    item.setFunction(ExpressionNode.Function.Item);
    item.getParameters().add(parseExpression(lexer,true));
    if (!lexer.getCurrent().equals("String_Node_Str"))     throw lexer.error("String_Node_Str" + lexer.getCurrent() + "String_Node_Str");
    lexer.next();
    result.setInner(item);
    focus=item;
  }
  if ("String_Node_Str".equals(lexer.getCurrent())) {
    lexer.next();
    focus.setInner(parseExpression(lexer,false));
  }
  result.setProximal(proximal);
  if (proximal) {
    while (lexer.isOp()) {
      focus.setOperation(ExpressionNode.Operation.fromCode(lexer.getCurrent()));
      focus.setOpStart(lexer.getCurrentStartLocation());
      focus.setOpEnd(lexer.getCurrentLocation());
      lexer.next();
      focus.setOpNext(parseExpression(lexer,false));
      focus=focus.getOpNext();
    }
    result=organisePrecedence(lexer,result);
  }
  return result;
}