X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=parser.l;h=8e3d397a1b6fefe7f76b1a7f792f2b3ad7003c69;hb=5cd55bddca592918f38deff675d05b650a71412e;hp=7e42f8a3b1056350cab4bad63f5e3b066c9a607a;hpb=c56cf062ff40624fad3b09223b527fc3a12c7b01;p=xboard.git diff --git a/parser.l b/parser.l old mode 100755 new mode 100644 index 7e42f8a..8e3d397 --- a/parser.l +++ b/parser.l @@ -244,8 +244,6 @@ extern void CopyBoard P((Board to, Board from)); result = LegalityTest(boards[yyboardindex], PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.! - EP_UNKNOWN, - initialRights, /* [HGM] assume all castlings allowed */ currentMoveString[1] - ONE, currentMoveString[0] - AAA, currentMoveString[3] - ONE, @@ -306,8 +304,6 @@ extern void CopyBoard P((Board to, Board from)); result = LegalityTest(boards[yyboardindex], PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.! - EP_UNKNOWN, - initialRights, /* [HGM] assume all castlings allowed */ currentMoveString[1] - ONE, currentMoveString[0] - AAA, currentMoveString[3] - ONE, @@ -317,7 +313,7 @@ extern void CopyBoard P((Board to, Board from)); if (currentMoveString[4] == NULLCHAR && (result == WhitePromotionKnight || result == BlackPromotionKnight || result == WhitePromotionQueen || result == BlackPromotionQueen)) { - if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier) + if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier || gameInfo.variant == VariantMakruk) currentMoveString[4] = PieceToChar(BlackFerz); else if(gameInfo.variant == VariantGreat) currentMoveString[4] = PieceToChar(BlackMan); @@ -360,8 +356,7 @@ extern void CopyBoard P((Board to, Board from)); return IllegalMove; - Disambiguate(boards[yyboardindex], - PosFlags(yyboardindex), EP_UNKNOWN, &cl); + Disambiguate(boards[yyboardindex], PosFlags(yyboardindex), &cl); currentMoveString[0] = cl.ff + AAA; currentMoveString[1] = cl.rf + ONE; @@ -415,8 +410,7 @@ extern void CopyBoard P((Board to, Board from)); if(c != '=' && c != '+' && c != NULLCHAR && CharToPiece(c) == EmptySquare) return IllegalMove; - Disambiguate(boards[yyboardindex], - PosFlags(yyboardindex), EP_UNKNOWN, &cl); + Disambiguate(boards[yyboardindex], PosFlags(yyboardindex), &cl); currentMoveString[0] = cl.ff + AAA; currentMoveString[1] = cl.rf + ONE; @@ -492,8 +486,6 @@ extern void CopyBoard P((Board to, Board from)); result = LegalityTest(boards[yyboardindex], PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.! - EP_UNKNOWN, - initialRights, /* [HGM] assume all castlings allowed */ currentMoveString[1] - ONE, currentMoveString[0] - AAA, currentMoveString[3] - ONE, @@ -505,7 +497,7 @@ extern void CopyBoard P((Board to, Board from)); result == WhitePromotionKnight || result == BlackPromotionKnight)) { currentMoveString[4] = PieceToChar(BlackQueen); // [HGM] shatranj: take care of variants without Queen - if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier) + if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier || gameInfo.variant == VariantMakruk) currentMoveString[4] = PieceToChar(BlackFerz); if(gameInfo.variant == VariantGreat) currentMoveString[4] = PieceToChar(BlackMan); @@ -533,8 +525,6 @@ extern void CopyBoard P((Board to, Board from)); result = LegalityTest(boards[yyboardindex], PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.! - EP_UNKNOWN, - initialRights, /* [HGM] assume all castlings allowed */ currentMoveString[1] - ONE, currentMoveString[0] - AAA, currentMoveString[3] - ONE, @@ -591,8 +581,7 @@ extern void CopyBoard P((Board to, Board from)); cl.ftIn < BOARD_LEFT ) return 0; - Disambiguate(boards[yyboardindex], - PosFlags(yyboardindex), EP_UNKNOWN, &cl); + Disambiguate(boards[yyboardindex], PosFlags(yyboardindex), &cl); currentMoveString[0] = cl.ff + AAA; currentMoveString[1] = cl.rf + ONE; @@ -652,8 +641,7 @@ extern void CopyBoard P((Board to, Board from)); cl.ftIn < BOARD_LEFT ) return 0; - Disambiguate(boards[yyboardindex], - PosFlags(yyboardindex), EP_UNKNOWN, &cl); + Disambiguate(boards[yyboardindex], PosFlags(yyboardindex), &cl); currentMoveString[0] = cl.ff + AAA; currentMoveString[1] = cl.rf + ONE; @@ -698,7 +686,7 @@ extern void CopyBoard P((Board to, Board from)); ft = BOARD_LEFT+2; } } - if(gameInfo.variant == VariantFischeRandom) { + if(PosFlags(0) & F_FRC_TYPE_CASTLING) { if (WhiteOnMove(yyboardindex)) { ff = initialRights[2]; ft = initialRights[1]; @@ -706,7 +694,10 @@ extern void CopyBoard P((Board to, Board from)); ff = initialRights[5]; ft = initialRights[4]; } - fprintf(debugFP, "Parser FRC long %d %d\n", ff, ft); + if (appData.debugMode) + { + fprintf(debugFP, "Parser FRC long %d %d\n", ff, ft); + }; if(ff < 0 || ft < 0) return 0; } sprintf(currentMoveString, "%c%c%c%c",ff+AAA,rf+ONE,ft+AAA,rt+ONE); @@ -715,8 +706,6 @@ extern void CopyBoard P((Board to, Board from)); } return (int) LegalityTest(boards[yyboardindex], PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: e.p.! - EP_UNKNOWN, - castlingRights[yyboardindex], /* [HGM] use true castling rights */ rf, ff, rt, ft, NULLCHAR); } @@ -752,7 +741,7 @@ extern void CopyBoard P((Board to, Board from)); ft = BOARD_RGHT-2; } } - if(gameInfo.variant == VariantFischeRandom) { + if(PosFlags(0) & F_FRC_TYPE_CASTLING) { if (WhiteOnMove(yyboardindex)) { ff = initialRights[2]; ft = initialRights[0]; @@ -772,8 +761,6 @@ extern void CopyBoard P((Board to, Board from)); return (int) LegalityTest(boards[yyboardindex], PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: e.p.! - EP_UNKNOWN, - castlingRights[yyboardindex], /* [HGM] use true castling rights */ rf, ff, rt, ft, NULLCHAR); } @@ -846,11 +833,11 @@ extern void CopyBoard P((Board to, Board from)); return (int) GameIsDrawn; } -(([Ww](hite)?)|([Bb](lack)?))" "([Mm]ate(s|ed)?)|([Ww][io]n(s)?.*) { +(([Ww](hite)?)|([Bb](lack)?))" "(([Mm]ates)|([Ww][io]n(s)?)) { return (int) (ToUpper(yytext[0]) == 'W' ? WhiteWins : BlackWins); } -(([Ww](hite)?)|([Bb](lack)?))" "([Mm]ate(s|ed)?)|([Ll]os[tes]+.*) { +(([Ww](hite)?)|([Bb](lack)?))" "(([Mm]ated)|([Ll]os[tes]+)) { return (int) (ToUpper(yytext[0]) == 'W' ? BlackWins : WhiteWins); } @@ -985,7 +972,7 @@ int yyoffset() static void output(ch) int ch; { - fprintf(stderr, "PARSER BUG: unmatched character '%c' (0%o)\n", + if(appData.debugMode) fprintf(debugFP, "PARSER BUG: unmatched character '%c' (0%o)\n", ch, ch); } @@ -997,7 +984,7 @@ static void unput(ch) StringToLex--; } else { if (unputCount >= UNPUT_BUF_SIZE) - fprintf(stderr, "PARSER BUG: unput buffer overflow '%c' (0%o)\n", + if(appData.debugMode) fprintf(debugFP, "PARSER BUG: unput buffer overflow '%c' (0%o)\n", ch, ch); unputBuffer[unputCount++] = ch; }