Ejemplo n.º 1
0
bool funcCHAR(ParserParam &param, Token *tok){
	switch(param.stack.back()){
		case 0:
			shift(param,tok,36);
			break;
		case 3:
			shift(param,tok,36);
			break;
		case 7:
			if(!rule3(param)) return false;
			break;
		case 8:
			if(!rule4(param)) return false;
			break;
		case 9:
			shift(param,tok,36);
			break;
		case 12:
			if(!rule5(param)) return false;
			break;
		case 14:
			if(!rule6(param)) return false;
			break;
		case 19:
			shift(param,tok,36);
			break;
		case 25:
			if(!rule15(param)) return false;
			break;
		case 27:
			shift(param,tok,36);
			break;
		case 30:
			if(!rule17(param)) return false;
			break;
		case 31:
			if(!rule18(param)) return false;
			break;
		case 33:
			if(!rule19(param)) return false;
			break;
		case 34:
			if(!rule20(param)) return false;
			break;
		default:
			return false;
		break;
	}
	return true;
}
Ejemplo n.º 2
0
bool funcEND(ParserParam &param, Token *tok){
	switch(param.stack.back()){
		case 1:
			shift(param,tok,2);
			break;
		case 2:
			param.isAccept = true;
			break;
		case 3:
			if(!rule2(param)) return false;
			break;
		case 4:
			if(!rule1(param)) return false;
			break;
		case 7:
			if(!rule3(param)) return false;
			break;
		case 8:
			if(!rule4(param)) return false;
			break;
		case 12:
			if(!rule5(param)) return false;
			break;
		case 14:
			if(!rule6(param)) return false;
			break;
		case 25:
			if(!rule15(param)) return false;
			break;
		case 30:
			if(!rule17(param)) return false;
			break;
		case 31:
			if(!rule18(param)) return false;
			break;
		case 33:
			if(!rule19(param)) return false;
			break;
		case 34:
			if(!rule20(param)) return false;
			break;
		default:
			return false;
		break;
	}
	return true;
}
Ejemplo n.º 3
0
char		pose(t_board *board, t_pos *move, char current, char rules)
{
    int		i;
    char		get;
    int		iget;


    /* printf("At %i-%i: ", cor.move->x, cor.move->y); */

    // Pose
    get = get_board(board, move->x, move->y);
    if ((get == EMPTY) &&
            (!(rules & RULE3) || (rule3(board, move->x, move->y, current))))
    {
        set_board(board, move->x, move->y, current);
        printf("Placed a ");
        if (current == BLACK)
        {
            printf("Black");
            current = WHITE;
        }
        else
        {
            printf("White");
            current = BLACK;
        }
        printf(" Stone at %i:%i\n", move->x, move->y);

        // Prise
        iget = getprise(board, move->x, move->y, current);
        if (iget)
        {
            printf("Taken %i ", iget*2);
            if (current == BLACK)
            {
                board->blacks += iget;
                printf("Black Stones (%i total)\n", board->blacks*2);
            }
            else
            {
                board->whites += iget;
                printf("Whites Stones (%i total)\n", board->whites*2);
            }
            prise(board, move->x, move->y, current);
        }

        // Règle de 5
        // (rules & RULE5) &&
        for (i = 0; i < 19*19; i++)
        {
            move->x = i / 19;
            move->y = i % 19; //
            if ((get_board(board, move->x, move->y) == OPPOSITE(current)) && (rule5(board, move->x, move->y, OPPOSITE(current), rules)))
            {
                if (current == WHITE)
                    printf("Blacks wins with a row!\n");
                if (current == BLACK)
                    printf("Whites wins with a row!\n");
                return (OPPOSITE(current) + 10);
            }
        }

    }
    else
    {
        printf("There's ");
        switch (get)
        {
        case BLACK:
            printf("a Black Stone");
            break;
        case WHITE:
            printf("a White Stone");
            break;
        case EMPTY:
            printf("nothing");
            break;
        }
        printf(" at %i:%i\n", move->x, move->y);
    }


    return (current);
}
Ejemplo n.º 4
0
bool funcNUM(ParserParam &param, Token *tok){
	switch(param.stack.back()){
		case 3:
			if(!rule2(param)) return false;
			break;
		case 4:
			if(!rule1(param)) return false;
			break;
		case 7:
			if(!rule3(param)) return false;
			break;
		case 8:
			if(!rule4(param)) return false;
			break;
		case 12:
			if(!rule5(param)) return false;
			break;
		case 14:
			if(!rule6(param)) return false;
			break;
		case 19:
			if(!rule67(param)) return false;
			break;
		case 22:
			shift(param,tok,23);
			break;
		case 25:
			if(!rule15(param)) return false;
			break;
		case 27:
			shift(param,tok,99);
			break;
		case 28:
			shift(param,tok,99);
			break;
		case 30:
			if(!rule17(param)) return false;
			break;
		case 31:
			if(!rule18(param)) return false;
			break;
		case 33:
			if(!rule19(param)) return false;
			break;
		case 34:
			if(!rule20(param)) return false;
			break;
		case 37:
			shift(param,tok,99);
			break;
		case 39:
			if(!rule25(param)) return false;
			break;
		case 41:
			if(!rule26(param)) return false;
			break;
		case 42:
			shift(param,tok,99);
			break;
		case 44:
			if(!rule27(param)) return false;
			break;
		case 46:
			if(!rule28(param)) return false;
			break;
		case 48:
			shift(param,tok,99);
			break;
		case 50:
			shift(param,tok,99);
			break;
		case 52:
			shift(param,tok,99);
			break;
		case 53:
			if(!rule29(param)) return false;
			break;
		case 55:
			shift(param,tok,99);
			break;
		case 57:
			shift(param,tok,99);
			break;
		case 58:
			if(!rule30(param)) return false;
			break;
		case 59:
			if(!rule31(param)) return false;
			break;
		case 60:
			shift(param,tok,99);
			break;
		case 62:
			if(!rule32(param)) return false;
			break;
		case 63:
			shift(param,tok,99);
			break;
		case 65:
			if(!rule33(param)) return false;
			break;
		case 67:
			shift(param,tok,99);
			break;
		case 70:
			shift(param,tok,99);
			break;
		case 73:
			shift(param,tok,99);
			break;
		case 76:
			shift(param,tok,99);
			break;
		case 79:
			shift(param,tok,99);
			break;
		case 81:
			shift(param,tok,99);
			break;
		case 84:
			shift(param,tok,99);
			break;
		case 87:
			shift(param,tok,99);
			break;
		case 89:
			shift(param,tok,99);
			break;
		case 93:
			shift(param,tok,99);
			break;
		case 96:
			shift(param,tok,99);
			break;
		case 100:
			if(!rule54(param)) return false;
			break;
		case 101:
			if(!rule55(param)) return false;
			break;
		case 102:
			if(!rule56(param)) return false;
			break;
		case 103:
			if(!rule57(param)) return false;
			break;
		case 104:
			if(!rule58(param)) return false;
			break;
		case 105:
			if(!rule59(param)) return false;
			break;
		case 106:
			if(!rule60(param)) return false;
			break;
		case 107:
			if(!rule61(param)) return false;
			break;
		case 108:
			if(!rule62(param)) return false;
			break;
		case 109:
			if(!rule63(param)) return false;
			break;
		case 110:
			if(!rule64(param)) return false;
			break;
		case 111:
			if(!rule65(param)) return false;
			break;
		case 112:
			if(!rule66(param)) return false;
			break;
		default:
			return false;
		break;
	}
	return true;
}
Ejemplo n.º 5
0
bool funcSEMI(ParserParam &param, Token *tok){
	switch(param.stack.back()){
		case 3:
			if(!rule2(param)) return false;
			break;
		case 4:
			if(!rule1(param)) return false;
			break;
		case 6:
			shift(param,tok,7);
			break;
		case 7:
			if(!rule3(param)) return false;
			break;
		case 8:
			if(!rule4(param)) return false;
			break;
		case 12:
			if(!rule5(param)) return false;
			break;
		case 14:
			if(!rule6(param)) return false;
			break;
		case 24:
			shift(param,tok,25);
			break;
		case 25:
			if(!rule15(param)) return false;
			break;
		case 27:
			shift(param,tok,39);
			break;
		case 28:
			shift(param,tok,39);
			break;
		case 30:
			if(!rule17(param)) return false;
			break;
		case 31:
			if(!rule18(param)) return false;
			break;
		case 33:
			if(!rule19(param)) return false;
			break;
		case 34:
			if(!rule20(param)) return false;
			break;
		case 37:
			shift(param,tok,39);
			break;
		case 39:
			if(!rule25(param)) return false;
			break;
		case 40:
			shift(param,tok,41);
			break;
		case 41:
			if(!rule26(param)) return false;
			break;
		case 43:
			shift(param,tok,44);
			break;
		case 44:
			if(!rule27(param)) return false;
			break;
		case 45:
			shift(param,tok,46);
			break;
		case 46:
			if(!rule28(param)) return false;
			break;
		case 50:
			shift(param,tok,39);
			break;
		case 52:
			shift(param,tok,39);
			break;
		case 53:
			if(!rule29(param)) return false;
			break;
		case 57:
			shift(param,tok,39);
			break;
		case 58:
			if(!rule30(param)) return false;
			break;
		case 59:
			if(!rule31(param)) return false;
			break;
		case 61:
			shift(param,tok,62);
			break;
		case 62:
			if(!rule32(param)) return false;
			break;
		case 64:
			shift(param,tok,65);
			break;
		case 65:
			if(!rule33(param)) return false;
			break;
		case 66:
			if(!rule35(param)) return false;
			break;
		case 68:
			if(!rule34(param)) return false;
			break;
		case 69:
			if(!rule37(param)) return false;
			break;
		case 71:
			if(!rule36(param)) return false;
			break;
		case 72:
			if(!rule39(param)) return false;
			break;
		case 74:
			if(!rule38(param)) return false;
			break;
		case 75:
			if(!rule41(param)) return false;
			break;
		case 77:
			if(!rule40(param)) return false;
			break;
		case 78:
			if(!rule44(param)) return false;
			break;
		case 80:
			if(!rule42(param)) return false;
			break;
		case 82:
			if(!rule43(param)) return false;
			break;
		case 83:
			if(!rule46(param)) return false;
			break;
		case 85:
			if(!rule45(param)) return false;
			break;
		case 86:
			if(!rule47(param)) return false;
			break;
		case 88:
			if(!rule48(param)) return false;
			break;
		case 91:
			if(!rule49(param)) return false;
			break;
		case 92:
			if(!rule50(param)) return false;
			break;
		case 95:
			if(!rule51(param)) return false;
			break;
		case 98:
			if(!rule52(param)) return false;
			break;
		case 99:
			if(!rule53(param)) return false;
			break;
		case 113:
			if(!rule68(param)) return false;
			break;
		default:
			return false;
		break;
	}
	return true;
}
Ejemplo n.º 6
0
bool funcREAD(ParserParam &param, Token *tok){
	switch(param.stack.back()){
		case 3:
			if(!rule2(param)) return false;
			break;
		case 4:
			if(!rule1(param)) return false;
			break;
		case 7:
			if(!rule3(param)) return false;
			break;
		case 8:
			if(!rule4(param)) return false;
			break;
		case 12:
			if(!rule5(param)) return false;
			break;
		case 14:
			if(!rule6(param)) return false;
			break;
		case 25:
			if(!rule15(param)) return false;
			break;
		case 27:
			shift(param,tok,63);
			break;
		case 28:
			shift(param,tok,63);
			break;
		case 30:
			if(!rule17(param)) return false;
			break;
		case 31:
			if(!rule18(param)) return false;
			break;
		case 33:
			if(!rule19(param)) return false;
			break;
		case 34:
			if(!rule20(param)) return false;
			break;
		case 37:
			shift(param,tok,63);
			break;
		case 39:
			if(!rule25(param)) return false;
			break;
		case 41:
			if(!rule26(param)) return false;
			break;
		case 44:
			if(!rule27(param)) return false;
			break;
		case 46:
			if(!rule28(param)) return false;
			break;
		case 50:
			shift(param,tok,63);
			break;
		case 52:
			shift(param,tok,63);
			break;
		case 53:
			if(!rule29(param)) return false;
			break;
		case 57:
			shift(param,tok,63);
			break;
		case 58:
			if(!rule30(param)) return false;
			break;
		case 59:
			if(!rule31(param)) return false;
			break;
		case 62:
			if(!rule32(param)) return false;
			break;
		case 65:
			if(!rule33(param)) return false;
			break;
		default:
			return false;
		break;
	}
	return true;
}