Both of the above use shallow, almost linear chains of conditional branches. The code is noticeably slower as a result. Even though the speed is still tolerable, it is straightforward to see that stairsteps of nested tests would be an important optimization.
In the parser, we can group the conditions according to the character class of a token's leading character. In the SQL builder, we can implement a "token class" as a more general category than the token type and allocate another byte for it, to precede the token type in the markup. In both situations, we would want to make the common cases as fast as possible by positioning them high up in the branch hierarchy.
Both of the above use shallow, almost linear chains of conditional branches. The code is noticeably slower as a result. Even though the speed is still tolerable, it is straightforward to see that stairsteps of nested tests would be an important optimization.
In the parser, we can group the conditions according to the character class of a token's leading character. In the SQL builder, we can implement a "token class" as a more general category than the token type and allocate another byte for it, to precede the token type in the markup. In both situations, we would want to make the common cases as fast as possible by positioning them high up in the branch hierarchy.