Exemple #1
0
Token* Scanner::NextToken() {
	while (ch == ' ' ||
			(ch >= 9 && ch <= 10) || ch == 13
	) NextCh();
	if ((ch == L'/' && Comment0()) || (ch == L'/' && Comment1())) return NextToken();
	int recKind = noSym;
	int recEnd = pos;
	t = CreateToken();
	t->pos = pos; t->col = col; t->line = line; t->charPos = charPos;
	int state = start.state(ch);
	tlen = 0; AddCh();

	switch (state) {
		case -1: { t->kind = eofSym; break; } // NextCh already done
		case 0: {
			case_0:
			if (recKind != noSym) {
				tlen = recEnd - t->pos;
				SetScannerBehindT();
			}
			t->kind = recKind; break;
		} // NextCh already done
		case 1:
			case_1:
			recEnd = pos; recKind = 1;
			if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_1;}
			else {t->kind = 1; wchar_t *literal = coco_string_create(tval, 0, tlen); t->kind = keywords.get(literal, t->kind); coco_string_delete(literal); break;}
		case 2:
			case_2:
			recEnd = pos; recKind = 2;
			if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_2;}
			else {t->kind = 2; break;}
		case 3:
			case_3:
			{t->kind = 3; break;}
		case 4:
			case_4:
			{t->kind = 4; break;}
		case 5:
			if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= L'&') || (ch >= L'(' && ch <= L'[') || (ch >= L']' && ch <= 65535)) {AddCh(); goto case_6;}
			else if (ch == 92) {AddCh(); goto case_7;}
			else {goto case_0;}
		case 6:
			case_6:
			if (ch == 39) {AddCh(); goto case_9;}
			else {goto case_0;}
		case 7:
			case_7:
			if ((ch >= L' ' && ch <= L'~')) {AddCh(); goto case_8;}
			else {goto case_0;}
		case 8:
			case_8:
			if ((ch >= L'0' && ch <= L'9') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_8;}
			else if (ch == 39) {AddCh(); goto case_9;}
			else {goto case_0;}
		case 9:
			case_9:
			{t->kind = 5; break;}
		case 10:
			case_10:
			recEnd = pos; recKind = 42;
			if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_10;}
			else {t->kind = 42; break;}
		case 11:
			case_11:
			recEnd = pos; recKind = 43;
			if ((ch >= L'-' && ch <= L'.') || (ch >= L'0' && ch <= L':') || (ch >= L'A' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_11;}
			else {t->kind = 43; break;}
		case 12:
			case_12:
			if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= L'!') || (ch >= L'#' && ch <= L'[') || (ch >= L']' && ch <= 65535)) {AddCh(); goto case_12;}
			else if (ch == 10 || ch == 13) {AddCh(); goto case_4;}
			else if (ch == L'"') {AddCh(); goto case_3;}
			else if (ch == 92) {AddCh(); goto case_14;}
			else {goto case_0;}
		case 13:
			recEnd = pos; recKind = 42;
			if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_10;}
			else if ((ch >= L'A' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_15;}
			else {t->kind = 42; break;}
		case 14:
			case_14:
			if ((ch >= L' ' && ch <= L'~')) {AddCh(); goto case_12;}
			else {goto case_0;}
		case 15:
			case_15:
			recEnd = pos; recKind = 42;
			if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_10;}
			else if ((ch >= L'A' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_15;}
			else if (ch == L'=') {AddCh(); goto case_11;}
			else {t->kind = 42; break;}
		case 16:
			{t->kind = 17; break;}
		case 17:
			{t->kind = 20; break;}
		case 18:
			{t->kind = 21; break;}
		case 19:
			case_19:
			{t->kind = 22; break;}
		case 20:
			{t->kind = 25; break;}
		case 21:
			case_21:
			{t->kind = 26; break;}
		case 22:
			case_22:
			{t->kind = 27; break;}
		case 23:
			{t->kind = 28; break;}
		case 24:
			{t->kind = 31; break;}
		case 25:
			{t->kind = 32; break;}
		case 26:
			{t->kind = 33; break;}
		case 27:
			{t->kind = 34; break;}
		case 28:
			{t->kind = 35; break;}
		case 29:
			case_29:
			{t->kind = 39; break;}
		case 30:
			case_30:
			{t->kind = 40; break;}
		case 31:
			recEnd = pos; recKind = 18;
			if (ch == L'.') {AddCh(); goto case_19;}
			else if (ch == L'>') {AddCh(); goto case_22;}
			else if (ch == L')') {AddCh(); goto case_30;}
			else {t->kind = 18; break;}
		case 32:
			recEnd = pos; recKind = 24;
			if (ch == L'.') {AddCh(); goto case_21;}
			else {t->kind = 24; break;}
		case 33:
			recEnd = pos; recKind = 30;
			if (ch == L'.') {AddCh(); goto case_29;}
			else {t->kind = 30; break;}

	}
	AppendVal(t);
	return t;
}
Exemple #2
0
Token* Scanner::NextToken() {
    while (ch == ' ' ||
            (ch >= 9 && ch <= 10) || ch == 13
          ) NextCh();
    if ((ch == L'/' && Comment0()) || (ch == L'/' && Comment1()) || (ch == L'/' && Comment2())) return NextToken();
    int recKind = noSym;
    int recEnd = pos;
    t = CreateToken();
    t->pos = pos;
    t->col = col;
    t->line = line;
    t->charPos = charPos;
    int state = start.state(ch);
    tlen = 0;
    AddCh();

    switch (state) {
    case -1: {
        t->kind = eofSym;    // NextCh already done
        break;
    }
    case 0: {
case_0:
        if (recKind != noSym) {
            tlen = recEnd - t->pos;
            SetScannerBehindT();
        }
        t->kind = recKind;
        break;
    } // NextCh already done
    case 1:
case_1:
        recEnd = pos;
        recKind = 1;
        if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {
            AddCh();
            goto case_1;
        }
        else {
            t->kind = 1;
            wchar_t *literal = coco_string_create(tval, 0, tlen);
            t->kind = keywords.get(literal, t->kind);
            coco_string_delete(literal);
            break;
        }
    case 2:
case_2:
        recEnd = pos;
        recKind = 2;
        if ((ch >= L'0' && ch <= L'9')) {
            AddCh();
            goto case_2;
        }
        else if (ch == L'F' || ch == L'L' || ch == L'f' || ch == L'l') {
            AddCh();
            goto case_13;
        }
        else if (ch == L'E' || ch == L'e') {
            AddCh();
            goto case_3;
        }
        else {
            t->kind = 2;
            break;
        }
    case 3:
case_3:
        if ((ch >= L'0' && ch <= L'9')) {
            AddCh();
            goto case_5;
        }
        else if (ch == L'+' || ch == L'-') {
            AddCh();
            goto case_4;
        }
        else {
            goto case_0;
        }
    case 4:
case_4:
        if ((ch >= L'0' && ch <= L'9')) {
            AddCh();
            goto case_5;
        }
        else {
            goto case_0;
        }
    case 5:
case_5:
        recEnd = pos;
        recKind = 2;
        if ((ch >= L'0' && ch <= L'9')) {
            AddCh();
            goto case_5;
        }
        else if (ch == L'F' || ch == L'L' || ch == L'f' || ch == L'l') {
            AddCh();
            goto case_13;
        }
        else {
            t->kind = 2;
            break;
        }
    case 6:
case_6:
        recEnd = pos;
        recKind = 2;
        if ((ch >= L'0' && ch <= L'9')) {
            AddCh();
            goto case_6;
        }
        else if (ch == L'F' || ch == L'L' || ch == L'f' || ch == L'l') {
            AddCh();
            goto case_13;
        }
        else if (ch == L'E' || ch == L'e') {
            AddCh();
            goto case_7;
        }
        else {
            t->kind = 2;
            break;
        }
    case 7:
case_7:
        if ((ch >= L'0' && ch <= L'9')) {
            AddCh();
            goto case_9;
        }
        else if (ch == L'+' || ch == L'-') {
            AddCh();
            goto case_8;
        }
        else {
            goto case_0;
        }
    case 8:
case_8:
        if ((ch >= L'0' && ch <= L'9')) {
            AddCh();
            goto case_9;
        }
        else {
            goto case_0;
        }
    case 9:
case_9:
        recEnd = pos;
        recKind = 2;
        if ((ch >= L'0' && ch <= L'9')) {
            AddCh();
            goto case_9;
        }
        else if (ch == L'F' || ch == L'L' || ch == L'f' || ch == L'l') {
            AddCh();
            goto case_13;
        }
        else {
            t->kind = 2;
            break;
        }
    case 10:
case_10:
        if ((ch >= L'0' && ch <= L'9')) {
            AddCh();
            goto case_12;
        }
        else if (ch == L'+' || ch == L'-') {
            AddCh();
            goto case_11;
        }
        else {
            goto case_0;
        }
    case 11:
case_11:
        if ((ch >= L'0' && ch <= L'9')) {
            AddCh();
            goto case_12;
        }
        else {
            goto case_0;
        }
    case 12:
case_12:
        recEnd = pos;
        recKind = 2;
        if ((ch >= L'0' && ch <= L'9')) {
            AddCh();
            goto case_12;
        }
        else if (ch == L'F' || ch == L'L' || ch == L'f' || ch == L'l') {
            AddCh();
            goto case_13;
        }
        else {
            t->kind = 2;
            break;
        }
    case 13:
case_13:
        {
            t->kind = 2;
            break;
        }
    case 14:
case_14:
        recEnd = pos;
        recKind = 3;
        if (ch == L'L' || ch == L'U' || ch == L'l' || ch == L'u') {
            AddCh();
            goto case_14;
        }
        else {
            t->kind = 3;
            break;
        }
    case 15:
case_15:
        if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {
            AddCh();
            goto case_16;
        }
        else {
            goto case_0;
        }
    case 16:
case_16:
        recEnd = pos;
        recKind = 3;
        if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {
            AddCh();
            goto case_16;
        }
        else if (ch == L'L' || ch == L'U' || ch == L'l' || ch == L'u') {
            AddCh();
            goto case_14;
        }
        else {
            t->kind = 3;
            break;
        }
    case 17:
        if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= L'&') || (ch >= L'(' && ch <= 65535)) {
            AddCh();
            goto case_18;
        }
        else {
            goto case_0;
        }
    case 18:
case_18:
        if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= L'&') || (ch >= L'(' && ch <= 65535)) {
            AddCh();
            goto case_18;
        }
        else if (ch == 39) {
            AddCh();
            goto case_19;
        }
        else {
            goto case_0;
        }
    case 19:
case_19:
        {
            t->kind = 4;
            break;
        }
    case 20:
case_20:
        if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= L'!') || (ch >= L'#' && ch <= 65535)) {
            AddCh();
            goto case_20;
        }
        else if (ch == L'"') {
            AddCh();
            goto case_21;
        }
        else {
            goto case_0;
        }
    case 21:
case_21:
        {
            t->kind = 5;
            break;
        }
    case 22:
    {
        t->kind = 25;
        break;
    }
    case 23:
    {
        t->kind = 26;
        break;
    }
    case 24:
    {
        t->kind = 27;
        break;
    }
    case 25:
    {
        t->kind = 28;
        break;
    }
    case 26:
    {
        t->kind = 29;
        break;
    }
    case 27:
    {
        t->kind = 30;
        break;
    }
    case 28:
    {
        t->kind = 31;
        break;
    }
    case 29:
    {
        t->kind = 32;
        break;
    }
    case 30:
    {
        t->kind = 33;
        break;
    }
    case 31:
    {
        t->kind = 34;
        break;
    }
    case 32:
case_32:
        if (ch == L'.') {
            AddCh();
            goto case_33;
        }
        else {
            goto case_0;
        }
    case 33:
case_33:
        {
            t->kind = 35;
            break;
        }
    case 34:
case_34:
        if (ch == L'e') {
            AddCh();
            goto case_35;
        }
        else {
            goto case_0;
        }
    case 35:
case_35:
        if (ch == L'f') {
            AddCh();
            goto case_36;
        }
        else {
            goto case_0;
        }
    case 36:
case_36:
        if (ch == L'i') {
            AddCh();
            goto case_37;
        }
        else {
            goto case_0;
        }
    case 37:
case_37:
        if (ch == L'n') {
            AddCh();
            goto case_38;
        }
        else {
            goto case_0;
        }
    case 38:
case_38:
        if (ch == L'e') {
            AddCh();
            goto case_39;
        }
        else {
            goto case_0;
        }
    case 39:
case_39:
        if (ch == 10 || ch == 13) {
            AddCh();
            goto case_40;
        }
        else if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= 65535)) {
            AddCh();
            goto case_39;
        }
        else {
            goto case_0;
        }
    case 40:
case_40:
        {
            t->kind = 110;
            break;
        }
    case 41:
case_41:
        if (ch == L'n') {
            AddCh();
            goto case_42;
        }
        else {
            goto case_0;
        }
    case 42:
case_42:
        if (ch == L'd') {
            AddCh();
            goto case_43;
        }
        else {
            goto case_0;
        }
    case 43:
case_43:
        if (ch == L'e') {
            AddCh();
            goto case_44;
        }
        else {
            goto case_0;
        }
    case 44:
case_44:
        if (ch == L'f') {
            AddCh();
            goto case_45;
        }
        else {
            goto case_0;
        }
    case 45:
case_45:
        if (ch == 10 || ch == 13) {
            AddCh();
            goto case_46;
        }
        else if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= 65535)) {
            AddCh();
            goto case_45;
        }
        else {
            goto case_0;
        }
    case 46:
case_46:
        {
            t->kind = 111;
            break;
        }
    case 47:
case_47:
        if (ch == 10 || ch == 13) {
            AddCh();
            goto case_48;
        }
        else if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= 65535)) {
            AddCh();
            goto case_47;
        }
        else {
            goto case_0;
        }
    case 48:
case_48:
        {
            t->kind = 112;
            break;
        }
    case 49:
case_49:
        if (ch == L'f') {
            AddCh();
            goto case_50;
        }
        else {
            goto case_0;
        }
    case 50:
case_50:
        if (ch == 10 || ch == 13) {
            AddCh();
            goto case_51;
        }
        else if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= 65535)) {
            AddCh();
            goto case_50;
        }
        else {
            goto case_0;
        }
    case 51:
case_51:
        {
            t->kind = 113;
            break;
        }
    case 52:
case_52:
        if (ch == L'e') {
            AddCh();
            goto case_53;
        }
        else {
            goto case_0;
        }
    case 53:
case_53:
        if (ch == 10 || ch == 13) {
            AddCh();
            goto case_54;
        }
        else if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= 65535)) {
            AddCh();
            goto case_53;
        }
        else {
            goto case_0;
        }
    case 54:
case_54:
        {
            t->kind = 114;
            break;
        }
    case 55:
case_55:
        if (ch == L'd') {
            AddCh();
            goto case_56;
        }
        else {
            goto case_0;
        }
    case 56:
case_56:
        if (ch == L'i') {
            AddCh();
            goto case_57;
        }
        else {
            goto case_0;
        }
    case 57:
case_57:
        if (ch == L'f') {
            AddCh();
            goto case_58;
        }
        else {
            goto case_0;
        }
    case 58:
case_58:
        if (ch == 10 || ch == 13) {
            AddCh();
            goto case_59;
        }
        else if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= 65535)) {
            AddCh();
            goto case_58;
        }
        else {
            goto case_0;
        }
    case 59:
case_59:
        {
            t->kind = 115;
            break;
        }
    case 60:
case_60:
        if (ch == L'c') {
            AddCh();
            goto case_61;
        }
        else {
            goto case_0;
        }
    case 61:
case_61:
        if (ch == L'l') {
            AddCh();
            goto case_62;
        }
        else {
            goto case_0;
        }
    case 62:
case_62:
        if (ch == L'u') {
            AddCh();
            goto case_63;
        }
        else {
            goto case_0;
        }
    case 63:
case_63:
        if (ch == L'd') {
            AddCh();
            goto case_64;
        }
        else {
            goto case_0;
        }
    case 64:
case_64:
        if (ch == L'e') {
            AddCh();
            goto case_65;
        }
        else {
            goto case_0;
        }
    case 65:
case_65:
        if (ch == 10 || ch == 13) {
            AddCh();
            goto case_66;
        }
        else if (ch <= 9 || (ch >= 11 && ch <= 12) || (ch >= 14 && ch <= 65535)) {
            AddCh();
            goto case_65;
        }
        else {
            goto case_0;
        }
    case 66:
case_66:
        {
            t->kind = 116;
            break;
        }
    case 67:
        recEnd = pos;
        recKind = 3;
        if ((ch >= L'8' && ch <= L'9')) {
            AddCh();
            goto case_71;
        }
        else if ((ch >= L'0' && ch <= L'7')) {
            AddCh();
            goto case_72;
        }
        else if (ch == L'.') {
            AddCh();
            goto case_6;
        }
        else if (ch == L'E' || ch == L'e') {
            AddCh();
            goto case_10;
        }
        else if (ch == L'L' || ch == L'U' || ch == L'l' || ch == L'u') {
            AddCh();
            goto case_14;
        }
        else if (ch == L'X' || ch == L'x') {
            AddCh();
            goto case_15;
        }
        else {
            t->kind = 3;
            break;
        }
    case 68:
case_68:
        recEnd = pos;
        recKind = 3;
        if ((ch >= L'0' && ch <= L'9')) {
            AddCh();
            goto case_68;
        }
        else if (ch == L'.') {
            AddCh();
            goto case_6;
        }
        else if (ch == L'E' || ch == L'e') {
            AddCh();
            goto case_10;
        }
        else if (ch == L'L' || ch == L'U' || ch == L'l' || ch == L'u') {
            AddCh();
            goto case_14;
        }
        else {
            t->kind = 3;
            break;
        }
    case 69:
        if ((ch >= L'0' && ch <= L'9')) {
            AddCh();
            goto case_2;
        }
        else if (ch == L'.') {
            AddCh();
            goto case_32;
        }
        else {
            goto case_0;
        }
    case 70:
case_70:
        if (ch == 9 || (ch >= 11 && ch <= 12) || ch == L' ') {
            AddCh();
            goto case_70;
        }
        else if (ch == L'd') {
            AddCh();
            goto case_34;
        }
        else if (ch == L'u') {
            AddCh();
            goto case_41;
        }
        else if (ch == L'i') {
            AddCh();
            goto case_73;
        }
        else if (ch == L'e') {
            AddCh();
            goto case_74;
        }
        else {
            goto case_0;
        }
    case 71:
case_71:
        if ((ch >= L'0' && ch <= L'9')) {
            AddCh();
            goto case_71;
        }
        else if (ch == L'.') {
            AddCh();
            goto case_6;
        }
        else if (ch == L'E' || ch == L'e') {
            AddCh();
            goto case_10;
        }
        else {
            goto case_0;
        }
    case 72:
case_72:
        recEnd = pos;
        recKind = 3;
        if ((ch >= L'8' && ch <= L'9')) {
            AddCh();
            goto case_71;
        }
        else if ((ch >= L'0' && ch <= L'7')) {
            AddCh();
            goto case_72;
        }
        else if (ch == L'.') {
            AddCh();
            goto case_6;
        }
        else if (ch == L'E' || ch == L'e') {
            AddCh();
            goto case_10;
        }
        else if (ch == L'L' || ch == L'U' || ch == L'l' || ch == L'u') {
            AddCh();
            goto case_14;
        }
        else {
            t->kind = 3;
            break;
        }
    case 73:
case_73:
        if (ch == L'f') {
            AddCh();
            goto case_47;
        }
        else if (ch == L'n') {
            AddCh();
            goto case_60;
        }
        else {
            goto case_0;
        }
    case 74:
case_74:
        if (ch == L'l') {
            AddCh();
            goto case_75;
        }
        else if (ch == L'n') {
            AddCh();
            goto case_55;
        }
        else {
            goto case_0;
        }
    case 75:
case_75:
        if (ch == L'i') {
            AddCh();
            goto case_49;
        }
        else if (ch == L's') {
            AddCh();
            goto case_52;
        }
        else {
            goto case_0;
        }
    case 76:
case_76:
        {
            t->kind = 93;
            break;
        }
    case 77:
    {
        t->kind = 96;
        break;
    }
    case 78:
    {
        t->kind = 99;
        break;
    }
    case 79:
    {
        t->kind = 100;
        break;
    }
    case 80:
        recEnd = pos;
        recKind = 1;
        if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'H' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {
            AddCh();
            goto case_1;
        }
        else if (ch == L'G') {
            AddCh();
            goto case_81;
        }
        else {
            t->kind = 1;
            wchar_t *literal = coco_string_create(tval, 0, tlen);
            t->kind = keywords.get(literal, t->kind);
            coco_string_delete(literal);
            break;
        }
    case 81:
case_81:
        recEnd = pos;
        recKind = 1;
        if ((ch >= L'0' && ch <= L'9') || ch == L'A' || (ch >= L'C' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {
            AddCh();
            goto case_1;
        }
        else if (ch == L'B') {
            AddCh();
            goto case_82;
        }
        else {
            t->kind = 1;
            wchar_t *literal = coco_string_create(tval, 0, tlen);
            t->kind = keywords.get(literal, t->kind);
            coco_string_delete(literal);
            break;
        }
    case 82:
case_82:
        recEnd = pos;
        recKind = 1;
        if ((ch >= L'0' && ch <= L'9') || (ch >= L'B' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {
            AddCh();
            goto case_1;
        }
        else if (ch == L'A') {
            AddCh();
            goto case_83;
        }
        else {
            t->kind = 1;
            wchar_t *literal = coco_string_create(tval, 0, tlen);
            t->kind = keywords.get(literal, t->kind);
            coco_string_delete(literal);
            break;
        }
    case 83:
case_83:
        recEnd = pos;
        recKind = 1;
        if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {
            AddCh();
            goto case_1;
        }
        else if (ch == L'(') {
            AddCh();
            goto case_76;
        }
        else {
            t->kind = 1;
            wchar_t *literal = coco_string_create(tval, 0, tlen);
            t->kind = keywords.get(literal, t->kind);
            coco_string_delete(literal);
            break;
        }

    }
    AppendVal(t);
    return t;
}
TokenRef Scanner::NextToken() {
  while (ch == ' ' ||
			(ch >= 9 && ch <= 10) || ch == 13 || ch == ' '
  ) NextCh();
	if ((ch == '/' && Comment0()) || (ch == '/' && Comment1())) return NextToken();
  int recKind = noSym;
  size_t recEnd = pos;

  t = CreateToken();
  t->pos = pos; t->col = col; t->line = line; t->charPos = charPos;
  int state = start.state(ch);
  tlen = 0; AddCh();

  switch (state) {
  case -1: { t->kind = eofSym; break; } // NextCh already done
  case 0: {
    case_0:
    if (recKind != noSym) {
      tlen = recEnd - t->pos;
      SetScannerBehindT();
    }

    t->kind = recKind; break;
  } // NextCh already done
		case 1:
			case_1:
			recEnd = pos; recKind = 1;
			if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || ch == '_' || (ch >= 'a' && ch <= 'z')) {AddCh(); goto case_1;}
			else {t->kind = 1; char *literal = coco_string_create(tval, 0, tlen); t->kind = keywords.get(literal, t->kind); coco_string_delete(literal); break;}
		case 2:
			case_2:
			if ((ch >= '0' && ch <= '9')) {AddCh(); goto case_3;}
			else {goto case_0;}
		case 3:
			case_3:
			recEnd = pos; recKind = 3;
			if ((ch >= '0' && ch <= '9')) {AddCh(); goto case_3;}
			else {t->kind = 3; break;}
		case 4:
			case_4:
			if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_5;}
			else {goto case_0;}
		case 5:
			case_5:
			if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_6;}
			else {goto case_0;}
		case 6:
			case_6:
			if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_7;}
			else {goto case_0;}
		case 7:
			case_7:
			if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_8;}
			else {goto case_0;}
		case 8:
			case_8:
			if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_9;}
			else {goto case_0;}
		case 9:
			case_9:
			recEnd = pos; recKind = 4;
			if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_10;}
			else {t->kind = 4; break;}
		case 10:
			case_10:
			if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_11;}
			else {goto case_0;}
		case 11:
			case_11:
			{t->kind = 4; break;}
		case 12:
			if ((ch >= 'A' && ch <= 'Z') || ch == '_' || (ch >= 'a' && ch <= 'z')) {AddCh(); goto case_13;}
			else {goto case_0;}
		case 13:
			case_13:
			recEnd = pos; recKind = 5;
			if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || ch == '_' || (ch >= 'a' && ch <= 'z')) {AddCh(); goto case_13;}
			else {t->kind = 5; break;}
		case 14:
			case_14:
			if (ch <= '!' || (ch >= '#' && ch <= '[') || (ch >= ']' && ch <= 65535)) {AddCh(); goto case_14;}
			else if (ch == '"') {AddCh(); goto case_15;}
			else if (ch == 92) {AddCh(); goto case_17;}
			else {goto case_0;}
		case 15:
			case_15:
			{t->kind = 6; break;}
		case 16:
			case_16:
			recEnd = pos; recKind = 2;
			if ((ch >= '0' && ch <= '9')) {AddCh(); goto case_16;}
			else if (ch == '.') {AddCh(); goto case_2;}
			else {t->kind = 2; break;}
		case 17:
			case_17:
			if (ch <= '!' || (ch >= '#' && ch <= '[') || (ch >= ']' && ch <= 65535)) {AddCh(); goto case_14;}
			else if (ch == 92) {AddCh(); goto case_17;}
			else if (ch == '"') {AddCh(); goto case_18;}
			else {goto case_0;}
		case 18:
			case_18:
			recEnd = pos; recKind = 6;
			if (ch <= '!' || (ch >= '#' && ch <= '[') || (ch >= ']' && ch <= 65535)) {AddCh(); goto case_14;}
			else if (ch == '"') {AddCh(); goto case_15;}
			else if (ch == 92) {AddCh(); goto case_17;}
			else {t->kind = 6; break;}
		case 19:
			{t->kind = 11; break;}
		case 20:
			{t->kind = 12; break;}
		case 21:
			{t->kind = 15; break;}
		case 22:
			{t->kind = 16; break;}
		case 23:
			{t->kind = 20; break;}
		case 24:
			{t->kind = 31; break;}
		case 25:
			{t->kind = 32; break;}
		case 26:
			{t->kind = 36; break;}
		case 27:
			{t->kind = 43; break;}
		case 28:
			{t->kind = 45; break;}
		case 29:
			{t->kind = 47; break;}
		case 30:
			{t->kind = 90; break;}
		case 31:
			{t->kind = 91; break;}
		case 32:
			{t->kind = 93; break;}
		case 33:
			recEnd = pos; recKind = 49;
			if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_4;}
			else {t->kind = 49; break;}

  }
  AppendVal(t);

  return t;
}