Program: 51549
Project: 51549
Buggy source:
public Symbol next_token() throws java.io.IOException {
  StringBuffer id;
  boolean ampersandId=false;
  for (; ; ) {
switch (nextChar) {
case '.':
switch (lookahead()) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
        break;
default :
      advance();
    return makeToken(ParserSym.DOT,"String_Node_Str");
}
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
final int leftOfPoint=0;
final int rightOfPoint=1;
final int inExponent=2;
int n=0, nDigits=0, nSign=0, exponent=0;
double mantissa=0.0;
int state=leftOfPoint;
for (; ; ) {
if (nextChar == '.') {
if (state == leftOfPoint) {
state=rightOfPoint;
mantissa=n;
n=nDigits=0;
nSign=1;
advance();
}
 else {
if (state == rightOfPoint) {
mantissa+=(n * java.lang.Math.pow(10,-nDigits));
}
 else {
exponent=n * nSign;
}
return makeNumber(mantissa,exponent);
}
}
 else if (nextChar == 'E' || nextChar == 'e') {
if (state == inExponent) {
exponent=n * nSign;
return makeNumber(mantissa,exponent);
}
 else {
if (state == leftOfPoint) {
mantissa=n;
}
 else {
mantissa+=(n * java.lang.Math.pow(10,-nDigits));
}
n=nDigits=0;
nSign=1;
advance();
state=inExponent;
}
}
 else if ((nextChar == '+' || nextChar == '-') && state == inExponent && nDigits == 0) {
nSign=-nSign;
advance();
}
 else if (nextChar >= '0' && nextChar <= '9') {
n=n * 10 + (nextChar - '0');
nDigits++;
advance();
}
 else {
if (state == leftOfPoint) {
mantissa=n;
}
 else if (state == rightOfPoint) {
mantissa+=(n * java.lang.Math.pow(10,-nDigits));
}
 else {
exponent=n * nSign;
}
return makeNumber(mantissa,exponent);
}
}
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
id=new StringBuffer();
for (; ; ) {
id.append((char)nextChar);
advance();
switch (nextChar) {
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '_':
break;
default :
String strId=id.toString();
Integer i=(Integer)m_resWordsTable.get(strId.toUpperCase());
if (i == null) {
return makeId(strId,false,false);
}
 else {
return makeRes(i.intValue());
}
}
}
case '&':
advance();
if (nextChar == '[') {
ampersandId=true;
}
 else {
return makeToken(ParserSym.UNKNOWN,"String_Node_Str");
}
case '[':
id=new StringBuffer();
for (; ; ) {
advance();
switch (nextChar) {
case ']':
advance();
if (nextChar == ']') {
id.append(']');
id.append(']');
break;
}
 else {
if (ampersandId) {
ampersandId=false;
return makeId(id.toString(),true,true);
}
 else {
return makeId(id.toString(),true,false);
}
}
case -1:
if (ampersandId) {
ampersandId=false;
return makeId(id.toString(),true,true);
}
 else {
return makeId(id.toString(),true,false);
}
default :
id.append((char)nextChar);
}
}
case ':':
advance();
return makeToken(ParserSym.COLON,"String_Node_Str");
case ',':
advance();
return makeToken(ParserSym.COMMA,"String_Node_Str");
case '=':
advance();
return makeToken(ParserSym.EQ,"String_Node_Str");
case '<':
advance();
switch (nextChar) {
case '>':
advance();
return makeToken(ParserSym.NE,"String_Node_Str");
case '=':
advance();
return makeToken(ParserSym.LE,"String_Node_Str");
default :
return makeToken(ParserSym.LT,"String_Node_Str");
}
case '>':
advance();
switch (nextChar) {
case '=':
advance();
return makeToken(ParserSym.GE,"String_Node_Str");
default :
return makeToken(ParserSym.GT,"String_Node_Str");
}
case '{':
advance();
return makeToken(ParserSym.LBRACE,"String_Node_Str");
case '(':
advance();
return makeToken(ParserSym.LPAREN,"String_Node_Str");
case '}':
advance();
return makeToken(ParserSym.RBRACE,"String_Node_Str");
case ')':
advance();
return makeToken(ParserSym.RPAREN,"String_Node_Str");
case '+':
advance();
return makeToken(ParserSym.PLUS,"String_Node_Str");
case '-':
advance();
return makeToken(ParserSym.MINUS,"String_Node_Str");
case '*':
advance();
return makeToken(ParserSym.ASTERISK,"String_Node_Str");
case '/':
advance();
return makeToken(ParserSym.SOLIDUS,"String_Node_Str");
case '|':
advance();
switch (nextChar) {
case '|':
advance();
return makeToken(ParserSym.CONCAT,"String_Node_Str");
default :
return makeToken(ParserSym.UNKNOWN,"String_Node_Str");
}
case '"':
id=new StringBuffer();
for (; ; ) {
advance();
switch (nextChar) {
case '"':
advance();
if (nextChar == '"') {
id.append('"');
break;
}
 else {
return makeString(id.toString());
}
case -1:
return makeString(id.toString());
default :
id.append((char)nextChar);
}
}
case '\'':
if (inFormula) {
inFormula=false;
advance();
return makeToken(ParserSym.QUOTE,"String_Node_Str");
}
 else if (previousSymbol == ParserSym.AS) {
inFormula=true;
advance();
return makeToken(ParserSym.QUOTE,"String_Node_Str");
}
id=new StringBuffer();
for (; ; ) {
advance();
switch (nextChar) {
case '\'':
advance();
if (nextChar == '\'') {
id.append('\'');
break;
}
 else {
return makeString(id.toString());
}
case -1:
return makeString(id.toString());
default :
id.append((char)nextChar);
}
}
case -1:
return makeToken(ParserSym.EOF,"String_Node_Str");
default :
iPrevChar=iChar;
advance();
break;
}
}
}

Fixed version (ground truth):
/** 
 * Recognizes and returns the next complete token.
 */
public Symbol next_token() throws IOException {
  StringBuffer id;
  boolean ampersandId=false;
  for (; ; ) {
switch (nextChar) {
case '.':
switch (lookahead()) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
        break;
default :
      advance();
    return makeToken(ParserSym.DOT,"String_Node_Str");
}
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
final int leftOfPoint=0;
final int rightOfPoint=1;
final int inExponent=2;
int n=0, nDigits=0, nSign=0, exponent=0;
double mantissa=0.0;
int state=leftOfPoint;
for (; ; ) {
if (nextChar == '.') {
if (state == leftOfPoint) {
state=rightOfPoint;
mantissa=n;
n=nDigits=0;
nSign=1;
advance();
}
 else {
if (state == rightOfPoint) {
mantissa+=(n * java.lang.Math.pow(10,-nDigits));
}
 else {
exponent=n * nSign;
}
return makeNumber(mantissa,exponent);
}
}
 else if (nextChar == 'E' || nextChar == 'e') {
if (state == inExponent) {
exponent=n * nSign;
return makeNumber(mantissa,exponent);
}
 else {
if (state == leftOfPoint) {
mantissa=n;
}
 else {
mantissa+=(n * java.lang.Math.pow(10,-nDigits));
}
n=nDigits=0;
nSign=1;
advance();
state=inExponent;
}
}
 else if ((nextChar == '+' || nextChar == '-') && state == inExponent && nDigits == 0) {
nSign=-nSign;
advance();
}
 else if (nextChar >= '0' && nextChar <= '9') {
n=n * 10 + (nextChar - '0');
nDigits++;
advance();
}
 else {
if (state == leftOfPoint) {
mantissa=n;
}
 else if (state == rightOfPoint) {
mantissa+=(n * java.lang.Math.pow(10,-nDigits));
}
 else {
exponent=n * nSign;
}
return makeNumber(mantissa,exponent);
}
}
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
id=new StringBuffer();
for (; ; ) {
id.append((char)nextChar);
advance();
switch (nextChar) {
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '_':
break;
default :
String strId=id.toString();
Integer i=(Integer)m_resWordsTable.get(strId.toUpperCase());
if (i == null) {
return makeId(strId,false,false);
}
 else {
return makeRes(i.intValue());
}
}
}
case '&':
advance();
if (nextChar == '[') {
ampersandId=true;
}
 else {
return makeToken(ParserSym.UNKNOWN,"String_Node_Str");
}
case '[':
id=new StringBuffer();
for (; ; ) {
advance();
switch (nextChar) {
case ']':
advance();
if (nextChar == ']') {
id.append(']');
break;
}
 else {
if (ampersandId) {
ampersandId=false;
return makeId(id.toString(),true,true);
}
 else {
return makeId(id.toString(),true,false);
}
}
case -1:
if (ampersandId) {
ampersandId=false;
return makeId(id.toString(),true,true);
}
 else {
return makeId(id.toString(),true,false);
}
default :
id.append((char)nextChar);
}
}
case ':':
advance();
return makeToken(ParserSym.COLON,"String_Node_Str");
case ',':
advance();
return makeToken(ParserSym.COMMA,"String_Node_Str");
case '=':
advance();
return makeToken(ParserSym.EQ,"String_Node_Str");
case '<':
advance();
switch (nextChar) {
case '>':
advance();
return makeToken(ParserSym.NE,"String_Node_Str");
case '=':
advance();
return makeToken(ParserSym.LE,"String_Node_Str");
default :
return makeToken(ParserSym.LT,"String_Node_Str");
}
case '>':
advance();
switch (nextChar) {
case '=':
advance();
return makeToken(ParserSym.GE,"String_Node_Str");
default :
return makeToken(ParserSym.GT,"String_Node_Str");
}
case '{':
advance();
return makeToken(ParserSym.LBRACE,"String_Node_Str");
case '(':
advance();
return makeToken(ParserSym.LPAREN,"String_Node_Str");
case '}':
advance();
return makeToken(ParserSym.RBRACE,"String_Node_Str");
case ')':
advance();
return makeToken(ParserSym.RPAREN,"String_Node_Str");
case '+':
advance();
return makeToken(ParserSym.PLUS,"String_Node_Str");
case '-':
advance();
return makeToken(ParserSym.MINUS,"String_Node_Str");
case '*':
advance();
return makeToken(ParserSym.ASTERISK,"String_Node_Str");
case '/':
advance();
return makeToken(ParserSym.SOLIDUS,"String_Node_Str");
case '|':
advance();
switch (nextChar) {
case '|':
advance();
return makeToken(ParserSym.CONCAT,"String_Node_Str");
default :
return makeToken(ParserSym.UNKNOWN,"String_Node_Str");
}
case '"':
id=new StringBuffer();
for (; ; ) {
advance();
switch (nextChar) {
case '"':
advance();
if (nextChar == '"') {
id.append('"');
break;
}
 else {
return makeString(id.toString());
}
case -1:
return makeString(id.toString());
default :
id.append((char)nextChar);
}
}
case '\'':
if (inFormula) {
inFormula=false;
advance();
return makeToken(ParserSym.QUOTE,"String_Node_Str");
}
 else if (previousSymbol == ParserSym.AS) {
inFormula=true;
advance();
return makeToken(ParserSym.QUOTE,"String_Node_Str");
}
id=new StringBuffer();
for (; ; ) {
advance();
switch (nextChar) {
case '\'':
advance();
if (nextChar == '\'') {
id.append('\'');
break;
}
 else {
return makeString(id.toString());
}
case -1:
return makeString(id.toString());
default :
id.append((char)nextChar);
}
}
case -1:
return makeToken(ParserSym.EOF,"String_Node_Str");
default :
iPrevChar=iChar;
advance();
break;
}
}
}