A brief overview of a CQL fileA CQL file has the word
cqlfollowed by a parentheses enclosed list of arguments, followed by filters. For example, here is a CQL file to find games where Black is in a pure mate: each empty square in the King's field is only attacked once:
cql (input heijden.pgn) btm mate square all $empty attack (k .) attack 1 (A $empty)CQL first reads the input file from the
inputparameter. Then CQL reads each game in the file
heijden.pgn. Next, CQL plays through each position in each game. Each time CQL reads a position, CQL checks whether each of the so-called filters is true of that position.
In this case there are three filters: btm, mate, and
square all $empty attack (k .) attack 1 (A $empty)In this case,
btmwill be true if the position is black to move;
matewill be true if the position is mate; and the
squarefilter checks that every empty square that is attacked by the Black king is attacked exactly once by a White piece.
If all these filters are true for a position, then CQL outputs the game (with some comments) to the output file.
If the CQL file is in "mate.cql" then the output file will be in "mate-out.pgn".
Basic syntaxA CQL file is mostly a sequence of filters separated by whitespace and punctuation.
Everything after a semicolon on a line in a CQL file is ignored as a comment.