A CQL file consists of the word
cql, followed by a parentheses enclosed list of arguments, followed by the body, which is a sequence of filters.
For example, here is a CQL file to find games where Black has at least two rooks and is stalemated
cql (input hhdbvi.pgn) btm stalemate ♜≥2CQL first reads the input pgn file from the
input parameter. Then CQL reads
each game in the file
hhdbvi.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 in the body is true of that position.
In this case there are three filters in the body: btm, stalemate, and
btm will be true if the position is black to move;
stalemate will be
true if the position is stalemate;
♜≥2 is true if there are at least two black rooks in the position.
If all these filters are true for some position in a game, then CQL outputs the game (with some comments) to the output file.