X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=parser.l;h=d96b95ae1e00e82567a79287a4418a73f70f9316;hb=6d9218e397e068f6249f19bbcce1ade720cfd791;hp=77837a7b6e2068eec9f8bd117872555d400a35ea;hpb=7b4dacf6fe9f8c10b6eb4d6070869a3d933dbeb5;p=xboard.git diff --git a/parser.l b/parser.l index 77837a7..d96b95a 100755 --- a/parser.l +++ b/parser.l @@ -9,9 +9,10 @@ * parser.l -- lex parser of algebraic chess moves for XBoard * * Copyright 1991 by Digital Equipment Corporation, Maynard, - * Massachusetts. Enhancements Copyright - * 1992-2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software - * Foundation, Inc. + * Massachusetts. + * + * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, + * 2006, 2007, 2008, 2009 Free Software Foundation, Inc. * * The following terms apply to Digital Equipment Corporation's copyright * interest in XBoard: @@ -705,7 +706,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); @@ -845,11 +849,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); } @@ -918,7 +922,7 @@ extern void CopyBoard P((Board to, Board from)); return (int) Comment; } -\([^()]*(\([^()]*\)[^()]*)+[^()]*\) { /* nested () */ +\([^()]*(\([^()]*(\([^()]*(\([^()]*\)[^()]*)*\)[^()]*)*\)[^()]*)+[^()]*\) { /* very nested () */ return (int) Comment; } @@ -984,7 +988,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); } @@ -996,7 +1000,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; }