Program: 11817
Project: 11817
Buggy source:
/** 
 * Parses a character-class-expression, not a character-class-escape. c-c-expression   ::= '[' c-group ']' c-group          ::= positive-c-group | negative-c-group | c-c-subtraction positive-c-group ::= (c-range | c-c-escape)+ negative-c-group ::= '^' positive-c-group c-c-subtraction  ::= (positive-c-group | negative-c-group) subtraction subtraction      ::= '-' c-c-expression c-range          ::= single-range | from-to-range single-range     ::= multi-c-escape | category-c-escape | block-c-escape | <any XML char> cc-normal-c      ::= <any character except [, ], \> from-to-range    ::= cc-normal-c '-' cc-normal-c
 * @param useNrage Ignored.
 * @return This returns no NrageToken.
 */
@Override protected RangeToken parseCharacterClass(boolean useNrange) throws ParseException {
  this.setContext(S_INBRACKETS);
  this.next();
  RangeToken base=null;
  RangeToken tok;
  if (this.read() == T_CHAR && this.chardata == '^') {
    this.next();
    base=Token.createRange();
    base.addRange(0,Token.UTF16_MAX);
    tok=Token.createRange();
  }
 else {
    tok=Token.createRange();
  }
  int type;
  boolean firstloop=true;
  while ((type=this.read()) != T_EOF) {
    if (type == T_CHAR && this.chardata == ']' && !firstloop) {
      if (base != null) {
        base.subtractRanges(tok);
        tok=base;
      }
      break;
    }
    int c=this.chardata;
    boolean end=false;
    if (type == T_BACKSOLIDUS) {
switch (c) {
case 'd':
case 'D':
case 'w':
case 'W':
case 's':
case 'S':
        tok.mergeRanges(this.getTokenForShorthand(c));
      end=true;
    break;
case 'i':
case 'I':
case 'c':
case 'C':
  c=this.processCIinCharacterClass(tok,c);
if (c < 0) end=true;
break;
case 'p':
case 'P':
int pstart=this.offset;
RangeToken tok2=this.processBacksolidus_pP(c);
if (tok2 == null) throw this.ex("String_Node_Str",pstart);
tok.mergeRanges(tok2);
end=true;
break;
default :
c=this.decodeEscaped();
}
}
 else if (type == T_XMLSCHEMA_CC_SUBTRACTION && !firstloop) {
if (base != null) {
base.subtractRanges(tok);
tok=base;
}
RangeToken range2=this.parseCharacterClass(false);
tok.subtractRanges(range2);
if (this.read() != T_CHAR || this.chardata != ']') throw this.ex("String_Node_Str",this.offset);
break;
}
this.next();
if (!end) {
if (type == T_CHAR) {
if (c == '[') throw this.ex("String_Node_Str",this.offset - 2);
if (c == ']') throw this.ex("String_Node_Str",this.offset - 2);
if (c == '-') throw this.ex("String_Node_Str",this.offset - 2);
}
if (this.read() != T_CHAR || this.chardata != '-') {
tok.addRange(c,c);
}
 else {
this.next();
if ((type=this.read()) == T_EOF) throw this.ex("String_Node_Str",this.offset);
if ((type == T_CHAR && this.chardata == ']') || type == T_XMLSCHEMA_CC_SUBTRACTION) {
throw this.ex("String_Node_Str",this.offset - 1);
}
 else {
int rangeend=this.chardata;
if (type == T_CHAR) {
if (rangeend == '[') throw this.ex("String_Node_Str",this.offset - 1);
if (rangeend == ']') throw this.ex("String_Node_Str",this.offset - 1);
if (rangeend == '-') throw this.ex("String_Node_Str",this.offset - 2);
}
 else if (type == T_BACKSOLIDUS) rangeend=this.decodeEscaped();
this.next();
if (c > rangeend) throw this.ex("String_Node_Str",this.offset - 1);
tok.addRange(c,rangeend);
}
}
}
firstloop=false;
}
if (this.read() == T_EOF) throw this.ex("String_Node_Str",this.offset);
tok.sortRanges();
tok.compactRanges();
this.setContext(S_NORMAL);
this.next();
return tok;
}

Fixed version (ground truth):
/** 
 * Parses a character-class-expression, not a character-class-escape. c-c-expression   ::= '[' c-group ']' c-group          ::= positive-c-group | negative-c-group | c-c-subtraction positive-c-group ::= (c-range | c-c-escape)+ negative-c-group ::= '^' positive-c-group c-c-subtraction  ::= (positive-c-group | negative-c-group) subtraction subtraction      ::= '-' c-c-expression c-range          ::= single-range | from-to-range single-range     ::= multi-c-escape | category-c-escape | block-c-escape | <any XML char> cc-normal-c      ::= <any character except [, ], \> from-to-range    ::= cc-normal-c '-' cc-normal-c
 * @param useNrange Ignored.
 * @return This returns no NrageToken.
 */
@Override protected RangeToken parseCharacterClass(boolean useNrange) throws ParseException {
  this.setContext(S_INBRACKETS);
  this.next();
  RangeToken base=null;
  RangeToken tok;
  if (this.read() == T_CHAR && this.chardata == '^') {
    this.next();
    base=Token.createRange();
    base.addRange(0,Token.UTF16_MAX);
    tok=Token.createRange();
  }
 else {
    tok=Token.createRange();
  }
  int type;
  boolean firstloop=true;
  while ((type=this.read()) != T_EOF) {
    if (type == T_CHAR && this.chardata == ']' && !firstloop) {
      if (base != null) {
        base.subtractRanges(tok);
        tok=base;
      }
      break;
    }
    int c=this.chardata;
    boolean end=false;
    if (type == T_BACKSOLIDUS) {
switch (c) {
case 'd':
case 'D':
case 'w':
case 'W':
case 's':
case 'S':
        tok.mergeRanges(this.getTokenForShorthand(c));
      end=true;
    break;
case 'i':
case 'I':
case 'c':
case 'C':
  c=this.processCIinCharacterClass(tok,c);
if (c < 0) end=true;
break;
case 'p':
case 'P':
int pstart=this.offset;
RangeToken tok2=this.processBacksolidus_pP(c);
if (tok2 == null) throw this.ex("String_Node_Str",pstart);
tok.mergeRanges(tok2);
end=true;
break;
default :
c=this.decodeEscaped();
}
}
 else if (type == T_XMLSCHEMA_CC_SUBTRACTION && !firstloop) {
if (base != null) {
base.subtractRanges(tok);
tok=base;
}
RangeToken range2=this.parseCharacterClass(false);
tok.subtractRanges(range2);
if (this.read() != T_CHAR || this.chardata != ']') throw this.ex("String_Node_Str",this.offset);
break;
}
this.next();
if (!end) {
if (type == T_CHAR) {
if (c == '[') throw this.ex("String_Node_Str",this.offset - 2);
if (c == ']') throw this.ex("String_Node_Str",this.offset - 2);
if (c == '-') throw this.ex("String_Node_Str",this.offset - 2);
}
if (this.read() != T_CHAR || this.chardata != '-') {
tok.addRange(c,c);
}
 else {
this.next();
if ((type=this.read()) == T_EOF) throw this.ex("String_Node_Str",this.offset);
if ((type == T_CHAR && this.chardata == ']') || type == T_XMLSCHEMA_CC_SUBTRACTION) {
throw this.ex("String_Node_Str",this.offset - 1);
}
 else {
int rangeend=this.chardata;
if (type == T_CHAR) {
if (rangeend == '[') throw this.ex("String_Node_Str",this.offset - 1);
if (rangeend == ']') throw this.ex("String_Node_Str",this.offset - 1);
if (rangeend == '-') throw this.ex("String_Node_Str",this.offset - 2);
}
 else if (type == T_BACKSOLIDUS) rangeend=this.decodeEscaped();
this.next();
if (c > rangeend) throw this.ex("String_Node_Str",this.offset - 1);
tok.addRange(c,rangeend);
}
}
}
firstloop=false;
}
if (this.read() == T_EOF) throw this.ex("String_Node_Str",this.offset);
tok.sortRanges();
tok.compactRanges();
this.setContext(S_NORMAL);
this.next();
return tok;
}