With atoms in hand, you can parse the comparisons at the heart of every WHERE clause. Today you combine two atoms and an operator into a comparison node.
Parse a comparison of two atoms into a binary comparison node carrying its operator.
A comparison joins two atoms with a relational operator - =, <>, <,
<=, >, >= - and evaluates to true or false for a given row. Parsing one is
a tidy three-step move: parse the left atom, check whether the next token is a
comparison operator, and if so consume it and parse the right atom, wrapping all
three in a Compare node.
Storing the operator as a small value on the node (a string or an enum) keeps the
executor’s job to a single lookup later. If there is no operator after the first
atom, the expression is just that atom - so this rule gracefully handles both
age > 18 and a bare age. Comparisons are the predicates a WHERE filters on;
next you combine several of them with AND and OR.
type Compare struct { Left Expr; Op string; Right Expr }// parse an atom, then if the next token is a comparison operator,// consume it and parse the right-hand atom into a Compare node