Program: 173984
Project: 173984
Buggy source:
/** 
 * A very simple variable handling: <br> We differt between: <html> <table border='1'> <tr> <th>Expression</th> <th>Type</th> <th>Description</th> </tr> <tr> <td>$a</td> <td>STANDARD</td> <td>Termination by followed whitespace, string start, or special variable ending e.g. for $$</td> </tr> <tr> <td>$a['arrayname']</td> <td>STANDARD</td> <td>Termination by last balanced ']'</td> </tr> <tr> <td>${...}</td> <td>CURLY_BRACED</td> <td>Termination by last balanced '}'</td> </tr> <tr> <td>$(...)</td> <td>GROUPED</td> <td>Termination by last balanced ')'</td> </tr> </table> </html>
 * @param context
 * @return
 */
private boolean isVariableStateHandled(ParseContext context){
  char c=context.getCharAtPos();
  if (context.inState(CODE) || context.inState(INIT)) {
    if (c == '$') {
      context.addTokenAndResetText();
      context.appendCharToText();
      context.switchTo(VARIABLE);
      return true;
    }
    return false;
  }
  if (!context.inState(VARIABLE)) {
    return false;
  }
  VariableContext variableContext=context.getVariableContext();
  VariableType type=variableContext.getType();
  if (type == null || type == VariableType.INITIAL) {
    return handleInitialVariableTypeDetermination(context,c);
  }
 else   if (type == VariableType.GROUPED) {
    return handleGroupedVariable(context);
  }
 else   if (type == VariableType.CURLY_BRACED) {
    return handleCurlyBracedVariable(context,c,variableContext);
  }
 else   if (type == VariableType.STANDARD) {
    return handleStandardVariables(context,c,variableContext);
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * A very simple variable handling: <br> We differt between: <html> <table border='1'> <tr> <th>Expression</th> <th>Type</th> <th>Description</th> </tr> <tr> <td>$a</td> <td>STANDARD</td> <td>Termination by followed whitespace, string start, or special variable ending e.g. for $$</td> </tr> <tr> <td>$a['arrayname']</td> <td>STANDARD</td> <td>Termination by last balanced ']'</td> </tr> <tr> <td>${...}</td> <td>CURLY_BRACED</td> <td>Termination by last balanced '}'</td> </tr> <tr> <td>$(...)</td> <td>GROUPED</td> <td>Termination by last balanced ')'</td> </tr> </table> </html>
 * @param context
 * @return
 */
private boolean isVariableStateHandled(ParseContext context){
  char c=context.getCharAtPos();
  if (context.inState(CODE) || context.inState(INIT)) {
    if (c == '$') {
      context.addTokenAndResetText();
      context.currentToken.start--;
      context.appendCharToText();
      context.switchTo(VARIABLE);
      return true;
    }
    return false;
  }
  if (!context.inState(VARIABLE)) {
    return false;
  }
  VariableContext variableContext=context.getVariableContext();
  VariableType type=variableContext.getType();
  if (type == null || type == VariableType.INITIAL) {
    return handleInitialVariableTypeDetermination(context,c);
  }
 else   if (type == VariableType.GROUPED) {
    return handleGroupedVariable(context);
  }
 else   if (type == VariableType.CURLY_BRACED) {
    return handleCurlyBracedVariable(context,c,variableContext);
  }
 else   if (type == VariableType.STANDARD) {
    return handleStandardVariables(context,c,variableContext);
  }
 else {
    return false;
  }
}